Viswanath KSP
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
......@@ -150,6 +150,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
private static final String NAMES = "names";
private static final String ACTIVATE = "activate";
private static final String DEACTIVATE = "deactivate";
private static final String PURGE = "purge";
private static final String MY_APP_ID = "org.onosproject.gui";
......@@ -438,9 +439,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
Key key = Key.of(intentKey, applicId);
log.debug("Attempting to select intent by key={}", key);
Intent intent = intentService.getIntent(key);
return intent;
return intentService.getIntent(key);
}
private final class RemoveIntent extends RequestHandler {
......@@ -448,14 +447,22 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
super(REMOVE_INTENT);
}
private boolean isIntentToBePurged(ObjectNode payload) {
return bool(payload, PURGE);
}
@Override
public void process(long sid, ObjectNode payload) {
Intent intent = findIntentByPayload(payload);
if (intent == null) {
log.warn("Unable to find intent from payload {}", payload);
} else {
log.debug("Removing intent {}", intent.key());
intentService.withdraw(intent);
log.debug("Withdrawing / Purging intent {}", intent.key());
if (isIntentToBePurged(payload)) {
intentService.purge(intent);
} else {
intentService.withdraw(intent);
}
}
}
}
......
......@@ -37,6 +37,11 @@
tooltip tt-msg="deactivateTip"
ng-click="(!!selId && isIntentInstalled()) ? deactivateIntent():''"></div>
<div ng-class="{'active': !!selId && isIntentWithdrawn()}"
icon icon-id="garbage" icon-size="42"
tooltip tt-msg="purgeTip"
ng-click="(!!selId && isIntentWithdrawn()) ? purgeIntent():''"></div>
</div>
</div>
......
......@@ -72,6 +72,7 @@
$scope.topoTip = 'Show selected intent on topology view';
$scope.deactivateTip = 'Remove selected intent';
$scope.purgeTip = 'Purge selected intent';
$scope.showIntent = function () {
var d = $scope.intentData;
......@@ -82,14 +83,23 @@
return $scope.intentState === 'Installed';
};
$scope.deactivateIntent = function () {
var content = ds.createDiv();
$scope.isIntentWithdrawn = function () {
return $scope.intentState === 'Withdrawn';
};
function executeAction(bPurge) {
var content = ds.createDiv(),
txt = bPurge ? 'purge' : 'withdraw' ;
content.append('p')
.text('Are you sure you want to remove the selected intent?');
$scope.intentData.intentPurge = bPurge;
content.append('p').
text('Are you sure you want to '+ txt +
' the selected intent?');
function dOk() {
var d = $scope.intentData;
$log.debug(d);
d && tts.removeIntent(d);
$scope.fired = true;
}
......@@ -105,6 +115,14 @@
.addOk(dOk)
.addCancel(dCancel)
.bindKeys();
}
$scope.deactivateIntent = function () {
executeAction(false);
};
$scope.purgeIntent = function () {
executeAction(true);
};
$scope.briefToggle = function () {
......
......@@ -181,11 +181,13 @@
wss.sendEvent('removeIntent', {
appId: d.appId,
appName: d.appName,
key: d.key
key: d.key,
purge: d.intentPurge
});
trafficMode = 'intents';
hoverMode = null;
flash.flash('Intent removed');
var txt = d.intentPurge ? 'purged' : 'withdrawn';
flash.flash('Intent ' + txt);
}
function addMultiSourceIntent () {
......