Allow deep linking into the app configure views

This commit is contained in:
Johannes Zellner
2019-09-18 17:45:13 +02:00
parent 930404e482
commit 0ae4d323f7
2 changed files with 18 additions and 4 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ app.config(['$routeProvider', function ($routeProvider) {
}).when('/users', {
controller: 'UsersController',
templateUrl: 'views/users.html?<%= revision %>'
}).when('/app/:appId', {
}).when('/app/:appId/:view?', {
controller: 'AppController',
templateUrl: 'views/app.html?<%= revision %>'
}).when('/appstore', {
+17 -3
View File
@@ -34,12 +34,23 @@
// });
// };
angular.module('Application').controller('AppController', ['$scope', '$location', '$timeout', '$interval', 'Client', function ($scope, $location, $timeout, $interval, Client) {
angular.module('Application').controller('AppController', ['$scope', '$location', '$timeout', '$interval', '$route', '$routeParams', 'Client', function ($scope, $location, $timeout, $interval, $route, $routeParams, Client) {
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
var appId = $location.path().slice('/app/'.length);
// Avoid full reload on path change
// https://stackoverflow.com/a/22614334
// reloadOnUrl: false in $routeProvider did not work!
var lastRoute = $route.current;
$scope.$on('$locationChangeSuccess', function (/* event */) {
if (lastRoute.$$route.originalPath === $route.current.$$route.originalPath) {
$route.current = lastRoute;
}
});
$scope.view = 'display';
var appId = $routeParams.appId;
if (!appId) return $location.path('/apps');
$scope.view = '';
$scope.app = null;
$scope.activeTask = null;
$scope.appIsRestarting = false;
@@ -57,6 +68,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.setView = function (view) {
if ($scope.view === view) return;
$route.updateParams({ view: view });
$scope[view].show();
$scope.view = view;
};
@@ -737,6 +749,8 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.app = app;
$scope.setView($routeParams.view || 'display');
asyncSeries([
fetchUsers,
fetchGroups,