[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
diff --git a/web/gui/src/main/webapp/app/view/intent/intent.html b/web/gui/src/main/webapp/app/view/intent/intent.html
index 9c025f6..3fa441a 100644
--- a/web/gui/src/main/webapp/app/view/intent/intent.html
+++ b/web/gui/src/main/webapp/app/view/intent/intent.html
@@ -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>
diff --git a/web/gui/src/main/webapp/app/view/intent/intent.js b/web/gui/src/main/webapp/app/view/intent/intent.js
index f241c83..1b49a98 100644
--- a/web/gui/src/main/webapp/app/view/intent/intent.js
+++ b/web/gui/src/main/webapp/app/view/intent/intent.js
@@ -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';
+            };
 
-                content.append('p')
-                    .text('Are you sure you want to remove the selected intent?');
+            function executeAction(bPurge) {
+                var content = ds.createDiv(),
+                    txt = bPurge ? 'purge' : 'withdraw' ;
+
+                $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 () {
diff --git a/web/gui/src/main/webapp/app/view/topo/topoTraffic.js b/web/gui/src/main/webapp/app/view/topo/topoTraffic.js
index 8b6085c..1836e1e 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoTraffic.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoTraffic.js
@@ -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 () {