diff --git a/js/app.js b/js/app.js index a586ea98..10d37f46 100644 --- a/js/app.js +++ b/js/app.js @@ -16,6 +16,16 @@ app = Sammy('#main', function (sam) { */ sam.helpers({ + // Serialize an object + serialize : function(obj) { + var str = []; + for(var p in obj) + if (obj.hasOwnProperty(p)) { + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); + } + return str.join("&"); + }, + // Flash helper to diplay instant notifications flash: function (level, message) { flashs = store.get('flash'); @@ -421,7 +431,7 @@ app = Sammy('#main', function (sam) { }); sam.get('#/apps/:app', function (c) { - c.api('/app/'+c.params['app']+'?raw=true', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8 + c.api('/app/'+c.params['app']+'?raw=true', function(data) { // http://api.yunohost.org/#!/app/app_info_get_9 c.view('app_info', data); }); }); @@ -432,6 +442,16 @@ app = Sammy('#main', function (sam) { }); }); + sam.post('#/apps', function(c) { + params = { 'label': c.params['label'], 'app': c.params['app'] } + delete c.params['label']; + delete c.params['app']; + params['args'] = c.serialize(c.params.toHash()); + c.api('/app', function() { // http://api.yunohost.org/#!/app/app_install_post_2 + c.redirect('#/apps'); + }, 'POST', params); + }); + sam.get('#/apps/refresh', function (c) { c.api('/app/lists', function(data) { // http://api.yunohost.org/#!/app/app_fetchlist_put_5 c.redirect(store.get('path')); diff --git a/views/app_install.ms b/views/app_install.ms index 85672556..a7c065f1 100644 --- a/views/app_install.ms +++ b/views/app_install.ms @@ -42,6 +42,7 @@ {{/manifest.arguments.install}}
+