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