nitweb: move index state configuration to index module
[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
24 .run(['$anchorScroll', function($anchorScroll) {
25 $anchorScroll.yOffset = 80;
26 }])
27
28 .config(function($stateProvider, $locationProvider) {
29 $stateProvider
30 .state('user', {
31 url: '/user',
32 templateUrl: 'views/user.html',
33 controller: 'UserCtrl',
34 controllerAs: 'userCtrl'
35 })
36 .state('docdown', {
37 url: '/docdown',
38 templateUrl: 'views/docdown.html',
39 controller: 'DocdownCtrl',
40 controllerAs: 'docdownCtrl'
41 })
42 .state('grades', {
43 url: '/grades',
44 templateUrl: 'views/grades.html',
45 controller: 'GradesCtrl',
46 controllerAs: 'gradesCtrl'
47 })
48 .state('login', {
49 url: '/login',
50 controller : function(){
51 window.location.replace('/login');
52 },
53 template : "<div></div>"
54 })
55 .state('logout', {
56 controller : function(){
57 window.location.replace('/logout');
58 },
59 template : "<div></div>"
60 })
61 .state('doc', {
62 url: '/doc/:id',
63 templateUrl: 'views/doc.html',
64 controller: 'EntityCtrl',
65 controllerAs: 'entityCtrl',
66 })
67 .state({
68 name: '404',
69 url: '*path',
70 templateUrl: 'views/error.html'
71 })
72 $locationProvider.html5Mode(true);
73 })
74
75 .filter('encodeURI', function() {
76 return encodeURIComponent;
77 });
78 })();