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