Committed by
Ray Milkey
[onos-5251] This changeset contains implementation of purging intents from ONOS UI
[onos-5251] Addressed review comments from patchset-1 addressed review comments from patchset-2 Change-Id: I93ebe7798b5324fb18738540d3ef6cef6ada395e
Showing
4 changed files
with
43 additions
and
11 deletions
| ... | @@ -150,6 +150,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -150,6 +150,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
| 150 | private static final String NAMES = "names"; | 150 | private static final String NAMES = "names"; |
| 151 | private static final String ACTIVATE = "activate"; | 151 | private static final String ACTIVATE = "activate"; |
| 152 | private static final String DEACTIVATE = "deactivate"; | 152 | private static final String DEACTIVATE = "deactivate"; |
| 153 | + private static final String PURGE = "purge"; | ||
| 153 | 154 | ||
| 154 | 155 | ||
| 155 | private static final String MY_APP_ID = "org.onosproject.gui"; | 156 | private static final String MY_APP_ID = "org.onosproject.gui"; |
| ... | @@ -438,9 +439,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -438,9 +439,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
| 438 | Key key = Key.of(intentKey, applicId); | 439 | Key key = Key.of(intentKey, applicId); |
| 439 | log.debug("Attempting to select intent by key={}", key); | 440 | log.debug("Attempting to select intent by key={}", key); |
| 440 | 441 | ||
| 441 | - Intent intent = intentService.getIntent(key); | 442 | + return intentService.getIntent(key); |
| 442 | - | ||
| 443 | - return intent; | ||
| 444 | } | 443 | } |
| 445 | 444 | ||
| 446 | private final class RemoveIntent extends RequestHandler { | 445 | private final class RemoveIntent extends RequestHandler { |
| ... | @@ -448,14 +447,22 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -448,14 +447,22 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
| 448 | super(REMOVE_INTENT); | 447 | super(REMOVE_INTENT); |
| 449 | } | 448 | } |
| 450 | 449 | ||
| 450 | + private boolean isIntentToBePurged(ObjectNode payload) { | ||
| 451 | + return bool(payload, PURGE); | ||
| 452 | + } | ||
| 453 | + | ||
| 451 | @Override | 454 | @Override |
| 452 | public void process(long sid, ObjectNode payload) { | 455 | public void process(long sid, ObjectNode payload) { |
| 453 | Intent intent = findIntentByPayload(payload); | 456 | Intent intent = findIntentByPayload(payload); |
| 454 | if (intent == null) { | 457 | if (intent == null) { |
| 455 | log.warn("Unable to find intent from payload {}", payload); | 458 | log.warn("Unable to find intent from payload {}", payload); |
| 456 | } else { | 459 | } else { |
| 457 | - log.debug("Removing intent {}", intent.key()); | 460 | + log.debug("Withdrawing / Purging intent {}", intent.key()); |
| 458 | - intentService.withdraw(intent); | 461 | + if (isIntentToBePurged(payload)) { |
| 462 | + intentService.purge(intent); | ||
| 463 | + } else { | ||
| 464 | + intentService.withdraw(intent); | ||
| 465 | + } | ||
| 459 | } | 466 | } |
| 460 | } | 467 | } |
| 461 | } | 468 | } | ... | ... |
| ... | @@ -37,6 +37,11 @@ | ... | @@ -37,6 +37,11 @@ |
| 37 | tooltip tt-msg="deactivateTip" | 37 | tooltip tt-msg="deactivateTip" |
| 38 | ng-click="(!!selId && isIntentInstalled()) ? deactivateIntent():''"></div> | 38 | ng-click="(!!selId && isIntentInstalled()) ? deactivateIntent():''"></div> |
| 39 | 39 | ||
| 40 | + <div ng-class="{'active': !!selId && isIntentWithdrawn()}" | ||
| 41 | + icon icon-id="garbage" icon-size="42" | ||
| 42 | + tooltip tt-msg="purgeTip" | ||
| 43 | + ng-click="(!!selId && isIntentWithdrawn()) ? purgeIntent():''"></div> | ||
| 44 | + | ||
| 40 | 45 | ||
| 41 | </div> | 46 | </div> |
| 42 | </div> | 47 | </div> | ... | ... |
| ... | @@ -72,6 +72,7 @@ | ... | @@ -72,6 +72,7 @@ |
| 72 | 72 | ||
| 73 | $scope.topoTip = 'Show selected intent on topology view'; | 73 | $scope.topoTip = 'Show selected intent on topology view'; |
| 74 | $scope.deactivateTip = 'Remove selected intent'; | 74 | $scope.deactivateTip = 'Remove selected intent'; |
| 75 | + $scope.purgeTip = 'Purge selected intent'; | ||
| 75 | 76 | ||
| 76 | $scope.showIntent = function () { | 77 | $scope.showIntent = function () { |
| 77 | var d = $scope.intentData; | 78 | var d = $scope.intentData; |
| ... | @@ -82,14 +83,23 @@ | ... | @@ -82,14 +83,23 @@ |
| 82 | return $scope.intentState === 'Installed'; | 83 | return $scope.intentState === 'Installed'; |
| 83 | }; | 84 | }; |
| 84 | 85 | ||
| 85 | - $scope.deactivateIntent = function () { | 86 | + $scope.isIntentWithdrawn = function () { |
| 86 | - var content = ds.createDiv(); | 87 | + return $scope.intentState === 'Withdrawn'; |
| 88 | + }; | ||
| 89 | + | ||
| 90 | + function executeAction(bPurge) { | ||
| 91 | + var content = ds.createDiv(), | ||
| 92 | + txt = bPurge ? 'purge' : 'withdraw' ; | ||
| 87 | 93 | ||
| 88 | - content.append('p') | 94 | + $scope.intentData.intentPurge = bPurge; |
| 89 | - .text('Are you sure you want to remove the selected intent?'); | 95 | + |
| 96 | + content.append('p'). | ||
| 97 | + text('Are you sure you want to '+ txt + | ||
| 98 | + ' the selected intent?'); | ||
| 90 | 99 | ||
| 91 | function dOk() { | 100 | function dOk() { |
| 92 | var d = $scope.intentData; | 101 | var d = $scope.intentData; |
| 102 | + $log.debug(d); | ||
| 93 | d && tts.removeIntent(d); | 103 | d && tts.removeIntent(d); |
| 94 | $scope.fired = true; | 104 | $scope.fired = true; |
| 95 | } | 105 | } |
| ... | @@ -105,6 +115,14 @@ | ... | @@ -105,6 +115,14 @@ |
| 105 | .addOk(dOk) | 115 | .addOk(dOk) |
| 106 | .addCancel(dCancel) | 116 | .addCancel(dCancel) |
| 107 | .bindKeys(); | 117 | .bindKeys(); |
| 118 | + } | ||
| 119 | + | ||
| 120 | + $scope.deactivateIntent = function () { | ||
| 121 | + executeAction(false); | ||
| 122 | + }; | ||
| 123 | + | ||
| 124 | + $scope.purgeIntent = function () { | ||
| 125 | + executeAction(true); | ||
| 108 | }; | 126 | }; |
| 109 | 127 | ||
| 110 | $scope.briefToggle = function () { | 128 | $scope.briefToggle = function () { | ... | ... |
| ... | @@ -181,11 +181,13 @@ | ... | @@ -181,11 +181,13 @@ |
| 181 | wss.sendEvent('removeIntent', { | 181 | wss.sendEvent('removeIntent', { |
| 182 | appId: d.appId, | 182 | appId: d.appId, |
| 183 | appName: d.appName, | 183 | appName: d.appName, |
| 184 | - key: d.key | 184 | + key: d.key, |
| 185 | + purge: d.intentPurge | ||
| 185 | }); | 186 | }); |
| 186 | trafficMode = 'intents'; | 187 | trafficMode = 'intents'; |
| 187 | hoverMode = null; | 188 | hoverMode = null; |
| 188 | - flash.flash('Intent removed'); | 189 | + var txt = d.intentPurge ? 'purged' : 'withdrawn'; |
| 190 | + flash.flash('Intent ' + txt); | ||
| 189 | } | 191 | } |
| 190 | 192 | ||
| 191 | function addMultiSourceIntent () { | 193 | function addMultiSourceIntent () { | ... | ... |
-
Please register or login to post a comment