Skip to content

Commit 4d52ece

Browse files
committed
Add routing for log
- Use /log route for CounterLog - Use /log route for CounterSplineLog - Use /log route for SmartLog - Extract P1Year report to own component - Extract P1Gas report to own component - Use single /report route for all existing report components
1 parent 0674195 commit 4d52ece

21 files changed

+1342
-1813
lines changed

www/app/DashboardController.js

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3477,29 +3477,13 @@ define(['app'], function (app) {
34773477
if (($scope.config.DashboardType == 2) || (window.myglobals.ismobile == true)) {
34783478
var vname = item.Name;
34793479
if (typeof item.Counter != 'undefined') {
3480-
if (item.Type == "RFXMeter") {
3481-
vname = '<img src="images/next.png" onclick="ShowCounterLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="16" width="16">' + " " + item.Name;
3482-
}
3483-
else {
3484-
if ((item.Type == "P1 Smart Meter") && (item.SubType == "Energy")) {
3485-
vname = '<img src="images/next.png" onclick="ShowSmartLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="16" width="16">' + " " + item.Name;
3486-
}
3487-
else if ((item.Type == "P1 Smart Meter") && (item.SubType == "Gas")) {
3488-
vname = '<img src="images/next.png" onclick="ShowCounterLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="16" width="16">' + " " + item.Name;
3489-
}
3490-
else if ((item.Type == "YouLess Meter") && (item.SwitchTypeVal == 0 || item.SwitchTypeVal == 4)) {
3491-
vname = '<img src="images/next.png" onclick="ShowCounterLogSpline(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="16" width="16">' + " " + item.Name;
3492-
}
3493-
else {
3494-
vname = '<img src="images/next.png" onclick="ShowCounterLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="16" width="16">' + " " + item.Name;
3495-
}
3496-
}
3480+
vname = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/next.png" height="16" width="16">' + " " + item.Name + '</a>';
34973481
}
34983482
else if ((item.Type == "Current") || (item.Type == "Current/Energy")) {
34993483
vname = '<img src="images/next.png" onclick="ShowCurrentLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.displaytype + ');" height="16" width="16">' + " " + item.Name;
35003484
}
35013485
else if ((item.Type == "Energy") || (item.SubType == "kWh") || (item.SubType == "Power")) {
3502-
vname = '<img src="images/next.png" onclick="ShowCounterLogSpline(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="16" width="16">' + " " + item.Name;
3486+
vname = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/next.png" height="16" width="16">' + " " + item.Name + '</a>';
35033487
}
35043488
else if (item.Type == "Air Quality") {
35053489
vname = '<img src="images/next.png" onclick="ShowAirQualityLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\');" height="16" width="16">' + " " + item.Name;
@@ -3737,30 +3721,27 @@ define(['app'], function (app) {
37373721
if (typeof item.Counter != 'undefined') {
37383722
if ((item.Type == "RFXMeter") || (item.Type == "YouLess Meter")) {
37393723
if (item.SwitchTypeVal == 1) {
3740-
imagehtml += 'Gas48.png" class="lcursor" onclick="ShowCounterLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="40" width="40"></td>\n';
3724+
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/Gas48.png" class="lcursor" height="40" width="40"></a></td>\n';
37413725
}
37423726
else if (item.SwitchTypeVal == 2) {
3743-
imagehtml += 'Water48_On.png" class="lcursor" onclick="ShowCounterLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="40" width="40"></td>\n';
3727+
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/Water48_On.png" class="lcursor" height="40" width="40"></a></td>\n';
37443728
}
37453729
else if (item.SwitchTypeVal == 3) {
3746-
imagehtml += 'Counter48.png" class="lcursor" onclick="ShowCounterLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="40" width="40"></td>\n';
3730+
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/Counter48.png.png" class="lcursor" height="40" width="40"></a></td>\n';
37473731
}
37483732
else if (item.SwitchTypeVal == 4) {
3749-
imagehtml += 'PV48.png" class="lcursor" onclick="ShowCounterLogSpline(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="40" width="40"></td>\n';
3733+
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/PV48.png" class="lcursor" height="40" width="40"></a></td>\n';
37503734
}
37513735
else {
3752-
imagehtml += 'Counter48.png" class="lcursor" onclick="ShowCounterLogSpline(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="40" width="40"></td>\n';
3736+
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/Counter48.png" class="lcursor" height="40" width="40"></a></td>\n';
37533737
}
37543738
}
37553739
else {
3756-
if ((item.Type == "P1 Smart Meter") && (item.SubType == "Energy")) {
3757-
imagehtml += 'Counter48.png" class="lcursor" onclick="ShowSmartLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="40" width="40"></td>\n';
3758-
}
3759-
else if ((item.Type == "P1 Smart Meter") && (item.SubType == "Gas")) {
3760-
imagehtml += 'Gas48.png" class="lcursor" onclick="ShowCounterLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="40" width="40"></td>\n';
3740+
if ((item.Type == "P1 Smart Meter") && (item.SubType == "Gas")) {
3741+
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/Gas48.png" class="lcursor" height="40" width="40"></a></td>\n';
37613742
}
37623743
else {
3763-
imagehtml += 'Counter48.png" class="lcursor" onclick="ShowCounterLog(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="40" width="40"></td>\n';
3744+
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/Counter48.png" class="lcursor" height="40" width="40"></a></td>\n';
37643745
}
37653746
}
37663747
if (
@@ -3780,10 +3761,10 @@ define(['app'], function (app) {
37803761
}
37813762
else if ((item.Type == "Energy") || (item.Type == "Power") || (item.SubType == "kWh")) {
37823763
if (((item.Type == "Energy") || (item.Type == "Power") || (item.SubType == "kWh")) && (item.SwitchTypeVal == 4)) {
3783-
imagehtml += 'PV48.png" class="lcursor" onclick="ShowCounterLogSpline(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="40" width="40"></td>\n';
3764+
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/PV48.png" class="lcursor" height="40" width="40"></a></td>\n';
37843765
}
37853766
else {
3786-
imagehtml += 'current48.png" class="lcursor" onclick="ShowCounterLogSpline(\'#dashcontent\',\'ShowFavorites\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" height="40" width="40"></td>\n';
3767+
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/current48.png" class="lcursor" height="40" width="40"></a></td>\n';
37873768
}
37883769
statushtml = "";
37893770
}
@@ -3841,7 +3822,7 @@ define(['app'], function (app) {
38413822
}
38423823
else if (item.SubType == "Text") {
38433824
var logLink = '#/Devices/' + item.idx + '/Log';
3844-
3825+
38453826
imagehtml = '<a href="' + logLink + '"><img src="images/text48.png" class="lcursor" height="40" width="40"></a></td>\n';
38463827
statushtml = item.Data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1<br />$2');
38473828
}

www/app/DevicesController.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,7 @@ define(['app'], function (app) {
320320
itemSubIcons += '&nbsp;<a href="' + graphLogLink + '"><img src="images/log.png" title="' + $.t('Log') + '"></a>';
321321
}
322322
else if (typeof item.Counter != 'undefined') {
323-
if ((item.Type == "P1 Smart Meter") && (item.SubType == "Energy")) {
324-
itemSubIcons += '&nbsp;<img src="images/log.png" title="' + $.t('Log') + '" onclick="ShowSmartLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');">';
325-
}
326-
else if ((item.Type == "YouLess Meter") && (item.SwitchTypeVal == 0 || item.SwitchTypeVal == 4)) {
327-
itemSubIcons += '&nbsp;<img src="images/log.png" title="' + $.t('Log') + '" onclick="ShowCounterLogSpline(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');">';
328-
}
329-
else {
330-
itemSubIcons += '&nbsp;<img src="images/log.png" title="' + $.t('Log') + '" onclick="ShowCounterLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');">';
331-
}
323+
itemSubIcons += '&nbsp;<a href="#/Devices/'+ item.idx +'/Log"><img src="images/log.png" title="' + $.t('Log') + '"></a>';
332324
}
333325
else if (typeof item.Direction != 'undefined') {
334326
itemSubIcons += '&nbsp;<img src="images/log.png" title="' + $.t('Log') + '" onclick="ShowWindLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\');">';
@@ -340,7 +332,7 @@ define(['app'], function (app) {
340332
itemSubIcons += '&nbsp;<img src="images/log.png" title="' + $.t('Log') + '" onclick="ShowRainLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\');">';
341333
}
342334
else if ((item.Type == "Energy") || (item.SubType == "kWh")) {
343-
itemSubIcons += '&nbsp;<img src="images/log.png" title="' + $.t('Log') + '" onclick="ShowCounterLogSpline(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');">';
335+
itemSubIcons += '&nbsp;<a href="#/Devices/'+ item.idx +'/Log"><img src="images/log.png" title="' + $.t('Log') + '"></a>';
344336
}
345337
else if (item.Type.indexOf("Current") == 0) {
346338
itemSubIcons += '&nbsp;<img src="images/log.png" title="' + $.t('Log') + '" onclick="ShowCurrentLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.displaytype + ');">';

www/app/UtilityController.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -754,15 +754,8 @@ define(['app'], function (app) {
754754
}
755755

756756
if (typeof item.Counter != 'undefined') {
757-
if ((item.Type == "P1 Smart Meter") && (item.SubType == "Energy")) {
758-
xhtm += '<a class="btnsmall" onclick="ShowSmartLog(\'#utilitycontent\',\'ShowUtilities\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" data-i18n="Log">Log</a> ';
759-
}
760-
else if ((item.Type == "YouLess Meter") && (item.SwitchTypeVal == 0 || item.SwitchTypeVal == 4)) {
761-
xhtm += '<a class="btnsmall" onclick="ShowCounterLogSpline(\'#utilitycontent\',\'ShowUtilities\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" data-i18n="Log">Log</a> ';
762-
}
763-
else {
764-
xhtm += '<a class="btnsmall" onclick="ShowCounterLog(\'#utilitycontent\',\'ShowUtilities\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" data-i18n="Log">Log</a> ';
765-
}
757+
xhtm += '<a class="btnsmall" href="' + graphLogLink + '" data-i18n="Log">Log</a> ';
758+
766759
if (permissions.hasPermission("Admin")) {
767760
if (item.Type == "P1 Smart Meter") {
768761
xhtm += '<a class="btnsmall" onclick="EditUtilityDevice(' + item.idx + ',\'' + escape(item.Name) + '\',\'' + escape(item.Description) + '\');" data-i18n="Edit">Edit</a> ';
@@ -821,7 +814,8 @@ define(['app'], function (app) {
821814
}
822815
}
823816
else if ((item.Type == "Energy") || (item.SubType == "kWh") || (item.Type == "Power")) {
824-
xhtm += '<a class="btnsmall" onclick="ShowCounterLogSpline(\'#utilitycontent\',\'ShowUtilities\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');" data-i18n="Log">Log</a> ';
817+
xhtm += '<a class="btnsmall" href="' + graphLogLink + '" data-i18n="Log">Log</a> ';
818+
825819
if (permissions.hasPermission("Admin")) {
826820
if ((item.Type == "Energy") || (item.SubType == "kWh")) {
827821
if (item.EnergyMeterMode == "") { item.EnergyMeterMode = "0" }

www/app/app.js

Lines changed: 14 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ document.addEventListener('DOMContentLoaded', function () {
44
Notification.requestPermission();
55
});
66

7-
define(['angularAMD', 'angular-route', 'angular-animate', 'ng-grid', 'ng-grid-flexible-height', 'highcharts-ng', 'angular-tree-control', 'ngDraggable', 'ngSanitize', 'angular-md5', 'ui.bootstrap', 'angular.directives-round-progress', 'angular.scrollglue', 'angular-websocket'], function (angularAMD) {
7+
define(['angularAMD', 'devices/deviceFactory', 'angular-route', 'angular-animate', 'ng-grid', 'ng-grid-flexible-height', 'highcharts-ng', 'angular-tree-control', 'ngDraggable', 'ngSanitize', 'angular-md5', 'ui.bootstrap', 'angular.directives-round-progress', 'angular.scrollglue', 'angular-websocket'], function (angularAMD, deviceFactory) {
88
var app = angular.module('domoticz', ['ngRoute', 'ngAnimate', 'ngGrid', 'highcharts-ng', 'treeControl', 'ngDraggable', 'ngSanitize', 'angular-md5', 'ui.bootstrap', 'angular.directives-round-progress', 'angular.directives-round-progress', 'angular.scrollglue', 'ngWebsocket']);
99

1010
isOnline = false;
@@ -267,58 +267,7 @@ define(['angularAMD', 'angular-route', 'angular-animate', 'ng-grid', 'ng-grid-fl
267267
}
268268
});
269269

270-
app.factory('Device', function () {
271-
return function Device(rawData) {
272-
var device = Object.assign({}, rawData);
273-
274-
device.isDimmer = function() {
275-
return ['Dimmer', 'Blinds Percentage', 'Blinds Percentage Inverted', 'TPI'].includes(this.SwitchType);
276-
};
277-
278-
device.isSelector = function() {
279-
return this.SwitchType === "Selector";
280-
};
281-
282-
device.isLED = function() {
283-
return (this.SubType.indexOf("RGB") >= 0 || this.SubType.indexOf("WW") >= 0);
284-
};
285-
286-
device.getLevels = function() {
287-
return this.LevelNames ? b64DecodeUnicode(this.LevelNames).split('|') : [];
288-
};
289-
290-
device.getLevelActions = function() {
291-
return this.LevelActions ? b64DecodeUnicode(this.LevelActions).split('|') : [];
292-
};
293-
294-
device.getSelectorLevelOptions = function () {
295-
return this.getLevels()
296-
.slice(1)
297-
.map(function (levelName, index) {
298-
return {
299-
label: levelName,
300-
value: (index + 1) * 10
301-
}
302-
});
303-
};
304-
305-
device.getDimmerLevelOptions = function (step) {
306-
var options = [];
307-
var step = step || 5;
308-
309-
for (var i = step; i <= 100; i+=step) {
310-
options.push({
311-
label: i + '%',
312-
value: i
313-
});
314-
}
315-
316-
return options;
317-
};
318-
319-
return device;
320-
};
321-
});
270+
app.factory('Device', deviceFactory);
322271

323272
app.factory('deviceApi', function($q, domoticzApi, dzTimeAndSun, Device) {
324273
return {
@@ -598,10 +547,10 @@ define(['angularAMD', 'angular-route', 'angular-animate', 'ng-grid', 'ng-grid-fl
598547
controllerUrl: 'app/log/DeviceLog.js',
599548
controllerAs: 'vm'
600549
})).
601-
when('/Devices/:id/TemperatureReport/:year?/:month?', angularAMD.route({
602-
templateUrl: 'views/log/device_temperature_report.html',
603-
controller: 'DeviceTemperatureReportController',
604-
controllerUrl: 'app/log/TemperatureReport.js',
550+
when('/Devices/:id/Report/:year?/:month?', angularAMD.route({
551+
templateUrl: 'app/report/DeviceReport.html',
552+
controller: 'DeviceReportController',
553+
controllerUrl: 'app/report/DeviceReport.js',
605554
controllerAs: 'vm'
606555
})).
607556
when('/DPFibaro', angularAMD.route({
@@ -1162,6 +1111,14 @@ define(['angularAMD', 'angular-route', 'angular-animate', 'ng-grid', 'ng-grid-fl
11621111
});
11631112
permissions.setPermissions(permissionList);
11641113

1114+
Highcharts.setOptions({
1115+
credits: {
1116+
enabled: true,
1117+
href: "http://www.domoticz.com",
1118+
text: "Domoticz.com"
1119+
}
1120+
});
1121+
11651122
/* this doesnt run, for some reason */
11661123
app.run(function (livesocket) {
11671124
console.log(livesocket);

0 commit comments

Comments
 (0)