Committed by
Simon Hunt
Adding first set of changes for bug onos-5071
Addressed review comments Addressed review comments for patch-2 Addressed review comments for patch-3 Fixed broken "show intent" on topo view. Change-Id: Ie76deca917d6cd6c98d121135e53b9093b5ed8ee
Showing
7 changed files
with
105 additions
and
22 deletions
| ... | @@ -88,6 +88,7 @@ import static org.onosproject.net.device.DeviceEvent.Type.PORT_STATS_UPDATED; | ... | @@ -88,6 +88,7 @@ import static org.onosproject.net.device.DeviceEvent.Type.PORT_STATS_UPDATED; |
| 88 | import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; | 88 | import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; |
| 89 | import static org.onosproject.net.link.LinkEvent.Type.LINK_ADDED; | 89 | import static org.onosproject.net.link.LinkEvent.Type.LINK_ADDED; |
| 90 | import static org.onosproject.ui.JsonUtils.envelope; | 90 | import static org.onosproject.ui.JsonUtils.envelope; |
| 91 | +import static org.onosproject.ui.JsonUtils.string; | ||
| 91 | import static org.onosproject.ui.topo.TopoJson.highlightsMessage; | 92 | import static org.onosproject.ui.topo.TopoJson.highlightsMessage; |
| 92 | import static org.onosproject.ui.topo.TopoJson.json; | 93 | import static org.onosproject.ui.topo.TopoJson.json; |
| 93 | 94 | ||
| ... | @@ -100,6 +101,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -100,6 +101,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
| 100 | private static final String REQ_DETAILS = "requestDetails"; | 101 | private static final String REQ_DETAILS = "requestDetails"; |
| 101 | private static final String UPDATE_META = "updateMeta"; | 102 | private static final String UPDATE_META = "updateMeta"; |
| 102 | private static final String ADD_HOST_INTENT = "addHostIntent"; | 103 | private static final String ADD_HOST_INTENT = "addHostIntent"; |
| 104 | + private static final String REMOVE_INTENT = "removeIntent"; | ||
| 103 | private static final String ADD_MULTI_SRC_INTENT = "addMultiSourceIntent"; | 105 | private static final String ADD_MULTI_SRC_INTENT = "addMultiSourceIntent"; |
| 104 | private static final String REQ_RELATED_INTENTS = "requestRelatedIntents"; | 106 | private static final String REQ_RELATED_INTENTS = "requestRelatedIntents"; |
| 105 | private static final String REQ_NEXT_INTENT = "requestNextRelatedIntent"; | 107 | private static final String REQ_NEXT_INTENT = "requestNextRelatedIntent"; |
| ... | @@ -220,6 +222,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -220,6 +222,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
| 220 | // TODO: migrate traffic related to separate app | 222 | // TODO: migrate traffic related to separate app |
| 221 | new AddHostIntent(), | 223 | new AddHostIntent(), |
| 222 | new AddMultiSourceIntent(), | 224 | new AddMultiSourceIntent(), |
| 225 | + new RemoveIntent(), | ||
| 223 | 226 | ||
| 224 | new ReqAllFlowTraffic(), | 227 | new ReqAllFlowTraffic(), |
| 225 | new ReqAllPortTraffic(), | 228 | new ReqAllPortTraffic(), |
| ... | @@ -426,6 +429,37 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -426,6 +429,37 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
| 426 | } | 429 | } |
| 427 | } | 430 | } |
| 428 | 431 | ||
| 432 | + private Intent findIntentByPayload(ObjectNode payload) { | ||
| 433 | + int appId = Integer.parseInt(string(payload, APP_ID)); | ||
| 434 | + String appName = string(payload, APP_NAME); | ||
| 435 | + ApplicationId applicId = new DefaultApplicationId(appId, appName); | ||
| 436 | + long intentKey = Long.decode(string(payload, KEY)); | ||
| 437 | + | ||
| 438 | + Key key = Key.of(intentKey, applicId); | ||
| 439 | + log.debug("Attempting to select intent by key={}", key); | ||
| 440 | + | ||
| 441 | + Intent intent = intentService.getIntent(key); | ||
| 442 | + | ||
| 443 | + return intent; | ||
| 444 | + } | ||
| 445 | + | ||
| 446 | + private final class RemoveIntent extends RequestHandler { | ||
| 447 | + private RemoveIntent() { | ||
| 448 | + super(REMOVE_INTENT); | ||
| 449 | + } | ||
| 450 | + | ||
| 451 | + @Override | ||
| 452 | + public void process(long sid, ObjectNode payload) { | ||
| 453 | + Intent intent = findIntentByPayload(payload); | ||
| 454 | + if (intent == null) { | ||
| 455 | + log.warn("Unable to find intent from payload {}", payload); | ||
| 456 | + } else { | ||
| 457 | + log.debug("Removing intent {}", intent.key()); | ||
| 458 | + intentService.withdraw(intent); | ||
| 459 | + } | ||
| 460 | + } | ||
| 461 | + } | ||
| 462 | + | ||
| 429 | private final class AddMultiSourceIntent extends RequestHandler { | 463 | private final class AddMultiSourceIntent extends RequestHandler { |
| 430 | private AddMultiSourceIntent() { | 464 | private AddMultiSourceIntent() { |
| 431 | super(ADD_MULTI_SRC_INTENT); | 465 | super(ADD_MULTI_SRC_INTENT); |
| ... | @@ -551,19 +585,11 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -551,19 +585,11 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
| 551 | 585 | ||
| 552 | @Override | 586 | @Override |
| 553 | public void process(long sid, ObjectNode payload) { | 587 | public void process(long sid, ObjectNode payload) { |
| 554 | - int appId = Integer.parseInt(string(payload, APP_ID)); | 588 | + Intent intent = findIntentByPayload(payload); |
| 555 | - String appName = string(payload, APP_NAME); | ||
| 556 | - ApplicationId applicId = new DefaultApplicationId(appId, appName); | ||
| 557 | - long intentKey = Long.decode(string(payload, KEY)); | ||
| 558 | - | ||
| 559 | - Key key = Key.of(intentKey, applicId); | ||
| 560 | - log.debug("Attempting to select intent key={}", key); | ||
| 561 | - | ||
| 562 | - Intent intent = intentService.getIntent(key); | ||
| 563 | if (intent == null) { | 589 | if (intent == null) { |
| 564 | - log.debug("no such intent found!"); | 590 | + log.warn("Unable to find intent from payload {}", payload); |
| 565 | } else { | 591 | } else { |
| 566 | - log.debug("starting to monitor intent {}", key); | 592 | + log.debug("starting to monitor intent {}", intent.key()); |
| 567 | traffic.monitor(intent); | 593 | traffic.monitor(intent); |
| 568 | } | 594 | } |
| 569 | } | 595 | } | ... | ... |
| ... | @@ -14,6 +14,13 @@ | ... | @@ -14,6 +14,13 @@ |
| 14 | icon icon-id="topo" icon-size="42" | 14 | icon icon-id="topo" icon-size="42" |
| 15 | tooltip tt-msg="topoTip" | 15 | tooltip tt-msg="topoTip" |
| 16 | ng-click="showIntent()"></div> | 16 | ng-click="showIntent()"></div> |
| 17 | + | ||
| 18 | + <div ng-class="{'active': !!selId}" | ||
| 19 | + icon icon-id="stop" icon-size="42" | ||
| 20 | + tooltip tt-msg="deactivateTip" | ||
| 21 | + ng-click="deactivateIntent()"></div> | ||
| 22 | + | ||
| 23 | + | ||
| 17 | </div> | 24 | </div> |
| 18 | </div> | 25 | </div> |
| 19 | 26 | ... | ... |
| ... | @@ -21,11 +21,17 @@ | ... | @@ -21,11 +21,17 @@ |
| 21 | (function () { | 21 | (function () { |
| 22 | 'use strict'; | 22 | 'use strict'; |
| 23 | 23 | ||
| 24 | + var dialogId = 'remove-intent-dialog', | ||
| 25 | + dialogOpts = { | ||
| 26 | + edge: 'right' | ||
| 27 | + }; | ||
| 28 | + | ||
| 24 | angular.module('ovIntent', []) | 29 | angular.module('ovIntent', []) |
| 25 | .controller('OvIntentCtrl', | 30 | .controller('OvIntentCtrl', |
| 26 | ['$log', '$scope', 'TableBuilderService', 'NavService', | 31 | ['$log', '$scope', 'TableBuilderService', 'NavService', |
| 32 | + 'TopoTrafficService', 'DialogService', | ||
| 27 | 33 | ||
| 28 | - function ($log, $scope, tbs, ns) { | 34 | + function ($log, $scope, tbs, ns, tts, ds) { |
| 29 | 35 | ||
| 30 | function selCb($event, row) { | 36 | function selCb($event, row) { |
| 31 | $log.debug('Got a click on:', row); | 37 | $log.debug('Got a click on:', row); |
| ... | @@ -34,9 +40,9 @@ | ... | @@ -34,9 +40,9 @@ |
| 34 | name = m ? m[2] : null; | 40 | name = m ? m[2] : null; |
| 35 | 41 | ||
| 36 | $scope.intentData = ($scope.selId && m) ? { | 42 | $scope.intentData = ($scope.selId && m) ? { |
| 37 | - intentAppId: id, | 43 | + appId: id, |
| 38 | - intentAppName: name, | 44 | + appName: name, |
| 39 | - intentKey: row.key | 45 | + key: row.key |
| 40 | } : null; | 46 | } : null; |
| 41 | } | 47 | } |
| 42 | 48 | ||
| ... | @@ -48,12 +54,42 @@ | ... | @@ -48,12 +54,42 @@ |
| 48 | }); | 54 | }); |
| 49 | 55 | ||
| 50 | $scope.topoTip = 'Show selected intent on topology view'; | 56 | $scope.topoTip = 'Show selected intent on topology view'; |
| 57 | + $scope.deactivateTip = 'Remove selected intent'; | ||
| 51 | 58 | ||
| 52 | $scope.showIntent = function () { | 59 | $scope.showIntent = function () { |
| 53 | var d = $scope.intentData; | 60 | var d = $scope.intentData; |
| 54 | d && ns.navTo('topo', d); | 61 | d && ns.navTo('topo', d); |
| 55 | }; | 62 | }; |
| 56 | 63 | ||
| 57 | - $log.log('OvIntentCtrl has been created'); | 64 | + $scope.deactivateIntent = function () { |
| 65 | + var content = ds.createDiv(); | ||
| 66 | + | ||
| 67 | + content.append('p') | ||
| 68 | + .text('Are you sure you want to remove the selected intent?'); | ||
| 69 | + | ||
| 70 | + function dOk() { | ||
| 71 | + var d = $scope.intentData; | ||
| 72 | + d && tts.removeIntent(d); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + function dCancel() { | ||
| 76 | + ds.closeDialog(); | ||
| 77 | + $log.debug('Canceling remove-intent action'); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + ds.openDialog(dialogId, dialogOpts) | ||
| 81 | + .setTitle('Confirm Action') | ||
| 82 | + .addContent(content) | ||
| 83 | + .addOk(dOk) | ||
| 84 | + .addCancel(dCancel) | ||
| 85 | + .bindKeys(); | ||
| 86 | + }; | ||
| 87 | + | ||
| 88 | + $scope.$on('$destroy', function () { | ||
| 89 | + ds.closeDialog(); | ||
| 90 | + $log.debug('OvIntentCtrl has been destroyed'); | ||
| 91 | + }); | ||
| 92 | + | ||
| 93 | + $log.debug('OvIntentCtrl has been created'); | ||
| 58 | }]); | 94 | }]); |
| 59 | }()); | 95 | }()); | ... | ... |
| ... | @@ -585,11 +585,11 @@ | ... | @@ -585,11 +585,11 @@ |
| 585 | setMap: setMap | 585 | setMap: setMap |
| 586 | }); | 586 | }); |
| 587 | 587 | ||
| 588 | - if (params.intentKey && params.intentAppId && params.intentAppName) { | 588 | + if (params.key && params.appId && params.appName) { |
| 589 | $scope.intentData = { | 589 | $scope.intentData = { |
| 590 | - key: params.intentKey, | 590 | + key: params.key, |
| 591 | - appId: params.intentAppId, | 591 | + appId: params.appId, |
| 592 | - appName: params.intentAppName | 592 | + appName: params.appName |
| 593 | }; | 593 | }; |
| 594 | } | 594 | } |
| 595 | 595 | ... | ... |
| ... | @@ -176,6 +176,18 @@ | ... | @@ -176,6 +176,18 @@ |
| 176 | flash.flash('Host-to-Host flow added'); | 176 | flash.flash('Host-to-Host flow added'); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | + function removeIntent (d) { | ||
| 180 | + $log.debug('Entering removeIntent'); | ||
| 181 | + wss.sendEvent('removeIntent', { | ||
| 182 | + appId: d.appId, | ||
| 183 | + appName: d.appName, | ||
| 184 | + key: d.key | ||
| 185 | + }); | ||
| 186 | + trafficMode = 'intents'; | ||
| 187 | + hoverMode = null; | ||
| 188 | + flash.flash('Intent removed'); | ||
| 189 | + } | ||
| 190 | + | ||
| 179 | function addMultiSourceIntent () { | 191 | function addMultiSourceIntent () { |
| 180 | var so = api.selectOrder(); | 192 | var so = api.selectOrder(); |
| 181 | wss.sendEvent('addMultiSourceIntent', { | 193 | wss.sendEvent('addMultiSourceIntent', { |
| ... | @@ -223,7 +235,8 @@ | ... | @@ -223,7 +235,8 @@ |
| 223 | // TODO: these should move to new UI demo app | 235 | // TODO: these should move to new UI demo app |
| 224 | // invoked from buttons on detail (multi-select) panel | 236 | // invoked from buttons on detail (multi-select) panel |
| 225 | addHostIntent: addHostIntent, | 237 | addHostIntent: addHostIntent, |
| 226 | - addMultiSourceIntent: addMultiSourceIntent | 238 | + addMultiSourceIntent: addMultiSourceIntent, |
| 239 | + removeIntent: removeIntent | ||
| 227 | }; | 240 | }; |
| 228 | }]); | 241 | }]); |
| 229 | }()); | 242 | }()); | ... | ... |
| ... | @@ -49,6 +49,7 @@ describe('factory: view/topo/topoTraffic.js', function() { | ... | @@ -49,6 +49,7 @@ describe('factory: view/topo/topoTraffic.js', function() { |
| 49 | 'requestTrafficForMode', | 49 | 'requestTrafficForMode', |
| 50 | 'addHostIntent', | 50 | 'addHostIntent', |
| 51 | 'addMultiSourceIntent', | 51 | 'addMultiSourceIntent', |
| 52 | + 'removeIntent', | ||
| 52 | ])).toBeTruthy(); | 53 | ])).toBeTruthy(); |
| 53 | }); | 54 | }); |
| 54 | 55 | ... | ... |
-
Please register or login to post a comment