Commit 54917e8f authored by akucera's avatar akucera
Browse files

trend working including UI

added link to the BMS
added link to the BMS charts
parent 2731375d
......@@ -50,45 +50,17 @@
var p = new SBMSPage({
addresses : [],
fieldsType : "field.insert.dataPoint",
fieldsType : "fields/insert.dataPoint",
endpoint : "datapoints",
addressType : "dataPoint",
debug : true,
//debug : true,
init: function() {
if (window.location.hash != null
&& window.location.hash != ""
&& window.location.hash != "#") {
var panel = window.location.hash.substring(1);
p.loadPanelFromFile("#nav" + panel);
} else {
p.loadPanelFromFile("li.opNav.active");
}
/*
$(".opDiv").hide();
// loading divs
$(".opDiv").each(function() {
p.semaphore++;
$(this).load($(this).attr("data-incl-file"), function() { if(--p.semaphore == 0) { p.delayedInit(); } });
});
$("#" + $("li.opNav.active").attr("data-show-div")).show();
*/
p.initPanels();
$(".opNav").click(function() { p.loadPanelFromFile($(this)); } );
//$("#kompasFrame").attr("src", p.mapURL);
},
loadPanelFromFile : function(srcSelector) {
var src = $(srcSelector);
p.switchTab("opNav", src);
$("#content").load(src.attr("data-incl-file"), function() {
p[src.attr("data-init-func")]();
});
},
initInsertSingle : function() {
$("#selectorTree").hide();
$(".selectorNav").click(
......@@ -110,7 +82,7 @@
}
});
p.loadList("field.insert.dataPoint",
p.loadList("fields/insert.dataPoint",
[ p.createParams ],
[
"#params",
......@@ -138,21 +110,21 @@
},
initInsertTrends : function() {
p.fieldsType = "field.insert.trend";
p.fieldsType = "fields/insert.trend";
p.endpoint = "trends";
p.addressType = "trend";
p.initBatchCommon();
},
initInsertPrograms : function() {
p.fieldsType = "field.insert.usage";
p.fieldsType = "fields/insert.usage";
p.endpoint = "relations";
p.addressType = "algorithm";
p.initBatchCommon();
},
initInsertInfluence : function() {
p.fieldsType = "field.insert.influence";
p.fieldsType = "fields/insert.influence";
p.endpoint = "relations";
p.addressType = "address";
p.initBatchCommon();
......@@ -282,7 +254,9 @@
}
}, "logBatch", "batchOverallStatus");
} else {
completeAction();
p.toggleButtonFinishing("batchOverallStatus");
// query to reopen the model
$.ajax({type: "get", url: SBMSPage.prototype.sbmsURL + "datapoints/" + data[0].bmsId }).done(completeAction);
}
},
......@@ -305,6 +279,7 @@
var query = p.sbmsURL + p.endpoint;
var d = {};
d[p.addressType] = address;
/*
if(p.debug) {
ba(overallStatusId);
$("#" + logId).append("\nDEBUG Mode - data are not sent. Data:\n" +
......@@ -313,6 +288,7 @@
ca(overallStatusId, "success");
return;
}
*/
$.ajax({
type : 'POST',
cache : false,
......@@ -412,7 +388,7 @@
} else if (iA < assertions.length) {
p.removeAssertions(assertions, ++iA, ids, 0);
} else {
$("#removeOverallStatus").html($.t("Finishing..."));
p.toggleButtonFinishing("removeOverallStatus");
// query to reopen the model
$.ajax({type: "get", url: SBMSPage.prototype.sbmsURL + "datapoints/" + ids[0] }).done(function() {
p.toggleButtonSuccess("removeOverallStatus");
......
......@@ -20,7 +20,7 @@
<li data-page="sparql"><a href="sparql.html" data-i18n="sparql">SPARQL</a></li>
</ul>
<form id="login" class="navbar-form navbar-right"
action="insert.html" method="GET">
action="#" method="GET">
<div class="form-group">
<label for="user" class="sr-only" data-i18n="user">User</label> <input
type="text" name="username" id="user" class="form-control"
......
<div class="row equal">
<div class="col-lg-6 col-md-4">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title" data-i18n="Filters">Filters</h3></div>
<div class="panel-body">
<p data-i18n="query.filters.text"></p>
<div class="row">
<div id="params" class="form-horizontal form-group"></div>
</div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title" data-i18n="Attributes">Attributes</h3></div>
<div class="panel-body">
<p data-i18n="query.attributes.text"></p>
<div class="btn-group btn-group-xs" role="group">
<button type="button" id="selectAll" class="btn btn-default" data-i18n="Select All">Select All</button>
<button type="button" id="deselectAll" class="btn btn-default" data-i18n="Deselect All">Deselect All</button>
</div>
<div class="row">
<div id="fields" class="form-horizontal form-group"></div>
</div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title" data-i18n="Grouping">Grouping</h3></div>
<div class="panel-body">
<p data-i18n="query.groups.text"></p>
<div class="row">
<div id="groups" class="form-horizontal form-group"></div>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -45,7 +45,7 @@
init: function () {
p.loadList("field.data", function(headers, params) {
p.loadList("fields/data.dataPoint", function(headers, params) {
dpId = p.getQueryVariable("bmsId");
if(!dpId) {
......
......@@ -15,33 +15,50 @@ var translation = {
"query.filters.text" : "Results have to meet the following criteria:",
"query.attributes.text" : "Resulting dataset will contain datapoints described by the following attributes:",
"query.groups.text" : "Result will be divided into groups according to the following criteria:",
'bmsId' : 'bmsId',
'type' : 'type',
'source.bimId' : 'source.bimId',
'source.type' : 'source.type',
'source.location' : 'source.location',
'scope.bimId' : 'scope.bimId',
'scope.type' : 'scope.type',
'scope.location' : 'scope.location',
'sensing.type' : 'sensing.type',
'sensing.window' : 'sensing.window',
'property.domain' : 'property.domain',
'property.quality' : 'property.quality',
'influenced.scope.bimId' : 'influenced.scope.bimId',
'influenced.property.quality' : 'influenced.property.quality',
'influenced.property.domain' : 'influenced.property.domain',
'bmsId' : 'BMS address',
'type' : 'Object type',
'source.bimId' : 'Source',
'source.type' : 'Source type',
'source.location' : 'Source location',
'scope.bimId' : 'Scope',
'scope.type' : 'Scope type',
'scope.location' : 'Scope location',
'sensing.type' : 'Sensing type',
'sensing.window' : 'Sensing window',
'property.domain' : 'O. property domain',
'property.quality' : 'O. property quality',
'influenced.scope.bimId' : 'Influenced &ndash; Scope',
'influenced.property.quality' : 'Influenced &ndash; Quality',
'influenced.property.domain' : 'Influenced &ndash; Domain',
'publisher.bimId' : 'Publisher device',
'noGrouping' : 'noGrouping',
'scope.room' : 'scope.room',
'scope.floor' : 'scope.floor',
'scope.building' : 'scope.building',
'scope.site' : 'scope.site',
'source.room' : 'source.room',
'source.floor' : 'source.floor',
'source.building' : 'source.building',
'source.site' : 'source.site',
'datapoint.type' : 'datapoint.type',
'UserDefined' : 'User defined',
'dataPoint.bmsId' : 'Sensor BMS address',
'dataPoint.type' : 'Sensor Object type',
'dataPoint.source.bimId' : 'Source',
'dataPoint.source.type' : 'Source type',
'dataPoint.source.location' : 'Source location',
'dataPoint.scope.bimId' : 'Scope',
'dataPoint.scope.type' : 'Scope type',
'dataPoint.scope.location' : 'Scope location',
'dataPoint.sensing.type' : 'Sensing type',
'dataPoint.sensing.window' : 'Sensing window',
'dataPoint.property.domain' : 'O. property domain',
'dataPoint.property.quality' : 'O. property quality',
'dataPoint.influenced.scope.bimId' : 'Influenced &ndash; Scope',
'dataPoint.influenced.property.quality' : 'Influenced &ndash; Quality',
'dataPoint.influenced.property.domain' : 'Influenced &ndash; Domain',
'dataPoint.publisher.bimId' : 'Publisher device',
'noGrouping' : 'No grouping',
'scope.room' : 'Scope &ndash; Room',
'scope.floor' : 'Scope &ndash; Floor',
'scope.building' : 'Scope &ndash; Building',
'scope.site' : 'Scope &ndash; Site',
'source.room' : 'Source &ndash; Room',
'source.floor' : 'Source &ndash; Floor',
'source.building' : 'Source &ndash; Building',
'source.site' : 'Source &ndash; Site',
'datapoint.type' : 'Data Point Type',
'UserDefined' : 'User defined',
'group' : 'Group'
}
},
......@@ -85,6 +102,30 @@ var translation = {
"influenced.property.quality" : "Ovlivňovaná veličina",
"influenced.property.domain" : "Ovlivňované Médium/Prostředí",
'publisher.bimId' : 'Publikující zařízení',
"dataPoint.bmsId" : "Adresa senzoru v BMS",
"dataPoint.type" : "Typ objektu (senzor)",
"dataPoint.source.bimId" : "Zdrojové zařízení",
"dataPoint.source.type" : "Typ zdroj. zařízení",
"dataPoint.source.location" : "Poloha zdroje",
"dataPoint.source.room" : "Místnost (zdroj)",
"dataPoint.source.floor" : "Podlaží (zdroj)",
"dataPoint.source.building" : "Budova (zdroj)",
"dataPoint.source.site" : "Areál (zdroj)",
"dataPoint.scope.bimId" : "Předmět zájmu (PZ)",
"dataPoint.scope.type" : "Typ PZ",
"dataPoint.scope.location" : "Poloha PZ",
"dataPoint.scope.room" : "Místost (PZ)",
"dataPoint.scope.floor" : "Podlaží (PZ)",
"dataPoint.scope.building" : "Budova (PZ)",
"dataPoint.scope.site" : "Areál (PZ)",
"dataPoint.sensing.type" : "Typ měření",
"dataPoint.sensing.window" : "Období měření",
"dataPoint.property.domain" : "Médium/Prostředí",
"dataPoint.property.quality" : "Veličina",
"dataPoint.influenced.scope.bimId" : "Ovlivňovaný PZ",
"dataPoint.influenced.property.quality" : "Ovlivňovaná veličina",
"dataPoint.influenced.property.domain" : "Ovlivňované Médium/Prostředí",
'dataPoint.publisher.bimId' : 'Publikující zařízení',
'temperature' : 'Teplota',
'Input' : 'Vstup',
'Output' : 'Výstup',
......@@ -108,7 +149,11 @@ var translation = {
'Water' : 'Voda',
'TemperatureSensor' : 'Teplotní čidlo',
'Room' : 'Místnost',
'StatelessDirectSensing' : 'Přímé měření'
'StatelessDirectSensing' : 'Přímé měření',
'group' : 'Skupina',
'Data Points' : 'Datové body',
'Trends' : 'Historická data',
'Relations' : 'Vztahy'
}
},
......
......@@ -21,6 +21,7 @@ function SBMSPage(custom) {
if(SBMSPage["noAuth"]) {
$("#login").hide();
}
SBMSPage.prototype.i18nInit();
SBMSPage.prototype.savePassInit();
initFunc();
......@@ -36,7 +37,13 @@ function SBMSPage(custom) {
SBMSPage.prototype.trees = {};
SBMSPage.prototype.mapURL = "https://kompas.muni.cz/auth/";
SBMSPage.prototype.sbmsURL = "/sbms/v1/";
SBMSPage.prototype.bmsChartsURL = "https://bms.muni.cz/Charts/";
SBMSPage.prototype.trendDBs = ["93", "94"];
SBMSPage.prototype.bmsURL = "https://bms.muni.cz/deltaweb/newlogin/?Referer=/deltaweb/navigator/index.asp&FrameSrc=%2Fdeltaweb%2Fnavigator%2FObject%5F{0}%2Easp%3FObjRef%3DBAC%2E{1}";
// "https://bms.muni.cz/deltaweb/newlogin/?Referer=/deltaweb/navigator/index.asp&FrameSrc=%2Fdeltaweb%2Fnavigator%2FObject%5F{0}%2Easp%3FObjRef%3DBAC%2E{1}";
// http://bms.muni.cz/deltaweb/login.asp?Referer=%2Fdeltaweb%2Fnavigator%2FObject%5FAV%2Easp%3FObjRef%3DBAC%2E11304%2EAV202 &logoffReason=1
// https://bms.muni.cz/deltaweb/newlogin/?Referer=/deltaweb/navigator/index.asp&FrameSrc=%2Fdeltaweb%2Fnavigator%2FObject%5FAV%2Easp%3FObjRef%3DBAC%2E11304%2EAV202 &logoffReason=1
// https://bms.muni.cz/deltaweb/shibblogin/SSOLogin.aspx?Referer=/deltaweb/navigator/index.asp&FrameSrc=%2Fdeltaweb%2Fnavigator%2FObject%5FAV%2Easp%3FObjRef%3DBAC%2E11304%2EAV202%20&logoffReason=1
SBMSPage.prototype.setAuth = function(xhr) {
xhr.setRequestHeader('authorization', "Basic " + Base64.encode($("#user").val() + ":" + $("#pass").val()));
};
......@@ -66,13 +73,17 @@ function SBMSPage(custom) {
//$("#status").html("Completed with " + status);
$(".sendButton").removeAttr("disabled");
};
SBMSPage.prototype.toggleButtonFinishing = function(id) {
$("#"+ id).html($.t("Finishing..."));
};
SBMSPage.prototype.loadList = function(type, func, params) {
this.loadList(type, func, params, null);
};
SBMSPage.prototype.loadList = function(type, func, params, member) {
var query= this.sbmsURL + "types/" + type;
var query= this.sbmsURL + type;
if(member != null && member != "") {
query+="/" + member;
}
......@@ -133,7 +144,7 @@ function SBMSPage(custom) {
$.ajax({
type: 'GET',
cache: true,
url: SBMSPage.prototype.sbmsURL + "types/field.source"
url: SBMSPage.prototype.sbmsURL + "fields/source"
}).done( function(fieldsList) {
// saving to cache
SBMSPage.prototype.fieldCategories = fieldsList;
......@@ -196,7 +207,7 @@ function SBMSPage(custom) {
// filling lists
$("select", "#params").each(function(key, selectEl) {
SBMSPage.prototype.loadList(SBMSPage.prototype.getField(selectEl.id) /*.replace("influenced.", "")*/, function(data, params) {
SBMSPage.prototype.loadList("types/" + SBMSPage.prototype.getField(selectEl.id) /*.replace("influenced.", "")*/, function(data, params) {
var select = $("#" + params[0]);
select.selectpicker();
var html = '<option value=""></option>';
......@@ -230,7 +241,7 @@ function SBMSPage(custom) {
var sid = "#" + id;
var field = SBMSPage.prototype.getField(id);
// load the first level
SBMSPage.prototype.loadList(field, function(data, params) {
SBMSPage.prototype.loadList("types/" + field, function(data, params) {
var treeName = params[0];
SBMSPage.prototype.trees[treeName] = { type: field, index: "0", selectId: sid };
SBMSPage.prototype.populateNode(SBMSPage.prototype.trees[treeName], data);
......@@ -313,7 +324,7 @@ function SBMSPage(custom) {
$.ajax({
type: 'GET',
cache: true,
url: SBMSPage.prototype.sbmsURL + "types/field.source"
url: SBMSPage.prototype.sbmsURL + "fields/source"
}).done( function(fieldsList) {
this.fieldCategories = fieldsList;
SBMSPage.prototype.enrichPVC(parent, fieldsList, callback);
......@@ -331,6 +342,18 @@ function SBMSPage(custom) {
if(fl[field] == "bim") {
$(this).append(' <button type="button" class="btn btn-default btn-xs mapButton" data-field="' + encodeURIComponent(field) + '" data-field-value="' + encodeURIComponent(propVal) + '"><span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span></button>');
}
if(fl[field] == "bms") {
$(this).append(' <button type="button" class="btn btn-default btn-xs bmsButton" data-field="' + encodeURIComponent(field) + '" data-field-value="' + encodeURIComponent(propVal) + '"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span></button>');
if(propVal.indexOf(".TL") > -1) {
for(var i = 0; i < SBMSPage.prototype.trendDBs.length; i++) {
if(propVal.startsWith(SBMSPage.prototype.trendDBs[i])) {
$(this).append(' <button type="button" class="btn btn-default btn-xs trendButton" data-field="' + encodeURIComponent(field) + '" data-field-value="' + encodeURIComponent(propVal) + '"><span class="glyphicon glyphicon-stats" aria-hidden="true"></span></button>');
break;
}
}
}
}
}
});
callback();
......@@ -365,6 +388,22 @@ SBMSPage.prototype.getQueryVariable = function(variable)
return(false);
};
SBMSPage.prototype.initPanels = function() {
if (window.location.hash != null
&& window.location.hash != ""
&& window.location.hash != "#") {
var panel = window.location.hash.substring(1);
p.loadPanelFromFile("#nav" + panel);
} else {
p.loadPanelFromFile("li.opNav.active");
}
$(".opNav").click(function() { p.loadPanelFromFile($(this)); } );
};
SBMSPage.prototype.switchPanel = function(navClass, divClass, activeNav, activeDiv) {
$("."+ divClass).hide();
$("." + navClass).removeClass("active");
......@@ -377,6 +416,17 @@ SBMSPage.prototype.switchTab = function(navClass, activeNav) {
activeNav.addClass("active");
};
SBMSPage.prototype.loadPanelFromFile = function(srcSelector) {
var src = $(srcSelector);
p.switchTab("opNav", src);
$("#content").load(src.attr("data-incl-file"), function() {
p[src.attr("data-init-func")]();
$("#content").localize();
$('a[data-sbms-tab-href="yes"]').attr("href",src.children().first().attr("href"));
});
};
SBMSPage.prototype.langPanelSetup = function(lang) {
$("#langIndicator").html($("a.langChange[data-lang='" + lang + "']").attr("data-lang-indicator-abbrev"));
......@@ -433,7 +483,11 @@ SBMSPage.prototype.showLoading = function() {
$(document).ajaxStop(function() {$("#loading").dialog("close");})
}
SBMSPage.prototype.savePassInit = function() {
var creds = (Cookies.get("sbms-login") != null) ? Cookies.get("sbms-login").split(":") : ["", ""];
$("#user").val(creds[0]);
$("#pass").val(creds[1]);
$("#login").submit(function() {
Cookies.set("sbms-login", $("#user").val() + ":" + $("#pass").val());
this.reset();
});
};
......
......@@ -51,19 +51,13 @@
var p = new SBMSPage ({
endpoint: "datapoints/",
init: function() {
$("#results").hide();
$("#resultsJSON").hide();
$("button#selectAll").click(function() {
$('input[name=fieldsC]').prop("checked", true);
});
$("button#deselectAll").click(function() {
$('input[name=fieldsC]').prop("checked", false);
});
$("#showJSON").click(function() {
p.switchPanel("resultsNav", "resultsDiv", this, "resultsJSON");
});
......@@ -72,7 +66,7 @@ var p = new SBMSPage ({
p.switchPanel("resultsNav", "resultsDiv", this, "resultsTable");
});
$("#mapSelect").dialog({
$("#fsSelect").dialog({
modal: true,
width: $(window).width() - 40,
height: $(window).height() - 40,
......@@ -83,26 +77,50 @@ var p = new SBMSPage ({
modal: true,
width: 800,
maxHeight: 800,
position: { my: "center top", at: "right top", of: $("#params") },
position: { my: "center top", at: "center top", of: $("#content") },
autoOpen: false
});
$("button#send").click(p.sendQuery);
p.loadList("field.data", [p.createList, function() { $('input[name=fieldsC]:eq(0)').prop("checked", true); } ], [ "#fields", "checkbox", "fieldsC" ]);
p.loadList("grouping", p.createList, [ "#groups", "radio", "groupsR" ]);
p.loadList("field.filter", p.createParams, ["#params", true,
function() {$("#treeSelect").dialog("open") },
function() {$("#treeSelect").dialog("close") },
function() {$("#mapSelect").dialog("open") },
function() { },
"kompasFrame",
"tree"
]);
p.initPanels();
},
initQueryDP : function() {
p.endpoint = "datapoints/";
p.initQueryAddress("dataPoint");
},
initQueryTrends : function() {
p.endpoint = "trends/"
p.initQueryAddress("trend");
},
initQueryAddress : function(addressType) {
$("button#selectAll").click(function() {
$('input[name=fieldsC]').prop("checked", true);
});
$("button#deselectAll").click(function() {
$('input[name=fieldsC]').prop("checked", false);
});
$("button#send").click(p.sendQuery);
p.loadList("fields/data." + addressType, [p.createList, function() { $('input[name=fieldsC]:eq(0)').prop("checked", true); } ], [ "#fields", "checkbox", "fieldsC" ]);
p.loadList("fields/grouping", p.createList, [ "#groups", "radio", "groupsR" ]);
p.loadList("fields/filter." + addressType, p.createParams, ["#params", true,
function() {$("#treeSelect").dialog("open") },
function() {$("#treeSelect").dialog("close") },
function() {$("#fsSelect").dialog("open") },
function() { },
"extFrame",
"tree"
]);
},
initQueryRelations : function() {
},
makeTableFromJSON: function(data, fieldsSelector, target) {
var html="<table id='jsonTable' class='table table-bordered table-hover'><thead><tr><th>group</th>";
......@@ -156,11 +174,23 @@ var p = new SBMSPage ({
// adding actions to buttons
$(target + " .mapButton").click(function() {
//$("#kompasFrame").attr("src", mapURL + "?code=" + decodeURIComponent(this.id.substring(6)));
$("#kompasFrame").attr("src", p.mapURL + "?code=" + $(this).attr("data-field-value"));
$("#mapSelect").dialog("open");
$("#extFrame").attr("src", p.mapURL + "?code=" + $(this).attr("data-field-value"));
$("#fsSelect").dialog("open");
});
$(target + " .trendButton").click(function() {
//$("#kompasFrame").attr("src", mapURL + "?code=" + decodeURIComponent(this.id.substring(6)));
$("#extFrame").attr("src", p.bmsChartsURL + "?tl=" + $(this).attr("data-field-value"));
$("#fsSelect").dialog("open");
});
$(target + " .bmsButton").click(function() {
//$("#kompasFrame").attr("src", mapURL + "?code=" + decodeURIComponent(this.id.substring(6)));
var propVal = $(this).attr("data-field-value");
$("#extFrame").attr("src", SBMSPage.prototype.bmsURL.replace("{0}", propVal.replace(/[0-9\.]/g,"")).replace("{1}", propVal));
$("#fsSelect").dialog("open");
});
});
},
......@@ -180,7 +210,7 @@ var p = new SBMSPage ({
data[p.getField(this.id)] = $(this).val();
}
});
var query= p.sbmsURL + "datapoints/"; //+ qs;
var query= p.sbmsURL + p.endpoint; //+ qs;
$.ajax({
type: 'GET',
cache: false,
......@@ -232,6 +262,11 @@ var p = new SBMSPage ({
.no-close .ui-dialog-titlebar-close {
display: none;
}