diff --git a/ui/src/app/api/alarm.service.js b/ui/src/app/api/alarm.service.js index 6c614917c9..f59ecbc05d 100644 --- a/ui/src/app/api/alarm.service.js +++ b/ui/src/app/api/alarm.service.js @@ -295,9 +295,8 @@ function AlarmService($http, $q, $interval, $filter, $timeout, utils, types) { if (alarmSourceListener.lastUpdateTs) { var interval = now - alarmSourceListener.lastUpdateTs; alarmSourceListener.alarmsQuery.startTime += interval; - } else { - alarmSourceListener.lastUpdateTs = now; } + alarmSourceListener.lastUpdateTs = now; } alarmSourceListener.alarmsUpdated(alarms, false); } diff --git a/ui/src/app/api/dashboard.service.js b/ui/src/app/api/dashboard.service.js index 74b68d0e4f..362a539457 100644 --- a/ui/src/app/api/dashboard.service.js +++ b/ui/src/app/api/dashboard.service.js @@ -63,7 +63,7 @@ function DashboardService($rootScope, $http, $q, $location, customerService) { return deferred.promise; } - function getTenantDashboards(pageLink) { + function getTenantDashboards(pageLink, applyCustomersInfo) { var deferred = $q.defer(); var url = '/api/tenant/dashboards?limit=' + pageLink.limit; if (angular.isDefined(pageLink.textSearch)) { @@ -76,22 +76,26 @@ function DashboardService($rootScope, $http, $q, $location, customerService) { url += '&textOffset=' + pageLink.textOffset; } $http.get(url, null).then(function success(response) { - customerService.applyAssignedCustomersInfo(response.data.data).then( - function success(data) { - response.data.data = data; - deferred.resolve(response.data); - }, - function fail() { - deferred.reject(); - } - ); + if (applyCustomersInfo) { + customerService.applyAssignedCustomersInfo(response.data.data).then( + function success(data) { + response.data.data = data; + deferred.resolve(response.data); + }, + function fail() { + deferred.reject(); + } + ); + } else { + deferred.resolve(response.data); + } }, function fail() { deferred.reject(); }); return deferred.promise; } - function getCustomerDashboards(customerId, pageLink) { + function getCustomerDashboards(customerId, pageLink, applyCustomersInfo) { var deferred = $q.defer(); var url = '/api/customer/' + customerId + '/dashboards?limit=' + pageLink.limit; if (angular.isDefined(pageLink.textSearch)) { @@ -104,15 +108,19 @@ function DashboardService($rootScope, $http, $q, $location, customerService) { url += '&textOffset=' + pageLink.textOffset; } $http.get(url, null).then(function success(response) { - customerService.applyAssignedCustomerInfo(response.data.data, customerId).then( - function success(data) { - response.data.data = data; - deferred.resolve(response.data); - }, - function fail() { - deferred.reject(); - } - ); + if (applyCustomersInfo) { + customerService.applyAssignedCustomerInfo(response.data.data, customerId).then( + function success(data) { + response.data.data = data; + deferred.resolve(response.data); + }, + function fail() { + deferred.reject(); + } + ); + } else { + deferred.resolve(response.data); + } }, function fail() { deferred.reject(); }); diff --git a/ui/src/app/api/entity.service.js b/ui/src/app/api/entity.service.js index c8a59cfc77..0022607c9e 100644 --- a/ui/src/app/api/entity.service.js +++ b/ui/src/app/api/entity.service.js @@ -267,9 +267,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device break; case types.entityType.dashboard: if (user.authority === 'CUSTOMER_USER') { - promise = dashboardService.getCustomerDashboards(customerId, pageLink); + promise = dashboardService.getCustomerDashboards(customerId, pageLink, false); } else { - promise = dashboardService.getTenantDashboards(pageLink); + promise = dashboardService.getTenantDashboards(pageLink, false); } break; case types.entityType.user: diff --git a/ui/src/app/api/subscription.js b/ui/src/app/api/subscription.js index 7334165792..52b884ce0d 100644 --- a/ui/src/app/api/subscription.js +++ b/ui/src/app/api/subscription.js @@ -674,11 +674,14 @@ export default class Subscription { alarmsUpdated(alarms, apply) { this.notifyDataLoaded(); + var updated = !angular.equals(this.alarms, alarms); this.alarms = alarms; if (this.subscriptionTimewindow && this.subscriptionTimewindow.realtimeWindowMs) { this.updateTimewindow(); } - this.onDataUpdated(apply); + if (updated) { + this.onDataUpdated(apply); + } } updateLegend(dataIndex, data, apply) { diff --git a/ui/src/app/api/user.service.js b/ui/src/app/api/user.service.js index 57486b0040..16686576d3 100644 --- a/ui/src/app/api/user.service.js +++ b/ui/src/app/api/user.service.js @@ -265,9 +265,9 @@ function UserService($http, $q, $rootScope, adminService, dashboardService, logi var pageLink = {limit: 100}; var fetchDashboardsPromise; if (currentUser.authority === 'TENANT_ADMIN') { - fetchDashboardsPromise = dashboardService.getTenantDashboards(pageLink); + fetchDashboardsPromise = dashboardService.getTenantDashboards(pageLink, false); } else { - fetchDashboardsPromise = dashboardService.getCustomerDashboards(currentUser.customerId, pageLink); + fetchDashboardsPromise = dashboardService.getCustomerDashboards(currentUser.customerId, pageLink, false); } fetchDashboardsPromise.then( function success(result) { diff --git a/ui/src/app/components/dashboard-autocomplete.directive.js b/ui/src/app/components/dashboard-autocomplete.directive.js index 59a56e1faa..ce7e4770fc 100644 --- a/ui/src/app/components/dashboard-autocomplete.directive.js +++ b/ui/src/app/components/dashboard-autocomplete.directive.js @@ -48,7 +48,7 @@ function DashboardAutocomplete($compile, $templateCache, $q, dashboardService, u var promise; if (scope.dashboardsScope === 'customer' || userService.getAuthority() === 'CUSTOMER_USER') { if (scope.customerId) { - promise = dashboardService.getCustomerDashboards(scope.customerId, pageLink); + promise = dashboardService.getCustomerDashboards(scope.customerId, pageLink, false); } else { promise = $q.when({data: []}); } @@ -60,7 +60,7 @@ function DashboardAutocomplete($compile, $templateCache, $q, dashboardService, u promise = $q.when({data: []}); } } else { - promise = dashboardService.getTenantDashboards(pageLink); + promise = dashboardService.getTenantDashboards(pageLink, false); } } diff --git a/ui/src/app/components/dashboard-select.directive.js b/ui/src/app/components/dashboard-select.directive.js index e0de25e0eb..d7b32d8b06 100644 --- a/ui/src/app/components/dashboard-select.directive.js +++ b/ui/src/app/components/dashboard-select.directive.js @@ -48,12 +48,12 @@ function DashboardSelect($compile, $templateCache, $q, $mdMedia, $mdPanel, $docu var promise; if (scope.dashboardsScope === 'customer' || userService.getAuthority() === 'CUSTOMER_USER') { if (scope.customerId && scope.customerId != types.id.nullUid) { - promise = dashboardService.getCustomerDashboards(scope.customerId, pageLink); + promise = dashboardService.getCustomerDashboards(scope.customerId, pageLink, false); } else { promise = $q.when({data: []}); } } else { - promise = dashboardService.getTenantDashboards(pageLink); + promise = dashboardService.getTenantDashboards(pageLink, false); } promise.then(function success(result) { diff --git a/ui/src/app/components/dashboard.directive.js b/ui/src/app/components/dashboard.directive.js index b4912eacc9..6605692d27 100644 --- a/ui/src/app/components/dashboard.directive.js +++ b/ui/src/app/components/dashboard.directive.js @@ -15,7 +15,6 @@ */ import './dashboard.scss'; -import $ from 'jquery'; import 'javascript-detect-element-resize/detect-element-resize'; import angularGridster from 'angular-gridster'; import thingsboardTypes from '../common/types.constant'; @@ -94,8 +93,8 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $ var highlightedWidget = null; var selectedWidget = null; - var gridsterParent = $('#gridster-parent', $element); - var gridsterElement = angular.element($('#gridster-child', gridsterParent)); + var gridsterParent = angular.element('#gridster-parent', $element); + var gridsterElement = angular.element('#gridster-child', gridsterParent); var vm = this; @@ -228,15 +227,15 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $ } }; - addResizeListener(gridsterParent[0], onGirdsterParentResize); // eslint-disable-line no-undef + addResizeListener(gridsterParent[0], onGridsterParentResize); // eslint-disable-line no-undef $scope.$on("$destroy", function () { - removeResizeListener(gridsterParent[0], onGirdsterParentResize); // eslint-disable-line no-undef + removeResizeListener(gridsterParent[0], onGridsterParentResize); // eslint-disable-line no-undef }); watchWidgets(); - function onGirdsterParentResize() { + function onGridsterParentResize() { if (gridsterParent.height() && autofillHeight()) { updateMobileOpts(); } @@ -244,6 +243,10 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $ function watchWidgets() { $scope.widgetsCollectionWatch = $scope.$watchCollection('vm.widgets', function () { + if (vm.skipInitialWidgetsWatch) { + $timeout(function() { vm.skipInitialWidgetsWatch = false; }); + return; + } var ids = []; for (var i=0;i - + {{action.displayName}} @@ -65,7 +65,7 @@ ng-show="!vm.isEdit && action.show" ng-click="action.onAction($event)" class="md-icon-button"> - + {{ action.name | translate }} @@ -114,7 +114,8 @@ isEdit: vm.isEdit, isMobile: vm.isMobileSize, dashboardTimewindow: vm.dashboardTimewindow, - dashboardTimewindowApi: vm.dashboardTimewindowApi }"> + dashboardTimewindowApi: vm.dashboardTimewindowApi, + dashboard: vm }"> diff --git a/ui/src/app/components/datasource-entity.tpl.html b/ui/src/app/components/datasource-entity.tpl.html index e788f30949..f2e080e838 100644 --- a/ui/src/app/components/datasource-entity.tpl.html +++ b/ui/src/app/components/datasource-entity.tpl.html @@ -186,7 +186,7 @@
datakey.timeseries-or-attributes-required
datakey.alarm-fields-required
-
datakey.function-types-required
datakey.alarm-fields-required
-
-
diff --git a/ui/src/app/dashboard/dashboards.controller.js b/ui/src/app/dashboard/dashboards.controller.js index 134baffc59..d2887f8abd 100644 --- a/ui/src/app/dashboard/dashboards.controller.js +++ b/ui/src/app/dashboard/dashboards.controller.js @@ -167,7 +167,7 @@ export function DashboardsController(userService, dashboardService, customerServ if (vm.dashboardsScope === 'tenant') { fetchDashboardsFunction = function (pageLink) { - return dashboardService.getTenantDashboards(pageLink); + return dashboardService.getTenantDashboards(pageLink, true); }; deleteDashboardFunction = function (dashboardId) { return dashboardService.deleteDashboard(dashboardId); @@ -290,7 +290,7 @@ export function DashboardsController(userService, dashboardService, customerServ }); } else if (vm.dashboardsScope === 'customer' || vm.dashboardsScope === 'customer_user') { fetchDashboardsFunction = function (pageLink) { - return dashboardService.getCustomerDashboards(customerId, pageLink); + return dashboardService.getCustomerDashboards(customerId, pageLink, true); }; deleteDashboardFunction = function (dashboardId) { return dashboardService.unassignDashboardFromCustomer(dashboardId); @@ -468,7 +468,7 @@ export function DashboardsController(userService, dashboardService, customerServ $event.stopPropagation(); } var pageSize = 10; - dashboardService.getTenantDashboards({limit: pageSize, textSearch: ''}).then( + dashboardService.getTenantDashboards({limit: pageSize, textSearch: ''}, false).then( function success(_dashboards) { var dashboards = { pageSize: pageSize, diff --git a/ui/src/app/layout/breadcrumb-label.filter.js b/ui/src/app/layout/breadcrumb-label.filter.js index 76a26325f2..02948105d6 100644 --- a/ui/src/app/layout/breadcrumb-label.filter.js +++ b/ui/src/app/layout/breadcrumb-label.filter.js @@ -22,18 +22,22 @@ export default function BreadcrumbLabel($translate) { var labelObj; labelObj = angular.fromJson(bLabel); if (labelObj) { + var translate = !(labelObj.translate && labelObj.translate === 'false'); + var key = translate ? $translate.use() : 'orig'; if (!labels[labelObj.label]) { - labels[labelObj.label] = labelObj.label; - var translate = !(labelObj.translate && labelObj.translate === 'false'); + labels[labelObj.label] = {}; + } + if (!labels[labelObj.label][key]) { + labels[labelObj.label][key] = labelObj.label; if (translate) { $translate([labelObj.label]).then( function (translations) { - labels[labelObj.label] = translations[labelObj.label]; + labels[labelObj.label][key] = translations[labelObj.label]; } ) } } - return labels[labelObj.label]; + return labels[labelObj.label][key]; } else { return ''; } diff --git a/ui/src/app/widget/lib/alarms-table-widget.tpl.html b/ui/src/app/widget/lib/alarms-table-widget.tpl.html index b7416e95a0..860128d32f 100644 --- a/ui/src/app/widget/lib/alarms-table-widget.tpl.html +++ b/ui/src/app/widget/lib/alarms-table-widget.tpl.html @@ -22,7 +22,7 @@
search - + {{'alarm.search' | translate}} @@ -32,7 +32,7 @@ close - + {{ 'action.close' | translate }} @@ -46,13 +46,13 @@ done - + {{ 'alarm.acknowledge' | translate }} clear - + {{ 'alarm.clear' | translate }} diff --git a/ui/src/app/widget/lib/analogue-compass.js b/ui/src/app/widget/lib/analogue-compass.js index a59b0dede0..46059c7582 100644 --- a/ui/src/app/widget/lib/analogue-compass.js +++ b/ui/src/app/widget/lib/analogue-compass.js @@ -17,6 +17,8 @@ import $ from 'jquery'; import canvasGauges from 'canvas-gauges'; /*import tinycolor from 'tinycolor2';*/ +/* eslint-disable angular/angularelement */ + export default class TbAnalogueCompass { constructor(ctx, canvasId) { this.ctx = ctx; @@ -436,3 +438,5 @@ export default class TbAnalogueCompass { }; } } + +/* eslint-enable angular/angularelement */ diff --git a/ui/src/app/widget/lib/entities-table-widget.tpl.html b/ui/src/app/widget/lib/entities-table-widget.tpl.html index 162e5f74de..2587da1779 100644 --- a/ui/src/app/widget/lib/entities-table-widget.tpl.html +++ b/ui/src/app/widget/lib/entities-table-widget.tpl.html @@ -21,7 +21,7 @@
search - + {{'entity.search' | translate}} @@ -31,7 +31,7 @@ close - + {{ 'action.close' | translate }} diff --git a/ui/src/app/widget/lib/map-widget2.js b/ui/src/app/widget/lib/map-widget2.js index 5d2711430a..44abb2b2ac 100644 --- a/ui/src/app/widget/lib/map-widget2.js +++ b/ui/src/app/widget/lib/map-widget2.js @@ -275,9 +275,11 @@ export default class TbMapWidgetV2 { for (var i = 0; i < latData.length; i++) { lat = latData[i][1]; lng = lngData[i][1]; - latLng = tbMap.map.createLatLng(lat, lng); - if (i == 0 || !latLngs[latLngs.length - 1].equals(latLng)) { - latLngs.push(latLng); + if (angular.isDefined(lat) && lat != null && angular.isDefined(lng) && lng != null) { + latLng = tbMap.map.createLatLng(lat, lng); + if (i == 0 || !latLngs[latLngs.length - 1].equals(latLng)) { + latLngs.push(latLng); + } } } if (latLngs.length > 0) { @@ -308,24 +310,28 @@ export default class TbMapWidgetV2 { // Create or update marker lat = latData[latData.length - 1][1]; lng = lngData[lngData.length - 1][1]; - latLng = tbMap.map.createLatLng(lat, lng); - if (!location.marker) { - location.marker = tbMap.map.createMarker(latLng, location.settings, - function (event) { - tbMap.callbacks.onLocationClick(location); - locationRowClick(event, location); - }, [location.dsIndex]); - tbMap.markers.push(location.marker); - locationChanged = true; - } else { - var prevPosition = tbMap.map.getMarkerPosition(location.marker); - if (!prevPosition.equals(latLng)) { - tbMap.map.setMarkerPosition(location.marker, latLng); + if (angular.isDefined(lat) && lat != null && angular.isDefined(lng) && lng != null) { + latLng = tbMap.map.createLatLng(lat, lng); + if (!location.marker) { + location.marker = tbMap.map.createMarker(latLng, location.settings, + function (event) { + tbMap.callbacks.onLocationClick(location); + locationRowClick(event, location); + }, [location.dsIndex]); + tbMap.markers.push(location.marker); locationChanged = true; + } else { + var prevPosition = tbMap.map.getMarkerPosition(location.marker); + if (!prevPosition.equals(latLng)) { + tbMap.map.setMarkerPosition(location.marker, latLng); + locationChanged = true; + } } } } - updateLocationStyle(location, dataMap); + if (location.marker) { + updateLocationStyle(location, dataMap); + } } } return locationChanged;