Format all JavaScript functions in same syntax.

Required for use minified js code in production mode.
This commit is contained in:
Emanuel Schuetze 2016-01-17 21:16:04 +01:00
parent 0e24d9b632
commit 851252dfe8
12 changed files with 1055 additions and 892 deletions

View File

@ -4,19 +4,26 @@
angular.module('OpenSlidesApp.assignments.projector', ['OpenSlidesApp.assignments']) angular.module('OpenSlidesApp.assignments.projector', ['OpenSlidesApp.assignments'])
.config(function(slidesProvider) { .config([
slidesProvider.registerSlide('assignments/assignment', { 'slidesProvider',
template: 'static/templates/assignments/slide_assignment.html', function(slidesProvider) {
}); slidesProvider.registerSlide('assignments/assignment', {
}) template: 'static/templates/assignments/slide_assignment.html',
});
}
])
.controller('SlideAssignmentCtrl', function($scope, Assignment) { .controller('SlideAssignmentCtrl', [
// Attention! Each object that is used here has to be dealt on server side. '$scope',
// Add it to the coresponding get_requirements method of the ProjectorElement 'Assignment',
// class. function($scope, Assignment) {
var id = $scope.element.id; // Attention! Each object that is used here has to be dealt on server side.
Assignment.find(id); // Add it to the coresponding get_requirements method of the ProjectorElement
Assignment.bindOne(id, $scope, 'assignment'); // class.
}); var id = $scope.element.id;
Assignment.find(id);
Assignment.bindOne(id, $scope, 'assignment');
}
]);
}()); }());

View File

@ -18,63 +18,66 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
} }
]) ])
.config(function($stateProvider) { .config([
$stateProvider '$stateProvider',
.state('assignments', { function($stateProvider) {
url: '/assignments', $stateProvider
abstract: true, .state('assignments', {
template: "<ui-view/>", url: '/assignments',
}) abstract: true,
.state('assignments.assignment', { template: "<ui-view/>",
abstract: true, })
template: "<ui-view/>", .state('assignments.assignment', {
}) abstract: true,
.state('assignments.assignment.list', { template: "<ui-view/>",
resolve: { })
assignments: function(Assignment) { .state('assignments.assignment.list', {
return Assignment.findAll(); resolve: {
}, assignments: function(Assignment) {
phases: function(Assignment) { return Assignment.findAll();
return Assignment.getPhases(); },
phases: function(Assignment) {
return Assignment.getPhases();
}
} }
} })
}) .state('assignments.assignment.detail', {
.state('assignments.assignment.detail', { controller: 'AssignmentDetailCtrl',
controller: 'AssignmentDetailCtrl', resolve: {
resolve: { assignment: function(Assignment, $stateParams) {
assignment: function(Assignment, $stateParams) { return Assignment.find($stateParams.id);
return Assignment.find($stateParams.id); },
}, users: function(User) {
users: function(User) { return User.findAll();
return User.findAll(); }
} }
} })
}) // redirects to assignment detail and opens assignment edit form dialog, uses edit url,
// redirects to assignment detail and opens assignment edit form dialog, uses edit url, // used by ui-sref links from agenda only
// used by ui-sref links from agenda only // (from assignment controller use AssignmentForm factory instead to open dialog in front
// (from assignment controller use AssignmentForm factory instead to open dialog in front // of current view without redirect)
// of current view without redirect) .state('assignments.assignment.detail.update', {
.state('assignments.assignment.detail.update', { onEnter: ['$stateParams', '$state', 'ngDialog', 'Assignment',
onEnter: ['$stateParams', '$state', 'ngDialog', 'Assignment', function($stateParams, $state, ngDialog, Assignment) {
function($stateParams, $state, ngDialog, Assignment) { ngDialog.open({
ngDialog.open({ template: 'static/templates/assignments/assignment-form.html',
template: 'static/templates/assignments/assignment-form.html', controller: 'AssignmentUpdateCtrl',
controller: 'AssignmentUpdateCtrl', className: 'ngdialog-theme-default wide-form',
className: 'ngdialog-theme-default wide-form', closeByEscape: false,
closeByEscape: false, closeByDocument: false,
closeByDocument: false, resolve: {
resolve: { assignment: function() {return Assignment.find($stateParams.id)}
assignment: function() {return Assignment.find($stateParams.id)} },
}, preCloseCallback: function() {
preCloseCallback: function() { $state.go('assignments.assignment.detail', {assignment: $stateParams.id});
$state.go('assignments.assignment.detail', {assignment: $stateParams.id}); return true;
return true; }
} });
}); }
} ]
] });
}); }
}) ])
// Service for generic assignment form (create and update) // Service for generic assignment form (create and update)
.factory('AssignmentForm', [ .factory('AssignmentForm', [

View File

@ -12,23 +12,27 @@ angular.module('OpenSlidesApp.core', [
'ui.tree', 'ui.tree',
]) ])
.config(['DSProvider', 'DSHttpAdapterProvider', function(DSProvider, DSHttpAdapterProvider) { .config([
// Reloads everything after 5 minutes. 'DSProvider',
// TODO: * find a way only to reload things that are still needed 'DSHttpAdapterProvider',
DSProvider.defaults.maxAge = 5 * 60 * 1000; // 5 minutes function(DSProvider, DSHttpAdapterProvider) {
DSProvider.defaults.reapAction = 'none'; // Reloads everything after 5 minutes.
DSProvider.defaults.basePath = '/rest'; // TODO: * find a way only to reload things that are still needed
DSProvider.defaults.afterReap = function(model, items) { DSProvider.defaults.maxAge = 5 * 60 * 1000; // 5 minutes
if (items.length > 5) { DSProvider.defaults.reapAction = 'none';
model.findAll({}, {bypassCache: true}); DSProvider.defaults.basePath = '/rest';
} else { DSProvider.defaults.afterReap = function(model, items) {
_.forEach(items, function (item) { if (items.length > 5) {
model.refresh(item[model.idAttribute]); model.findAll({}, {bypassCache: true});
}); } else {
} _.forEach(items, function (item) {
}; model.refresh(item[model.idAttribute]);
DSHttpAdapterProvider.defaults.forceTrailingSlash = true; });
}]) }
};
DSHttpAdapterProvider.defaults.forceTrailingSlash = true;
}
])
.factory('autoupdate', [ .factory('autoupdate', [
'DS', 'DS',
@ -129,23 +133,27 @@ angular.module('OpenSlidesApp.core', [
} }
]) ])
.run(['DS', 'autoupdate', function(DS, autoupdate) { .run([
autoupdate.on_message(function(data) { 'DS',
// TODO: when MODEL.find() is called after this 'autoupdate',
// a new request is fired. This could be a bug in DS function(DS, autoupdate) {
autoupdate.on_message(function(data) {
// TODO: when MODEL.find() is called after this
// a new request is fired. This could be a bug in DS
// TODO: Do not send the status code to the client, but make the decission // TODO: Do not send the status code to the client, but make the decission
// on the server side. It is an implementation detail, that tornado // on the server side. It is an implementation detail, that tornado
// sends request to wsgi, which should not concern the client. // sends request to wsgi, which should not concern the client.
console.log("Received object: " + data.collection + ", " + data.id); console.log("Received object: " + data.collection + ", " + data.id);
if (data.status_code == 200) { if (data.status_code == 200) {
DS.inject(data.collection, data.data); DS.inject(data.collection, data.data);
} else if (data.status_code == 404) { } else if (data.status_code == 404) {
DS.eject(data.collection, data.id); DS.eject(data.collection, data.id);
} }
// TODO: handle other statuscodes // TODO: handle other statuscodes
}); });
}]) }
])
.factory('loadGlobalData', [ .factory('loadGlobalData', [
'$rootScope', '$rootScope',
@ -310,12 +318,15 @@ angular.module('OpenSlidesApp.core', [
* be removed. See http://www.js-data.io/docs/dsdefaults#onconflict for * be removed. See http://www.js-data.io/docs/dsdefaults#onconflict for
* more information. * more information.
*/ */
.factory('Projector', ['DS', function(DS) { .factory('Projector', [
return DS.defineResource({ 'DS',
name: 'core/projector', function(DS) {
onConflict: 'replace', return DS.defineResource({
}); name: 'core/projector',
}]) onConflict: 'replace',
});
}
])
/* Converts number of seconds into string "hh:mm:ss" or "mm:ss" */ /* Converts number of seconds into string "hh:mm:ss" or "mm:ss" */
.filter('osSecondsToTime', [ .filter('osSecondsToTime', [

View File

@ -6,70 +6,80 @@
angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core']) angular.module('OpenSlidesApp.core.projector', ['OpenSlidesApp.core'])
// Provider to register slides in a .config() statement. // Provider to register slides in a .config() statement.
.provider('slides', function() { .provider('slides', [
var slidesMap = {}; function() {
var slidesMap = {};
this.registerSlide = function(name, config) { this.registerSlide = function(name, config) {
slidesMap[name] = config; slidesMap[name] = config;
return this; return this;
}; };
this.$get = function($templateRequest, $q) { this.$get = function($templateRequest, $q) {
var self = this; var self = this;
return { return {
getElements: function(projector) { getElements: function(projector) {
var elements = []; var elements = [];
var factory = this; var factory = this;
_.forEach(projector.elements, function(element) { _.forEach(projector.elements, function(element) {
if (element.name in slidesMap) { if (element.name in slidesMap) {
element.template = slidesMap[element.name].template; element.template = slidesMap[element.name].template;
elements.push(element); elements.push(element);
} else {
console.log("Unknown slide: " + element.name);
}
});
return elements;
}
};
};
}
])
.config([
'slidesProvider',
function(slidesProvider) {
slidesProvider.registerSlide('core/customslide', {
template: 'static/templates/core/slide_customslide.html',
});
slidesProvider.registerSlide('core/clock', {
template: 'static/templates/core/slide_clock.html',
});
slidesProvider.registerSlide('core/countdown', {
template: 'static/templates/core/slide_countdown.html',
});
slidesProvider.registerSlide('core/message', {
template: 'static/templates/core/slide_message.html',
});
}
])
.controller('ProjectorCtrl', [
'$scope',
'Projector',
'slides',
function($scope, Projector, slides) {
Projector.find(1).then(function() {
$scope.$watch(function () {
return Projector.lastModified(1);
}, function () {
$scope.elements = [];
_.forEach(slides.getElements(Projector.get(1)), function(element) {
if (!element.error) {
$scope.elements.push(element);
} else { } else {
console.log("Unknown slide: " + element.name); console.error("Error for slide " + element.name + ": " + element.error);
} }
}); });
return elements; $scope.scroll = -5 * Projector.get(1).scroll;
} $scope.scale = 100 + 20 * Projector.get(1).scale;
};
};
})
.config(function(slidesProvider) {
slidesProvider.registerSlide('core/customslide', {
template: 'static/templates/core/slide_customslide.html',
});
slidesProvider.registerSlide('core/clock', {
template: 'static/templates/core/slide_clock.html',
});
slidesProvider.registerSlide('core/countdown', {
template: 'static/templates/core/slide_countdown.html',
});
slidesProvider.registerSlide('core/message', {
template: 'static/templates/core/slide_message.html',
});
})
.controller('ProjectorCtrl', function($scope, Projector, slides) {
Projector.find(1).then(function() {
$scope.$watch(function () {
return Projector.lastModified(1);
}, function () {
$scope.elements = [];
_.forEach(slides.getElements(Projector.get(1)), function(element) {
if (!element.error) {
$scope.elements.push(element);
} else {
console.error("Error for slide " + element.name + ": " + element.error);
}
}); });
$scope.scroll = -5 * Projector.get(1).scroll;
$scope.scale = 100 + 20 * Projector.get(1).scale;
}); });
}); }
}) ])
.controller('SlideCustomSlideCtrl', [ .controller('SlideCustomSlideCtrl', [
'$scope', '$scope',

View File

@ -84,219 +84,244 @@ angular.module('OpenSlidesApp.core.site', [
} }
]) ])
.config(function($urlRouterProvider, $locationProvider) { .config([
// define fallback url and html5Mode '$urlRouterProvider',
$urlRouterProvider.otherwise('/'); '$locationProvider',
$locationProvider.html5Mode(true); function($urlRouterProvider, $locationProvider) {
}) // define fallback url and html5Mode
$urlRouterProvider.otherwise('/');
$locationProvider.html5Mode(true);
}
])
.config(function($httpProvider) { .config([
// Combine the django csrf system with the angular csrf system '$httpProvider',
$httpProvider.defaults.xsrfCookieName = 'csrftoken'; function($httpProvider) {
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; // Combine the django csrf system with the angular csrf system
}) $httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
}
])
.config(function(uiSelectConfig) { .config([
uiSelectConfig.theme = 'bootstrap'; 'uiSelectConfig',
}) function(uiSelectConfig) {
uiSelectConfig.theme = 'bootstrap';
}
])
.config(function($stateProvider, $urlMatcherFactoryProvider) { .config([
// Make the trailing slash optional '$stateProvider',
$urlMatcherFactoryProvider.strictMode(false); '$urlMatcherFactoryProvider',
function($stateProvider, $urlMatcherFactoryProvider) {
// Make the trailing slash optional
$urlMatcherFactoryProvider.strictMode(false);
// Use stateProvider.decorator to give default values to our states // Use stateProvider.decorator to give default values to our states
$stateProvider.decorator('views', function(state, parent) { $stateProvider.decorator('views', function(state, parent) {
var result = {}, var result = {},
views = parent(state); views = parent(state);
if (state.abstract || state.data && state.data.extern) { if (state.abstract || state.data && state.data.extern) {
return views; return views;
} }
angular.forEach(views, function(config, name) { angular.forEach(views, function(config, name) {
// Sets default values for templateUrl // Sets default values for templateUrl
var patterns = state.name.split('.'), var patterns = state.name.split('.'),
templateUrl, templateUrl,
controller, controller,
defaultControllers = { defaultControllers = {
create: 'CreateCtrl', create: 'CreateCtrl',
update: 'UpdateCtrl', update: 'UpdateCtrl',
list: 'ListCtrl', list: 'ListCtrl',
detail: 'DetailCtrl', detail: 'DetailCtrl',
}; };
// templateUrl // templateUrl
if (_.last(patterns).match(/(create|update)/)) { if (_.last(patterns).match(/(create|update)/)) {
// When state_patterns is in the form "app.module.create" or // When state_patterns is in the form "app.module.create" or
// "app.module.update", use the form template. // "app.module.update", use the form template.
templateUrl = 'static/templates/' + patterns[0] + '/' + patterns[1] + '-form.html'; templateUrl = 'static/templates/' + patterns[0] + '/' + patterns[1] + '-form.html';
} else {
// Replaces the first point through a slash (the app name)
var appName = state.name.replace('.', '/');
// Replaces any folowing points though a -
templateUrl = 'static/templates/' + appName.replace(/\./g, '-') + '.html';
}
config.templateUrl = state.templateUrl || templateUrl;
// controller
if (patterns.length >= 3) {
controller = _.capitalize(patterns[1]) + defaultControllers[_.last(patterns)];
config.controller = state.controller || controller;
}
result[name] = config;
});
return result;
})
.decorator('url', function(state, parent) {
var defaultUrl;
if (state.abstract) {
defaultUrl = '';
} else { } else {
// Replaces the first point through a slash (the app name) var patterns = state.name.split('.'),
var appName = state.name.replace('.', '/'); defaultUrls = {
// Replaces any folowing points though a - create: '/new',
templateUrl = 'static/templates/' + appName.replace(/\./g, '-') + '.html'; update: '/edit',
} list: '',
config.templateUrl = state.templateUrl || templateUrl; // The id is expected to be an integer, if not, the url has to
// be defined manually
detail: '/{id:int}',
};
// controller defaultUrl = defaultUrls[_.last(patterns)];
if (patterns.length >= 3) {
controller = _.capitalize(patterns[1]) + defaultControllers[_.last(patterns)];
config.controller = state.controller || controller;
} }
result[name] = config;
state.url = state.url || defaultUrl;
return parent(state);
}); });
return result; }
}) ])
.decorator('url', function(state, parent) { .config([
var defaultUrl; '$stateProvider',
'$locationProvider',
if (state.abstract) { function($stateProvider, $locationProvider) {
defaultUrl = ''; // Core urls
} else { $stateProvider
var patterns = state.name.split('.'), .state('dashboard', {
defaultUrls = { url: '/',
create: '/new', templateUrl: 'static/templates/dashboard.html'
update: '/edit', })
list: '', .state('projector', {
// The id is expected to be an integer, if not, the url has to url: '/projector',
// be defined manually
detail: '/{id:int}',
};
defaultUrl = defaultUrls[_.last(patterns)];
}
state.url = state.url || defaultUrl;
return parent(state);
});
})
.config(function($stateProvider, $locationProvider) {
// Core urls
$stateProvider
.state('dashboard', {
url: '/',
templateUrl: 'static/templates/dashboard.html'
})
.state('projector', {
url: '/projector',
data: {extern: true},
onEnter: function($window) {
$window.location.href = this.url;
}
})
.state('core', {
url: '/core',
abstract: true,
template: "<ui-view/>",
})
// legal notice and version
.state('legalnotice', {
url: '/legalnotice',
controller: 'LegalNoticeCtrl',
})
//config
.state('config', {
url: '/config',
controller: 'ConfigCtrl',
resolve: {
configOption: function($http) {
return $http({ 'method': 'OPTIONS', 'url': '/rest/core/config/' });
}
}
})
// customslide
.state('core.customslide', {
url: '/customslide',
abstract: true,
template: "<ui-view/>",
})
.state('core.customslide.detail', {
resolve: {
customslide: function(Customslide, $stateParams) {
return Customslide.find($stateParams.id);
}
}
})
// redirects to customslide detail and opens customslide edit form dialog, uses edit url,
// used by ui-sref links from agenda only
// (from customslide controller use CustomSlideForm factory instead to open dialog in front
// of current view without redirect)
.state('core.customslide.detail.update', {
onEnter: ['$stateParams', '$state', 'ngDialog', 'Customslide',
function($stateParams, $state, ngDialog, Customslide) {
ngDialog.open({
template: 'static/templates/core/customslide-form.html',
controller: 'CustomslideUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
resolve: {
customslide: function() {return Customslide.find($stateParams.id) }
},
preCloseCallback: function() {
$state.go('core.customslide.detail', {customslide: $stateParams.id});
return true;
}
});
}]
})
// tag
.state('core.tag', {
url: '/tag',
abstract: true,
template: "<ui-view/>",
})
.state('core.tag.list', {
resolve: {
tags: function(Tag) {
return Tag.findAll();
}
}
})
.state('core.tag.create', {})
.state('core.tag.detail', {
resolve: {
tag: function(Tag, $stateParams) {
return Tag.find($stateParams.id);
}
}
})
.state('core.tag.detail.update', {
views: {
'@core.tag': {}
}
});
$locationProvider.html5Mode(true);
})
// Helper to add ui.router states at runtime.
// Needed for the django url_patterns.
.provider('runtimeStates', function($stateProvider) {
this.$get = function($q, $timeout, $state) {
return {
addState: function(name, state) {
$stateProvider.state(name, state);
}
};
};
})
// Load the django url patterns
.run(function(runtimeStates, $http) {
$http.get('/core/url_patterns/').then(function(data) {
for (var pattern in data.data) {
runtimeStates.addState(pattern, {
'url': data.data[pattern],
data: {extern: true}, data: {extern: true},
onEnter: function($window) { onEnter: function($window) {
$window.location.href = this.url; $window.location.href = this.url;
} }
})
.state('core', {
url: '/core',
abstract: true,
template: "<ui-view/>",
})
// legal notice and version
.state('legalnotice', {
url: '/legalnotice',
controller: 'LegalNoticeCtrl',
})
//config
.state('config', {
url: '/config',
controller: 'ConfigCtrl',
resolve: {
configOption: function($http) {
return $http({ 'method': 'OPTIONS', 'url': '/rest/core/config/' });
}
}
})
// customslide
.state('core.customslide', {
url: '/customslide',
abstract: true,
template: "<ui-view/>",
})
.state('core.customslide.detail', {
resolve: {
customslide: function(Customslide, $stateParams) {
return Customslide.find($stateParams.id);
}
}
})
// redirects to customslide detail and opens customslide edit form dialog, uses edit url,
// used by ui-sref links from agenda only
// (from customslide controller use CustomSlideForm factory instead to open dialog in front
// of current view without redirect)
.state('core.customslide.detail.update', {
onEnter: ['$stateParams', '$state', 'ngDialog', 'Customslide',
function($stateParams, $state, ngDialog, Customslide) {
ngDialog.open({
template: 'static/templates/core/customslide-form.html',
controller: 'CustomslideUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
resolve: {
customslide: function() {return Customslide.find($stateParams.id) }
},
preCloseCallback: function() {
$state.go('core.customslide.detail', {customslide: $stateParams.id});
return true;
}
});
}]
})
// tag
.state('core.tag', {
url: '/tag',
abstract: true,
template: "<ui-view/>",
})
.state('core.tag.list', {
resolve: {
tags: function(Tag) {
return Tag.findAll();
}
}
})
.state('core.tag.create', {})
.state('core.tag.detail', {
resolve: {
tag: function(Tag, $stateParams) {
return Tag.find($stateParams.id);
}
}
})
.state('core.tag.detail.update', {
views: {
'@core.tag': {}
}
}); });
}
}); $locationProvider.html5Mode(true);
}) }
])
// Helper to add ui.router states at runtime.
// Needed for the django url_patterns.
.provider('runtimeStates', [
'$stateProvider',
function($stateProvider) {
this.$get = function($q, $timeout, $state) {
return {
addState: function(name, state) {
$stateProvider.state(name, state);
}
};
};
}
])
// Load the django url patterns
.run([
'runtimeStates',
'$http',
function(runtimeStates, $http) {
$http.get('/core/url_patterns/').then(function(data) {
for (var pattern in data.data) {
runtimeStates.addState(pattern, {
'url': data.data[pattern],
data: {extern: true},
onEnter: function($window) {
$window.location.href = this.url;
}
});
}
});
}
])
// angular formly config options // angular formly config options
.run([ .run([
@ -321,42 +346,46 @@ angular.module('OpenSlidesApp.core.site', [
// html-tag os-form-field to generate generic from fields // html-tag os-form-field to generate generic from fields
// TODO: make it possible to use other fields then config fields // TODO: make it possible to use other fields then config fields
.directive('osFormField', function($parse, Config) { .directive('osFormField', [
function getHtmlType(type) { '$parse',
return { 'Config',
string: 'text', function($parse, Config) {
text: 'textarea', function getHtmlType(type) {
integer: 'number', return {
boolean: 'checkbox', string: 'text',
choice: 'choice', text: 'textarea',
}[type]; integer: 'number',
} boolean: 'checkbox',
choice: 'choice',
return { }[type];
restrict: 'E',
scope: true,
templateUrl: '/static/templates/config-form-field.html',
link: function ($scope, iElement, iAttrs, controller, transcludeFn) {
var field = $parse(iAttrs.field)($scope);
var config = Config.get(field.key);
$scope.type = getHtmlType(field.input_type);
if ($scope.type == 'choice') {
$scope.choices = field.choices;
}
$scope.label = field.label;
$scope.key = 'field-' + field.key;
$scope.value = config.value;
$scope.help_text = field.help_text;
$scope.default_value = field.default_value;
$scope.reset = function () {
$scope.value = $scope.default_value;
$scope.save(field.key, $scope.value);
}
} }
};
})
.controller("MainMenuCtrl", [ return {
restrict: 'E',
scope: true,
templateUrl: '/static/templates/config-form-field.html',
link: function ($scope, iElement, iAttrs, controller, transcludeFn) {
var field = $parse(iAttrs.field)($scope);
var config = Config.get(field.key);
$scope.type = getHtmlType(field.input_type);
if ($scope.type == 'choice') {
$scope.choices = field.choices;
}
$scope.label = field.label;
$scope.key = 'field-' + field.key;
$scope.value = config.value;
$scope.help_text = field.help_text;
$scope.default_value = field.default_value;
$scope.reset = function () {
$scope.value = $scope.default_value;
$scope.save(field.key, $scope.value);
}
}
};
}
])
.controller('MainMenuCtrl', [
'$scope', '$scope',
'mainMenu', 'mainMenu',
function ($scope, mainMenu) { function ($scope, mainMenu) {
@ -364,15 +393,21 @@ angular.module('OpenSlidesApp.core.site', [
} }
]) ])
.controller("LanguageCtrl", function ($scope, gettextCatalog, Languages, filterFilter) { .controller('LanguageCtrl', [
$scope.languages = Languages.getLanguages(); '$scope',
$scope.selectedLanguage = filterFilter($scope.languages, {selected: true}); 'gettextCatalog',
// controller to switch app language 'Languages',
$scope.switchLanguage = function (lang) { 'filterFilter',
$scope.languages = Languages.setCurrentLanguage(lang); function ($scope, gettextCatalog, Languages, filterFilter) {
$scope.languages = Languages.getLanguages();
$scope.selectedLanguage = filterFilter($scope.languages, {selected: true}); $scope.selectedLanguage = filterFilter($scope.languages, {selected: true});
}; // controller to switch app language
}) $scope.switchLanguage = function (lang) {
$scope.languages = Languages.setCurrentLanguage(lang);
$scope.selectedLanguage = filterFilter($scope.languages, {selected: true});
};
}
])
// Projector Sidebar Controller // Projector Sidebar Controller
.controller('ProjectorSidebarCtrl', [ .controller('ProjectorSidebarCtrl', [
@ -398,16 +433,21 @@ angular.module('OpenSlidesApp.core.site', [
]) ])
// Config Controller // Config Controller
.controller('ConfigCtrl', function($scope, Config, configOption) { .controller('ConfigCtrl', [
Config.bindAll({}, $scope, 'configs'); '$scope',
$scope.configGroups = configOption.data.config_groups; 'Config',
'configOption',
function($scope, Config, configOption) {
Config.bindAll({}, $scope, 'configs');
$scope.configGroups = configOption.data.config_groups;
// save changed config value // save changed config value
$scope.save = function(key, value) { $scope.save = function(key, value) {
Config.get(key).value = value; Config.get(key).value = value;
Config.save(key); Config.save(key);
}; };
}) }
])
// Provide generic customslide form fields for create and update view // Provide generic customslide form fields for create and update view
@ -744,58 +784,78 @@ angular.module('OpenSlidesApp.core.site', [
]) ])
// Tag Controller // Tag Controller
.controller('TagListCtrl', function($scope, Tag) { .controller('TagListCtrl', [
Tag.bindAll({}, $scope, 'tags'); '$scope',
'Tag',
function($scope, Tag) {
Tag.bindAll({}, $scope, 'tags');
// setup table sorting // setup table sorting
$scope.sortColumn = 'name'; $scope.sortColumn = 'name';
$scope.reverse = false; $scope.reverse = false;
// function to sort by clicked column // function to sort by clicked column
$scope.toggleSort = function ( column ) { $scope.toggleSort = function ( column ) {
if ( $scope.sortColumn === column ) { if ( $scope.sortColumn === column ) {
$scope.reverse = !$scope.reverse; $scope.reverse = !$scope.reverse;
}
$scope.sortColumn = column;
};
// save changed tag
$scope.save = function (tag) {
Tag.save(tag);
};
$scope.delete = function (tag) {
Tag.destroy(tag.id).then(
function(success) {
//TODO: success message
} }
); $scope.sortColumn = column;
}; };
})
.controller('TagDetailCtrl', function($scope, Tag, tag) { // save changed tag
Tag.bindOne(tag.id, $scope, 'tag'); $scope.save = function (tag) {
}) Tag.save(tag);
};
$scope.delete = function (tag) {
Tag.destroy(tag.id).then(
function(success) {
//TODO: success message
}
);
};
}
])
.controller('TagCreateCtrl', function($scope, $state, Tag) { .controller('TagDetailCtrl', [
$scope.tag = {}; '$scope',
$scope.save = function (tag) { 'Tag',
Tag.create(tag).then( 'tag',
function(success) { function($scope, Tag, tag) {
$state.go('core.tag.list'); Tag.bindOne(tag.id, $scope, 'tag');
} }
); ])
};
})
.controller('TagUpdateCtrl', function($scope, $state, Tag, tag) { .controller('TagCreateCtrl', [
$scope.tag = tag; '$scope',
$scope.save = function (tag) { '$state',
Tag.save(tag).then( 'Tag',
function(success) { function($scope, $state, Tag) {
$state.go('core.tag.list'); $scope.tag = {};
} $scope.save = function (tag) {
); Tag.create(tag).then(
}; function(success) {
}) $state.go('core.tag.list');
}
);
};
}
])
.controller('TagUpdateCtrl', [
'$scope',
'$state',
'Tag',
'tag',
function($scope, $state, Tag, tag) {
$scope.tag = tag;
$scope.save = function (tag) {
Tag.save(tag).then(
function(success) {
$state.go('core.tag.list');
}
);
};
}
])
// counter of new (unread) chat messages // counter of new (unread) chat messages
.value('NewChatMessages', []) .value('NewChatMessages', [])
@ -846,14 +906,17 @@ angular.module('OpenSlidesApp.core.site', [
} }
]) ])
.directive('osFocusMe', function ($timeout) { .directive('osFocusMe', [
return { '$timeout',
link: function (scope, element, attrs, model) { function ($timeout) {
$timeout(function () { return {
element[0].focus(); link: function (scope, element, attrs, model) {
}); $timeout(function () {
} element[0].focus();
}; });
}); }
};
}
]);
}()); }());

View File

@ -18,69 +18,79 @@ angular.module('OpenSlidesApp.mediafiles.site', ['ngFileUpload', 'OpenSlidesApp.
} }
]) ])
.config(function($stateProvider) { .config([
$stateProvider '$stateProvider',
.state('mediafiles', { function($stateProvider) {
url: '/mediafiles', $stateProvider
abstract: true, .state('mediafiles', {
template: "<ui-view/>", url: '/mediafiles',
}) abstract: true,
.state('mediafiles.mediafile', { template: "<ui-view/>",
abstract: true, })
template: "<ui-view/>", .state('mediafiles.mediafile', {
}) abstract: true,
.state('mediafiles.mediafile.list', { template: "<ui-view/>",
resolve: { })
mediafiles: function(Mediafile) { .state('mediafiles.mediafile.list', {
return Mediafile.findAll(); resolve: {
mediafiles: function(Mediafile) {
return Mediafile.findAll();
}
} }
} })
}) .state('mediafiles.mediafile.create', {})
.state('mediafiles.mediafile.create', {}) .state('mediafiles.mediafile.detail', {
.state('mediafiles.mediafile.detail', { url: '/{id:int}',
url: '/{id:int}', abstract: true,
abstract: true, resolve: {
resolve: { mediafile: function(Mediafile, $stateParams) {
mediafile: function(Mediafile, $stateParams) { var id = $stateParams.id;
var id = $stateParams.id; var file = Mediafile.find(id);
var file = Mediafile.find(id); return file;
return file; }
},
template: "<ui-view/>",
})
.state('mediafiles.mediafile.detail.update', {
views: {
'@mediafiles.mediafile': {}
} }
}, });
template: "<ui-view/>", }
}) ])
.state('mediafiles.mediafile.detail.update', {
views: { .controller('MediafileListCtrl', [
'@mediafiles.mediafile': {} '$scope',
'$http',
'$timeout',
'Upload',
'Mediafile',
function($scope, $http, $timeout, Upload, Mediafile) {
Mediafile.bindAll({}, $scope, 'mediafiles');
// setup table sorting
$scope.sortColumn = 'title';
$scope.filterPresent = '';
$scope.reverse = false;
// function to sort by clicked column
$scope.toggleSort = function ( column ) {
if ( $scope.sortColumn === column ) {
$scope.reverse = !$scope.reverse;
} }
}); $scope.sortColumn = column;
}) };
.controller('MediafileListCtrl', function($scope, $http, $timeout, Upload, Mediafile) { // delete
Mediafile.bindAll({}, $scope, 'mediafiles'); $scope.delete = function (mediafile) {
//TODO: add confirm message
// setup table sorting Mediafile.destroy(mediafile.id).then(
$scope.sortColumn = 'title'; function(success) {
$scope.filterPresent = ''; //TODO: success message
$scope.reverse = false; }
// function to sort by clicked column );
$scope.toggleSort = function ( column ) { };
if ( $scope.sortColumn === column ) { }
$scope.reverse = !$scope.reverse; ])
}
$scope.sortColumn = column;
};
// delete
$scope.delete = function (mediafile) {
//TODO: add confirm message
Mediafile.destroy(mediafile.id).then(
function(success) {
//TODO: success message
}
);
};
})
.controller('MediafileCreateCtrl', [ .controller('MediafileCreateCtrl', [
'$scope', '$scope',

View File

@ -298,12 +298,18 @@ angular.module('OpenSlidesApp.motions', ['OpenSlidesApp.users'])
} }
]) ])
.factory('Category', ['DS', function(DS) { .factory('Category', [
return DS.defineResource({ 'DS',
name: 'motions/category', function(DS) {
}); return DS.defineResource({
}]) name: 'motions/category',
});
.run(['Motion', 'Category', function(Motion, Category) {}]); }
])
.run([
'Motion',
'Category',
function(Motion, Category) {}
]);
}()); }());

View File

@ -4,20 +4,28 @@
angular.module('OpenSlidesApp.motions.projector', ['OpenSlidesApp.motions']) angular.module('OpenSlidesApp.motions.projector', ['OpenSlidesApp.motions'])
.config(function(slidesProvider) { .config([
slidesProvider.registerSlide('motions/motion', { 'slidesProvider',
template: 'static/templates/motions/slide_motion.html', function(slidesProvider) {
}); slidesProvider.registerSlide('motions/motion', {
}) template: 'static/templates/motions/slide_motion.html',
});
}
])
.controller('SlideMotionCtrl', function($scope, Motion, User) { .controller('SlideMotionCtrl', [
// Attention! Each object that is used here has to be dealt on server side. '$scope',
// Add it to the coresponding get_requirements method of the ProjectorElement 'Motion',
// class. 'User',
var id = $scope.element.id; function($scope, Motion, User) {
Motion.find(id); // Attention! Each object that is used here has to be dealt on server side.
User.findAll(); // Add it to the coresponding get_requirements method of the ProjectorElement
Motion.bindOne(id, $scope, 'motion'); // class.
}); var id = $scope.element.id;
Motion.find(id);
User.findAll();
Motion.bindOne(id, $scope, 'motion');
}
]);
}()); }());

View File

@ -18,121 +18,124 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
} }
]) ])
.config(function($stateProvider) { .config([
$stateProvider '$stateProvider',
.state('motions', { function($stateProvider) {
url: '/motions', $stateProvider
abstract: true, .state('motions', {
template: "<ui-view/>", url: '/motions',
}) abstract: true,
.state('motions.motion', { template: "<ui-view/>",
abstract: true, })
template: "<ui-view/>", .state('motions.motion', {
}) abstract: true,
.state('motions.motion.list', { template: "<ui-view/>",
resolve: { })
motions: function(Motion) { .state('motions.motion.list', {
return Motion.findAll(); resolve: {
}, motions: function(Motion) {
categories: function(Category) { return Motion.findAll();
return Category.findAll(); },
}, categories: function(Category) {
tags: function(Tag) { return Category.findAll();
return Tag.findAll(); },
}, tags: function(Tag) {
users: function(User) { return Tag.findAll();
return User.findAll(); },
}, users: function(User) {
workflows: function(Workflow) { return User.findAll();
return Workflow.findAll(); },
workflows: function(Workflow) {
return Workflow.findAll();
}
} }
} })
}) .state('motions.motion.detail', {
.state('motions.motion.detail', { resolve: {
resolve: { motion: function(Motion, $stateParams) {
motion: function(Motion, $stateParams) { return Motion.find($stateParams.id);
return Motion.find($stateParams.id); },
}, categories: function(Category) {
categories: function(Category) { return Category.findAll();
return Category.findAll(); },
}, users: function(User) {
users: function(User) { return User.findAll();
return User.findAll(); },
}, mediafiles: function(Mediafile) {
mediafiles: function(Mediafile) { return Mediafile.findAll();
return Mediafile.findAll(); },
}, tags: function(Tag) {
tags: function(Tag) { return Tag.findAll();
return Tag.findAll(); }
} }
} })
}) // redirects to motion detail and opens motion edit form dialog, uses edit url,
// redirects to motion detail and opens motion edit form dialog, uses edit url, // used by ui-sref links from agenda only
// used by ui-sref links from agenda only // (from motion controller use MotionForm factory instead to open dialog in front of
// (from motion controller use MotionForm factory instead to open dialog in front of // current view without redirect)
// current view without redirect) .state('motions.motion.detail.update', {
.state('motions.motion.detail.update', { onEnter: ['$stateParams', '$state', 'ngDialog', 'Motion',
onEnter: ['$stateParams', '$state', 'ngDialog', 'Motion', function($stateParams, $state, ngDialog, Motion) {
function($stateParams, $state, ngDialog, Motion) { ngDialog.open({
ngDialog.open({ template: 'static/templates/motions/motion-form.html',
template: 'static/templates/motions/motion-form.html', controller: 'MotionUpdateCtrl',
controller: 'MotionUpdateCtrl', className: 'ngdialog-theme-default wide-form',
className: 'ngdialog-theme-default wide-form', closeByEscape: false,
closeByEscape: false, closeByDocument: false,
closeByDocument: false, resolve: {
resolve: { motion: function() {return Motion.find($stateParams.id)}
motion: function() {return Motion.find($stateParams.id)} },
}, preCloseCallback: function() {
preCloseCallback: function() { $state.go('motions.motion.detail', {motion: $stateParams.id});
$state.go('motions.motion.detail', {motion: $stateParams.id}); return true;
return true; }
} });
}); }
]
})
.state('motions.motion.import', {
url: '/import',
controller: 'MotionImportCtrl',
resolve: {
motions: function(Motion) {
return Motion.findAll();
},
categories: function(Category) {
return Category.findAll();
},
users: function(User) {
return User.findAll();
}
} }
] })
}) // categories
.state('motions.motion.import', { .state('motions.category', {
url: '/import', url: '/category',
controller: 'MotionImportCtrl', abstract: true,
resolve: { template: "<ui-view/>",
motions: function(Motion) { })
return Motion.findAll(); .state('motions.category.list', {
}, resolve: {
categories: function(Category) { categories: function(Category) {
return Category.findAll(); return Category.findAll();
}, }
users: function(User) {
return User.findAll();
} }
} })
}) .state('motions.category.create', {})
// categories .state('motions.category.detail', {
.state('motions.category', { resolve: {
url: '/category', category: function(Category, $stateParams) {
abstract: true, return Category.find($stateParams.id);
template: "<ui-view/>", }
})
.state('motions.category.list', {
resolve: {
categories: function(Category) {
return Category.findAll();
} }
} })
}) .state('motions.category.detail.update', {
.state('motions.category.create', {}) views: {
.state('motions.category.detail', { '@motions.category': {}
resolve: {
category: function(Category, $stateParams) {
return Category.find($stateParams.id);
} }
} });
}) }
.state('motions.category.detail.update', { ])
views: {
'@motions.category': {}
}
});
})
// Service for generic motion form (create and update) // Service for generic motion form (create and update)
.factory('MotionForm', [ .factory('MotionForm', [
@ -874,50 +877,70 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
]) ])
.controller('CategoryListCtrl', function($scope, Category) { .controller('CategoryListCtrl', [
Category.bindAll({}, $scope, 'categories'); '$scope',
'Category',
function($scope, Category) {
Category.bindAll({}, $scope, 'categories');
// setup table sorting // setup table sorting
$scope.sortColumn = 'name'; $scope.sortColumn = 'name';
$scope.reverse = false; $scope.reverse = false;
// function to sort by clicked column // function to sort by clicked column
$scope.toggleSort = function ( column ) { $scope.toggleSort = function ( column ) {
if ( $scope.sortColumn === column ) { if ( $scope.sortColumn === column ) {
$scope.reverse = !$scope.reverse; $scope.reverse = !$scope.reverse;
}
$scope.sortColumn = column;
};
// delete selected category
$scope.delete = function (category) {
Category.destroy(category.id);
};
})
.controller('CategoryDetailCtrl', function($scope, Category, category) {
Category.bindOne(category.id, $scope, 'category');
})
.controller('CategoryCreateCtrl', function($scope, $state, Category) {
$scope.category = {};
$scope.save = function (category) {
Category.create(category).then(
function(success) {
$state.go('motions.category.list');
} }
); $scope.sortColumn = column;
}; };
})
.controller('CategoryUpdateCtrl', function($scope, $state, Category, category) { // delete selected category
$scope.category = category; $scope.delete = function (category) {
$scope.save = function (category) { Category.destroy(category.id);
Category.save(category).then( };
function(success) { }
$state.go('motions.category.list'); ])
}
); .controller('CategoryDetailCtrl', [
}; '$scope',
}); 'Category',
'category',
function($scope, Category, category) {
Category.bindOne(category.id, $scope, 'category');
}
])
.controller('CategoryCreateCtrl', [
'$scope',
'$state',
'Category',
function($scope, $state, Category) {
$scope.category = {};
$scope.save = function (category) {
Category.create(category).then(
function(success) {
$state.go('motions.category.list');
}
);
};
}
])
.controller('CategoryUpdateCtrl', [
'$scope',
'$state',
'Category',
'category',
function($scope, $state, Category, category) {
$scope.category = category;
$scope.save = function (category) {
Category.save(category).then(
function(success) {
$state.go('motions.category.list');
}
);
};
}
]);
}()); }());

View File

@ -60,80 +60,92 @@ angular.module('OpenSlidesApp.users', [])
} }
]) ])
.factory('User', ['DS', 'Group', 'jsDataModel', function(DS, Group, jsDataModel) { .factory('User', [
var name = 'users/user'; 'DS',
return DS.defineResource({ 'Group',
name: name, 'jsDataModel',
useClass: jsDataModel, function(DS, Group, jsDataModel) {
computed: { var name = 'users/user';
full_name: function () { return DS.defineResource({
return this.get_full_name(); name: name,
useClass: jsDataModel,
computed: {
full_name: function () {
return this.get_full_name();
},
short_name: function () {
return this.get_short_name();
},
}, },
short_name: function () { methods: {
return this.get_short_name(); getResourceName: function () {
}, return name;
}, },
methods: { get_short_name: function() {
getResourceName: function () { // should be the same as in the python user model.
return name; var firstName = _.trim(this.first_name),
}, lastName = _.trim(this.last_name),
get_short_name: function() { name;
// should be the same as in the python user model.
var firstName = _.trim(this.first_name),
lastName = _.trim(this.last_name),
name;
if (firstName && lastName) { if (firstName && lastName) {
// TODO: check config // TODO: check config
name = [firstName, lastName].join(' '); name = [firstName, lastName].join(' ');
} else { } else {
name = firstName || lastName || this.username; name = firstName || lastName || this.username;
}
return name;
},
get_full_name: function() {
// should be the same as in the python user model.
var firstName = _.trim(this.first_name),
lastName = _.trim(this.last_name),
structure_level = _.trim(this.structure_level),
name;
if (firstName && lastName) {
// TODO: check config
name = [firstName, lastName].join(' ');
} else {
name = firstName || lastName || this.username;
}
if (structure_level) {
name = name + " (" + structure_level + ")";
}
return name;
},
getPerms: function() {
var allPerms = [];
var allGroups = this.groups;
// Add registered group
allGroups.push(2);
_.forEach(allGroups, function(groupId) {
var group = Group.get(groupId);
if (group) {
_.forEach(group.permissions, function(perm) {
allPerms.push(perm);
});
} }
}); return name;
return _.uniq(allPerms); },
get_full_name: function() {
// should be the same as in the python user model.
var firstName = _.trim(this.first_name),
lastName = _.trim(this.last_name),
structure_level = _.trim(this.structure_level),
name;
if (firstName && lastName) {
// TODO: check config
name = [firstName, lastName].join(' ');
} else {
name = firstName || lastName || this.username;
}
if (structure_level) {
name = name + " (" + structure_level + ")";
}
return name;
},
getPerms: function() {
var allPerms = [];
var allGroups = this.groups;
// Add registered group
allGroups.push(2);
_.forEach(allGroups, function(groupId) {
var group = Group.get(groupId);
if (group) {
_.forEach(group.permissions, function(perm) {
allPerms.push(perm);
});
}
});
return _.uniq(allPerms);
},
}, },
}, });
}); }
}]) ])
.factory('Group', ['DS', function(DS) { .factory('Group', [
return DS.defineResource({ 'DS',
name: 'users/group', function(DS) {
}); return DS.defineResource({
}]) name: 'users/group',
});
}
])
.run(['User', 'Group', function(User, Group) {}]); .run([
'User',
'Group',
function(User, Group) {}
]);
}()); }());

View File

@ -4,19 +4,26 @@
angular.module('OpenSlidesApp.users.projector', ['OpenSlidesApp.users']) angular.module('OpenSlidesApp.users.projector', ['OpenSlidesApp.users'])
.config(function(slidesProvider) { .config([
slidesProvider.registerSlide('users/user', { 'slidesProvider',
template: 'static/templates/users/slide_user.html', function(slidesProvider) {
}); slidesProvider.registerSlide('users/user', {
}) template: 'static/templates/users/slide_user.html',
});
}
])
.controller('SlideUserCtrl', function($scope, User) { .controller('SlideUserCtrl', [
// Attention! Each object that is used here has to be dealt on server side. '$scope',
// Add it to the coresponding get_requirements method of the ProjectorElement 'User',
// class. function($scope, User) {
var id = $scope.element.id; // Attention! Each object that is used here has to be dealt on server side.
User.find(id); // Add it to the coresponding get_requirements method of the ProjectorElement
User.bindOne(id, $scope, 'user'); // class.
}); var id = $scope.element.id;
User.find(id);
User.bindOne(id, $scope, 'user');
}
]);
}()); }());

View File

@ -18,120 +18,123 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
} }
]) ])
.config(function($stateProvider) { .config([
$stateProvider '$stateProvider',
.state('users', { function($stateProvider) {
url: '/users', $stateProvider
abstract: true, .state('users', {
template: "<ui-view/>", url: '/users',
}) abstract: true,
.state('users.user', { template: "<ui-view/>",
abstract: true, })
template: "<ui-view/>", .state('users.user', {
}) abstract: true,
.state('users.user.list', { template: "<ui-view/>",
resolve: { })
users: function(User) { .state('users.user.list', {
return User.findAll(); resolve: {
} users: function(User) {
} return User.findAll();
})
.state('users.user.create', {
resolve: {
groups: function(Group) {
return Group.findAll();
}
}
})
.state('users.user.detail', {
resolve: {
user: function(User, $stateParams) {
return User.find($stateParams.id);
},
groups: function(Group) {
return Group.findAll();
}
}
})
.state('users.user.detail.profile', {
views: {
'@users.user': {},
},
url: '/profile',
controller: 'UserProfileCtrl',
})
.state('users.user.detail.password', {
views: {
'@users.user': {},
},
url: '/password',
controller: 'UserPasswordCtrl',
})
.state('users.user.import', {
url: '/import',
controller: 'UserImportCtrl',
resolve: {
groups: function(Group) {
return Group.findAll();
}
}
})
// groups
.state('users.group', {
url: '/groups',
abstract: true,
template: "<ui-view/>",
})
.state('users.group.list', {
resolve: {
groups: function(Group) {
return Group.findAll();
}
}
})
.state('users.group.create', {
resolve: {
permissions: function($http) {
return $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' });
}
}
})
.state('users.group.detail', {
resolve: {
group: function(Group, $stateParams) {
return Group.find($stateParams.id);
}
}
})
.state('users.group.detail.update', {
views: {
'@users.group': {}
},
resolve: {
permissions: function($http) {
return $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' });
}
}
})
.state('login', {
template: null,
url: '/login',
params: { guest_enabled: false },
onEnter: ['$state', '$stateParams', 'ngDialog', function($state, $stateParams, ngDialog) {
ngDialog.open({
template: 'static/templates/core/login-form.html',
controller: 'LoginFormCtrl',
showClose: $stateParams.guest_enabled,
closeByEscape: $stateParams.guest_enabled,
closeByDocument: $stateParams.guest_enabled,
preCloseCallback: function() {
$state.go('dashboard');
return true;
} }
}); }
}] })
}); .state('users.user.create', {
}) resolve: {
groups: function(Group) {
return Group.findAll();
}
}
})
.state('users.user.detail', {
resolve: {
user: function(User, $stateParams) {
return User.find($stateParams.id);
},
groups: function(Group) {
return Group.findAll();
}
}
})
.state('users.user.detail.profile', {
views: {
'@users.user': {},
},
url: '/profile',
controller: 'UserProfileCtrl',
})
.state('users.user.detail.password', {
views: {
'@users.user': {},
},
url: '/password',
controller: 'UserPasswordCtrl',
})
.state('users.user.import', {
url: '/import',
controller: 'UserImportCtrl',
resolve: {
groups: function(Group) {
return Group.findAll();
}
}
})
// groups
.state('users.group', {
url: '/groups',
abstract: true,
template: "<ui-view/>",
})
.state('users.group.list', {
resolve: {
groups: function(Group) {
return Group.findAll();
}
}
})
.state('users.group.create', {
resolve: {
permissions: function($http) {
return $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' });
}
}
})
.state('users.group.detail', {
resolve: {
group: function(Group, $stateParams) {
return Group.find($stateParams.id);
}
}
})
.state('users.group.detail.update', {
views: {
'@users.group': {}
},
resolve: {
permissions: function($http) {
return $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' });
}
}
})
.state('login', {
template: null,
url: '/login',
params: { guest_enabled: false },
onEnter: ['$state', '$stateParams', 'ngDialog', function($state, $stateParams, ngDialog) {
ngDialog.open({
template: 'static/templates/core/login-form.html',
controller: 'LoginFormCtrl',
showClose: $stateParams.guest_enabled,
closeByEscape: $stateParams.guest_enabled,
closeByDocument: $stateParams.guest_enabled,
preCloseCallback: function() {
$state.go('dashboard');
return true;
}
});
}]
});
}
])
.run([ .run([
'operator', 'operator',