143 lines
3.9 KiB
HTML
143 lines
3.9 KiB
HTML
<%frame "frame.html"%>
|
|
|
|
<h1>Check Parameters</h1>
|
|
|
|
<div class="flex row">
|
|
<table id="checkTable"></table>
|
|
</div>
|
|
|
|
<div class="flex">
|
|
<div>
|
|
Warnschwelle: <input id="WarnLower"> < LastValue < <input id="WarnUpper"><br>
|
|
Kritische Schwelle: <input id="CritLower"> < LastValue < <input id="CritUpper"><br>
|
|
<button onclick="apply();">Übernehmen</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var selected = {}
|
|
|
|
$("#checkTable").DataTable({
|
|
columns: [
|
|
{ title: "", data: null },
|
|
{ title: "PerfName", data: "PerfName" },
|
|
{ title: "CheckState", data: "CheckState" },
|
|
{ title: "LastValue", data: "LastValue" },
|
|
{ title: "WarnLower", data: "WarnLower" },
|
|
{ title: "WarnUpper", data: "WarnUpper" },
|
|
{ title: "CritLower", data: "CritLower" },
|
|
{ title: "CritUpper", data: "CritUpper" },
|
|
|
|
],
|
|
columnDefs: [
|
|
{ targets: 0, data: null, defaultContent: "" }
|
|
],
|
|
select: "os",
|
|
fixedHeader: true,
|
|
ajax: {
|
|
url: "/collections/SkyCheckState",
|
|
dataSrc: function(d){
|
|
var pvl = []
|
|
$.each( d, function(){
|
|
$.each( this.PerformanceValues, function(){
|
|
pvl.push( this );
|
|
});
|
|
});
|
|
return pvl;
|
|
}
|
|
}
|
|
})
|
|
.on( "select", function(e,dt,type,indexes){
|
|
var items = dt.rows( indexes ).data();
|
|
|
|
$.each( items, function(){
|
|
selected[this.PerfName] = this;
|
|
});
|
|
|
|
loadEditor(Object.values(selected));
|
|
})
|
|
.on( "deselect", function(e,dt,type,indexes){
|
|
var items = dt.rows( indexes ).data();
|
|
|
|
$.each( items, function(){
|
|
delete selected[this.PerfName];
|
|
});
|
|
|
|
loadEditor(Object.values(selected));
|
|
});
|
|
|
|
var currentLoadedSelection = [];
|
|
|
|
function getInput(fieldName, o, parse = null)
|
|
{
|
|
if (!$("#" + fieldName).prop("disabled"))
|
|
if (parse)
|
|
o[fieldName] = parse($("#" + fieldName).val());
|
|
else
|
|
o[fieldName] = $("#" + fieldName).val();
|
|
}
|
|
|
|
function setInput(fieldName,o)
|
|
{
|
|
if (!o.hasOwnProperty(fieldName))
|
|
$("#" + fieldName).val("").prop("disabled",true);
|
|
else
|
|
$("#" + fieldName).val(o[fieldName]).prop("disabled",false);
|
|
}
|
|
function collectCommonField(c, o, fieldName)
|
|
{
|
|
if (c[fieldName] != o[fieldName])
|
|
delete c[fieldName];
|
|
}
|
|
function getCommonObject( oList )
|
|
{
|
|
if (oList.length == 0)
|
|
return {}
|
|
|
|
var first = oList.shift();
|
|
var common = {};
|
|
|
|
for (var k in first)
|
|
common[k] = first[k];
|
|
|
|
for (var o in oList)
|
|
{
|
|
for (var k in oList[o])
|
|
collectCommonField(common, oList[o], k);
|
|
}
|
|
|
|
return common;
|
|
}
|
|
|
|
function loadEditor(selection)
|
|
{
|
|
var common = getCommonObject( selection );
|
|
|
|
setInput("WarnLower", common);
|
|
setInput("WarnUpper", common);
|
|
setInput("CritLower", common);
|
|
setInput("CritUpper", common);
|
|
|
|
currentLoadedSelection = selection;
|
|
}
|
|
function apply()
|
|
{
|
|
var change = {};
|
|
|
|
getInput("WarnLower", change, parseFloat);
|
|
getInput("WarnUpper", change, parseFloat);
|
|
getInput("CritLower", change, parseFloat);
|
|
getInput("CritUpper", change, parseFloat);
|
|
|
|
$.each( currentLoadedSelection, function(){
|
|
Object.assign( this, change );
|
|
|
|
skyapi().put( "/collections/SkyCheckState/" + this.ID, this);
|
|
});
|
|
|
|
$("#checkTable").DataTable().ajax.reload( null, false );
|
|
}
|
|
|
|
</script>
|