Factor common code
[netvirt.git] / ovsdb-ui / module / src / main / resources / ovsdb / ovsdb.module.js
1 /*\r
2  * Copyright (c) 2015 Inocybe Technologies and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 define(['angularAMD', 'app/routingConfig', 'Restangular', 'angular-translate', 'angular-translate-loader-static-files', 'app/core/core.services', 'common/config/env.module'], function(ng) {\r
10   'use strict';\r
11 \r
12   var ovsdb = angular.module('app.ovsdb', ['app.core', 'pascalprecht.translate', 'ui.router.state', 'restangular', 'config']);\r
13   ovsdb.register = ovsdb; // for unit test\r
14 \r
15   ovsdb.config(function($stateProvider, $compileProvider, $controllerProvider, $provide, NavHelperProvider) {\r
16     ovsdb.register = {\r
17       controller : $controllerProvider.register,\r
18       directive : $compileProvider.directive,\r
19       factory : $provide.factory,\r
20       service : $provide.service\r
21 \r
22     };\r
23 \r
24     NavHelperProvider.addControllerUrl('src/app/ovsdb/ovsdb.controller.js');\r
25     NavHelperProvider.addToMenu('Ovsdb', {\r
26      "link" : "#/ovsdb/index",\r
27      "active" : "main.ovsdb.*",\r
28      "title" : "OVSDB",\r
29      "icon" : "icon-sitemap",\r
30      "page" : {\r
31         "title" : "OVSDB",\r
32         "description" : "OVSDB"\r
33      }\r
34     });\r
35 \r
36     var access = routingConfig.accessLevels;\r
37     $stateProvider.state('main.ovsdb', {\r
38       url: 'ovsdb',\r
39       abstract: true,\r
40       views : {\r
41         'content' : {\r
42           templateUrl: 'src/app/ovsdb/root.tpl.html',\r
43           controller: 'RootOvsdbCtrl'\r
44         }\r
45       }\r
46     });\r
47 \r
48     $stateProvider.state('main.ovsdb.index', {\r
49       url: '/index',\r
50       access: access.admin,\r
51       views: {\r
52         '': {\r
53           templateUrl: 'src/app/ovsdb/index.tpl.html',\r
54           controller: 'OvsdbCtrl'\r
55         }\r
56       }\r
57     });\r
58   });\r
59 \r
60   return ovsdb;\r
61 });\r