FCLT#59401 Single page als gebouwdashboard - prototype Facilitor 2020 Work In Progress

svn path=/Website/trunk/; revision=44612
This commit is contained in:
Alex Tiehuis
2019-10-24 15:21:29 +00:00
parent 493a5cacb9
commit e2bea05dbb
2 changed files with 304 additions and 115 deletions

View File

@@ -19,36 +19,9 @@
<!-- Dark mode -->
<link rel="stylesheet" href="dark-mode.css">
<style>
body {font-size: 0.85rem;}
#list-locations tbody tr:hover,
#list-buildings tbody tr:hover,
#list-issues tbody tr:hover,
#list-issue-orders tbody tr:hover {
cursor: pointer;
}
.bg-linen {
background-color: #77212e !important;
color: #fff !important;
text-shadow: 0px 0px 12px #333;
background: url(./img/application-1920x480-1920x480.jpg);
}
.bg-linen h1 {
font-weight: bold !important;
}
.bg-cornsilk { background-color: #ff6f61 !important; color: #fff !important; }
.bg-light {background-color: #f5d6c6 !important; color: #000 !important;}
[data-theme="dark"] .bg-cornsilk,
[data-theme="dark"] .bg-linen {
background-color: black !important;
color: ivory !important;
}
div[name=badge] {
position: absolute;
top: 0;
right: 3px;
}
</style>
<!-- Facilitor style overrules for this page -->
<link rel="stylesheet" href="consoles.css">
</head>
<body id="page-top" class="h-100 bg-white">
@@ -138,37 +111,51 @@
</div>
<div class="container">
<div class="row" hidden>
<div class="card shadow col-xl-7 bg-light">
<div class="card-body">
<div id="filter-disciplinetypes" class="table-responsive">
<h2>Vakgroeptypen</h2>
<p>Filter meldingen op vakgroeptype</p>
<div class="row">
<div class="col-xl-7">
<div class="row" hidden>
<div class="card shadow col-xl-12 bg-light">
<div class="card-body">
<div id="filter-disciplinetypes" class="table-responsive">
<h2>Vakgroeptypen</h2>
<p>Filter meldingen op vakgroeptype</p>
</div>
</div>
</div>
</div>
<div class="row" hidden>
<div class="card shadow col-xl-12 bg-light">
<div class="card-body">
<div id="filter-issuedisciplines" class="table-responsive">
<h2>Vakgroepen</h2>
<p>Filter meldingen op Vakgroep</p>
</div>
</div>
</div>
</div>
<div class="row" hidden>
<div class="card shadow col-xl-12 bg-light">
<div class="card-body">
<div id="filter-issuetypes" class="table-responsive">
<h2>Standaardmeldingen</h2>
<p>Filter meldingen op type melding</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-5">
<div class="row" hidden>
<div class="card shadow col-xl-12 bg-light">
<div class="card-body">
<div class="chart-area">
<canvas id="show-report" class="chartjs-render-monitor"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row" hidden>
<div class="card shadow col-xl-7 bg-light">
<div class="card-body">
<div id="filter-issuedisciplines" class="table-responsive">
<h2>Vakgroepen</h2>
<p>Filter meldingen op Vakgroep</p>
</div>
</div>
</div>
</div>
<div class="row" hidden>
<div class="card shadow col-xl-7 bg-light">
<div class="card-body">
<div id="filter-issuetypes" class="table-responsive">
<h2>Standaardmeldingen</h2>
<p>Filter meldingen op type melding</p>
</div>
</div>
</div>
</div>
<div class="row" hidden>
<div class="card mb-3 shadow col-xl-7 bg-light">
<div class="card-body">
@@ -214,6 +201,27 @@
</div>
</div>
<div class="container">
<div class="row" hidden>
<div class="card mb-3 shadow col-xl-7 bg-light">
<div class="card-body">
<div id="list-contracts" class="table-responsive">
<h2>Contracten</h2>
<p>Loading..</p>
</div>
</div>
</div>
<div class="card mb-3 shadow col-xl-5 bg-light">
<div class="card-body">
<div id="show-contract" hidden>
<h2>Details</h2>
<p>-</p>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="card mb-3 shadow col-xl-7 bg-light">
@@ -258,6 +266,7 @@
<!-- Page level plugins -->
<script src="vendor/datatables/jquery.dataTables.min.js"></script>
<script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
<script src="vendor/chart.js/chart.min.js"></script>
<!-- Page level custom scripts -->
<script src="js/demo/datatables-demo.js"></script>

View File

@@ -1,7 +1,8 @@
var targets = {},
models = {},
day_in_ms = 86400000,
language = "EN";
language = "EN",
windowObjectReference;
var lcl = {
NL: {
"sProcessing": "Bezig...",
@@ -29,6 +30,8 @@ var lcl = {
"title_show_user": "Gebruiker",
"title_list_locations": "Locaties",
"title_show_location": "Locatie",
"title_list_contracts": "Contracten",
"title_show_contract": "Contract",
"title_list_buildings": "Gebouwen",
"title_show_building": "Gebouw",
"title_filter_floors": "Verdiepingen",
@@ -89,6 +92,8 @@ var lcl = {
"title_show_user": "Gebraucher",
"title_list_locations": "Standorte",
"title_show_location": "Standort",
"title_list_contracts": "Verträge",
"title_show_contract": "Vertrag",
"title_list_buildings": "Gebäude",
"title_show_building": "Gebäude",
"title_filter_floors": "Stockwerke",
@@ -127,6 +132,8 @@ var lcl = {
"title_show_user": "User",
"title_list_locations": "Locations",
"title_show_location": "Location",
"title_list_contracts": "Contracts",
"title_show_contract": "Contract",
"title_list_buildings": "Buildings",
"title_show_building": "Building",
"title_filter_floors": "Floors",
@@ -172,6 +179,8 @@ var lcl = {
"title_show_user": "Utilisateur",
"title_list_locations": "Emplacements",
"title_show_location": "Emplacement",
"title_list_contracts": "Contracts",
"title_show_contract": "Contract",
"title_list_buildings": "Immeubles",
"title_show_building": "Immeuble",
"title_filter_floors": "étages",
@@ -405,7 +414,7 @@ function filterData(obj) {
btn_has_icon = targets[obj.target].btn_has_icon;
for (row = 0; row < obj.data[obj.table].length; row += 1) {
formbody += '<button type="button" class="btn text-center ' + btn_size_class + ' ' + settings.btn_text_class + ' ' + settings.btn_class + '" recid=' + obj.data[obj.table][row].id + '>' +
'<div class="">' + (btn_has_icon? '<i class="fa fa-info-circle fa-lg"></i>' : "") + '</div>';
'<div class="">' + (btn_has_icon? '<i class="fa fa-tag fa-lg"></i>' : "") + '</div>';
for (column in obj.columns) {
if (column !== "id") {
col_info = columnInfo(obj, row, column);
@@ -423,7 +432,7 @@ function filterData(obj) {
function populate(obj) {
"use strict";
if (models[obj.url].id) {
if (targets[obj.target].report || models[obj.url].id) {
var $this = $("#" + targets[obj.target].selector),
h2;
obj.columns = obj.columns || targets[obj.target].columns;
@@ -437,6 +446,8 @@ function populate(obj) {
} else if (targets[obj.target].filter) {
var fdata = filterData(obj);
$this.html(h2 + '<form id="' + targets[obj.target].selector + '-form" class="form-inline">' + fdata + '</form>');
} else if (targets[obj.target].report) {
$this.html(h2);
} else {
var $this, thead, tbody, table;
thead = '<thead class="thead-dark">' + theadColumns(obj) + '</thead>';
@@ -474,7 +485,7 @@ function api2(obj) {
obj.filter = (obj.filter ? obj.filter + "&" : "?") + "fields=" + Object.keys(targets[obj.target].columns).join(",");
}
var ajaxHdl = $.ajax({
url: "../../../api2/" + obj.url + (obj.filter || ""),
url: settings.facilitor_url + "api2/" + obj.url + (obj.filter || ""),
dataType: "json",
success: function(data, textStatus, jqXHR) {
console.log("Ajax success start: " + (obj.target || obj.model));
@@ -553,6 +564,7 @@ function initAutocomplete() {
// refactoring
var settings = {
facilitor_url: "../../",
btn_class: "btn-light",
btn_text_class: "text-primary",
btn_selected_class: "btn-success",
@@ -745,7 +757,7 @@ function Customfield(parms) {
function Customfields(parms) {
"use strict";
var self = this, custom_field;
this.custom_fields = parms.data[parms.table].custom_fields;
this.custom_fields = (parms.data[parms.table].custom_fields? parms.data[parms.table].custom_fields.sort(function (a, b) { return (a.sequence > b.sequence? 1 : -1) }) : []);
this.single = parms.single;
this.target = parms.target;
this.table = parms.table;
@@ -764,22 +776,27 @@ function Customfields(parms) {
}
function Target(parms) {
"use strict";
var self = this;
var choose = function(first_choice, fallback_choice) {
return (typeof first_choice != "undefined"? first_choice : fallback_choice);
};
this.title = parms.title;
this.selector = parms.selector;
this.mode = parms.mode;
this.columns = parms.columns || {};
this.events = parms.events || "click";
this.events = choose(parms.events, "click");
this.trigger = parms.trigger || false;
this.ready = parms.ready || false;
this.filter = parms.filter || false;
this.report = parms.report || false;
this.trigger_selector = (this.filter? "button" : "table tbody tr");
this.iconcolumn = parms.iconcolumn || false;
this.btn_size_class = parms.btn_size_class || settings.btn_size_class;
this.btn_has_icon = (typeof parms.btn_has_icon != "undefined"? parms.btn_has_icon : true);
this.btn_size_class = choose(parms.btn_size_class, settings.btn_size_class);
this.btn_has_icon = choose(parms.btn_has_icon, true);
this.show_custom_fields = parms.show_custom_fields || false;
this.show_custom_field_when_empty = parms.show_custom_field_when_empty || false;
console.log(self);
}
$(function() {
"use strict";
targets = {
@@ -862,22 +879,27 @@ $(function() {
district: {
}
},
trigger: function() {
trigger: function(event) {
var $this = $(this),
$this_tr = $this.closest("tr[recid]"), index;
if ($this_tr.length) {
if ($this_tr.hasClass("table-success")) {
$this_tr.removeClass("table-success");
index = targets.list_locations.selected_ids.indexOf($this_tr.attr("recid"));
if (index !== -1) {
targets.list_locations.selected_ids.splice(index, 1);
}
if (event.ctrlKey) {
// show locations in Facilitor
windowObjectReference = window.open(settings.facilitor_url + "?u=locatie&k=" + $this_tr.attr("recid"));
} else {
targets.list_locations.data_table
.rows(".table-success").nodes().to$().removeClass("table-success");
$this_tr.addClass("table-success");
targets.list_locations.selected_ids = targets.list_locations.selected_ids || [];
targets.list_locations.selected_ids = [$this_tr.attr("recid")];
if ($this_tr.hasClass("table-success")) {
$this_tr.removeClass("table-success");
index = targets.list_locations.selected_ids.indexOf($this_tr.attr("recid"));
if (index !== -1) {
targets.list_locations.selected_ids.splice(index, 1);
}
} else {
targets.list_locations.data_table
.rows(".table-success").nodes().to$().removeClass("table-success");
$this_tr.addClass("table-success");
targets.list_locations.selected_ids = targets.list_locations.selected_ids || [];
targets.list_locations.selected_ids = [$this_tr.attr("recid")];
}
}
}
api2({
@@ -886,12 +908,17 @@ $(function() {
target: "show_location",
filter: "?limit=1&scope=fo&include=custom_fields&id=" + $this_tr.attr("recid")
});
api2({
url: "contracts",
target: "list_contracts",
filter: "?scope=fo&location=" + $this_tr.attr("recid")
});
// redraw list_buildings table and select first row in case there is only 1 result
redrawTable({ target: "list_buildings" });
},
ready: function(obj) {
$("#" + targets[obj.target].selector).closest(".row").attr("hidden", false);
targets[obj.target].data_table = $('table', '#' + targets[obj.target].selector).DataTable(tColumnDefs(obj));
targets.list_locations.data_table = $('table', '#' + targets.list_locations.selector).DataTable(tColumnDefs(obj));
// select first row in case there is only 1 result
autoselectRow({ target: obj.target });
}
@@ -924,6 +951,95 @@ $(function() {
console.log("ready trigger stop: " + obj.target);
}
}),
list_contracts: new Target({
title: "title_list_contracts",
selector: "list-contracts",
mode: "list",
columns: {
id: {
},
name: {
},
place: {
},
contracttype: {
},
description: {
},
contractor: {
},
department: {
},
status: {
},
enddate: {
}
},
trigger: function(event) {
var $this = $(this),
$this_tr = $this.closest("tr[recid]");
if ($this_tr.length) {
if (event.ctrlKey) {
// show locations in Facilitor
windowObjectReference = window.open(settings.facilitor_url + "?u=contract&k=" + $this_tr.attr("recid"));
} else {
targets.list_contracts.data_table
.rows(".table-success").nodes().to$().removeClass("table-success");
$this_tr.addClass("table-success");
}
}
api2({
url: "contracts",
single: "contract",
target: "show_contract",
filter: "?limit=1&scope=fo&include=custom_fields&id=" + $this_tr.attr("recid")
});
},
ready: function(obj) {
$("#" + targets.show_contract.selector).html("");
$("#" + targets.list_contracts.selector).closest(".row").attr("hidden", false);
targets.list_contracts.data_table = $('table', '#' + targets.list_contracts.selector).DataTable(tColumnDefs(obj));
autoselectRow({ target: obj.target });
}
}),
show_contract: new Target({
title: "title_show_contract",
selector: "show-contract",
mode: "show",
show_custom_fields: true,
columns: {
id: {
},
name: {
hidden: true
},
place: {
},
contracttype: {
},
description: {
},
contractor: {
},
department: {
},
status: {
},
enddate: {
}
},
ready: function(obj) {
console.log("ready trigger start: " + obj.target);
$("#" + targets.show_contract.selector).attr("hidden", false);
// specific form title
$("h2[name=formtitle]", $("#" + targets.show_contract.selector)).html(lcl[language][targets.show_contract.title] + " " + columnInfo(obj, undefined, "name").column_data);
// resize textarea
$("textarea", $("#" + targets.show_contract.selector)).each(function() {
$(this).innerHeight($(this).prop("scrollHeight") + "px");
});
console.log("ready trigger stop: " + obj.target);
}
}),
list_buildings: new Target({
title: "title_list_buildings",
selector: "list-buildings",
@@ -945,16 +1061,21 @@ $(function() {
label: "Functie"
}
},
trigger: function() {
trigger: function(event) {
var $this = $(this),
$this_tr = $this.closest("tr[recid]");
if ($this_tr.length) {
targets.list_buildings.data_table
.rows(".table-success").nodes().to$().removeClass("table-success");
$this_tr.addClass("table-success");
if (event.ctrlKey) {
// show locations in Facilitor
windowObjectReference = window.open(settings.facilitor_url + "?u=gebouw&k=" + $this_tr.attr("recid"));
} else {
targets.list_buildings.data_table
.rows(".table-success").nodes().to$().removeClass("table-success");
$this_tr.addClass("table-success");
}
}
codeAddress($("td[name='location']", $this_tr).html());
$("#" + targets.filter_disciplinetypes.selector + ",#" + targets.filter_issuedisciplines.selector).closest(".row").attr("hidden", false);
$("#" + targets.filter_disciplinetypes.selector + ",#" + targets.filter_issuedisciplines.selector + ",#" + targets.report.selector ).closest(".row").attr("hidden", false);
// reset classes for all buttons
resetAllButtonClasses({
context: "#filter-disciplinetypes, #filter-issuedisciplines, #filter-issuetypes"
@@ -977,6 +1098,7 @@ $(function() {
});
},
ready: function(obj) {
$("#" + targets.list_issue_orders.selector + ",#" + targets.filter_disciplinetypes.selector + ",#" + targets.filter_issuedisciplines.selector + ",#" + targets.report.selector + ",#" + targets.list_issues.selector).closest(".row").attr("hidden", true);
targets.list_buildings.data_table = $('table', '#list-buildings').DataTable(tColumnDefs(obj));
}
}),
@@ -1086,7 +1208,7 @@ $(function() {
hidden: true
}
},
trigger: function() {
trigger: function(event) {
var $this = $(this);
var disciplinetype = $("div[name=disciplinetype]", $this).attr("recid");
if (event.altKey) {
@@ -1154,7 +1276,7 @@ $(function() {
hidden: true
}
},
trigger: function() {
trigger: function(event) {
var $this = $(this),
index, recid = $(this).attr("recid");
var disciplinetype = $("div[name=disciplinetype]", $this).attr("recid");
@@ -1200,6 +1322,60 @@ $(function() {
console.log("ready trigger stop: " + obj.target);
}
}),
report: new Target({
title: "title_show_report",
selector: "show-report",
mode: "show",
show_custom_fields: false,
report: true,
columns: {
melding_datum: {
},
scf_count: {
}
},
ready: function(obj) {
console.log("ready trigger start: " + obj.target);
var ctx = document.getElementById(targets[obj.target].selector).getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: obj.data.Mld_v_udr_meldings.map(function(value) { return value.melding_datum; }),
datasets: [{
label: '# of Votes',
data: obj.data.Mld_v_udr_meldings.map(function(value) { return value.scf_count; }),
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
console.log("ready trigger stop: " + obj.target);
}
}),
filter_floors: new Target({
title: "title_filter_floors",
selector: "filter-floors",
@@ -1268,13 +1444,18 @@ $(function() {
label: "Onderwerp"
}
},
trigger: function() {
trigger: function(event) {
var $this = $(this),
$this_tr = $this.closest("tr[recid]");
if ($this_tr.length) {
targets.list_issues.data_table
.rows(".table-success").nodes().to$().removeClass("table-success");
$this_tr.addClass("table-success");
if (event.ctrlKey) {
// show locations in Facilitor
windowObjectReference = window.open(settings.facilitor_url + "?u=melding&k=" + $this_tr.attr("recid"));
} else {
targets.list_issues.data_table
.rows(".table-success").nodes().to$().removeClass("table-success");
$this_tr.addClass("table-success");
}
}
api2({
url: "issues",
@@ -1285,11 +1466,13 @@ $(function() {
api2({
url: "orders",
target: "list_issue_orders",
filter: "?scope=fo&issue=" + $this_tr.attr("recid")
filter: "?scope=fo&status=1,2,3,4,5,6,7,8,9,10&issue=" + $this_tr.attr("recid")
});
},
ready: function(obj) {
console.log("ready trigger start: " + obj.target);
$("#" + targets.show_issue.selector).html("");
$("#" + targets.list_issue_orders.selector).closest(".row").attr("hidden", true);
$("#" + targets.list_issues.selector).closest(".row").attr("hidden", false);
var disciplinetypes = {},
disciplines = {},
@@ -1355,33 +1538,24 @@ $(function() {
show_custom_fields: true,
columns: {
id: {
label: "Id"
},
name: {
label: "Nr",
hidden: true
},
subject: {
label: "Onderwerp"
},
issuetype: {
label: "Type"
},
description: {
label: "Omschrijving",
type: "textarea"
},
requestor: {
label: "Melder"
},
contact: {
label: "Geregistreerd"
},
issuedate: {
label: "op"
},
enddate: {
label: "Gereed"
},
progress: {
label: "Voortgang",
@@ -1429,7 +1603,7 @@ $(function() {
filter: "?limit=1&include=custom_fields&id=" + data_row.issueobjects[0].object.id
});
} else {
$("#show-issue-object").html("");
$("#" + targets.show_issue_object.selector).html("");
}
console.log("ready trigger stop: " + obj.target);
}
@@ -1440,16 +1614,12 @@ $(function() {
mode: "show",
columns: {
id: {
label: "Id"
},
name: {
label: "Id naam"
},
type: {
label: "Type"
},
description: {
label: "Omschrijving"
}
},
ready: function(obj) {
@@ -1462,28 +1632,30 @@ $(function() {
mode: "list",
columns: {
id: {
label: "Id"
},
owner: {
label: "Eigenaar"
sequence: {
},
issueordertype: {
},
company: {
label: "Bedrijf"
},
status: {
label: "Status"
},
description: {
label: "Omschrijving"
}
},
trigger: function() {
trigger: function(event) {
var $this = $(this),
$this_tr = $this.closest("tr[recid]");
if ($this_tr.length) {
targets.list_issue_orders.data_table
.rows(".table-success").nodes().to$().removeClass("table-success");
$this_tr.addClass("table-success");
if (event.ctrlKey) {
// show locations in Facilitor
windowObjectReference = window.open(settings.facilitor_url + "?u=opdracht&k=" + $this_tr.attr("recid"));
} else {
targets.list_issue_orders.data_table
.rows(".table-success").nodes().to$().removeClass("table-success");
$this_tr.addClass("table-success");
}
}
api2({
url: "orders",
@@ -1493,6 +1665,7 @@ $(function() {
});
},
ready: function(obj) {
$("#" + targets.show_order.selector).html("");
$("#" + targets[obj.target].selector).closest(".row").attr("hidden", false);
targets[obj.target].data_table = $('table', '#list-issue-orders').DataTable(tColumnDefs(obj));
// select first row in case there is only 1 result
@@ -1503,6 +1676,7 @@ $(function() {
title: "title_show_order",
selector: "show-order",
mode: "show",
show_custom_fields: true,
columns: {
id: {
},
@@ -1545,6 +1719,7 @@ $(function() {
issues: {},
locations: {},
buildings: {},
contracts: {},
floors: {},
orders: {},
objects: {},
@@ -1589,4 +1764,9 @@ $(function() {
url: "about",
target: "show_about"
});
api2({
url: "reports",
target: "report",
filter: "?usrrap_key=2227"
});
});