blob: 0b843f47bade02c21d491579b8983614e93630a0 [file] [log] [blame]
Bri Prebilic Colee0311892015-05-15 11:27:15 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Bri Prebilic Colee0311892015-05-15 11:27:15 -07003 *
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 'use strict';
19
20 var modules = [
Bri Prebilic Cole8db16402015-05-18 13:50:31 -070021 'ngRoute',
Bri Prebilic Cole3c3361c2015-05-19 12:07:29 -070022 'ngResource',
Bri Prebilic Colef3eba312015-05-21 16:35:06 -070023 'ngAnimate',
Bri Prebilic Cole8db16402015-05-18 13:50:31 -070024 'cordMast',
Bri Prebilic Cole3c3361c2015-05-19 12:07:29 -070025 'cordFoot',
26 'cordNav'
Bri Prebilic Colee0311892015-05-15 11:27:15 -070027 ],
28 viewIds = [
29 'login',
30 'home',
31 'user',
Bri Prebilic Cole8db16402015-05-18 13:50:31 -070032 'bundle'
Bri Prebilic Colee0311892015-05-15 11:27:15 -070033 ],
34 viewDependencies = [],
35 dependencies;
36
37 function capitalize(word) {
38 return word ? word[0].toUpperCase() + word.slice(1) : word;
39 }
40
41 viewIds.forEach(function (id) {
42 if (id) {
43 viewDependencies.push('cord' + capitalize(id));
44 }
45 });
46
47 dependencies = modules.concat(viewDependencies);
48
49 angular.module('cordGui', dependencies)
50 .config(['$routeProvider', function ($routeProvider) {
51 $routeProvider
52 .otherwise({
53 redirectTo: '/login'
54 });
55
56 function viewCtrlName(vid) {
57 return 'Cord' + capitalize(vid) + 'Ctrl';
58 }
59
60 function viewTemplateUrl(vid) {
61 return 'app/view/' + vid + '/' + vid + '.html';
62 }
63
64 viewIds.forEach(function (vid) {
65 if (vid) {
66 $routeProvider.when('/' + vid, {
67 controller: viewCtrlName(vid),
68 controllerAs: 'ctrl',
69 templateUrl: viewTemplateUrl(vid)
70 });
71 }
72 });
73 }])
Bri Prebilic Coled189e282015-06-05 10:00:22 -070074 .controller('CordCtrl', ['$scope', '$location',
75 function ($scope, $location) {
Bri Prebilic Cole60553c82015-06-05 08:50:17 -070076 $scope.shared = {
Bri Prebilic Colef34c9892015-06-08 11:51:01 -070077 url: 'http://' + $location.host() + ':' + $location.port(),
78 userActivity: {}
Bri Prebilic Cole60553c82015-06-05 08:50:17 -070079 };
80 $scope.page = {};
81 }]);
Bri Prebilic Colee0311892015-05-15 11:27:15 -070082}());