Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 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 | 'use strict'; |
| 19 | |
| 20 | var modules = [ |
Bri Prebilic Cole | 8db1640 | 2015-05-18 13:50:31 -0700 | [diff] [blame] | 21 | 'ngRoute', |
Bri Prebilic Cole | 3c3361c | 2015-05-19 12:07:29 -0700 | [diff] [blame] | 22 | 'ngResource', |
Bri Prebilic Cole | f3eba31 | 2015-05-21 16:35:06 -0700 | [diff] [blame] | 23 | 'ngAnimate', |
Bri Prebilic Cole | 8db1640 | 2015-05-18 13:50:31 -0700 | [diff] [blame] | 24 | 'cordMast', |
Bri Prebilic Cole | 3c3361c | 2015-05-19 12:07:29 -0700 | [diff] [blame] | 25 | 'cordFoot', |
| 26 | 'cordNav' |
Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 27 | ], |
| 28 | viewIds = [ |
| 29 | 'login', |
| 30 | 'home', |
| 31 | 'user', |
Bri Prebilic Cole | 8db1640 | 2015-05-18 13:50:31 -0700 | [diff] [blame] | 32 | 'bundle' |
Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 33 | ], |
| 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 Cole | d189e28 | 2015-06-05 10:00:22 -0700 | [diff] [blame] | 74 | .controller('CordCtrl', ['$scope', '$location', |
| 75 | function ($scope, $location) { |
Bri Prebilic Cole | 60553c8 | 2015-06-05 08:50:17 -0700 | [diff] [blame] | 76 | $scope.shared = { |
Bri Prebilic Cole | f34c989 | 2015-06-08 11:51:01 -0700 | [diff] [blame] | 77 | url: 'http://' + $location.host() + ':' + $location.port(), |
| 78 | userActivity: {} |
Bri Prebilic Cole | 60553c8 | 2015-06-05 08:50:17 -0700 | [diff] [blame] | 79 | }; |
| 80 | $scope.page = {}; |
| 81 | }]); |
Bri Prebilic Cole | e031189 | 2015-05-15 11:27:15 -0700 | [diff] [blame] | 82 | }()); |