UI: fix url handling issue. Improve timeseries table widget.

This commit is contained in:
Igor Kulikov 2017-03-13 16:00:49 +02:00
parent e3619ecb0c
commit b38a4d2ff8
5 changed files with 39 additions and 25 deletions

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
import injectTapEventPlugin from 'react-tap-event-plugin';
import UrlHandler from './url.handler';
/* eslint-disable import/no-unresolved, import/default */
@ -38,7 +39,7 @@ export default function AppConfig($provide,
injectTapEventPlugin();
$locationProvider.html5Mode(true);
//$urlRouterProvider.otherwise('/home');
$urlRouterProvider.otherwise(UrlHandler);
storeProvider.setCaching(false);
$translateProvider.useSanitizeValueStrategy('sanitize');

View File

@ -14,9 +14,10 @@
* limitations under the License.
*/
import Flow from '@flowjs/ng-flow/dist/ng-flow-standalone.min';
import UrlHandler from './url.handler';
/*@ngInject*/
export default function AppRun($rootScope, $window, $log, $state, $mdDialog, $filter, loginService, userService, $translate) {
export default function AppRun($rootScope, $window, $injector, $location, $log, $state, $mdDialog, $filter, loginService, userService, $translate) {
$window.Flow = Flow;
var frame = $window.frameElement;
@ -36,19 +37,17 @@ export default function AppRun($rootScope, $window, $log, $state, $mdDialog, $fi
initWatchers();
checkCurrentState();
function initWatchers() {
$rootScope.unauthenticatedHandle = $rootScope.$on('unauthenticated', function (event, doLogout) {
if (doLogout) {
$state.go('login');
} else {
checkCurrentState();
UrlHandler($injector, $location);
}
});
$rootScope.authenticatedHandle = $rootScope.$on('authenticated', function () {
checkCurrentState();
UrlHandler($injector, $location);
});
$rootScope.forbiddenHandle = $rootScope.$on('forbidden', function () {
@ -110,24 +109,6 @@ export default function AppRun($rootScope, $window, $log, $state, $mdDialog, $fi
})
}
function checkCurrentState() {
if (userService.isUserLoaded() === true) {
if (userService.isAuthenticated()) {
gotoDefaultPlace();
} else {
$state.go('login');
}
} else {
if ($rootScope.userLoadedHandle) {
$rootScope.userLoadedHandle();
}
$rootScope.userLoadedHandle = $rootScope.$on('userLoaded', function () {
$rootScope.userLoadedHandle();
checkCurrentState();
});
}
}
function gotoDefaultPlace(params) {
userService.gotoDefaultPlace(params);
}

View File

@ -67,6 +67,7 @@ export default function WidgetController($scope, $timeout, $window, $element, $q
height: 0,
isEdit: isEdit,
isMobile: false,
widgetConfig: widget.config,
settings: widget.config.settings,
units: widget.config.units || '',
decimals: angular.isDefined(widget.config.decimals) ? widget.config.decimals : 2,

31
ui/src/app/url.handler.js Normal file
View File

@ -0,0 +1,31 @@
/*
* Copyright © 2016-2017 The Thingsboard Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default function UrlHandler($injector, $location) {
var userService = $injector.get('userService');
if (userService.isUserLoaded() === true) {
userService.gotoDefaultPlace();
} else {
var $rootScope = $injector.get('$rootScope');
if ($rootScope.userLoadedHandle) {
$rootScope.userLoadedHandle();
}
$rootScope.userLoadedHandle = $rootScope.$on('userLoaded', function () {
$rootScope.userLoadedHandle();
UrlHandler($injector, $location);
});
}
}