blob: 0f3649b9c2cbb8c153268540fc3bb0d2b027a735 [file] [log] [blame]
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -08001/*
2 * Copyright 2015 Open Networking Laboratory
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 () {
Matteo Scandolo9fb53f72016-01-26 11:34:15 -080018 'use strict';
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080019
Matteo Scandolo9fb53f72016-01-26 11:34:15 -080020 var modules = [
21 'ngRoute',
22 'ngResource',
23 'ngAnimate',
Matteo Scandolo94992fd2016-01-27 13:51:07 -080024 'ngCookies',
Matteo Scandolo61bea662016-01-26 17:21:39 -080025 'cordRest',
Matteo Scandolo9fb53f72016-01-26 11:34:15 -080026 'cordMast',
27 'cordFoot',
28 'cordNav',
29 'cordLogin',
30 'cordHome',
31 'cordUser',
32 'cordBundle'
Matteo Scandoloc6036502016-01-26 15:17:10 -080033 ];
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -080034
Matteo Scandoloc6036502016-01-26 15:17:10 -080035 angular.module('cordGui', modules)
Matteo Scandolo9fb53f72016-01-26 11:34:15 -080036 .config(['$routeProvider', function ($routeProvider) {
37 $routeProvider
38 .when('/login', {
39 controller: 'CordLoginCtrl',
40 controllerAs: 'ctrl',
41 templateUrl: 'app/view/login/login.html'
42 })
43 .when('/home', {
44 controller: 'CordHomeCtrl',
45 controllerAs: 'ctrl',
46 templateUrl: 'app/view/home/home.html'
47 })
48 .when('/user', {
49 controller: 'CordUserCtrl',
50 controllerAs: 'ctrl',
51 templateUrl: 'app/view/user/user.html'
52 })
53 .when('/bundle', {
54 controller: 'CordBundleCtrl',
55 controllerAs: 'ctrl',
56 templateUrl: 'app/view/bundle/bundle.html'
57 })
58 .otherwise({
59 redirectTo: '/login'
60 });
61 }])
Matteo Scandoloe0628502016-01-27 14:42:42 -080062 .controller('CordCtrl', function ($scope, $location, cordConfig) {
63 $scope.shared = {
64 url: 'http://' + $location.host() + ':' + $location.port()
65 };
66 $scope.shared.userActivity = cordConfig.userActivity;
67 $scope.page = {};
68 })
Matteo Scandolo61bea662016-01-26 17:21:39 -080069 .constant('cordConfig', {
70 url: '',
71 userActivity: {}, //check if really needed
Matteo Scandolo10fb87c2016-01-27 14:30:22 -080072 activeBundle: 0,
Matteo Scandolo61bea662016-01-26 17:21:39 -080073 bundles: [
74 {
75 "id": "family",
76 "name": "Family Bundle",
77 "desc": "Description for family bundle",
78 "functions": [
79 {
80 "id": "internet",
81 "name": "Internet",
82 "desc": "Basic internet connectivity.",
83 "params": {}
84 },
85 {
86 "id": "firewall",
87 "name": "Firewall",
88 "desc": "Normal firewall protection.",
89 "params": {}
90 },
91 {
92 "id": "url_filter",
93 "name": "Parental Control",
94 "desc": "Variable levels of URL filtering.",
95 "params": {
96 "level": "PG",
Matteo Scandolo39c65a52016-01-27 12:00:18 -080097 "levels": [ "PG", "PG_13", "R" ]
Matteo Scandolo61bea662016-01-26 17:21:39 -080098 }
99 }
100 ]
101 },
102 {
103 "id": "basic",
104 "name": "Basic Bundle",
105 "desc": "Description for basic bundle",
106 "functions": [
107 {
108 "id": "internet",
109 "name": "Internet",
110 "desc": "Basic internet connectivity.",
111 "params": {}
112 },
113 {
114 "id": "firewall",
115 "name": "Firewall",
116 "desc": "Normal firewall protection.",
117 "params": {}
118 }
119 ]
120 }
121 ]
122 })
Matteo Scandolo94992fd2016-01-27 13:51:07 -0800123 .run(function($rootScope, $location, cordConfig, User){
Matteo Scandolo61bea662016-01-26 17:21:39 -0800124 cordConfig.url = 'http://' + $location.host() + ':' + $location.port();
Matteo Scandolo94992fd2016-01-27 13:51:07 -0800125
126 // basic authentication
127 $rootScope.$on('$routeChangeStart', function(next, current) {
128 if(!User.isLoggedIn()){
129 $location.path('/login');
130 }
131 });
Matteo Scandolo61bea662016-01-26 17:21:39 -0800132 });
Matteo Scandolo4eb4ccb2016-01-26 11:02:16 -0800133}());