[Kimchi-devel] [PATCH][Wok 1/5] Adapt Wok UI to new Plugins API returns

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Tue May 31 17:51:34 UTC 2016


This patch avoids error in UI due to changes in Plugins API.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 ui/js/src/wok.api.js   |  2 +-
 ui/js/src/wok.logos.js | 10 +++++++---
 ui/js/src/wok.main.js  |  8 ++++++--
 ui/js/wok.user-log.js  |  3 ++-
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/ui/js/src/wok.api.js b/ui/js/src/wok.api.js
index 5238594..5b7e09a 100644
--- a/ui/js/src/wok.api.js
+++ b/ui/js/src/wok.api.js
@@ -99,7 +99,7 @@ var wok = {
 
     listPlugins : function(suc, err, sync) {
         wok.requestJSON({
-            url : 'plugins',
+            url : 'pluginsmanager',
             type : 'GET',
             contentType : 'application/json',
             dataType : 'json',
diff --git a/ui/js/src/wok.logos.js b/ui/js/src/wok.logos.js
index a825108..98dcf5c 100644
--- a/ui/js/src/wok.logos.js
+++ b/ui/js/src/wok.logos.js
@@ -78,18 +78,22 @@ wok.logos = function(element, powered) {
         wok.listPlugins(function(plugins) {
             if(plugins && plugins.length > 0) {
                 $(plugins).each(function(i, p) {
+                    if (p.enabled == false) {
+                        // Skip
+			return true;
+                    }
                     var url = wok.substitute(pluginUrl, {
-                        plugin: p
+                        plugin: p.name
                     });
                     obj[i] = {
-                        name : p
+                        name : p.name
                     }
                     var pluginVersions;
                     pluginVersions = retrieveVersion(url);
                     if(pluginVersions && pluginVersions.length > 0){
                         obj[i].version = pluginVersions;
                     }
-                    var imagepath = url+'/images/'+p;
+                    var imagepath = url+'/images/'+p.name;
                     if(checkImage(imagepath+'.svg') == 200) {
                         obj[i].image = imagepath+'.svg';
                     }
diff --git a/ui/js/src/wok.main.js b/ui/js/src/wok.main.js
index 2146b3d..fcb7d84 100644
--- a/ui/js/src/wok.main.js
+++ b/ui/js/src/wok.main.js
@@ -129,11 +129,15 @@ wok.main = function() {
         var wokTabs = retrieveTabs(wokConfigUrl);
         wok.listPlugins(function(plugins) {
             $(plugins).each(function(i, p) {
+                if (p.enabled == false) {
+                    // Skip plugin
+                    return true;
+                }
                 var url = wok.substitute(pluginConfigUrl, {
-                    plugin: p
+                    plugin: p.name
                 });
                 var i18nUrl = wok.substitute(pluginI18nUrl, {
-                    plugin: p
+                    plugin: p.name
                 });
                 wok.getI18n(function(i18nObj){ $.extend(i18n, i18nObj)},
                             function(i18nObj){ //i18n is not define by plugin
diff --git a/ui/js/wok.user-log.js b/ui/js/wok.user-log.js
index e787ee6..2c58827 100644
--- a/ui/js/wok.user-log.js
+++ b/ui/js/wok.user-log.js
@@ -170,7 +170,8 @@ wok.initUserLogWindow = function() {
   var pluginsData = [];
   wok.listPlugins(function(pluginReturn) {
         $.each(pluginReturn, function(i, obj) {
-          pluginsData.push({"app": obj});
+          if (obj.enabled == false) { return true; }
+          pluginsData.push({"app": obj.name});
         });
         pluginsData.unshift({"app": "wok"});
         var pluginsTt = new Bloodhound({
-- 
2.1.0




More information about the Kimchi-devel mailing list