UI: Minor fixed. Improve Timeseries table widget.
This commit is contained in:
parent
7c6cdb148c
commit
0ffac9c20b
File diff suppressed because one or more lines are too long
@ -27,7 +27,7 @@
|
|||||||
"angular-gridster": "^0.13.14",
|
"angular-gridster": "^0.13.14",
|
||||||
"angular-hotkeys": "^1.7.0",
|
"angular-hotkeys": "^1.7.0",
|
||||||
"angular-jwt": "^0.1.6",
|
"angular-jwt": "^0.1.6",
|
||||||
"angular-material": "^1.1.1",
|
"angular-material": "1.1.1",
|
||||||
"angular-material-data-table": "^0.10.9",
|
"angular-material-data-table": "^0.10.9",
|
||||||
"angular-material-icons": "^0.7.1",
|
"angular-material-icons": "^0.7.1",
|
||||||
"angular-messages": "1.5.8",
|
"angular-messages": "1.5.8",
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export default angular.module('thingsboard.api.telemetryWebsocket', [thingsboard
|
|||||||
.factory('telemetryWebsocketService', TelemetryWebsocketService)
|
.factory('telemetryWebsocketService', TelemetryWebsocketService)
|
||||||
.name;
|
.name;
|
||||||
|
|
||||||
const RECONNECT_INTERVAL = 5000;
|
const RECONNECT_INTERVAL = 2000;
|
||||||
const WS_IDLE_TIMEOUT = 90000;
|
const WS_IDLE_TIMEOUT = 90000;
|
||||||
|
|
||||||
/*@ngInject*/
|
/*@ngInject*/
|
||||||
@ -145,6 +145,7 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
function subscribe (subscriber) {
|
function subscribe (subscriber) {
|
||||||
|
isActive = true;
|
||||||
var cmdId = nextCmdId();
|
var cmdId = nextCmdId();
|
||||||
subscribers[cmdId] = subscriber;
|
subscribers[cmdId] = subscriber;
|
||||||
subscribersCount++;
|
subscribersCount++;
|
||||||
@ -163,19 +164,25 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
function unsubscribe (subscriber) {
|
function unsubscribe (subscriber) {
|
||||||
if (subscriber.subscriptionCommand) {
|
if (isActive) {
|
||||||
subscriber.subscriptionCommand.unsubscribe = true;
|
var cmdId = null;
|
||||||
if (subscriber.type === types.dataKeyType.timeseries) {
|
if (subscriber.subscriptionCommand) {
|
||||||
cmdsWrapper.tsSubCmds.push(subscriber.subscriptionCommand);
|
subscriber.subscriptionCommand.unsubscribe = true;
|
||||||
} else if (subscriber.type === types.dataKeyType.attribute) {
|
if (subscriber.type === types.dataKeyType.timeseries) {
|
||||||
cmdsWrapper.attrSubCmds.push(subscriber.subscriptionCommand);
|
cmdsWrapper.tsSubCmds.push(subscriber.subscriptionCommand);
|
||||||
|
} else if (subscriber.type === types.dataKeyType.attribute) {
|
||||||
|
cmdsWrapper.attrSubCmds.push(subscriber.subscriptionCommand);
|
||||||
|
}
|
||||||
|
cmdId = subscriber.subscriptionCommand.cmdId;
|
||||||
|
} else if (subscriber.historyCommand) {
|
||||||
|
cmdId = subscriber.historyCommand.cmdId;
|
||||||
}
|
}
|
||||||
delete subscribers[subscriber.subscriptionCommand.cmdId];
|
if (cmdId && subscribers[cmdId]) {
|
||||||
} else if (subscriber.historyCommand) {
|
delete subscribers[cmdId];
|
||||||
delete subscribers[subscriber.historyCommand.cmdId];
|
subscribersCount--;
|
||||||
|
}
|
||||||
|
publishCommands();
|
||||||
}
|
}
|
||||||
subscribersCount--;
|
|
||||||
publishCommands();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkToClose () {
|
function checkToClose () {
|
||||||
@ -187,23 +194,24 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tryOpenSocket () {
|
function tryOpenSocket () {
|
||||||
isActive = true;
|
if (isActive) {
|
||||||
if (!isOpened && !isOpening) {
|
if (!isOpened && !isOpening) {
|
||||||
isOpening = true;
|
isOpening = true;
|
||||||
if (userService.isJwtTokenValid()) {
|
if (userService.isJwtTokenValid()) {
|
||||||
openSocket(userService.getJwtToken());
|
|
||||||
} else {
|
|
||||||
userService.refreshJwtToken().then(function success() {
|
|
||||||
openSocket(userService.getJwtToken());
|
openSocket(userService.getJwtToken());
|
||||||
}, function fail() {
|
} else {
|
||||||
isOpening = false;
|
userService.refreshJwtToken().then(function success() {
|
||||||
$rootScope.$broadcast('unauthenticated');
|
openSocket(userService.getJwtToken());
|
||||||
});
|
}, function fail() {
|
||||||
|
isOpening = false;
|
||||||
|
$rootScope.$broadcast('unauthenticated');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (socketCloseTimer) {
|
||||||
|
$timeout.cancel(socketCloseTimer);
|
||||||
|
socketCloseTimer = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (socketCloseTimer) {
|
|
||||||
$timeout.cancel(socketCloseTimer);
|
|
||||||
socketCloseTimer = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +230,7 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset(closeSocket) {
|
function reset(close) {
|
||||||
if (socketCloseTimer) {
|
if (socketCloseTimer) {
|
||||||
$timeout.cancel(socketCloseTimer);
|
$timeout.cancel(socketCloseTimer);
|
||||||
socketCloseTimer = null;
|
socketCloseTimer = null;
|
||||||
@ -233,7 +241,7 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty
|
|||||||
cmdsWrapper.tsSubCmds = [];
|
cmdsWrapper.tsSubCmds = [];
|
||||||
cmdsWrapper.historyCmds = [];
|
cmdsWrapper.historyCmds = [];
|
||||||
cmdsWrapper.attrSubCmds = [];
|
cmdsWrapper.attrSubCmds = [];
|
||||||
if (closeSocket) {
|
if (close) {
|
||||||
closeSocket();
|
closeSocket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,12 +35,10 @@
|
|||||||
tb-mouseup="vm.widgetMouseUp($event, widget)"
|
tb-mouseup="vm.widgetMouseUp($event, widget)"
|
||||||
ng-click=""
|
ng-click=""
|
||||||
tb-contextmenu="vm.openWidgetContextMenu($event, widget, $mdOpenMousepointMenu)"
|
tb-contextmenu="vm.openWidgetContextMenu($event, widget, $mdOpenMousepointMenu)"
|
||||||
style="
|
ng-style="{cursor: 'pointer',
|
||||||
cursor: pointer;
|
color: vm.widgetColor(widget),
|
||||||
color: {{vm.widgetColor(widget)}};
|
backgroundColor: vm.widgetBackgroundColor(widget),
|
||||||
background-color: {{vm.widgetBackgroundColor(widget)}};
|
padding: vm.widgetPadding(widget)}">
|
||||||
padding: {{vm.widgetPadding(widget)}}
|
|
||||||
">
|
|
||||||
<div class="tb-widget-title" layout="column" ng-show="vm.showWidgetTitle(widget) || vm.hasTimewindow(widget)">
|
<div class="tb-widget-title" layout="column" ng-show="vm.showWidgetTitle(widget) || vm.hasTimewindow(widget)">
|
||||||
<span ng-show="vm.showWidgetTitle(widget)" class="md-subhead">{{widget.config.title}}</span>
|
<span ng-show="vm.showWidgetTitle(widget)" class="md-subhead">{{widget.config.title}}</span>
|
||||||
<tb-timewindow ng-if="vm.hasTimewindow(widget)" ng-model="widget.config.timewindow"></tb-timewindow>
|
<tb-timewindow ng-if="vm.hasTimewindow(widget)" ng-model="widget.config.timewindow"></tb-timewindow>
|
||||||
|
|||||||
@ -119,6 +119,10 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS
|
|||||||
scope.attributesDeferred.resolve();
|
scope.attributesDeferred.resolve();
|
||||||
}
|
}
|
||||||
if (scope.deviceId && scope.attributeScope) {
|
if (scope.deviceId && scope.attributeScope) {
|
||||||
|
scope.attributes = {
|
||||||
|
count: 0,
|
||||||
|
data: []
|
||||||
|
};
|
||||||
scope.checkSubscription();
|
scope.checkSubscription();
|
||||||
scope.attributesDeferred = deviceService.getDeviceAttributes(scope.deviceId, scope.attributeScope.value,
|
scope.attributesDeferred = deviceService.getDeviceAttributes(scope.deviceId, scope.attributeScope.value,
|
||||||
scope.query, function(attributes, update) {
|
scope.query, function(attributes, update) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user