Skip to content

Commit

Permalink
Create/upload project forms
Browse files Browse the repository at this point in the history
  • Loading branch information
LeldeLace committed Nov 15, 2024
1 parent cb1fb65 commit dc67cb4
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 9 deletions.
13 changes: 12 additions & 1 deletion app/imports/client/platform/templates/diagrams/diagrams.html
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ <h4 class="modal-title">Upload</h4>

<template name="configuratorDiagramOptions">
{{#each configuratorDiagrams}}
<option id="{{_id}}">{{name}}</option>
<option {{selected}} id="{{_id}}" >{{name}}</option>
{{/each}}
</template>

Expand Down Expand Up @@ -540,6 +540,17 @@ <h4 class="modal-title">Project Settings</h4>
</div>
</div>

<div class="form-group">
<label for="schema-tag" class="col-sm-3 control-label">Schema Tag</label>
<div class="col-sm-9">
<select class="form-control" id="schema-tags" >
{{#each schema_tags}}
<option value="{{name}}">{{display_name}}</option>
{{/each}}
</select>
</div>
</div>

<div class="form-group">
<label for="ontology-endpoint" class="col-sm-3 control-label">SPARQL Endpoint</label>
<div class="col-sm-9">
Expand Down
55 changes: 50 additions & 5 deletions app/imports/client/platform/templates/diagrams/diagrams.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ Template.diagramsRibbon.events({
//shows dialog window to enter diagram name
'click #add': function(e) {
Dialog.destroyTooltip(e);
let dt = [];
for (const d of DiagramTypes.find({}, {$sort: {name: 1}})) {
let e = {_id:d._id, name:d.name};
if ( d.name == 'Query' )
e.selected = 'selected';
dt.push(e);
}
Template.configuratorDiagramOptions.configuratorDiagrams.set(dt);
$('#add-diagram').modal("show");
},

Expand Down Expand Up @@ -188,6 +196,7 @@ Template.diagramsToolbar.events({
'click #upload-project': function(e) {
// e.preventDefault();
Dialog.destroyTooltip(e);
Template.uploadProject.loading.set(false);
$('#upload-project-form').modal("show");
},

Expand Down Expand Up @@ -675,6 +684,8 @@ Template.uploadProject.events({


Template.ontologySettings.schemas = new ReactiveVar([{name: ""}]);
Template.ontologySettings.allSchemas = new ReactiveVar();
Template.ontologySettings.schemaTags = new ReactiveVar([{name:"All", display_name: "All schemas"}]);
Template.ontologySettings.uri = new ReactiveVar("");
Template.ontologySettings.endpoint = new ReactiveVar("");
Template.ontologySettings.queryEngineType = new ReactiveVar("");
Expand Down Expand Up @@ -862,7 +873,11 @@ Template.ontologySettings.events({
Template.ontologySettings.indirectClassMembershipRole.set("");
}
},

'change #schema-tags' : function(){
var tag = $("#schema-tags").val();
Template.ontologySettings.schemas.set(getSchemas(tag));
//var tag = $("#schema-tags").find(":selected").attr("id");
},
//adds context menu item
'click #add-graph-menu-item': function() {
var graphs = Template.ontologySettings.graphs.get();
Expand Down Expand Up @@ -905,8 +920,32 @@ Template.ontologySettings.events({
});


function getSchemas(tag) {
let schemas = [];
const allSchemas = Template.ontologySettings.allSchemas.get();

for ( const sc of allSchemas ) {
if ( tag != 'All' && sc.tags.includes(tag))
schemas.push(sc);
else if ( tag == 'All' )
schemas.push(sc);
}

schemas.unshift({display_name: ""});
return schemas;
}

Template.ontologySettings.rendered = async function() {
var rr = await dataShapes.getOntologies();
var rr = await dataShapes.getOntologiesAndTags();
var tags = rr.tags;
tags.unshift({name:"All", display_name: "All schemas"});
Template.ontologySettings.schemaTags.set(tags);

var schemas = rr.schemas;
Template.ontologySettings.allSchemas.set(schemas);
schemas = getSchemas('All');

// var schemas = await dataShapes.getOntologies();
var proj = Projects.findOne({_id: Session.get("activeProject")});

if (proj) {
Expand All @@ -920,14 +959,14 @@ Template.ontologySettings.rendered = async function() {
// else Template.ontologySettings.graphs.set([]);

if (proj.schema != undefined && proj.schema != "") {
var selected = rr.filter(function(o){ return o.display_name == proj.schema});
var selected = schemas.filter(function(o){ return o.display_name == proj.schema});
if ( selected.length > 0 ) {
selected[0]["selected"] = "selected";
}
}
}

Template.ontologySettings.schemas.set(rr);
Template.ontologySettings.schemas.set(schemas);
}

Template.ontologySettings.helpers({
Expand Down Expand Up @@ -958,6 +997,10 @@ Template.ontologySettings.helpers({
schemas: function() {
return Template.ontologySettings.schemas.get();
},

schema_tags:function() {
return Template.ontologySettings.schemaTags.get();
},

useStringLiteralConversionList: function() {
var proj = Projects.findOne({_id: Session.get("activeProject")});
Expand Down Expand Up @@ -1123,10 +1166,12 @@ Template.ontologySettings.helpers({


//returns diagram types for drop down when user creates a new diagram
Template.configuratorDiagramOptions.configuratorDiagrams = new ReactiveVar();

Template.configuratorDiagramOptions.helpers({
configuratorDiagrams: function() {
return DiagramTypes.find({}, {$sort: {name: 1}});
return Template.configuratorDiagramOptions.configuratorDiagrams.get();
//return DiagramTypes.find({}, {$sort: {name: 1}});
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Template.projectsT.events({
//opens new project dialog (modal)
'click #createProject' : function(e, templ) {
e.preventDefault();

Template.createProjectModal.loading.set(false);
$("#add-project").modal("show");

return false;
Expand Down
3 changes: 1 addition & 2 deletions app/imports/client/platform/templates/structure/structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Template.structureRibbon.events({

'click #add': function(e) {
e.preventDefault();

Template.createProjectModal.loading.set(false);
$("#add-project").modal("show");
return;
},
Expand All @@ -190,7 +190,6 @@ function setServices (tool_id) {
if ( tool_id != 'undefined')
{
var services = Services.findOne({toolId: tool_id });
console.log("Atrada rīkam services", services)
if (services && services.schemas)
{
result.schemas = [];
Expand Down

0 comments on commit dc67cb4

Please sign in to comment.