Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 1 | /* |
| 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 Scandolo | 9fb53f7 | 2016-01-26 11:34:15 -0800 | [diff] [blame] | 18 | 'use strict'; |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 19 | |
Matteo Scandolo | 9fb53f7 | 2016-01-26 11:34:15 -0800 | [diff] [blame] | 20 | var modules = [ |
| 21 | 'ngRoute', |
| 22 | 'ngResource', |
| 23 | 'ngAnimate', |
Matteo Scandolo | 94992fd | 2016-01-27 13:51:07 -0800 | [diff] [blame] | 24 | 'ngCookies', |
Matteo Scandolo | 61bea66 | 2016-01-26 17:21:39 -0800 | [diff] [blame] | 25 | 'cordRest', |
Matteo Scandolo | 9fb53f7 | 2016-01-26 11:34:15 -0800 | [diff] [blame] | 26 | 'cordMast', |
| 27 | 'cordFoot', |
Matteo Scandolo | 9fb53f7 | 2016-01-26 11:34:15 -0800 | [diff] [blame] | 28 | 'cordLogin', |
| 29 | 'cordHome', |
| 30 | 'cordUser', |
| 31 | 'cordBundle' |
Matteo Scandolo | c603650 | 2016-01-26 15:17:10 -0800 | [diff] [blame] | 32 | ]; |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 33 | |
Matteo Scandolo | c603650 | 2016-01-26 15:17:10 -0800 | [diff] [blame] | 34 | angular.module('cordGui', modules) |
Matteo Scandolo | 35b7b21 | 2016-01-28 09:41:49 -0800 | [diff] [blame] | 35 | .config(function ($routeProvider, $httpProvider) { |
| 36 | |
| 37 | $httpProvider.interceptors.push('SetCSRFToken'); |
| 38 | |
Matteo Scandolo | 9fb53f7 | 2016-01-26 11:34:15 -0800 | [diff] [blame] | 39 | $routeProvider |
| 40 | .when('/login', { |
| 41 | controller: 'CordLoginCtrl', |
| 42 | controllerAs: 'ctrl', |
| 43 | templateUrl: 'app/view/login/login.html' |
| 44 | }) |
| 45 | .when('/home', { |
| 46 | controller: 'CordHomeCtrl', |
| 47 | controllerAs: 'ctrl', |
| 48 | templateUrl: 'app/view/home/home.html' |
| 49 | }) |
| 50 | .when('/user', { |
| 51 | controller: 'CordUserCtrl', |
| 52 | controllerAs: 'ctrl', |
| 53 | templateUrl: 'app/view/user/user.html' |
| 54 | }) |
| 55 | .when('/bundle', { |
| 56 | controller: 'CordBundleCtrl', |
| 57 | controllerAs: 'ctrl', |
| 58 | templateUrl: 'app/view/bundle/bundle.html' |
| 59 | }) |
| 60 | .otherwise({ |
| 61 | redirectTo: '/login' |
| 62 | }); |
Matteo Scandolo | 35b7b21 | 2016-01-28 09:41:49 -0800 | [diff] [blame] | 63 | }) |
Matteo Scandolo | e062850 | 2016-01-27 14:42:42 -0800 | [diff] [blame] | 64 | .controller('CordCtrl', function ($scope, $location, cordConfig) { |
| 65 | $scope.shared = { |
| 66 | url: 'http://' + $location.host() + ':' + $location.port() |
| 67 | }; |
| 68 | $scope.shared.userActivity = cordConfig.userActivity; |
| 69 | $scope.page = {}; |
| 70 | }) |
Matteo Scandolo | 61bea66 | 2016-01-26 17:21:39 -0800 | [diff] [blame] | 71 | .constant('cordConfig', { |
| 72 | url: '', |
| 73 | userActivity: {}, //check if really needed |
Matteo Scandolo | 90621b3 | 2016-01-27 16:40:21 -0800 | [diff] [blame] | 74 | activeBundle: 1, |
Matteo Scandolo | 61bea66 | 2016-01-26 17:21:39 -0800 | [diff] [blame] | 75 | bundles: [ |
| 76 | { |
| 77 | "id": "family", |
| 78 | "name": "Family Bundle", |
| 79 | "desc": "Description for family bundle", |
| 80 | "functions": [ |
| 81 | { |
| 82 | "id": "internet", |
| 83 | "name": "Internet", |
| 84 | "desc": "Basic internet connectivity.", |
| 85 | "params": {} |
| 86 | }, |
| 87 | { |
| 88 | "id": "firewall", |
| 89 | "name": "Firewall", |
| 90 | "desc": "Normal firewall protection.", |
| 91 | "params": {} |
| 92 | }, |
| 93 | { |
| 94 | "id": "url_filter", |
| 95 | "name": "Parental Control", |
| 96 | "desc": "Variable levels of URL filtering.", |
| 97 | "params": { |
| 98 | "level": "PG", |
Matteo Scandolo | 39c65a5 | 2016-01-27 12:00:18 -0800 | [diff] [blame] | 99 | "levels": [ "PG", "PG_13", "R" ] |
Matteo Scandolo | 61bea66 | 2016-01-26 17:21:39 -0800 | [diff] [blame] | 100 | } |
| 101 | } |
| 102 | ] |
| 103 | }, |
| 104 | { |
| 105 | "id": "basic", |
| 106 | "name": "Basic Bundle", |
| 107 | "desc": "Description for basic bundle", |
| 108 | "functions": [ |
| 109 | { |
| 110 | "id": "internet", |
| 111 | "name": "Internet", |
| 112 | "desc": "Basic internet connectivity.", |
| 113 | "params": {} |
| 114 | }, |
| 115 | { |
| 116 | "id": "firewall", |
| 117 | "name": "Firewall", |
| 118 | "desc": "Normal firewall protection.", |
| 119 | "params": {} |
| 120 | } |
| 121 | ] |
| 122 | } |
| 123 | ] |
| 124 | }) |
Matteo Scandolo | 94992fd | 2016-01-27 13:51:07 -0800 | [diff] [blame] | 125 | .run(function($rootScope, $location, cordConfig, User){ |
Matteo Scandolo | 61bea66 | 2016-01-26 17:21:39 -0800 | [diff] [blame] | 126 | cordConfig.url = 'http://' + $location.host() + ':' + $location.port(); |
Matteo Scandolo | 94992fd | 2016-01-27 13:51:07 -0800 | [diff] [blame] | 127 | |
| 128 | // basic authentication |
| 129 | $rootScope.$on('$routeChangeStart', function(next, current) { |
| 130 | if(!User.isLoggedIn()){ |
| 131 | $location.path('/login'); |
| 132 | } |
| 133 | }); |
Matteo Scandolo | 61bea66 | 2016-01-26 17:21:39 -0800 | [diff] [blame] | 134 | }); |
Matteo Scandolo | 4eb4ccb | 2016-01-26 11:02:16 -0800 | [diff] [blame] | 135 | }()); |