mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Improve readability of api() calls
This commit is contained in:
parent
35099d0dbc
commit
9c7ed43a24
15 changed files with 162 additions and 170 deletions
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// List installed apps
|
// List installed apps
|
||||||
app.get('#/apps', function (c) {
|
app.get('#/apps', function (c) {
|
||||||
c.api('/apps?installed', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8
|
c.api('GET', '/apps?installed', {}, function(data) {
|
||||||
var apps = data['apps'];
|
var apps = data['apps'];
|
||||||
c.arraySortById(apps);
|
c.arraySortById(apps);
|
||||||
c.view('app/app_list', {apps: apps});
|
c.view('app/app_list', {apps: apps});
|
||||||
|
@ -109,8 +109,8 @@
|
||||||
|
|
||||||
// List available apps
|
// List available apps
|
||||||
app.get('#/apps/install', function (c) {
|
app.get('#/apps/install', function (c) {
|
||||||
c.api('/apps', function (data) { // http://api.yunohost.org/#!/app/app_list_get_8
|
c.api('GET', '/apps', {}, function (data) {
|
||||||
c.api('/apps?raw', function (dataraw) { // http://api.yunohost.org/#!/app/app_list_get_8
|
c.api('GET', '/apps?raw', {}, function (dataraw) {
|
||||||
var apps = []
|
var apps = []
|
||||||
$.each(data['apps'], function(k, v) {
|
$.each(data['apps'], function(k, v) {
|
||||||
app = dataraw[v['id']];
|
app = dataraw[v['id']];
|
||||||
|
@ -201,7 +201,7 @@
|
||||||
|
|
||||||
// Get app information
|
// Get app information
|
||||||
app.get('#/apps/:app', function (c) {
|
app.get('#/apps/:app', function (c) {
|
||||||
c.api('/apps/'+c.params['app']+'?raw', function(data) { // http://api.yunohost.org/#!/app/app_info_get_9
|
c.api('GET', '/apps/'+c.params['app']+'?raw', {}, function(data) {
|
||||||
// Presentation
|
// Presentation
|
||||||
data.settings.allowed_users = (data.settings.allowed_users) ? data.settings.allowed_users.replace(',', ', ')+"." : y18n.t('everyone_has_access');
|
data.settings.allowed_users = (data.settings.allowed_users) ? data.settings.allowed_users.replace(',', ', ')+"." : y18n.t('everyone_has_access');
|
||||||
|
|
||||||
|
@ -221,14 +221,14 @@
|
||||||
|
|
||||||
// Get app debug page
|
// Get app debug page
|
||||||
app.get('#/apps/:app/debug', function (c) {
|
app.get('#/apps/:app/debug', function (c) {
|
||||||
c.api('/apps/'+c.params['app']+'/debug', function(data) {
|
c.api('GET', '/apps/'+c.params['app']+'/debug', {}, function(data) {
|
||||||
c.view('app/app_debug', data);
|
c.view('app/app_debug', data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get app actions list
|
// Get app actions list
|
||||||
app.get('#/apps/:app/actions', function (c) {
|
app.get('#/apps/:app/actions', function (c) {
|
||||||
c.api('/apps/'+c.params['app']+'/actions', function(data) {
|
c.api('GET', '/apps/'+c.params['app']+'/actions', {}, function(data) {
|
||||||
$.each(data.actions, function(_, action) {
|
$.each(data.actions, function(_, action) {
|
||||||
formatYunoHostStyleArguments(action.arguments, c.params);
|
formatYunoHostStyleArguments(action.arguments, c.params);
|
||||||
|
|
||||||
|
@ -264,14 +264,14 @@
|
||||||
'args': c.serialize(c.params.toHash())
|
'args': c.serialize(c.params.toHash())
|
||||||
}
|
}
|
||||||
|
|
||||||
c.api('/apps/'+app_id+'/actions/'+action_id, function() { // http://api.yunohost.org/#!/app/app_install_post_2
|
c.api('PUT', '/apps/'+app_id+'/actions/'+action_id, params, function() {
|
||||||
c.redirect('#/apps/'+app_id+'/actions');
|
c.redirect('#/apps/'+app_id+'/actions');
|
||||||
}, 'PUT', params);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get app config panel
|
// Get app config panel
|
||||||
app.get('#/apps/:app/config-panel', function (c) {
|
app.get('#/apps/:app/config-panel', function (c) {
|
||||||
c.api('/apps/'+c.params['app']+'/config-panel', function(data) {
|
c.api('GET', '/apps/'+c.params['app']+'/config-panel', {}, function(data) {
|
||||||
$.each(data.config_panel.panel, function(_, panel) {
|
$.each(data.config_panel.panel, function(_, panel) {
|
||||||
$.each(panel.sections, function(_, section) {
|
$.each(panel.sections, function(_, section) {
|
||||||
formatYunoHostStyleArguments(section.options, c.params);
|
formatYunoHostStyleArguments(section.options, c.params);
|
||||||
|
@ -297,9 +297,9 @@
|
||||||
'args': c.serialize(c.params.toHash())
|
'args': c.serialize(c.params.toHash())
|
||||||
}
|
}
|
||||||
|
|
||||||
c.api('/apps/'+app_id+'/config', function() { // http://api.yunohost.org/#!/app/app_install_post_2
|
c.api('POST', '/apps/'+app_id+'/config', params, function() {
|
||||||
c.redirect('#/apps/'+app_id+'/config-panel');
|
c.redirect('#/apps/'+app_id+'/config-panel');
|
||||||
}, 'POST', params);
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
// Special case for custom app installation.
|
// Special case for custom app installation.
|
||||||
|
@ -477,7 +477,7 @@
|
||||||
|
|
||||||
// App installation form
|
// App installation form
|
||||||
app.get('#/apps/install/:app', function (c) {
|
app.get('#/apps/install/:app', function (c) {
|
||||||
c.api('/apps?raw', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8
|
c.api('GET', '/apps?raw', {}, function(data) {
|
||||||
var app_name = c.params["app"];
|
var app_name = c.params["app"];
|
||||||
var app_infos = data[app_name];
|
var app_infos = data[app_name];
|
||||||
if (app_infos['state'] === "validated")
|
if (app_infos['state'] === "validated")
|
||||||
|
@ -543,9 +543,9 @@
|
||||||
delete params['args'];
|
delete params['args'];
|
||||||
}
|
}
|
||||||
|
|
||||||
c.api('/apps', function() { // http://api.yunohost.org/#!/app/app_install_post_2
|
c.api('POST', '/apps', params, function() {
|
||||||
c.redirect('#/apps');
|
c.redirect('#/apps');
|
||||||
}, 'POST', params);
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c.flash('warning', y18n.t('app_install_cancel'));
|
c.flash('warning', y18n.t('app_install_cancel'));
|
||||||
|
@ -608,9 +608,9 @@
|
||||||
y18n.t('applications'),
|
y18n.t('applications'),
|
||||||
y18n.t('confirm_uninstall', [c.params['app']]),
|
y18n.t('confirm_uninstall', [c.params['app']]),
|
||||||
function() {
|
function() {
|
||||||
c.api('/apps/'+ c.params['app'], function() { // http://api.yunohost.org/#!/app/app_remove_delete_4
|
c.api('DELETE', '/apps/'+ c.params['app'], {}, function() { // http://api.yunohost.org/#!/app/app_remove_delete_4
|
||||||
c.redirect('#/apps');
|
c.redirect('#/apps');
|
||||||
}, 'DELETE');
|
});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -621,8 +621,8 @@
|
||||||
|
|
||||||
// Manage app access
|
// Manage app access
|
||||||
app.get('#/apps/:app/access', function (c) {
|
app.get('#/apps/:app/access', function (c) {
|
||||||
c.api('/apps/'+c.params['app']+'?raw', function(data) { // http://api.yunohost.org/#!/app/app_info_get_9
|
c.api('GET', '/apps/'+c.params['app']+'?raw', {}, function(data) {
|
||||||
c.api('/users', function(dataUsers) {
|
c.api('GET', '/users', {}, function(dataUsers) {
|
||||||
|
|
||||||
// allowed_users as array
|
// allowed_users as array
|
||||||
if (typeof data.settings.allowed_users !== 'undefined') {
|
if (typeof data.settings.allowed_users !== 'undefined') {
|
||||||
|
@ -674,10 +674,10 @@
|
||||||
apps: c.params['app'],
|
apps: c.params['app'],
|
||||||
users: []
|
users: []
|
||||||
};
|
};
|
||||||
c.api('/access?'+c.serialize(params), function(data) { // http://api.yunohost.org/#!/app/app_removeaccess_delete_12
|
c.api('DELETE', '/access?'+c.serialize(params), params, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
||||||
}, 'DELETE', params);
|
});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -696,10 +696,10 @@
|
||||||
apps: c.params['app'],
|
apps: c.params['app'],
|
||||||
users: c.params['user']
|
users: c.params['user']
|
||||||
};
|
};
|
||||||
c.api('/access?'+c.serialize(params), function(data) { // http://api.yunohost.org/#!/app/app_removeaccess_delete_12
|
c.api('DELETE', '/access?'+c.serialize(params), params, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
||||||
}, 'DELETE', params); // passing 'params' here is useless because jQuery doesn't handle ajax datas for DELETE requests. Passing parameters through uri.
|
});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -718,10 +718,10 @@
|
||||||
apps: c.params['app'],
|
apps: c.params['app'],
|
||||||
users: null
|
users: null
|
||||||
};
|
};
|
||||||
c.api('/access', function() { // http://api.yunohost.org/#!/app/app_addaccess_put_13
|
c.api('PUT', '/access', params, function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
||||||
}, 'PUT', params);
|
});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -736,10 +736,10 @@
|
||||||
users: c.params['user'],
|
users: c.params['user'],
|
||||||
apps: c.params['app']
|
apps: c.params['app']
|
||||||
};
|
};
|
||||||
c.api('/access', function() { // http://api.yunohost.org/#!/app/app_addaccess_put_13
|
c.api('PUT', '/access', params, function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
||||||
}, 'PUT', params);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clear access (reset)
|
// Clear access (reset)
|
||||||
|
@ -751,10 +751,10 @@
|
||||||
var params = {
|
var params = {
|
||||||
apps: c.params['app']
|
apps: c.params['app']
|
||||||
};
|
};
|
||||||
c.api('/access', function() { //
|
c.api('POST', '/access', params, function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
||||||
}, 'POST', params);
|
});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -769,10 +769,10 @@
|
||||||
y18n.t('applications'),
|
y18n.t('applications'),
|
||||||
y18n.t('confirm_app_default'),
|
y18n.t('confirm_app_default'),
|
||||||
function() {
|
function() {
|
||||||
c.api('/apps/'+ c.params['app'] +'/default', function() { //
|
c.api('PUT', '/apps/'+c.params['app']+'/default', {}, function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app']);
|
c.redirect('#/apps/'+ c.params['app']);
|
||||||
}, 'PUT');
|
});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -783,7 +783,7 @@
|
||||||
|
|
||||||
// Get app change label page
|
// Get app change label page
|
||||||
app.get('#/apps/:app/changelabel', function (c) {
|
app.get('#/apps/:app/changelabel', function (c) {
|
||||||
c.api('/apps/'+c.params['app']+'?raw', function(app_data) {
|
c.api('GET', '/apps/'+c.params['app']+'?raw', {}, function(app_data) {
|
||||||
data = {
|
data = {
|
||||||
id: c.params['app'],
|
id: c.params['app'],
|
||||||
label: app_data.settings.label,
|
label: app_data.settings.label,
|
||||||
|
@ -795,16 +795,16 @@
|
||||||
// Change app label
|
// Change app label
|
||||||
app.post('#/apps/:app/changelabel', function (c) {
|
app.post('#/apps/:app/changelabel', function (c) {
|
||||||
params = {'new_label': c.params['label']};
|
params = {'new_label': c.params['label']};
|
||||||
c.api('/apps/' + c.params['app'] + '/label', function(data) { // Call changelabel API
|
c.api('PUT', '/apps/' + c.params['app'] + '/label', params, function(data) { // Call changelabel API
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app']);
|
c.redirect('#/apps/'+ c.params['app']);
|
||||||
}, 'PUT', params);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get app change URL page
|
// Get app change URL page
|
||||||
app.get('#/apps/:app/changeurl', function (c) {
|
app.get('#/apps/:app/changeurl', function (c) {
|
||||||
c.api('/apps/'+c.params['app']+'?raw', function(app_data) {
|
c.api('GET', '/apps/'+c.params['app']+'?raw', {}, function(app_data) {
|
||||||
c.api('/domains', function(domain_data) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
c.api('GET', '/domains', {}, function(domain_data) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
||||||
|
|
||||||
// Display a list of available domains
|
// Display a list of available domains
|
||||||
var domains = [];
|
var domains = [];
|
||||||
|
@ -836,10 +836,10 @@
|
||||||
y18n.t('confirm_app_change_url', [c.params['app']]),
|
y18n.t('confirm_app_change_url', [c.params['app']]),
|
||||||
function() {
|
function() {
|
||||||
params = {'domain': c.params['domain'], 'path': c.params['path']};
|
params = {'domain': c.params['domain'], 'path': c.params['path']};
|
||||||
c.api('/apps/' + c.params['app'] + '/changeurl', function(data) { // Call changeurl API
|
c.api('PUT', '/apps/' + c.params['app'] + '/changeurl', params, function(data) { // Call changeurl API
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app']);
|
c.redirect('#/apps/'+ c.params['app']);
|
||||||
}, 'PUT', params);
|
});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
|
|
@ -50,10 +50,10 @@
|
||||||
id:c.params['storage'],
|
id:c.params['storage'],
|
||||||
name:y18n.t('local_archives')
|
name:y18n.t('local_archives')
|
||||||
};
|
};
|
||||||
c.api('/hooks/backup', function(hooks) {
|
c.api('GET', '/hooks/backup', {}, function(hooks) {
|
||||||
data['hooks'] = c.groupHooks(hooks['hooks']);
|
data['hooks'] = c.groupHooks(hooks['hooks']);
|
||||||
data['apps'] = {};
|
data['apps'] = {};
|
||||||
c.api('/apps?with_backup', function(apps_list) {
|
c.api('GET', '/apps?with_backup', {}, function(apps_list) {
|
||||||
data['apps'] = apps_list.apps;
|
data['apps'] = apps_list.apps;
|
||||||
c.view('backup/backup_create', data, c.selectAllOrNone);
|
c.view('backup/backup_create', data, c.selectAllOrNone);
|
||||||
});
|
});
|
||||||
|
@ -63,10 +63,10 @@
|
||||||
|
|
||||||
app.post('#/backup/:storage', function (c) {
|
app.post('#/backup/:storage', function (c) {
|
||||||
var params = c.ungroupHooks(c.params['system_parts'],c.params['apps']);
|
var params = c.ungroupHooks(c.params['system_parts'],c.params['apps']);
|
||||||
c.api('/backup', function() {
|
c.api('POST', '/backup', params, function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/backup/'+ c.params['storage']);
|
c.redirect('#/backup/'+ c.params['storage']);
|
||||||
}, 'POST', params);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Restore a backup
|
// Restore a backup
|
||||||
|
@ -77,10 +77,10 @@
|
||||||
$.proxy(function(c){
|
$.proxy(function(c){
|
||||||
var params = c.ungroupHooks(c.params['system_parts'],c.params['apps']);
|
var params = c.ungroupHooks(c.params['system_parts'],c.params['apps']);
|
||||||
params['force'] = '';
|
params['force'] = '';
|
||||||
c.api('/backup/restore/'+c.params['archive'], function(data) {
|
c.api('POST', '/backup/restore/'+c.params['archive'], params, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
|
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
|
||||||
}, 'POST', params);
|
});
|
||||||
}, this, c),
|
}, this, c),
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -95,9 +95,9 @@
|
||||||
y18n.t('backup'),
|
y18n.t('backup'),
|
||||||
y18n.t('confirm_delete', [c.params['archive']]),
|
y18n.t('confirm_delete', [c.params['archive']]),
|
||||||
function(){
|
function(){
|
||||||
c.api('/backup/archives/'+c.params['archive'], function(data) {
|
c.api('DELETE', '/backup/archives/'+c.params['archive'], {}, function(data) {
|
||||||
c.redirect('#/backup/'+ c.params['storage']);
|
c.redirect('#/backup/'+ c.params['storage']);
|
||||||
}, 'DELETE');
|
});
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -108,9 +108,9 @@
|
||||||
|
|
||||||
// Download a backup
|
// Download a backup
|
||||||
app.get('#/backup/:storage/:archive/download', function (c) {
|
app.get('#/backup/:storage/:archive/download', function (c) {
|
||||||
c.api('/backup/'+c.params['archive']+'/download', function(data) {
|
c.api('GET', '/backup/'+c.params['archive']+'/download', {}, function(data) {
|
||||||
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
|
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
|
||||||
}, 'GET');
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Copy a backup
|
// Copy a backup
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
|
|
||||||
// Get archive info
|
// Get archive info
|
||||||
app.get('#/backup/:storage/:archive', function (c) {
|
app.get('#/backup/:storage/:archive', function (c) {
|
||||||
c.api('/backup/archives/'+c.params['archive']+'?with_details', function(data) {
|
c.api('GET', '/backup/archives/'+c.params['archive']+'?with_details', {}, function(data) {
|
||||||
data.storage = {
|
data.storage = {
|
||||||
id: c.params['storage'],
|
id: c.params['storage'],
|
||||||
name: y18n.t('local_archives')
|
name: y18n.t('local_archives')
|
||||||
|
@ -143,7 +143,7 @@
|
||||||
|
|
||||||
// Archive list
|
// Archive list
|
||||||
app.get('#/backup/:storage', function (c) {
|
app.get('#/backup/:storage', function (c) {
|
||||||
c.api('/backup/archives?with_info', function(data) {
|
c.api('GET', '/backup/archives?with_info', {}, function(data) {
|
||||||
data.storage = {
|
data.storage = {
|
||||||
id: 'local',
|
id: 'local',
|
||||||
name: y18n.t('local_archives')
|
name: y18n.t('local_archives')
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
|
|
||||||
// List existing domains
|
// List existing domains
|
||||||
app.get('#/domains', function (c) {
|
app.get('#/domains', function (c) {
|
||||||
c.api('/domains', function(data) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
c.api('GET', '/domains', {}, function(data) {
|
||||||
c.api('/domains/main', function(data2) {
|
c.api('PUT', '/domains/main', {}, function(data2) {
|
||||||
var domains = [];
|
var domains = [];
|
||||||
$.each(data.domains, function(k, domain) {
|
$.each(data.domains, function(k, domain) {
|
||||||
domains.push({
|
domains.push({
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
domains: domains,
|
domains: domains,
|
||||||
main_domain_form: main_domain_form
|
main_domain_form: main_domain_form
|
||||||
});
|
});
|
||||||
}, 'PUT');
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -77,15 +77,15 @@
|
||||||
params.domain = c.params['domain'];
|
params.domain = c.params['domain'];
|
||||||
}
|
}
|
||||||
|
|
||||||
c.api('/domains?'+endurl, function(data) { // http://api.yunohost.org/#!/domain/domain_add_post_1
|
c.api('POST', '/domains?'+endurl, params, function(data) {
|
||||||
c.redirect('#/domains');
|
c.redirect('#/domains');
|
||||||
}, 'POST', params);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get existing domain info
|
// Get existing domain info
|
||||||
app.get('#/domains/:domain', function (c) {
|
app.get('#/domains/:domain', function (c) {
|
||||||
c.api('/domains/main', function(dataMain) {
|
c.api('PUT', '/domains/main', {}, function(dataMain) {
|
||||||
c.api('/apps?installed', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8
|
c.api('GET', '/apps?installed', {}, function(data) {
|
||||||
|
|
||||||
// FIXME - This dirty trick (along with the previous API call
|
// FIXME - This dirty trick (along with the previous API call
|
||||||
// for apps installed) should be removed once letsencrypt_ynh
|
// for apps installed) should be removed once letsencrypt_ynh
|
||||||
|
@ -107,12 +107,12 @@
|
||||||
};
|
};
|
||||||
c.view('domain/domain_info', domain);
|
c.view('domain/domain_info', domain);
|
||||||
});
|
});
|
||||||
}, 'PUT');
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Domain DNS
|
// Domain DNS
|
||||||
app.get('#/domains/:domain/dns', function (c) {
|
app.get('#/domains/:domain/dns', function (c) {
|
||||||
c.api('/domains/' + c.params['domain'] + '/dns', function(data) {
|
c.api('GET', '/domains/' + c.params['domain'] + '/dns', {}, function(data) {
|
||||||
var domain = {
|
var domain = {
|
||||||
name: c.params['domain'],
|
name: c.params['domain'],
|
||||||
dns: data
|
dns: data
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
|
|
||||||
// Domain certificate
|
// Domain certificate
|
||||||
app.get('#/domains/:domain/cert-management', function (c) {
|
app.get('#/domains/:domain/cert-management', function (c) {
|
||||||
c.api('/domains/cert-status/' + c.params['domain'] + '?full', function(data) {
|
c.api('GET', '/domains/cert-status/' + c.params['domain'] + '?full', {}, function(data) {
|
||||||
|
|
||||||
var s = data["certificates"][c.params['domain']];
|
var s = data["certificates"][c.params['domain']];
|
||||||
var status_ = {
|
var status_ = {
|
||||||
|
@ -209,10 +209,10 @@
|
||||||
y18n.t('certificate'),
|
y18n.t('certificate'),
|
||||||
y18n.t('confirm_cert_install_LE', [c.params['domain']]),
|
y18n.t('confirm_cert_install_LE', [c.params['domain']]),
|
||||||
function(){
|
function(){
|
||||||
c.api('/domains/cert-install/' + c.params['domain'], function(data) {
|
c.api('POST', '/domains/cert-install/' + c.params['domain'], {}, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
|
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
|
||||||
}, 'POST');
|
});
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -227,10 +227,10 @@
|
||||||
y18n.t('certificate'),
|
y18n.t('certificate'),
|
||||||
y18n.t('confirm_cert_regen_selfsigned', [c.params['domain']]),
|
y18n.t('confirm_cert_regen_selfsigned', [c.params['domain']]),
|
||||||
function(){
|
function(){
|
||||||
c.api('/domains/cert-install/' + c.params['domain'] + "?self_signed", function(data) {
|
c.api('POST', '/domains/cert-install/' + c.params['domain'] + "?self_signed", {}, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
|
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
|
||||||
}, 'POST');
|
});
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -245,10 +245,10 @@
|
||||||
y18n.t('certificate'),
|
y18n.t('certificate'),
|
||||||
y18n.t('confirm_cert_manual_renew_LE', [c.params['domain']]),
|
y18n.t('confirm_cert_manual_renew_LE', [c.params['domain']]),
|
||||||
function(){
|
function(){
|
||||||
c.api('/domains/cert-renew/' + c.params['domain'] + "?force", function(data) {
|
c.api('POST', '/domains/cert-renew/' + c.params['domain'] + "?force", {}, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
|
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
|
||||||
}, 'POST');
|
});
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -263,10 +263,10 @@
|
||||||
y18n.t('certificate'),
|
y18n.t('certificate'),
|
||||||
y18n.t('confirm_cert_revert_to_selfsigned', [c.params['domain']]),
|
y18n.t('confirm_cert_revert_to_selfsigned', [c.params['domain']]),
|
||||||
function(){
|
function(){
|
||||||
c.api('/domains/cert-install/' + c.params['domain'] + "?self_signed&force", function(data) {
|
c.api('POST', '/domains/cert-install/' + c.params['domain'] + "?self_signed&force", {}, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
|
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
|
||||||
}, 'POST');
|
});
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -282,10 +282,10 @@
|
||||||
y18n.t('domains'),
|
y18n.t('domains'),
|
||||||
y18n.t('confirm_delete', [c.params['domain']]),
|
y18n.t('confirm_delete', [c.params['domain']]),
|
||||||
function(){
|
function(){
|
||||||
c.api('/domains/'+ c.params['domain'], function(data) { // http://api.yunohost.org/#!/domain/domain_remove_delete_3
|
c.api('DELETE', '/domains/'+ c.params['domain'], {}, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/domains');
|
c.redirect('#/domains');
|
||||||
}, 'DELETE');
|
});
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -308,10 +308,10 @@
|
||||||
var params = {
|
var params = {
|
||||||
new_domain: c.params['domain']
|
new_domain: c.params['domain']
|
||||||
};
|
};
|
||||||
c.api('/domains/main', function(data) { // http://api.yunohost.org/#!/tools/tools_maindomain_put_1
|
c.api('PUT', '/domains/main', params, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/domains');
|
c.redirect('#/domains');
|
||||||
}, 'PUT', params);
|
});
|
||||||
|
|
||||||
// Wait 15s and refresh the page
|
// Wait 15s and refresh the page
|
||||||
var refreshDomain = window.setTimeout(function(){
|
var refreshDomain = window.setTimeout(function(){
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// Firewall status
|
// Firewall status
|
||||||
app.get('#/tools/firewall', function (c) {
|
app.get('#/tools/firewall', function (c) {
|
||||||
c.api('/firewall?raw', function(data) {
|
c.api('GET', '/firewall?raw', {}, function(data) {
|
||||||
var firewall = {
|
var firewall = {
|
||||||
ports: {},
|
ports: {},
|
||||||
upnp: false
|
upnp: false
|
||||||
|
@ -44,10 +44,10 @@
|
||||||
var params = {
|
var params = {
|
||||||
action : c.params['action']
|
action : c.params['action']
|
||||||
};
|
};
|
||||||
c.api('/firewall/upnp', function(data) {
|
c.api('GET', '/firewall/upnp', params, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/firewall');
|
c.redirect('#/tools/firewall');
|
||||||
}, 'GET', params);
|
});
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -115,10 +115,10 @@
|
||||||
port : port,
|
port : port,
|
||||||
protocol : protocol
|
protocol : protocol
|
||||||
};
|
};
|
||||||
c.api('/firewall/port?'+endurl, function(data) {
|
c.api(method, '/firewall/port?'+endurl, params, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/firewall');
|
c.redirect('#/tools/firewall');
|
||||||
}, method, params);
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
var params = {
|
var params = {
|
||||||
password: c.params['password']
|
password: c.params['password']
|
||||||
};
|
};
|
||||||
c.api('/login', function(data) {
|
c.api('POST', '/login', params, function(data) {
|
||||||
store.set('connected', true);
|
store.set('connected', true);
|
||||||
c.trigger('login');
|
c.trigger('login');
|
||||||
$('#masthead .logout-btn').fadeIn();
|
$('#masthead .logout-btn').fadeIn();
|
||||||
|
@ -90,19 +90,19 @@
|
||||||
} else {
|
} else {
|
||||||
c.redirect('#/');
|
c.redirect('#/');
|
||||||
}
|
}
|
||||||
}, 'POST', params, false);
|
}, undefined, false);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('#/logout', function (c) {
|
app.get('#/logout', function (c) {
|
||||||
c.api('/logout', function (data) {
|
c.api('GET', '/logout', {}, function (data) {
|
||||||
store.clear('url');
|
store.clear('url');
|
||||||
store.clear('connected');
|
store.clear('connected');
|
||||||
store.set('path', '#/');
|
store.set('path', '#/');
|
||||||
c.trigger('logout');
|
c.trigger('logout');
|
||||||
c.flash('success', y18n.t('logged_out'));
|
c.flash('success', y18n.t('logged_out'));
|
||||||
c.redirect('#/login');
|
c.redirect('#/login');
|
||||||
}, 'GET', {}, false);
|
}, undefined, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -13,29 +13,28 @@
|
||||||
var monitorData = {};
|
var monitorData = {};
|
||||||
|
|
||||||
// Why this method ?
|
// Why this method ?
|
||||||
c.api('/services/glances', function(data) { // ?
|
c.api('GET', '/services/glances', {}, function(data) {
|
||||||
monitorData.status = true;
|
monitorData.status = true;
|
||||||
|
|
||||||
if (data.status == 'running') {
|
if (data.status == 'running') {
|
||||||
c.api('/monitor/system', function(data) {
|
c.api('GET', '/monitor/system', {}, function(data) {
|
||||||
monitorData.system = data;
|
monitorData.system = data;
|
||||||
|
|
||||||
c.api('/monitor/disk', function(data) {
|
c.api('GET', '/monitor/disk', {}, function(data) {
|
||||||
monitorData.disk = data;
|
monitorData.disk = data;
|
||||||
|
|
||||||
c.api('/monitor/network', function(data) {
|
c.api('GET', '/monitor/network', {}, function(data) {
|
||||||
monitorData.network = data;
|
monitorData.network = data;
|
||||||
|
|
||||||
// Remove useless interface
|
// Remove useless interface
|
||||||
delete monitorData.network.usage.lo;
|
delete monitorData.network.usage.lo;
|
||||||
|
|
||||||
// Get YunoHost versions too
|
// Get YunoHost versions too
|
||||||
c.api('/diagnosis', function(diagnosis) {
|
c.api('GET', '/diagnosis', {}, function(diagnosis) {
|
||||||
monitorData.versions = diagnosis.packages;
|
monitorData.versions = diagnosis.packages;
|
||||||
c.view('tools/tools_monitoring', monitorData);
|
c.view('tools/tools_monitoring', monitorData);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -43,8 +42,7 @@
|
||||||
monitorData.status = false;
|
monitorData.status = false;
|
||||||
c.view('tools/tools_monitoring', monitorData);
|
c.view('tools/tools_monitoring', monitorData);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}, 'GET');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -92,9 +92,9 @@
|
||||||
|
|
||||||
store.set('url', window.location.hostname +'/yunohost/api');
|
store.set('url', window.location.hostname +'/yunohost/api');
|
||||||
store.set('user', 'admin');
|
store.set('user', 'admin');
|
||||||
c.api('/postinstall', function(data) { // http://api.yunohost.org/#!/tools/tools_postinstall_post_0
|
c.api('POST', '/postinstall', params, function(data) {
|
||||||
c.redirect('#/login');
|
c.redirect('#/login');
|
||||||
}, 'POST', params);
|
});
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// All services status
|
// All services status
|
||||||
app.get('#/services', function (c) {
|
app.get('#/services', function (c) {
|
||||||
c.api('/services', function(data) { // ?
|
c.api('GET', '/services', {}, function(data) {
|
||||||
var data2 = {
|
var data2 = {
|
||||||
services: []
|
services: []
|
||||||
};
|
};
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
// Status & actions for a service
|
// Status & actions for a service
|
||||||
app.get('#/services/:service', function (c) {
|
app.get('#/services/:service', function (c) {
|
||||||
c.api('/services/'+ c.params['service'], function(data) { // ?
|
c.api('GET', '/services/'+ c.params['service'], {}, function(data) { // ?
|
||||||
var data2 = {
|
var data2 = {
|
||||||
service: data
|
service: data
|
||||||
};
|
};
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
}
|
}
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.view('service/service_info', data2);
|
c.view('service/service_info', data2);
|
||||||
}, 'GET');
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Service log
|
// Service log
|
||||||
|
@ -74,14 +74,14 @@
|
||||||
var params = {
|
var params = {
|
||||||
number: 50
|
number: 50
|
||||||
};
|
};
|
||||||
c.api('/services/'+ c.params['service'] +'/log', function(data) { // ?
|
c.api('GET', '/services/'+ c.params['service'] +'/log', params, function(data) { // ?
|
||||||
data2 = { 'logs': [], 'name': c.params['service'] };
|
data2 = { 'logs': [], 'name': c.params['service'] };
|
||||||
$.each(data, function(k, v) {
|
$.each(data, function(k, v) {
|
||||||
data2.logs.push({filename: k, filecontent: v.join('\n')});
|
data2.logs.push({filename: k, filecontent: v.join('\n')});
|
||||||
});
|
});
|
||||||
|
|
||||||
c.view('service/service_log', data2);
|
c.view('service/service_log', data2);
|
||||||
}, 'GET', params);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enable/Disable & Start/Stop service
|
// Enable/Disable & Start/Stop service
|
||||||
|
@ -116,10 +116,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method && endurl) {
|
if (method && endurl) {
|
||||||
c.api('/services/'+ endurl, function(data) {
|
c.api(method, '/services/'+ endurl, {}, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/services/'+ c.params['service']);
|
c.redirect('#/services/'+ c.params['service']);
|
||||||
}, method);
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
|
|
@ -33,24 +33,24 @@
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/adminpw');
|
c.redirect('#/tools/adminpw');
|
||||||
} else {
|
} else {
|
||||||
c.api('/login', function(data) {
|
c.api('POST', '/login', { 'password': params['old_password'] }, function(data) {
|
||||||
// Remove useless variable
|
// Remove useless variable
|
||||||
delete params['old_password'];
|
delete params['old_password'];
|
||||||
delete params['confirm_new_password'];
|
delete params['confirm_new_password'];
|
||||||
|
|
||||||
// Update password and redirect to the home
|
// Update password and redirect to the home
|
||||||
c.api('/adminpw', function(data) { // http://api.yunohost.org/#!/tools/tools_adminpw_put_3
|
c.api('PUT', '/adminpw', params, function(data) {
|
||||||
c.redirect('#/logout');
|
c.redirect('#/logout');
|
||||||
}, 'PUT', params);
|
});
|
||||||
}, 'POST', { 'password': params['old_password'] }, false);
|
}, undefined, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// System update & upgrade
|
// System update & upgrade
|
||||||
app.get('#/update', function (c) {
|
app.get('#/update', function (c) {
|
||||||
c.api('/update', function(data) {
|
c.api('PUT', '/update', {}, function(data) {
|
||||||
c.view('update/update', data);
|
c.view('update/update', data);
|
||||||
}, 'PUT');
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Upgrade apps or packages
|
// Upgrade apps or packages
|
||||||
|
@ -60,12 +60,10 @@
|
||||||
// confirm_update_apps and confirm_update_packages
|
// confirm_update_apps and confirm_update_packages
|
||||||
y18n.t('confirm_update_' + c.params['type'].toLowerCase()),
|
y18n.t('confirm_update_' + c.params['type'].toLowerCase()),
|
||||||
function(){
|
function(){
|
||||||
c.api('/upgrade?'+c.params["type"],
|
c.api('PUT', '/upgrade?'+c.params["type"], {}, function(data) {
|
||||||
function(data) {
|
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/logs');
|
c.redirect('#/tools/logs');
|
||||||
},
|
});
|
||||||
'PUT');
|
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -80,12 +78,10 @@
|
||||||
y18n.t('tools'),
|
y18n.t('tools'),
|
||||||
y18n.t('confirm_update_specific_app', [c.params['app']]),
|
y18n.t('confirm_update_specific_app', [c.params['app']]),
|
||||||
function(){
|
function(){
|
||||||
c.api('/upgrade/apps?app='+c.params['app'].toLowerCase(),
|
c.api('PUT', '/upgrade/apps?app='+c.params['app'].toLowerCase(), {}, function(data) {
|
||||||
function(data) {
|
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/logs');
|
c.redirect('#/tools/logs');
|
||||||
},
|
});
|
||||||
'PUT');
|
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -96,7 +92,7 @@
|
||||||
|
|
||||||
// Display journals list
|
// Display journals list
|
||||||
app.get('#/tools/logs', function (c) {
|
app.get('#/tools/logs', function (c) {
|
||||||
c.api("/logs?limit=25&with_details", function(categories) {
|
c.api('GET', "/logs?limit=25&with_details", {}, function(categories) {
|
||||||
data = [];
|
data = [];
|
||||||
category_icons = {
|
category_icons = {
|
||||||
'operation': 'wrench',
|
'operation': 'wrench',
|
||||||
|
@ -139,7 +135,7 @@
|
||||||
var number = (c.params["number"])?c.params["number"]:50;
|
var number = (c.params["number"])?c.params["number"]:50;
|
||||||
params += "&number=" + number;
|
params += "&number=" + number;
|
||||||
|
|
||||||
c.api("/logs/display" + params, function(log) {
|
c.api('GET', "/logs/display" + params, {}, function(log) {
|
||||||
if ('metadata' in log) {
|
if ('metadata' in log) {
|
||||||
if (!'env' in log.metadata && 'args' in log.metadata) {
|
if (!'env' in log.metadata && 'args' in log.metadata) {
|
||||||
log.metadata.env = log.metadata.args
|
log.metadata.env = log.metadata.args
|
||||||
|
@ -222,10 +218,10 @@
|
||||||
// confirm_reboot_action_reboot or confirm_reboot_action_shutdown
|
// confirm_reboot_action_reboot or confirm_reboot_action_shutdown
|
||||||
y18n.t('confirm_reboot_action_' + action),
|
y18n.t('confirm_reboot_action_' + action),
|
||||||
function(){
|
function(){
|
||||||
c.api('/'+action+'?force', function(data) {
|
c.api('PUT', '/'+action+'?force', {}, function(data) {
|
||||||
// This code is not executed due to 502 response (reboot or shutdown)
|
// This code is not executed due to 502 response (reboot or shutdown)
|
||||||
c.redirect('#/logout');
|
c.redirect('#/logout');
|
||||||
}, 'PUT', {}, false, function (xhr) {
|
}, function (xhr) {
|
||||||
c.flash('success', y18n.t('tools_' + action + '_done'))
|
c.flash('success', y18n.t('tools_' + action + '_done'))
|
||||||
// Disconnect from the webadmin
|
// Disconnect from the webadmin
|
||||||
store.clear('url');
|
store.clear('url');
|
||||||
|
@ -249,7 +245,7 @@
|
||||||
// Force scrollTop on page load
|
// Force scrollTop on page load
|
||||||
$('html, body').scrollTop(0);
|
$('html, body').scrollTop(0);
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
});
|
}, false);
|
||||||
|
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
|
@ -271,7 +267,7 @@
|
||||||
var private = (c.params.splat[0] == 'private');
|
var private = (c.params.splat[0] == 'private');
|
||||||
|
|
||||||
var endurl = (private) ? '?private' : '';
|
var endurl = (private) ? '?private' : '';
|
||||||
c.api('/diagnosis'+endurl, function(diagnosis) {
|
c.api('GET', '/diagnosis'+endurl, {}, function(diagnosis) {
|
||||||
c.view('tools/tools_diagnosis', {
|
c.view('tools/tools_diagnosis', {
|
||||||
'diagnosis' : JSON.stringify(diagnosis, undefined, 4),
|
'diagnosis' : JSON.stringify(diagnosis, undefined, 4),
|
||||||
'raw' : diagnosis,
|
'raw' : diagnosis,
|
||||||
|
@ -282,8 +278,8 @@
|
||||||
|
|
||||||
// Reboot or shutdown button
|
// Reboot or shutdown button
|
||||||
app.get('#/tools/migrations', function (c) {
|
app.get('#/tools/migrations', function (c) {
|
||||||
c.api('/migrations?pending', function(pending_migrations) {
|
c.api('GET', '/migrations?pending', {}, function(pending_migrations) {
|
||||||
c.api('/migrations?done', function(done_migrations) {
|
c.api('GET', '/migrations?done', {}, function(done_migrations) {
|
||||||
pending_migrations = pending_migrations.migrations;
|
pending_migrations = pending_migrations.migrations;
|
||||||
done_migrations = done_migrations.migrations;
|
done_migrations = done_migrations.migrations;
|
||||||
|
|
||||||
|
@ -331,19 +327,17 @@
|
||||||
// /tools/migrations/run page "directly" somehow ...
|
// /tools/migrations/run page "directly" somehow ...
|
||||||
if (withAcceptDisclaimerFlag)
|
if (withAcceptDisclaimerFlag)
|
||||||
{
|
{
|
||||||
c.api('/migrations/migrate?accept_disclaimer',
|
c.api('POST', '/migrations/migrate?accept_disclaimer', {}, function (data) {
|
||||||
function (data) {
|
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/migrations');
|
c.redirect('#/tools/migrations');
|
||||||
}, 'POST')
|
})
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c.api('/migrations/migrate',
|
c.api('POST', '/migrations/migrate', {}, function (data) {
|
||||||
function (data) {
|
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/migrations');
|
c.redirect('#/tools/migrations');
|
||||||
}, 'POST')
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -352,10 +346,10 @@
|
||||||
y18n.t('migrations'),
|
y18n.t('migrations'),
|
||||||
y18n.t('confirm_migrations_skip'),
|
y18n.t('confirm_migrations_skip'),
|
||||||
function(){
|
function(){
|
||||||
c.api('/migrations/migrate?skip&targets=' + c.params['migration_id'], function(data) {
|
c.api('POST', '/migrations/migrate?skip&targets=' + c.params['migration_id'], {}, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/migrations');
|
c.redirect('#/tools/migrations');
|
||||||
}, 'POST');
|
});
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -366,7 +360,7 @@
|
||||||
|
|
||||||
// List available apps lists
|
// List available apps lists
|
||||||
app.get('#/tools/appslists', function (c) {
|
app.get('#/tools/appslists', function (c) {
|
||||||
c.api('/appslists', function(data) {
|
c.api('GET', '/appslists', {}, function(data) {
|
||||||
list = [];
|
list = [];
|
||||||
$.each(data, function(listname, listinfo) {
|
$.each(data, function(listname, listinfo) {
|
||||||
list.push({
|
list.push({
|
||||||
|
@ -379,7 +373,7 @@
|
||||||
c.view('tools/tools_appslists_list', {
|
c.view('tools/tools_appslists_list', {
|
||||||
appslists: list
|
appslists: list
|
||||||
});
|
});
|
||||||
}, 'GET');
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add a new apps list
|
// Add a new apps list
|
||||||
|
@ -389,15 +383,15 @@
|
||||||
'url' : c.params['appslist_url']
|
'url' : c.params['appslist_url']
|
||||||
}
|
}
|
||||||
|
|
||||||
c.api('/appslists', function(data) {
|
c.api('PUT', '/appslists', list, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/appslists/' + list.name);
|
c.redirect('#/tools/appslists/' + list.name);
|
||||||
}, 'PUT', list);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Show appslist info and operations
|
// Show appslist info and operations
|
||||||
app.get('#/tools/appslists/:appslist', function (c) {
|
app.get('#/tools/appslists/:appslist', function (c) {
|
||||||
c.api('/appslists', function(data) {
|
c.api('GET', '/appslists', {}, function(data) {
|
||||||
if (typeof data[c.params['appslist']] !== 'undefined') {
|
if (typeof data[c.params['appslist']] !== 'undefined') {
|
||||||
list = {
|
list = {
|
||||||
'name' : c.params['appslist'],
|
'name' : c.params['appslist'],
|
||||||
|
@ -412,22 +406,22 @@
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/appslists');
|
c.redirect('#/tools/appslists');
|
||||||
}
|
}
|
||||||
}, 'GET');
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Refresh available apps list
|
// Refresh available apps list
|
||||||
app.get('#/tools/appslists/refresh', function (c) {
|
app.get('#/tools/appslists/refresh', function (c) {
|
||||||
c.api('/appslists', function(data) {
|
c.api('PUT', '/appslists', {}, function(data) {
|
||||||
// c.redirect(store.get('path'));
|
// c.redirect(store.get('path'));
|
||||||
c.redirect('#/apps/install');
|
c.redirect('#/apps/install');
|
||||||
}, 'PUT');
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Refresh specific apps list
|
// Refresh specific apps list
|
||||||
app.get('#/tools/appslists/:appslist/refresh', function (c) {
|
app.get('#/tools/appslists/:appslist/refresh', function (c) {
|
||||||
c.api('/appslists', function(data) {
|
c.api('PUT', '/appslists', {'name' : c.params['appslist']}, function(data) {
|
||||||
c.redirect('#/tools/appslists');
|
c.redirect('#/tools/appslists');
|
||||||
}, 'PUT', {'name' : c.params['appslist']});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove apps list
|
// Remove apps list
|
||||||
|
@ -436,9 +430,9 @@
|
||||||
y18n.t('appslist'),
|
y18n.t('appslist'),
|
||||||
y18n.t('appslists_confirm_remove', [c.params['app']]),
|
y18n.t('appslists_confirm_remove', [c.params['app']]),
|
||||||
function() {
|
function() {
|
||||||
c.api('/appslists', function() {
|
c.api('DELETE', '/appslists', {'name' : c.params['appslist']}, function() {
|
||||||
c.redirect('#/tools/appslists');
|
c.redirect('#/tools/appslists');
|
||||||
}, 'DELETE', {'name' : c.params['appslist']});
|
});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
|
|
||||||
// List existing users
|
// List existing users
|
||||||
app.get('#/users', function (c) {
|
app.get('#/users', function (c) {
|
||||||
c.api('/users', function(data) { // http://api.yunohost.org/#!/user/user_list_get_3
|
c.api('GET', '/users', {}, function(data) {
|
||||||
c.view('user/user_list', data);
|
c.view('user/user_list', data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create user form
|
// Create user form
|
||||||
app.get('#/users/create', function (c) {
|
app.get('#/users/create', function (c) {
|
||||||
c.api('/domains', function(data) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
c.api('GET', '/domains', {}, function(data) {
|
||||||
|
|
||||||
// Password min length
|
// Password min length
|
||||||
data.password_min_length = PASSWORD_MIN_LENGTH;
|
data.password_min_length = PASSWORD_MIN_LENGTH;
|
||||||
|
@ -52,9 +52,9 @@
|
||||||
// Compute email field
|
// Compute email field
|
||||||
c.params['mail'] = c.params['email'] + c.params['domain'];
|
c.params['mail'] = c.params['email'] + c.params['domain'];
|
||||||
|
|
||||||
c.api('/users', function(data) { // http://api.yunohost.org/#!/user/user_create_post_2
|
c.api('POST', '/users', c.params.toHash(), function(data) {
|
||||||
c.redirect('#/users');
|
c.redirect('#/users');
|
||||||
}, 'POST', c.params.toHash());
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.flash('fail', y18n.t('passwords_dont_match'));
|
c.flash('fail', y18n.t('passwords_dont_match'));
|
||||||
|
@ -65,15 +65,15 @@
|
||||||
|
|
||||||
// Show user information
|
// Show user information
|
||||||
app.get('#/users/:user', function (c) {
|
app.get('#/users/:user', function (c) {
|
||||||
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_info_get_0
|
c.api('GET', '/users/'+ c.params['user'], {}, function(data) {
|
||||||
c.view('user/user_info', data);
|
c.view('user/user_info', data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Edit user form
|
// Edit user form
|
||||||
app.get('#/users/:user/edit', function (c) {
|
app.get('#/users/:user/edit', function (c) {
|
||||||
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_info_get_0
|
c.api('GET', '/users/'+ c.params['user'], {}, function(data) {
|
||||||
c.api('/domains', function(dataDomains) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
c.api('GET', '/domains', {}, function(dataDomains) {
|
||||||
|
|
||||||
// Password min length
|
// Password min length
|
||||||
data.password_min_length = PASSWORD_MIN_LENGTH;
|
data.password_min_length = PASSWORD_MIN_LENGTH;
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
// Update user information
|
// Update user information
|
||||||
app.put('#/users/:user', function (c) {
|
app.put('#/users/:user', function (c) {
|
||||||
// Get full user object
|
// Get full user object
|
||||||
c.api('/users/'+ c.params['user'], function(user) {
|
c.api('GET', '/users/'+ c.params['user'], {}, function(user) {
|
||||||
// Force unit or disable quota
|
// Force unit or disable quota
|
||||||
if (c.params['mailbox_quota']) {
|
if (c.params['mailbox_quota']) {
|
||||||
c.params['mailbox_quota'] += "M";
|
c.params['mailbox_quota'] += "M";
|
||||||
|
@ -175,9 +175,9 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
params['change_password'] = params['password'];
|
params['change_password'] = params['password'];
|
||||||
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_update_put_1
|
c.api('PUT', '/users/'+ c.params['user'], params, function(data) {
|
||||||
c.redirect('#/users/'+ c.params['user']);
|
c.redirect('#/users/'+ c.params['user']);
|
||||||
}, 'PUT', params);
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.flash('fail', y18n.t('passwords_dont_match'));
|
c.flash('fail', y18n.t('passwords_dont_match'));
|
||||||
|
@ -186,9 +186,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_update_put_1
|
c.api('PUT', '/users/'+ c.params['user'], params, function(data) {
|
||||||
c.redirect('#/users/'+ c.params['user']);
|
c.redirect('#/users/'+ c.params['user']);
|
||||||
}, 'PUT', params);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 'GET');
|
}, 'GET');
|
||||||
|
@ -209,9 +209,9 @@
|
||||||
y18n.t('users'),
|
y18n.t('users'),
|
||||||
confirmModalContent,
|
confirmModalContent,
|
||||||
function(){
|
function(){
|
||||||
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_delete_delete_4
|
c.api('DELETE', '/users/'+ c.params['user'], params, function(data) {
|
||||||
c.redirect('#/users');
|
c.redirect('#/users');
|
||||||
}, 'DELETE', params);
|
});
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
app.bind('login', function(e, data) {
|
app.bind('login', function(e, data) {
|
||||||
c.api('/users', function(data) {
|
c.api('GET', '/users', {}, function(data) {
|
||||||
// Warn admin if no users are created.
|
// Warn admin if no users are created.
|
||||||
if (typeof data.users !== 'undefined' && data.users.length === 0) {
|
if (typeof data.users !== 'undefined' && data.users.length === 0) {
|
||||||
c.flash('warning', y18n.t('warning_first_user'));
|
c.flash('warning', y18n.t('warning_first_user'));
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
c.flash('fail', y18n.t('error_retrieve_feed', [securityFeed]));
|
c.flash('fail', y18n.t('error_retrieve_feed', [securityFeed]));
|
||||||
});
|
});
|
||||||
|
|
||||||
c.api("/diagnosis", function(data) {
|
c.api("GET", "/diagnosis", {}, function(data) {
|
||||||
versions = data.packages;
|
versions = data.packages;
|
||||||
$('#yunohost-version').html(y18n.t('footer_version', [versions.yunohost.version, versions.yunohost.repo]));
|
$('#yunohost-version').html(y18n.t('footer_version', [versions.yunohost.version, versions.yunohost.repo]));
|
||||||
if (data.security["CVE-2017-5754"].vulnerable) {
|
if (data.security["CVE-2017-5754"].vulnerable) {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
function prefetchDomains(req) {
|
function prefetchDomains(req) {
|
||||||
// Preload domains list.
|
// Preload domains list.
|
||||||
req.params.domains = [];
|
req.params.domains = [];
|
||||||
req.api('/domains', function(data) {
|
req.api('GET', '/domains', {}, function(data) {
|
||||||
req.params.domains = data.domains;
|
req.params.domains = data.domains;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
function prefetchUsers(req){
|
function prefetchUsers(req){
|
||||||
// Preload users lists.
|
// Preload users lists.
|
||||||
req.params.users = [];
|
req.params.users = [];
|
||||||
req.api('/users', function(data) {
|
req.api('GET', '/users', {}, function(data) {
|
||||||
req.params.users = data.users;
|
req.params.users = data.users;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
// API call
|
// API call
|
||||||
api: function(uri, callback, method, data, websocket, callbackOnFailure) {
|
api: function(method, uri, data, callback, callbackOnFailure, websocket) {
|
||||||
c = this;
|
c = this;
|
||||||
|
|
||||||
method = typeof method !== 'undefined' ? method : 'GET';
|
method = typeof method !== 'undefined' ? method : 'GET';
|
||||||
|
|
|
@ -150,7 +150,7 @@
|
||||||
sam.store.set('url', window.location.hostname + '/yunohost/api');
|
sam.store.set('url', window.location.hostname + '/yunohost/api');
|
||||||
|
|
||||||
if (sam.store.get('connected')) {
|
if (sam.store.get('connected')) {
|
||||||
this.api('/diagnosis', function(diagnosis) {
|
this.api('GET', '/diagnosis', {}, function(diagnosis) {
|
||||||
versions = diagnosis.packages;
|
versions = diagnosis.packages;
|
||||||
$('#yunohost-version').html(y18n.t('footer_version', [versions.yunohost.version, versions.yunohost.repo]));
|
$('#yunohost-version').html(y18n.t('footer_version', [versions.yunohost.version, versions.yunohost.repo]));
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="actions-group">
|
<div class="actions-group">
|
||||||
<a href="javascript:void(null);" onclick="c.api('/logs/display?path={{#if log.name}}{{ log.name }}{{else}}{{ log.log_path }}{{/if}}&share', function(data) { $('div.loader').remove(); window.open(data.url, '_blank'); });" class="btn btn-success">
|
<a href="javascript:void(null);" onclick="c.api('GET', '/logs/display?path={{#if log.name}}{{ log.name }}{{else}}{{ log.log_path }}{{/if}}&share', {}, function(data) { $('div.loader').remove(); window.open(data.url, '_blank'); });" class="btn btn-success">
|
||||||
<span class="fa-cloud-upload"></span> {{t 'logs_share_with_yunopaste'}}
|
<span class="fa-cloud-upload"></span> {{t 'logs_share_with_yunopaste'}}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue