Converting builtin applications to be delivered in a self-contained manner via OAR files.

Change-Id: I5b7c6939aacc263248868fac2e0f69124c5f3609
diff --git a/web/gui/src/main/webapp/app/view/app/app.js b/web/gui/src/main/webapp/app/view/app/app.js
index 1d46471..236099d 100644
--- a/web/gui/src/main/webapp/app/view/app/app.js
+++ b/web/gui/src/main/webapp/app/view/app/app.js
@@ -1,14 +1,14 @@
 /*
  * Copyright 2015 Open Networking Laboratory
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the 'License');
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an 'AS IS' BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
@@ -21,19 +21,49 @@
 (function () {
     'use strict';
 
-    var selRow;
+    var selRow, selection;
 
     angular.module('ovApp', [])
     .controller('OvAppCtrl',
-        ['$log', '$scope', 'TableBuilderService',
+        ['$log', '$scope', 'TableBuilderService', 'WebSocketService',
 
-    function ($log, $scope, tbs) {
+    function ($log, $scope, tbs, wss) {
         function selCb($event, row) {
             selRow = angular.element($event.currentTarget);
-            // adjust which toolbar buttons are selected
+            selection = row;
             $log.debug('Got a click on:', row);
+            // adjust which toolbar buttons are selected
+            d3.select('#app-activate').classed('active', row && row.state === 'INSTALLED');
+            d3.select('#app-deactivate').classed('active', row && row.state === 'ACTIVE');
+            d3.select('#app-uninstall').classed('active', row);
         }
 
+        d3.select('#app-install').on('click', function () {
+            $log.debug('Initiating install');
+            var evt = document.createEvent("HTMLEvents");
+            evt.initEvent("click", true, true);
+            document.getElementById('file').dispatchEvent(evt);
+        });
+
+        function appAction(action) {
+            if (selection) {
+                $log.debug('Initiating uninstall of', selection);
+                wss.sendEvent('appManagementRequest', {action: action, name: selection.id});
+            }
+        }
+
+        d3.select('#file').on('change', function () {
+            var file = document.getElementById('file').value.replace('C:\\fakepath\\', '');
+            $log.info('Handling file', file);
+            var evt = document.createEvent("HTMLEvents");
+            evt.initEvent("click", true, true);
+            document.getElementById('app-upload').dispatchEvent(evt);
+        });
+
+        d3.select('#app-uninstall').on('click', function () { appAction('uninstall'); });
+        d3.select('#app-activate').on('click', function () { appAction('activate'); });
+        d3.select('#app-deactivate').on('click', function () { appAction('deactivate'); });
+
         tbs.buildTable({
             self: this,
             scope: $scope,