Skip to content

Commit

Permalink
keep track of OEKG modifications #1448
Browse files Browse the repository at this point in the history
  • Loading branch information
adelmemariani committed Nov 1, 2023
1 parent da778d0 commit 076f20e
Show file tree
Hide file tree
Showing 16 changed files with 410 additions and 703 deletions.
281 changes: 150 additions & 131 deletions factsheet/frontend/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions factsheet/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"react": "^17.0.2",
"react-beautiful-dnd": "^13.1.1",
"react-checkbox-tree": "^1.8.0",
"react-diff-viewer-continued": "^3.3.1",
"react-dom": "^17.0.2",
"react-fontawesome": "^1.7.1",
"react-force-graph": "^1.41.12",
Expand Down
7 changes: 6 additions & 1 deletion factsheet/frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ThemeProvider } from '@mui/material/styles';
import theme from './styles/oep-theme.js';
import ComparisonBoardMain from "./components/comparisonBoardMain";
import HistoryTable from './components/historyTable.js';
import Diff from './components/oekg_modifications.js';

function App() {
const [factsheet, setFactsheet] = useState({});
Expand Down Expand Up @@ -41,7 +42,11 @@ function App() {


if (url_params === 'oekg_history') {
return <ThemeProvider theme={theme}><HistoryTable/></ThemeProvider>
return <ThemeProvider theme={theme}><HistoryTable /></ThemeProvider>
}

if (url_params === 'oekg_modifications') {
return <ThemeProvider theme={theme}><Diff /></ThemeProvider>
}

if (loading === false) {
Expand Down
58 changes: 58 additions & 0 deletions factsheet/frontend/src/components/oekg_modifications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React, { PureComponent, Fragment, useState, useEffect } from "react";
import conf from "../conf.json";
import axios from "axios";
import LinearProgress from '@mui/material/LinearProgress';
import Box from '@mui/material/Box';
import ReactDiffViewer from 'react-diff-viewer-continued';
import Divider from '@mui/material/Divider';
import Typography from '@mui/material/Typography';
import Stack from '@mui/material/Stack';

export default function Diff() {
const [modifications, setModifications] = useState({});
const [loading, setLoading] = useState(true);

const getModifications= async () => {
const { data } = await axios.get(conf.toep + `sirop/get_oekg_modifications/`);
return data;
};

useEffect(() => {
getModifications().then((data) => {
setModifications(JSON.parse(data));
setLoading(false);
});
}, []);

if (loading === false) {
return (
<Box sx={{ width: '100%' }}>
{
modifications.map((row, index) =>
<Box>
<div style={{ backgroundColor: "#001c30e6", color: "white" }}>
<Stack direction="row" alignItems="center" justifyContent={'space-between'}>
<Typography variant="h6" gutterBottom style={{ margin: "10px" }}>
{index + 1 }
</Typography>
<Typography variant="h6" gutterBottom style={{ margin: "10px" }}>
{row.fields.timestamp}
</Typography>
<Typography variant="h6" gutterBottom style={{ margin: "10px" }}>
{row.fields.user}
</Typography>
</Stack>
</div>
<ReactDiffViewer oldValue={row.fields.old_state} newValue={row.fields.new_state} splitView={true} />
<Divider style={{ marginTop: "10px" }}/>
</Box>
)
}

</Box>
);
} else {
return <LinearProgress />
}

}
4 changes: 2 additions & 2 deletions factsheet/frontend/src/conf.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"localhost": "http://localhost:8000/",
"toep1": "http://toep.iks.cs.ovgu.de/",
"toep3": "http://localhost:8000/",
"toep": "https://openenergy-platform.org/"
"toep": "http://localhost:8000/",
"toep2": "https://openenergy-platform.org/"
}
27 changes: 27 additions & 0 deletions factsheet/migrations/0004_auto_20231101_1613.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.2.7 on 2023-11-01 15:13

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('factsheet', '0003_alter_historyofoekg_timestamp'),
]

operations = [
migrations.CreateModel(
name='OEKG_Modifications',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('old_state', models.JSONField()),
('new_state', models.JSONField()),
('user', models.CharField(max_length=200)),
('timestamp', models.DateTimeField(default=django.utils.timezone.now)),
],
),
migrations.DeleteModel(
name='HistoryOfOEKG',
),
]
8 changes: 3 additions & 5 deletions factsheet/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
from django.utils import timezone


class HistoryOfOEKG(models.Model):
triple_subject = models.TextField()
triple_predicate = models.TextField()
triple_object = models.TextField()
type_of_action = models.CharField(max_length=100)
class OEKG_Modifications(models.Model):
old_state = models.JSONField()
new_state = models.JSONField()
user = models.CharField(max_length=200)
timestamp = models.DateTimeField(default=timezone.now)
2 changes: 1 addition & 1 deletion factsheet/static/factsheet/js/787.ec5380d6.chunk.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions factsheet/static/factsheet/js/main.54fc63bd.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ object-assign
@license MIT
*/

/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/

/*! fromentries. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
Expand Down
1 change: 1 addition & 0 deletions factsheet/static/factsheet/js/main.54fc63bd.js.map

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions factsheet/static/factsheet/js/main.ad8576ff.js

This file was deleted.

1 change: 0 additions & 1 deletion factsheet/static/factsheet/js/main.ad8576ff.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion factsheet/templates/factsheet/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
{% endblock main-content-body %}

{% block after-body-bottom-js %}
<script src="{% static 'factsheet/js/main.279f8558.js' %}"></script>
<script src="{% static 'factsheet/js/main.54fc63bd.js' %}"></script>
{% endblock after-body-bottom-js %}
7 changes: 3 additions & 4 deletions factsheet/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
re_path(r'^factsheet/*', views.factsheets_index),
re_path(r'^compare/*', views.factsheets_index),
re_path(r'^oekg_history/*', views.factsheets_index),
re_path(r'^oekg_modifications/*', views.factsheets_index),
path(r"add/", views.create_factsheet),
path(r"get_oekg_history/", views.get_history),
path(r"update/", views.update_factsheet),
Expand All @@ -25,8 +26,6 @@
path(r"query/", views.query_oekg),
path(r"get_scenarios/", views.get_scenarios),
path(r"test_query/", views.test_query),




path(r"get_oekg_modifications/", views.get_oekg_modifications),

]
Loading

0 comments on commit 076f20e

Please sign in to comment.