GUI -- Bug fixing and refactoring app view - WIP.
Change-Id: I23012972ac762a62391289a2200bf0b95e4ed9c3
Showing
3 changed files
with
50 additions
and
23 deletions
... | @@ -7,10 +7,22 @@ | ... | @@ -7,10 +7,22 @@ |
7 | icon icon-size="36" icon-id="refresh" | 7 | icon icon-size="36" icon-id="refresh" |
8 | ng-click="toggleRefresh()"></div> | 8 | ng-click="toggleRefresh()"></div> |
9 | <div class="separator"></div> | 9 | <div class="separator"></div> |
10 | - <div id="app-install" icon icon-size="36" icon-id="plus" class="active"></div> | 10 | + <div id="app-install" |
11 | - <div id="app-activate" icon icon-size="36" icon-id="play"></div> | 11 | + icon icon-size="36" icon-id="plus" |
12 | - <div id="app-deactivate" icon icon-size="36" icon-id="stop"></div> | 12 | + class="active"> |
13 | - <div id="app-uninstall" icon icon-size="36" icon-id="garbage"></div> | 13 | + </div> |
14 | + <div id="app-activate" | ||
15 | + icon icon-size="36" icon-id="play" | ||
16 | + ng-class="{active: ctrlBtnState.installed}"> | ||
17 | + </div> | ||
18 | + <div id="app-deactivate" | ||
19 | + icon icon-size="36" icon-id="stop" | ||
20 | + ng-class="{active: ctrlBtnState.active}"> | ||
21 | + </div> | ||
22 | + <div id="app-uninstall" | ||
23 | + icon icon-size="36" icon-id="garbage" | ||
24 | + ng-class="{active: ctrlBtnState.selection}"> | ||
25 | + </div> | ||
14 | </div> | 26 | </div> |
15 | 27 | ||
16 | <form id="app-form" method="POST" action="rs/applications/upload" | 28 | <form id="app-form" method="POST" action="rs/applications/upload" | ... | ... |
... | @@ -21,23 +21,39 @@ | ... | @@ -21,23 +21,39 @@ |
21 | (function () { | 21 | (function () { |
22 | 'use strict'; | 22 | 'use strict'; |
23 | 23 | ||
24 | - var selRow, selection; | 24 | + var selectionObj; |
25 | 25 | ||
26 | angular.module('ovApp', []) | 26 | angular.module('ovApp', []) |
27 | .controller('OvAppCtrl', | 27 | .controller('OvAppCtrl', |
28 | - ['$log', '$scope', 'TableBuilderService', 'WebSocketService', | 28 | + ['$log', '$scope', 'FnService', 'TableBuilderService', 'WebSocketService', |
29 | + | ||
30 | + function ($log, $scope, fs, tbs, wss) { | ||
31 | + $scope.ctrlBtnState = {}; | ||
32 | + // TODO: clean up view | ||
33 | + // all DOM manipulation (adding styles, getting elements and doing stuff | ||
34 | + // with them) should be done in directives | ||
29 | 35 | ||
30 | - function ($log, $scope, tbs, wss) { | ||
31 | function selCb($event, row) { | 36 | function selCb($event, row) { |
32 | - selRow = angular.element($event.currentTarget); | 37 | + $scope.ctrlBtnState.selection = !!$scope.selId; |
33 | - selection = row; | 38 | + selectionObj = row; |
34 | $log.debug('Got a click on:', row); | 39 | $log.debug('Got a click on:', row); |
35 | - // adjust which toolbar buttons are selected | 40 | + |
36 | - d3.select('#app-activate').classed('active', row && row.state === 'INSTALLED'); | 41 | + if ($scope.ctrlBtnState.selection) { |
37 | - d3.select('#app-deactivate').classed('active', row && row.state === 'ACTIVE'); | 42 | + $scope.ctrlBtnState.installed = row.state === 'INSTALLED'; |
38 | - d3.select('#app-uninstall').classed('active', row); | 43 | + $scope.ctrlBtnState.active = row.state === 'ACTIVE'; |
44 | + } else { | ||
45 | + $scope.ctrlBtnState.installed = false; | ||
46 | + $scope.ctrlBtnState.active = false; | ||
47 | + } | ||
39 | } | 48 | } |
40 | 49 | ||
50 | + tbs.buildTable({ | ||
51 | + scope: $scope, | ||
52 | + tag: 'app', | ||
53 | + selCb: selCb | ||
54 | + }); | ||
55 | + | ||
56 | + // TODO: use d3 click events -- move to directive | ||
41 | d3.select('#app-install').on('click', function () { | 57 | d3.select('#app-install').on('click', function () { |
42 | $log.debug('Initiating install'); | 58 | $log.debug('Initiating install'); |
43 | var evt = document.createEvent("HTMLEvents"); | 59 | var evt = document.createEvent("HTMLEvents"); |
... | @@ -45,18 +61,21 @@ | ... | @@ -45,18 +61,21 @@ |
45 | document.getElementById('file').dispatchEvent(evt); | 61 | document.getElementById('file').dispatchEvent(evt); |
46 | }); | 62 | }); |
47 | 63 | ||
64 | + // TODO: use d3 to select elements -- move to directive | ||
48 | document.getElementById('app-form-response').onload = function () { | 65 | document.getElementById('app-form-response').onload = function () { |
49 | document.getElementById('app-form').reset(); | 66 | document.getElementById('app-form').reset(); |
50 | - $scope.refresh(); | 67 | + $scope.$apply(); |
68 | + //$scope.sortCallback($scope.sortParams); | ||
51 | }; | 69 | }; |
52 | 70 | ||
53 | function appAction(action) { | 71 | function appAction(action) { |
54 | - if (selection) { | 72 | + if ($scope.ctrlBtnState.selection) { |
55 | - $log.debug('Initiating uninstall of', selection); | 73 | + $log.debug('Initiating ' + action + ' of', selectionObj); |
56 | - wss.sendEvent('appManagementRequest', {action: action, name: selection.id}); | 74 | + wss.sendEvent('appManagementRequest', {action: action, name: selectionObj.id}); |
57 | } | 75 | } |
58 | } | 76 | } |
59 | 77 | ||
78 | + // TODO: use d3 to select elements -- move to directive | ||
60 | d3.select('#file').on('change', function () { | 79 | d3.select('#file').on('change', function () { |
61 | var file = document.getElementById('file').value.replace('C:\\fakepath\\', ''); | 80 | var file = document.getElementById('file').value.replace('C:\\fakepath\\', ''); |
62 | $log.info('Handling file', file); | 81 | $log.info('Handling file', file); |
... | @@ -65,16 +84,11 @@ | ... | @@ -65,16 +84,11 @@ |
65 | document.getElementById('app-upload').dispatchEvent(evt); | 84 | document.getElementById('app-upload').dispatchEvent(evt); |
66 | }); | 85 | }); |
67 | 86 | ||
87 | + // TODO: move to directive | ||
68 | d3.select('#app-uninstall').on('click', function () { appAction('uninstall'); }); | 88 | d3.select('#app-uninstall').on('click', function () { appAction('uninstall'); }); |
69 | d3.select('#app-activate').on('click', function () { appAction('activate'); }); | 89 | d3.select('#app-activate').on('click', function () { appAction('activate'); }); |
70 | d3.select('#app-deactivate').on('click', function () { appAction('deactivate'); }); | 90 | d3.select('#app-deactivate').on('click', function () { appAction('deactivate'); }); |
71 | 91 | ||
72 | - tbs.buildTable({ | ||
73 | - scope: $scope, | ||
74 | - tag: 'app', | ||
75 | - selCb: selCb | ||
76 | - }); | ||
77 | - | ||
78 | $log.log('OvAppCtrl has been created'); | 92 | $log.log('OvAppCtrl has been created'); |
79 | }]); | 93 | }]); |
80 | }()); | 94 | }()); | ... | ... |
... | @@ -47,6 +47,7 @@ | ... | @@ -47,6 +47,7 @@ |
47 | 47 | ||
48 | function coordFromLngLat(loc) { | 48 | function coordFromLngLat(loc) { |
49 | var p = api.projection(); | 49 | var p = api.projection(); |
50 | + // suspected cause of ONOS-2109 | ||
50 | return p ? p([loc.lng, loc.lat]) : [0, 0]; | 51 | return p ? p([loc.lng, loc.lat]) : [0, 0]; |
51 | } | 52 | } |
52 | 53 | ... | ... |
-
Please register or login to post a comment