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-hotkeys": "^1.7.0",
 | 
			
		||||
    "angular-jwt": "^0.1.6",
 | 
			
		||||
    "angular-material": "^1.1.1",
 | 
			
		||||
    "angular-material": "1.1.1",
 | 
			
		||||
    "angular-material-data-table": "^0.10.9",
 | 
			
		||||
    "angular-material-icons": "^0.7.1",
 | 
			
		||||
    "angular-messages": "1.5.8",
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ export default angular.module('thingsboard.api.telemetryWebsocket', [thingsboard
 | 
			
		||||
    .factory('telemetryWebsocketService', TelemetryWebsocketService)
 | 
			
		||||
    .name;
 | 
			
		||||
 | 
			
		||||
const RECONNECT_INTERVAL = 5000;
 | 
			
		||||
const RECONNECT_INTERVAL = 2000;
 | 
			
		||||
const WS_IDLE_TIMEOUT = 90000;
 | 
			
		||||
 | 
			
		||||
/*@ngInject*/
 | 
			
		||||
@ -145,6 +145,7 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function subscribe (subscriber) {
 | 
			
		||||
        isActive = true;
 | 
			
		||||
        var cmdId = nextCmdId();
 | 
			
		||||
        subscribers[cmdId] = subscriber;
 | 
			
		||||
        subscribersCount++;
 | 
			
		||||
@ -163,19 +164,25 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function unsubscribe (subscriber) {
 | 
			
		||||
        if (subscriber.subscriptionCommand) {
 | 
			
		||||
            subscriber.subscriptionCommand.unsubscribe = true;
 | 
			
		||||
            if (subscriber.type === types.dataKeyType.timeseries) {
 | 
			
		||||
                cmdsWrapper.tsSubCmds.push(subscriber.subscriptionCommand);
 | 
			
		||||
            } else if (subscriber.type === types.dataKeyType.attribute) {
 | 
			
		||||
                cmdsWrapper.attrSubCmds.push(subscriber.subscriptionCommand);
 | 
			
		||||
        if (isActive) {
 | 
			
		||||
            var cmdId = null;
 | 
			
		||||
            if (subscriber.subscriptionCommand) {
 | 
			
		||||
                subscriber.subscriptionCommand.unsubscribe = true;
 | 
			
		||||
                if (subscriber.type === types.dataKeyType.timeseries) {
 | 
			
		||||
                    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];
 | 
			
		||||
        } else if (subscriber.historyCommand) {
 | 
			
		||||
            delete subscribers[subscriber.historyCommand.cmdId];
 | 
			
		||||
            if (cmdId && subscribers[cmdId]) {
 | 
			
		||||
                delete subscribers[cmdId];
 | 
			
		||||
                subscribersCount--;
 | 
			
		||||
            }
 | 
			
		||||
            publishCommands();
 | 
			
		||||
        }
 | 
			
		||||
        subscribersCount--;
 | 
			
		||||
        publishCommands();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function checkToClose () {
 | 
			
		||||
@ -187,23 +194,24 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function tryOpenSocket () {
 | 
			
		||||
        isActive = true;
 | 
			
		||||
        if (!isOpened && !isOpening) {
 | 
			
		||||
            isOpening = true;
 | 
			
		||||
            if (userService.isJwtTokenValid()) {
 | 
			
		||||
                openSocket(userService.getJwtToken());
 | 
			
		||||
            } else {
 | 
			
		||||
                userService.refreshJwtToken().then(function success() {
 | 
			
		||||
        if (isActive) {
 | 
			
		||||
            if (!isOpened && !isOpening) {
 | 
			
		||||
                isOpening = true;
 | 
			
		||||
                if (userService.isJwtTokenValid()) {
 | 
			
		||||
                    openSocket(userService.getJwtToken());
 | 
			
		||||
                }, function fail() {
 | 
			
		||||
                    isOpening = false;
 | 
			
		||||
                    $rootScope.$broadcast('unauthenticated');
 | 
			
		||||
                });
 | 
			
		||||
                } else {
 | 
			
		||||
                    userService.refreshJwtToken().then(function success() {
 | 
			
		||||
                        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) {
 | 
			
		||||
            $timeout.cancel(socketCloseTimer);
 | 
			
		||||
            socketCloseTimer = null;
 | 
			
		||||
@ -233,7 +241,7 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty
 | 
			
		||||
        cmdsWrapper.tsSubCmds = [];
 | 
			
		||||
        cmdsWrapper.historyCmds = [];
 | 
			
		||||
        cmdsWrapper.attrSubCmds = [];
 | 
			
		||||
        if (closeSocket) {
 | 
			
		||||
        if (close) {
 | 
			
		||||
            closeSocket();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -35,12 +35,10 @@
 | 
			
		||||
										tb-mouseup="vm.widgetMouseUp($event, widget)"
 | 
			
		||||
										ng-click=""
 | 
			
		||||
										tb-contextmenu="vm.openWidgetContextMenu($event, widget, $mdOpenMousepointMenu)"
 | 
			
		||||
								style="
 | 
			
		||||
								cursor: pointer;
 | 
			
		||||
								color: {{vm.widgetColor(widget)}};
 | 
			
		||||
								background-color: {{vm.widgetBackgroundColor(widget)}};
 | 
			
		||||
								padding: {{vm.widgetPadding(widget)}}
 | 
			
		||||
								">
 | 
			
		||||
									    ng-style="{cursor: 'pointer',
 | 
			
		||||
            									   color: vm.widgetColor(widget),
 | 
			
		||||
            									   backgroundColor: vm.widgetBackgroundColor(widget),
 | 
			
		||||
            									   padding: vm.widgetPadding(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>
 | 
			
		||||
									<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();
 | 
			
		||||
            }
 | 
			
		||||
            if (scope.deviceId && scope.attributeScope) {
 | 
			
		||||
                scope.attributes = {
 | 
			
		||||
                    count: 0,
 | 
			
		||||
                    data: []
 | 
			
		||||
                };
 | 
			
		||||
                scope.checkSubscription();
 | 
			
		||||
                scope.attributesDeferred = deviceService.getDeviceAttributes(scope.deviceId, scope.attributeScope.value,
 | 
			
		||||
                    scope.query, function(attributes, update) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user