Install app

This commit is contained in:
Kload 2013-11-22 15:31:47 +01:00
parent 1a8def8c7f
commit 7cff1d7690
2 changed files with 22 additions and 1 deletions

View file

@ -16,6 +16,16 @@ app = Sammy('#main', function (sam) {
*/ */
sam.helpers({ 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 helper to diplay instant notifications
flash: function (level, message) { flash: function (level, message) {
flashs = store.get('flash'); flashs = store.get('flash');
@ -421,7 +431,7 @@ app = Sammy('#main', function (sam) {
}); });
sam.get('#/apps/:app', function (c) { 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); 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) { sam.get('#/apps/refresh', function (c) {
c.api('/app/lists', function(data) { // http://api.yunohost.org/#!/app/app_fetchlist_put_5 c.api('/app/lists', function(data) { // http://api.yunohost.org/#!/app/app_fetchlist_put_5
c.redirect(store.get('path')); c.redirect(store.get('path'));

View file

@ -42,6 +42,7 @@
</div> </div>
{{/manifest.arguments.install}} {{/manifest.arguments.install}}
<hr> <hr>
<input type="hidden" name="app" value="{{manifest.id}}">
<div class="text-center"> <div class="text-center">
<input type="submit" class="btn btn-success slide back" value="Install"> <input type="submit" class="btn btn-success slide back" value="Install">
</div> </div>