Skip to content

Commit

Permalink
Merge branch 'develop' into feature-enhance-embargo-are
Browse files Browse the repository at this point in the history
  • Loading branch information
wingechr authored Aug 30, 2024
2 parents ef77b8c + bdfe88b commit f9f712f
Show file tree
Hide file tree
Showing 36 changed files with 1,495 additions and 154 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/automated-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,22 @@ jobs:
run: |
python -m pip install --upgrade pip 'setuptools<72.0.0' wheel
pip install -r requirements.txt
pip install tox
pip install tox-uv
- name: Add schemas for testing
env:
PGPASSWORD: postgres
run: |
psql -h localhost -p 5432 -U postgres -c "CREATE SCHEMA IF NOT EXISTS sandbox" oedb
psql -h localhost -p 5432 -U postgres -c "CREATE SCHEMA IF NOT EXISTS _sandbox" oedb
- name: OEO-Integration & Test data
- name: oeo & oeo-ext integration
run: |
mkdir -p ontologies/oeo/1/
mkdir -p ontologies/oeo/1/imports
mkdir -p ontologies/oeo/1/modules
wget https://openenergy-platform.org/ontology/oeo/releases/oeo-full.owl -P ontologies/oeo/1/
wget https://openenergyplatform.org/ontology/oeo/releases/oeo-full.owl -P ontologies/oeo/1/
mkdir -p ontologies/oeo_ext/
cp oeo_ext/oeo_extended_store/oeox_template/oeo_ext_template_empty.owl ontologies/oeo_ext/oeo_ext.owl
- name: Collectstatic files & compress
run: |
cp oeplatform/securitysettings.py.default oeplatform/securitysettings.py
Expand Down
38 changes: 27 additions & 11 deletions dataedit/static/metaedit/metaedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ var MetaEdit = function(config) {
iconlib: 'fontawesome5',
mode: 'form',
compact: true,
remove_button_labels: true,
disable_collapse: true,
prompt_before_delete: false,
object_layout: "normal",
Expand Down Expand Up @@ -331,18 +330,14 @@ var MetaEdit = function(config) {

// TODO catch init error


window.JSONEditor.defaults.callbacks = {
"autocomplete": {
"search_name": function search(jseditor_editor, input) {
var url = "/api/v0/oeo-search?query=" + input;
var url = "https://openenergyplatform.org/api/v0/oeo-search?query=" + input;

return new Promise(function(resolve) {
fetch(url, {
mode: 'cors',
headers: {
'Access-Control-Allow-Origin': '*',
},
}).then(function(response) {
return response.json();
}).then(function(data) {
Expand All @@ -365,6 +360,18 @@ var MetaEdit = function(config) {
return selected_value;
},
},
"button": {
"openModalAction": function openOeoExtPlugin(jseditor, e) {
// Perform the HTMX request or any other desired action

htmx.ajax('GET', createUrl, {
target: '.modal-body',
swap: 'innerHTML',
trigger: 'click'
});
$('#formModal').modal('show');
}
}
};
});
} else {
Expand All @@ -379,7 +386,7 @@ var MetaEdit = function(config) {
iconlib: 'fontawesome5',
mode: 'form',
compact: true,
remove_button_labels: true,
// remove_button_labels: true,
disable_collapse: true,
prompt_before_delete: false,
object_layout: "normal",
Expand Down Expand Up @@ -420,14 +427,11 @@ var MetaEdit = function(config) {
window.JSONEditor.defaults.callbacks = {
"autocomplete": {
"search_name": function search(jseditor_editor, input) {
var url = "/api/v0/oeo-search?query=" + input;
var url = "https://openenergyplatform.org/api/v0/oeo-search?query=" + input;

return new Promise(function(resolve) {
fetch(url, {
mode: 'cors',
headers: {
'Access-Control-Allow-Origin': '*',
},
}).then(function(response) {
return response.json();
}).then(function(data) {
Expand All @@ -450,6 +454,18 @@ var MetaEdit = function(config) {
return selected_value;
},
},
"button": {
"openModalAction": function openOeoExtPlugin(jseditor, e) {
// Perform the HTMX request or any other desired action

htmx.ajax('GET', createUrl, {
target: '.modal-body',
swap: 'innerHTML',
trigger: 'click'
});
$('#formModal').modal('show');
}
}
};
});
}
Expand Down
35 changes: 34 additions & 1 deletion dataedit/static/metaedit/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "oemetaBuilder - Create & edit oemetadata json files using OEMetadata v1.6",
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/OpenEnergyPlatform/oemetadata/master/oemetadata/latest/schema.json",
"description": "Create & edit oemetadata json files using the OEMetadata v1.6 schema. See the Open Energy Platform metadata standard: https://github.com/OpenEnergyPlatform/oemetadata",
"description": "Application to create oemetadata in JSON format and download the JSON file to use it later or edit metadata on existing data tables. The builder currently uses the OEMetadata v1.6 schema. See the Open Energy Platform metadata standard: https://github.com/OpenEnergyPlatform/oemetadata",
"type": "object",
"properties": {
"name": {
Expand Down Expand Up @@ -63,6 +63,17 @@
"badge": "Platinum",
"title": "Path",
"format": "uri"
},
"openModalButton": {
"description": "Button to open a modal for HTMX request",
"format": "button",
"options": {
"button": {
"text": "Open OEO-EXT",
"icon": "external-link-alt",
"action": "openModalAction"
}
}
}
},
"badge": "Platinum",
Expand Down Expand Up @@ -580,6 +591,17 @@
"badge": "Platinum",
"title": "Path",
"format": "uri"
},
"openModalButton": {
"description": "Button to open a modal for HTMX request",
"format": "button",
"options": {
"button": {
"text": "Open OEO-EXT",
"icon": "external-link-alt",
"action": "openModalAction"
}
}
}
},
"badge": "Platinum",
Expand Down Expand Up @@ -625,6 +647,17 @@
"badge": "Platinum",
"title": "Path",
"format": "uri"
},
"openModalButton": {
"description": "Button to open a modal for HTMX request",
"format": "button",
"options": {
"button": {
"text": "Open OEO-EXT",
"icon": "external-link-alt",
"action": "openModalAction"
}
}
}
},
"badge": "Platinum",
Expand Down

Large diffs are not rendered by default.

76 changes: 63 additions & 13 deletions dataedit/templates/dataedit/meta_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,85 @@ <h2 class="site-header">
{% endblock site-header %}

{% block main %}
<div class="main-header">
<h1 class="main-header__title">
<i class="fa fa-tags d-none mr-2" id="metaedit-icon"></i> Edit Metadata
</h1>
<div class="main-header__wizard">
{% if table %}{{ schema }} / {% if table_label %} <a href="/dataedit/view/{{ schema }}/{{ table }}">{{ table_label }}</a> {% else %} <a href="/dataedit/view/{{ schema }}/{{ table }}">{{ table }}</a> {% endif %} / {% else %} Standalone (no data table attached) {% endif %} OEMetaBuilder
<!-- Indicate weather the user got permissions fot this table -->
{% if can_add %}
<span class="success-badge">
You can edit the metadata.
</span>
{% endif %}
</div>
</div>
<div class=" d-flex justify-content-center">
<div class="spinner-border text-primary m-5 d-none" role="status" id="metaedit-loading">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<div class="row d-none fixed-controls" id="metaedit-controls">
<div class="col">
<span class="" {% if not can_add %} data-bs-toggle="popover" title="You need write permissions on this table to upload meta data" {% endif %}>
<a href="#metaedit-submit" class="btn btn-sm btn-success mr-2 {% if not can_add %} disabled {% endif %}" id="metaedit-submit"><span class="spinner-border text-light d-none mr-2 spinner-border-sm" id="metaedit-submitting"></span>Submit</a>
</span>
<button class="btn btn-sm btn-primary mr-2" id="metaedit-cancel">Cancel</button>
<button class="btn btn-sm btn-primary mr-2" id="metaedit-download">Download</button>
</div>
</div>

<div class="row">

<div class="col">
<form iv id="metaedit-form">
<!-- placeholder -->
</form>
</div>
<div class="col">
<form iv id="metaedit-form">
<!-- placeholder -->
</form>
</div>
</div>
<div class="row d-none" id="metaedit-controls">
<div class="col">
<span class="" {% if not can_add %} data-bs-toggle="popover" title="You need write permissions on this table to upload meta data" {% endif %}>
<a href="#metaedit-submit" class="btn btn-sm btn-success mr-2 {% if not can_add %} disabled {% endif %}" id="metaedit-submit"><span class="spinner-border text-light d-none mr-2 spinner-border-sm" id="metaedit-submitting"></span>Submit</a>
</span>
<button class="btn btn-sm btn-primary mr-2" id="metaedit-cancel">Cancel</button>
<button class="btn btn-sm btn-primary mr-2" id="metaedit-download">Download</button>

<div>
<!-- Modal for oeo extended -->
<div class="modal fade" id="formModal" tabindex="-1" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalLabel">Add your custom units as extension to the oeo:</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<!-- Insert the form here -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>

</div>
</div>
</div>
</div>
</div>

{% endblock main %}

{% block after-body-bottom-js %}

<style>

.fixed-controls {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 1000; /* Ensure it is above other content */
background-color: white; /* Optional: Background color to make it stand out */
padding: 10px; /* Optional: Padding for better spacing */
border-radius: 5px; /* Optional: Rounded corners for better aesthetics */
box-shadow: 0 2px 10px rgba(0,0,0,0.1); /* Optional: Add a slight shadow for better visibility */
}
</style>
{% compress js %}
<script src="/static/metaedit/vendor/json-editor-2.9.1/jsoneditor.min.js"></script>
<script src="/static/metaedit/metaedit.js"></script>
<script src="{% static 'modelview/htmx.min.js' %}"></script>
{% endcompress %}
<!-- fix imports below - we dont use cdn anymore -->
<script src="https://unpkg.com/@trevoreyre/autocomplete-js"></script>
Expand All @@ -54,6 +103,7 @@ <h2 class="site-header">
/>

<script>
var createUrl = '{% url "oeo_ext:oeo-ext-plugin-ui-create" %}';
var config = JSON.parse("{{ config|escapejs }}");
MetaEdit(config);
$(function () {
Expand Down
36 changes: 17 additions & 19 deletions dataedit/templates/dataedit/opr_review.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,19 @@ <h2 id="review-field-name" style="display:none"></h2>
{% endblock main %}

{% block after-body-bottom-js %}
<script>
<script type="text/javascript">
const fieldDescriptionsData = JSON.parse(document.getElementById("field-descriptions-json").textContent);
var config = JSON.parse("{{ config|escapejs }}");
let state_dict = JSON.parse('{{ state_dict | escapejs }}');
if ( state_dict && Object.keys(state_dict).length > 0) {
for (let [key, value] of Object.entries(state_dict)) {
let field_id = `#field_${key}`.replace(/\./g, "\\.");
$(field_id).addClass(`field-${value}`);
for (let [key, value] of Object.entries(state_dict)) {
let field_id = `#field_${key}`.replace(/\./g, "\\.");
$(field_id).addClass(`field-${value}`);
}
}
}

// var existing_review = JSON.parse("{{ existing_review | escapejs }}");
</script>
<script type="text/javascript">

document.addEventListener("DOMContentLoaded", function() {
let keys = document.querySelectorAll(".key");
keys.forEach(key => {
Expand All @@ -339,20 +338,19 @@ <h2 id="review-field-name" style="display:none"></h2>
key.textContent = formattedWords.join(" ");
});
});
</script>
<script>
var initialReviewerSuggestions = {};

window.onload = function() {
var suggestions = document.querySelectorAll('.suggestion--highlight');
var initialReviewerSuggestions = {};

window.onload = function() {
var suggestions = document.querySelectorAll('.suggestion--highlight');

suggestions.forEach(function(suggestion) {
var field = suggestion.id.split('_')[1];
initialReviewerSuggestions[field] = suggestion.innerText;
});
console.log(initialReviewerSuggestions);
}
</script>
suggestions.forEach(function(suggestion) {
var field = suggestion.id.split('_')[1];
initialReviewerSuggestions[field] = suggestion.innerText;
});
// console.log(initialReviewerSuggestions);
}
</script>

{% compress js %}
<script src="/static/peer_review/opr_reviewer.js"></script>
Expand Down
14 changes: 14 additions & 0 deletions dataedit/templates/dataedit/tag_overview.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
{% extends "dataedit/base.html" %}
{% load static %}

{% block site-header %}
<div class="main-header">
<h1 class="main-header__title">
<svg width="20" height="20" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.31781 2.68742C3.35608 3.12457 3 3.62628 3 4C3 4.37372 3.35608 4.87543 4.31781 5.31258C5.23441 5.72922 6.53579 6 8 6C9.46421 6 10.7656 5.72922 11.6822 5.31258C12.6439 4.87543 13 4.37372 13 4C13 3.62628 12.6439 3.12457 11.6822 2.68742C10.7656 2.27078 9.46421 2 8 2C6.53579 2 5.23441 2.27078 4.31781 2.68742ZM13 5.69813C12.729 5.90046 12.4201 6.07563 12.096 6.22295C11.022 6.71114 9.57336 7 8 7C6.42664 7 4.97802 6.71114 3.90401 6.22295C3.5799 6.07563 3.27105 5.90046 3 5.69813V7C3 7.37372 3.35608 7.87543 4.31781 8.31258C5.23441 8.72922 6.53579 9 8 9C9.46421 9 10.7656 8.72922 11.6822 8.31258C12.6439 7.87543 13 7.37372 13 7V5.69813ZM14 4C14 2.993 13.1249 2.24472 12.096 1.77705C11.022 1.28886 9.57336 1 8 1C6.42664 1 4.97802 1.28886 3.90401 1.77705C2.87513 2.24472 2 2.993 2 4V13C2 14.007 2.87513 14.7553 3.90401 15.2229C4.97802 15.7111 6.42664 16 8 16C9.57336 16 11.022 15.7111 12.096 15.2229C13.1249 14.7553 14 14.007 14 13V4ZM13 8.69813C12.729 8.90046 12.4201 9.07563 12.096 9.22295C11.022 9.71114 9.57336 10 8 10C6.42664 10 4.97802 9.71114 3.90401 9.22295C3.5799 9.07563 3.27105 8.90046 3 8.69813V10C3 10.3737 3.35608 10.8754 4.31781 11.3126C5.23441 11.7292 6.53579 12 8 12C9.46421 12 10.7656 11.7292 11.6822 11.3126C12.6439 10.8754 13 10.3737 13 10V8.69813ZM13 11.6981C12.729 11.9005 12.4201 12.0756 12.096 12.2229C11.022 12.7111 9.57336 13 8 13C6.42664 13 4.97802 12.7111 3.90401 12.2229C3.5799 12.0756 3.27105 11.9005 3 11.6981V13C3 13.3737 3.35608 13.8754 4.31781 14.3126C5.23441 14.7292 6.53579 15 8 15C9.46421 15 10.7656 14.7292 11.6822 14.3126C12.6439 13.8754 13 13.3737 13 13V11.6981Z" fill="#293B46"/>
</svg>
Database
</h1>
<div class="main-header__wizard">
Tags
</div>
</div>
{% endblock site-header %}

{% block data_content %}

{% load dataedit.taghandler %}
Expand Down
2 changes: 2 additions & 0 deletions dataedit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1820,6 +1820,8 @@ def get(self, request, schema, table):
)

context_dict = {
"schema": schema,
"table": table,
"config": json.dumps(
{
"schema": schema,
Expand Down
Loading

0 comments on commit f9f712f

Please sign in to comment.