blob: ec73b08f34d5b7d61295bcd26f418244e2efd0cf [file] [log] [blame]
Bri Prebilic Colee0311892015-05-15 11:27:15 -07001/*
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 () {
18 'use strict';
19
20 var modules = [
21 'ngRoute'
22 ],
23 viewIds = [
24 'login',
25 'home',
26 'user',
27 'sub'
28 ],
29 viewDependencies = [],
30 dependencies;
31
32 function capitalize(word) {
33 return word ? word[0].toUpperCase() + word.slice(1) : word;
34 }
35
36 viewIds.forEach(function (id) {
37 if (id) {
38 viewDependencies.push('cord' + capitalize(id));
39 }
40 });
41
42 dependencies = modules.concat(viewDependencies);
43
44 angular.module('cordGui', dependencies)
45 .config(['$routeProvider', function ($routeProvider) {
46 $routeProvider
47 .otherwise({
48 redirectTo: '/login'
49 });
50
51 function viewCtrlName(vid) {
52 return 'Cord' + capitalize(vid) + 'Ctrl';
53 }
54
55 function viewTemplateUrl(vid) {
56 return 'app/view/' + vid + '/' + vid + '.html';
57 }
58
59 viewIds.forEach(function (vid) {
60 if (vid) {
61 $routeProvider.when('/' + vid, {
62 controller: viewCtrlName(vid),
63 controllerAs: 'ctrl',
64 templateUrl: viewTemplateUrl(vid)
65 });
66 }
67 });
68 }])
69 .controller('CordCtrl', [function () {
70
71 }]);
72}());