2016-03-18 23:03:28 +01:00
|
|
|
var app = angular.module('semaphore', ['scs.couch-potato', 'ui.router', 'ui.bootstrap', 'angular-loading-bar']);
|
2014-08-24 19:36:34 +02:00
|
|
|
|
2016-03-18 23:03:28 +01:00
|
|
|
couchPotato.configureApp(app);
|
|
|
|
|
|
|
|
app.run(['$rootScope', '$window', '$couchPotato', '$injector', '$state', '$http', function ($rootScope, $window, $couchPotato, $injector, $state, $http) {
|
|
|
|
app.lazy = $couchPotato;
|
|
|
|
|
|
|
|
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
|
|
|
|
if (toState.pageTitle) {
|
|
|
|
$rootScope.pageTitle = "Loading " + toState.pageTitle;
|
|
|
|
} else {
|
|
|
|
$rootScope.pageTitle = "Loading..";
|
|
|
|
}
|
2014-08-24 19:36:34 +02:00
|
|
|
});
|
2016-03-18 23:03:28 +01:00
|
|
|
|
|
|
|
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
|
|
|
|
$rootScope.previousState = {
|
|
|
|
name: fromState.name,
|
|
|
|
params: fromParams
|
|
|
|
}
|
|
|
|
|
|
|
|
if (toState.pageTitle) {
|
|
|
|
$rootScope.pageTitle = toState.pageTitle;
|
|
|
|
} else {
|
|
|
|
$rootScope.pageTitle = "Ansible-Semaphore Page";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$rootScope.refreshUser = function () {
|
|
|
|
$rootScope.user = null;
|
|
|
|
$rootScope.loggedIn = false;
|
|
|
|
|
|
|
|
$http.get('/api/user')
|
|
|
|
.then(function (user) {
|
|
|
|
$rootScope.user = user;
|
|
|
|
$rootScope.loggedIn = true;
|
|
|
|
}, function () {
|
|
|
|
$state.go('login');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$rootScope.refreshUser();
|
|
|
|
}]);
|