Bri Prebilic Cole

GUI -- Created initial device view

Change-Id: Ie9b2a4e743d7a8070c3dfe736ad5a953547bd2f9
...@@ -5,4 +5,5 @@ ...@@ -5,4 +5,5 @@
5 <ul> 5 <ul>
6 <li> <a ng-click="navCtrl.hideNav()" href="#/sample">Sample View</a></li> 6 <li> <a ng-click="navCtrl.hideNav()" href="#/sample">Sample View</a></li>
7 <li> <a ng-click="navCtrl.hideNav()" href="#/topo">Topology View</a></li> 7 <li> <a ng-click="navCtrl.hideNav()" href="#/topo">Topology View</a></li>
8 + <li> <a ng-click="navCtrl.hideNav()" href="#/device">Device View</a></li>
8 </ul> 9 </ul>
......
...@@ -57,12 +57,14 @@ ...@@ -57,12 +57,14 @@
57 <!-- {INJECTED-JAVASCRIPT} --> 57 <!-- {INJECTED-JAVASCRIPT} -->
58 <script src="view/sample/sample.js"></script> 58 <script src="view/sample/sample.js"></script>
59 <script src="view/topo/topo.js"></script> 59 <script src="view/topo/topo.js"></script>
60 + <script src="view/device/device.js"></script>
60 <!-- TODO: inject javascript refs server-side --> 61 <!-- TODO: inject javascript refs server-side -->
61 62
62 <!-- This is where contributed stylesheets will get injected --> 63 <!-- This is where contributed stylesheets will get injected -->
63 <!-- {INJECTED-STYLESHEETS} --> 64 <!-- {INJECTED-STYLESHEETS} -->
64 <link rel="stylesheet" href="view/sample/sample.css"> 65 <link rel="stylesheet" href="view/sample/sample.css">
65 <link rel="stylesheet" href="view/topo/topo.css"> 66 <link rel="stylesheet" href="view/topo/topo.css">
67 + <link rel="stylesheet" href="view/device/device.css">
66 <!-- TODO: inject style-sheet refs server-side --> 68 <!-- TODO: inject style-sheet refs server-side -->
67 </head> 69 </head>
68 <body class="light" ng-app="onosApp"> 70 <body class="light" ng-app="onosApp">
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
30 // NOTE: 'ov' == 'Onos View'... 30 // NOTE: 'ov' == 'Onos View'...
31 'ovSample', 31 'ovSample',
32 'ovTopo', 32 'ovTopo',
33 + 'ovDevice',
33 // (end of view modules) 34 // (end of view modules)
34 35
35 // core modules... 36 // core modules...
...@@ -81,6 +82,11 @@ ...@@ -81,6 +82,11 @@
81 controllerAs: 'ctrl', 82 controllerAs: 'ctrl',
82 templateUrl: 'view/topo/topo.html' 83 templateUrl: 'view/topo/topo.html'
83 }) 84 })
85 + .when('/device', {
86 + controller: 'OvDeviceCtrl',
87 + controllerAs: 'ctrl',
88 + templateUrl: 'view/device/device.html'
89 + })
84 .otherwise({ 90 .otherwise({
85 redirectTo: '/' 91 redirectTo: '/'
86 }) 92 })
......
1 +/*
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 +/*
18 + ONOS GUI -- Sample View -- CSS file
19 +
20 + @author Simon Hunt
21 + */
22 +
23 +#ov-device table {
24 + border: 1px;
25 + /*color: darkorange;*/
26 +}
...\ No newline at end of file ...\ No newline at end of file
1 +<!-- Device partial HTML -->
2 +<div id="ov-device">
3 + <h2>Device View</h2>
4 +
5 + <table>
6 + <tr ng-repeat="dev in ctrl.deviceData">
7 + <!-- add more property fields for table from device data -->
8 + <td>{{dev.id}}</td>
9 + <td>{{dev.mfr}}</td>
10 + <td>{{dev.hw}}</td>
11 + <td>{{dev.sw}}</td>
12 + </tr>
13 + </table>
14 +
15 +</div>
1 +/*
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 +/*
18 + ONOS GUI -- Sample View Module
19 +
20 + @author Simon Hunt
21 + @author Bri Prebilic Cole
22 + */
23 +
24 +(function () {
25 + 'use strict';
26 +
27 + var urlSuffix = '/onos/v1/devices';
28 +
29 + // TODO : refactor into remote service
30 + function buildUrl($loc) {
31 + return $loc.protocol() + '://' + $loc.host() + ':' + $loc.port();
32 + }
33 +
34 + angular.module('ovDevice', [])
35 + .controller('OvDeviceCtrl', ['$log', '$http', '$location',
36 + function ($log, $http, $loc) {
37 + var self = this;
38 + self.deviceData = [];
39 + var url = buildUrl($loc) + urlSuffix;
40 + $log.log(url);
41 +
42 + $http.get(url).then(
43 + //success
44 + function (response) {
45 + self.deviceData = response.data.devices;
46 + },
47 + //failure
48 + function (response) {
49 + $log.warn('Failed to get device data ', response.status);
50 + }
51 + );
52 +
53 + $log.log('OvDeviceCtrl has been created');
54 + }]);
55 +}());
1 +/*
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 +/*
18 + ONOS GUI -- Device Controller - Unit Tests
19 +
20 + @author Simon Hunt
21 + */
22 +describe('Controller: OvDeviceCtrl', function () {
23 + // instantiate the Device module
24 + beforeEach(module('ovDevice'));
25 +
26 + var $log, $controller, ctrl, $mockHttp;
27 +
28 + var fakeData = {
29 + "devices": [
30 + {
31 + "id": "of:0000000000000001",
32 + "available": true,
33 + "role": "MASTER",
34 + "mfr": "Nicira, Inc.",
35 + "hw": "Open vSwitch",
36 + "sw": "2.0.1",
37 + "serial": "None",
38 + "annotations": {
39 + "protocol": "OF_10"
40 + }
41 + },
42 + {
43 + "id": "of:0000000000000004",
44 + "available": true,
45 + "role": "MASTER",
46 + "mfr": "Nicira, Inc.",
47 + "hw": "Open vSwitch",
48 + "sw": "2.0.1",
49 + "serial": "None",
50 + "annotations": {
51 + "protocol": "OF_10"
52 + }
53 + }]
54 + };
55 +
56 + // we need an instance of the controller
57 + beforeEach(inject(function(_$log_, _$controller_, $httpBackend) {
58 + $log = _$log_;
59 + $controller = _$controller_;
60 + $mockHttp = $httpBackend;
61 +
62 + $mockHttp.whenGET(/devices/).respond(fakeData);
63 +
64 + }));
65 +
66 + //afterEach($mockHttp.resetExpectations);
67 +
68 + it('should be an empty array', function () {
69 + ctrl = $controller('OvDeviceCtrl');
70 + expect(ctrl.deviceData).toEqual([]);
71 + });
72 +
73 + it('should have data in it', function () {
74 + ctrl = $controller('OvDeviceCtrl');
75 + $mockHttp.flush();
76 + expect(ctrl.deviceData).toEqual(fakeData.devices);
77 + })
78 +});
1 +{
2 + "devices": [
3 + {
4 + "id": "of:0000000000000001",
5 + "available": true,
6 + "role": "MASTER",
7 + "mfr": "Nicira, Inc.",
8 + "hw": "Open vSwitch",
9 + "sw": "2.0.1",
10 + "serial": "None",
11 + "annotations": {
12 + "protocol": "OF_10"
13 + }
14 + },
15 + {
16 + "id": "of:0000000000000004",
17 + "available": true,
18 + "role": "MASTER",
19 + "mfr": "Nicira, Inc.",
20 + "hw": "Open vSwitch",
21 + "sw": "2.0.1",
22 + "serial": "None",
23 + "annotations": {
24 + "protocol": "OF_10"
25 + }
26 + },
27 + {
28 + "id": "of:0000000000000005",
29 + "available": true,
30 + "role": "MASTER",
31 + "mfr": "Nicira, Inc.",
32 + "hw": "Open vSwitch",
33 + "sw": "2.0.1",
34 + "serial": "None",
35 + "annotations": {
36 + "protocol": "OF_10"
37 + }
38 + },
39 + {
40 + "id": "of:0000000000000002",
41 + "available": true,
42 + "role": "MASTER",
43 + "mfr": "Nicira, Inc.",
44 + "hw": "Open vSwitch",
45 + "sw": "2.0.1",
46 + "serial": "None",
47 + "annotations": {
48 + "protocol": "OF_10"
49 + }
50 + },
51 + {
52 + "id": "of:0000000000000003",
53 + "available": true,
54 + "role": "MASTER",
55 + "mfr": "Nicira, Inc.",
56 + "hw": "Open vSwitch",
57 + "sw": "2.0.1",
58 + "serial": "None",
59 + "annotations": {
60 + "protocol": "OF_10"
61 + }
62 + },
63 + {
64 + "id": "of:0000000000000006",
65 + "available": true,
66 + "role": "MASTER",
67 + "mfr": "Nicira, Inc.",
68 + "hw": "Open vSwitch",
69 + "sw": "2.0.1",
70 + "serial": "None",
71 + "annotations": {
72 + "protocol": "OF_10"
73 + }
74 + },
75 + {
76 + "id": "of:0000000000000007",
77 + "available": true,
78 + "role": "MASTER",
79 + "mfr": "Nicira, Inc.",
80 + "hw": "Open vSwitch",
81 + "sw": "2.0.1",
82 + "serial": "None",
83 + "annotations": {
84 + "protocol": "OF_10"
85 + }
86 + }
87 + ]
88 +}
...\ No newline at end of file ...\ No newline at end of file