nitweb: replace ngRouter by ui.router
[nit.git] / share / nitweb / javascripts / nitweb.js
1 /*
2 * Copyright 2016 Alexandre Terrasa <alexandre@moz-code.org>.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 (function() {
18 angular.module('nitweb', ['ui.router', 'ngSanitize', 'angular-loading-bar', 'index', 'entities', 'docdown', 'metrics', 'users', 'grades'])
19
20 .config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
21 cfpLoadingBarProvider.includeSpinner = false;
22 }])
23 .config(function($stateProvider, $locationProvider) {
24 $stateProvider
25 .state('index', {
26 url: '/',
27 templateUrl: 'views/index.html',
28 controller: 'IndexCtrl',
29 controllerAs: 'indexCtrl'
30 })
31 .state('user', {
32 url: '/user',
33 templateUrl: 'views/user.html',
34 controller: 'UserCtrl',
35 controllerAs: 'userCtrl'
36 })
37 .state('docdown', {
38 url: '/docdown',
39 templateUrl: 'views/docdown.html',
40 controller: 'DocdownCtrl',
41 controllerAs: 'docdownCtrl'
42 })
43 .state('grades', {
44 url: '/grades',
45 templateUrl: 'views/grades.html',
46 controller: 'GradesCtrl',
47 controllerAs: 'gradesCtrl'
48 })
49 .state('login', {
50 url: '/login',
51 controller : function(){
52 window.location.replace('/login');
53 },
54 template : "<div></div>"
55 })
56 .state('logout', {
57 controller : function(){
58 window.location.replace('/logout');
59 },
60 template : "<div></div>"
61 })
62 .state('doc', {
63 url: '/doc/:id',
64 templateUrl: 'views/doc.html',
65 controller: 'EntityCtrl',
66 controllerAs: 'entityCtrl',
67 })
68 .state({
69 name: '404',
70 url: '*path',
71 templateUrl: 'views/error.html'
72 })
73 $locationProvider.html5Mode(true);
74 })
75
76 .filter('encodeURI', function() {
77 return encodeURIComponent;
78 });
79 })();