mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[enh] Variable assignment code cleanup. (#161)
This commit is contained in:
parent
bd1abcb89d
commit
6cbd81f2e6
12 changed files with 160 additions and 124 deletions
|
@ -11,7 +11,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('/apps?installed', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8
|
||||||
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});
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
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('/apps', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8
|
||||||
c.api('/apps?raw', function(dataraw) { // http://api.yunohost.org/#!/app/app_list_get_8
|
c.api('/apps?raw', function(dataraw) { // http://api.yunohost.org/#!/app/app_list_get_8
|
||||||
apps = [];
|
var apps = [];
|
||||||
$.each(data['apps'], function(k, v) {
|
$.each(data['apps'], function(k, v) {
|
||||||
// Keep only uninstalled apps, or multi-instance apps
|
// Keep only uninstalled apps, or multi-instance apps
|
||||||
if ((!v['installed'] || dataraw[v['id']].manifest.multi_instance) && !v['id'].match(/__[0-9]{1,5}$/)) {
|
if ((!v['installed'] || dataraw[v['id']].manifest.multi_instance) && !v['id'].match(/__[0-9]{1,5}$/)) {
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
|
|
||||||
// Helper function that build app installation form
|
// Helper function that build app installation form
|
||||||
app.helper('appInstallForm', function(appId, manifest, params) {
|
app.helper('appInstallForm', function(appId, manifest, params) {
|
||||||
data = {
|
var data = {
|
||||||
id: appId,
|
id: appId,
|
||||||
manifest: manifest
|
manifest: manifest
|
||||||
};
|
};
|
||||||
|
@ -286,10 +286,11 @@
|
||||||
|
|
||||||
// Clone a hidden input with empty value
|
// Clone a hidden input with empty value
|
||||||
// https://stackoverflow.com/questions/476426/submit-an-html-form-with-empty-checkboxes
|
// https://stackoverflow.com/questions/476426/submit-an-html-form-with-empty-checkboxes
|
||||||
inputClone = {};
|
var inputClone = {
|
||||||
inputClone.name = data.manifest.arguments.install[k].name;
|
name : data.manifest.arguments.install[k].name,
|
||||||
inputClone.inputType = 'hidden';
|
inputType : 'hidden',
|
||||||
inputClone.default = 0;
|
default : 0
|
||||||
|
};
|
||||||
data.manifest.arguments.install.push(inputClone);
|
data.manifest.arguments.install.push(inputClone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,13 +320,11 @@
|
||||||
// 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('/apps?raw', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8
|
||||||
|
|
||||||
c.appInstallForm(
|
c.appInstallForm(
|
||||||
c.params['app'],
|
c.params['app'],
|
||||||
data[c.params['app']].manifest,
|
data[c.params['app']].manifest,
|
||||||
c.params
|
c.params
|
||||||
);
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -333,11 +332,14 @@
|
||||||
app.post('#/apps', function(c) {
|
app.post('#/apps', function(c) {
|
||||||
// Warn admin if app is going to be installed on domain root.
|
// Warn admin if app is going to be installed on domain root.
|
||||||
if (c.params['path'] !== '/' || confirm(y18n.t('confirm_install_domain_root', [c.params['domain']]))) {
|
if (c.params['path'] !== '/' || confirm(y18n.t('confirm_install_domain_root', [c.params['domain']]))) {
|
||||||
params = { 'label': c.params['label'], 'app': c.params['app'] };
|
var params = {
|
||||||
delete c.params['label'];
|
label: c.params['label'],
|
||||||
delete c.params['app'];
|
app: c.params['app']
|
||||||
|
};
|
||||||
|
|
||||||
// Check for duplicate arg produced by empty checkbox. (See inputClone)
|
// Check for duplicate arg produced by empty checkbox. (See inputClone)
|
||||||
|
delete c.params['label'];
|
||||||
|
delete c.params['app'];
|
||||||
$.each(c.params, function(k, v) {
|
$.each(c.params, function(k, v) {
|
||||||
if (typeof(v) === 'object' && Array.isArray(v)) {
|
if (typeof(v) === 'object' && Array.isArray(v)) {
|
||||||
// And return only first value
|
// And return only first value
|
||||||
|
@ -346,6 +348,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
params['args'] = c.serialize(c.params.toHash());
|
params['args'] = c.serialize(c.params.toHash());
|
||||||
|
|
||||||
// Do not pass empty args.
|
// Do not pass empty args.
|
||||||
if (params['args'] === "") {
|
if (params['args'] === "") {
|
||||||
delete params['args'];
|
delete params['args'];
|
||||||
|
@ -365,7 +368,10 @@
|
||||||
// Install custom app from github
|
// Install custom app from github
|
||||||
app.post('#/apps/install/custom', function(c) {
|
app.post('#/apps/install/custom', function(c) {
|
||||||
|
|
||||||
params = { 'label': c.params['label'], 'app': c.params['url'] };
|
var params = {
|
||||||
|
label: c.params['label'],
|
||||||
|
app: c.params['url']
|
||||||
|
};
|
||||||
delete c.params['label'];
|
delete c.params['label'];
|
||||||
delete c.params['url'];
|
delete c.params['url'];
|
||||||
|
|
||||||
|
@ -475,7 +481,10 @@
|
||||||
y18n.t('applications'),
|
y18n.t('applications'),
|
||||||
y18n.t('confirm_access_remove_all', [c.params['app']]),
|
y18n.t('confirm_access_remove_all', [c.params['app']]),
|
||||||
function() {
|
function() {
|
||||||
params = {'apps': c.params['app'], 'users':[]};
|
var params = {
|
||||||
|
apps: c.params['app'],
|
||||||
|
users: []
|
||||||
|
};
|
||||||
c.api('/access?'+c.serialize(params), function(data) { // http://api.yunohost.org/#!/app/app_removeaccess_delete_12
|
c.api('/access?'+c.serialize(params), function(data) { // http://api.yunohost.org/#!/app/app_removeaccess_delete_12
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
||||||
|
@ -494,7 +503,10 @@
|
||||||
y18n.t('applications'),
|
y18n.t('applications'),
|
||||||
y18n.t('confirm_access_remove_user', [c.params['app'], c.params['user']]),
|
y18n.t('confirm_access_remove_user', [c.params['app'], c.params['user']]),
|
||||||
function() {
|
function() {
|
||||||
params = {'apps': c.params['app'], 'users': c.params['user']};
|
var params = {
|
||||||
|
apps: c.params['app'],
|
||||||
|
users: c.params['user']
|
||||||
|
};
|
||||||
c.api('/access?'+c.serialize(params), function(data) { // http://api.yunohost.org/#!/app/app_removeaccess_delete_12
|
c.api('/access?'+c.serialize(params), function(data) { // http://api.yunohost.org/#!/app/app_removeaccess_delete_12
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
c.redirect('#/apps/'+ c.params['app']+ '/access');
|
||||||
|
@ -513,7 +525,10 @@
|
||||||
y18n.t('applications'),
|
y18n.t('applications'),
|
||||||
y18n.t('confirm_access_add', [c.params['app']]),
|
y18n.t('confirm_access_add', [c.params['app']]),
|
||||||
function() {
|
function() {
|
||||||
params = {'apps': c.params['app'], 'users': null};
|
var params = {
|
||||||
|
apps: c.params['app'],
|
||||||
|
users: null
|
||||||
|
};
|
||||||
c.api('/access', function() { // http://api.yunohost.org/#!/app/app_addaccess_put_13
|
c.api('/access', function() { // http://api.yunohost.org/#!/app/app_addaccess_put_13
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
||||||
|
@ -528,7 +543,10 @@
|
||||||
|
|
||||||
// Grant access for a specific user
|
// Grant access for a specific user
|
||||||
app.post('#/apps/:app/access/add', function (c) {
|
app.post('#/apps/:app/access/add', function (c) {
|
||||||
params = {'users': c.params['user'], 'apps': c.params['app']};
|
var params = {
|
||||||
|
users: c.params['user'],
|
||||||
|
apps: c.params['app']
|
||||||
|
};
|
||||||
c.api('/access', function() { // http://api.yunohost.org/#!/app/app_addaccess_put_13
|
c.api('/access', function() { // http://api.yunohost.org/#!/app/app_addaccess_put_13
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
||||||
|
@ -541,7 +559,9 @@
|
||||||
y18n.t('applications'),
|
y18n.t('applications'),
|
||||||
y18n.t('confirm_access_clear', [c.params['app']]),
|
y18n.t('confirm_access_clear', [c.params['app']]),
|
||||||
function() {
|
function() {
|
||||||
params = {'apps': c.params['app']};
|
var params = {
|
||||||
|
apps: c.params['app']
|
||||||
|
};
|
||||||
c.api('/access', function() { //
|
c.api('/access', function() { //
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
c.redirect('#/apps/'+ c.params['app'] +'/access');
|
||||||
|
|
|
@ -18,14 +18,15 @@
|
||||||
'system_yunohost',
|
'system_yunohost',
|
||||||
'system_nginx'
|
'system_nginx'
|
||||||
];
|
];
|
||||||
|
|
||||||
// Storage list
|
// Storage list
|
||||||
app.get('#/backup', function (c) {
|
app.get('#/backup', function (c) {
|
||||||
var storages = [];
|
var storages = [];
|
||||||
var item = {
|
var item = {
|
||||||
id: 'local',
|
id: 'local',
|
||||||
name: y18n.t('local_archives'),
|
name: y18n.t('local_archives'),
|
||||||
uri: '/home/yunohost.backup/'
|
uri: '/home/yunohost.backup/'
|
||||||
};
|
};
|
||||||
storages.push(item);
|
storages.push(item);
|
||||||
|
|
||||||
c.view('backup/backup', {'storages':storages});
|
c.view('backup/backup', {'storages':storages});
|
||||||
|
@ -44,14 +45,14 @@
|
||||||
|
|
||||||
// Create a backup
|
// Create a backup
|
||||||
app.get('#/backup/:storage/create', function (c) {
|
app.get('#/backup/:storage/create', function (c) {
|
||||||
var data=[];
|
var data = [];
|
||||||
data['storage']={
|
data['storage'] = {
|
||||||
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('/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('/apps?with_backup', function(apps_list) {
|
||||||
data['apps'] = apps_list.apps;
|
data['apps'] = apps_list.apps;
|
||||||
c.view('backup/backup_create', data);
|
c.view('backup/backup_create', data);
|
||||||
|
@ -74,13 +75,13 @@
|
||||||
y18n.t('backup'),
|
y18n.t('backup'),
|
||||||
y18n.t('confirm_restore', [c.params['archive']]),
|
y18n.t('confirm_restore', [c.params['archive']]),
|
||||||
$.proxy(function(c){
|
$.proxy(function(c){
|
||||||
var params=c.ungroupHooks(c.params['hooks'],c.params['apps']);
|
var params = c.ungroupHooks(c.params['hooks'],c.params['apps']);
|
||||||
params['force']='';
|
params['force'] = '';
|
||||||
c.api('/backup/restore/'+c.params['archive'], function(data) {
|
c.api('/backup/restore/'+c.params['archive'], 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);
|
}, 'POST', params);
|
||||||
},this,c),
|
}, this, c),
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
|
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
|
||||||
|
@ -127,14 +128,14 @@
|
||||||
// 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('/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')
|
||||||
};
|
};
|
||||||
data['other_storages']=[];
|
data.other_storages = [];
|
||||||
data['name']=c.params['archive'];
|
data.name = c.params['archive'];
|
||||||
data['hooks']=c.groupHooks(Object.keys(data['system']));
|
data.hooks = c.groupHooks(Object.keys(data['system']));
|
||||||
data['items']=(data['hooks']!={} || data['apps']!=[]);
|
data.items = (data['hooks']!={} || data['apps']!=[]);
|
||||||
c.view('backup/backup_info', data);
|
c.view('backup/backup_info', data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -142,16 +143,16 @@
|
||||||
// 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('/backup/archives?with_info', function(data) {
|
||||||
data['storage']={
|
data.storage = {
|
||||||
id:'local',
|
id: 'local',
|
||||||
name:y18n.t('local_archives')
|
name: y18n.t('local_archives')
|
||||||
};
|
};
|
||||||
data['archives2']=[];
|
data.archives2 = [];
|
||||||
$.each(data['archives'], function(name, info) {
|
$.each(data['archives'], function(name, info) {
|
||||||
info['name']=name;
|
info.name = name;
|
||||||
data['archives2'].unshift(info)
|
data.archives2.unshift(info)
|
||||||
});
|
});
|
||||||
data['archives']=data['archives2'];
|
data.archives = data.archives2;
|
||||||
c.view('backup/backup_list', data);
|
c.view('backup/backup_list', data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
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('/domains', function(data) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
||||||
c.api('/domains/main', function(data2) {
|
c.api('/domains/main', function(data2) {
|
||||||
domains = [];
|
var domains = [];
|
||||||
$.each(data.domains, function(k, domain) {
|
$.each(data.domains, function(k, domain) {
|
||||||
domains.push({
|
domains.push({
|
||||||
url: domain,
|
url: domain,
|
||||||
|
@ -21,11 +21,14 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// Do not show main domain form if we have only 1 domain
|
// Do not show main domain form if we have only 1 domain
|
||||||
main_domain_form = (domains.length > 1) ? true: false;
|
var main_domain_form = (domains.length > 1) ? true: false;
|
||||||
|
|
||||||
// Sort domains with main domain first
|
// Sort domains with main domain first
|
||||||
domains.sort(function(a, b){ return -2*(a.main) + 1; });
|
domains.sort(function(a, b){ return -2*(a.main) + 1; });
|
||||||
c.view('domain/domain_list', {domains: domains, main_domain_form: main_domain_form});
|
c.view('domain/domain_list', {
|
||||||
|
domains: domains,
|
||||||
|
main_domain_form: main_domain_form
|
||||||
|
});
|
||||||
}, 'PUT');
|
}, 'PUT');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -40,10 +43,10 @@
|
||||||
c.params.ddomains = ['.nohost.me', '.noho.st'];
|
c.params.ddomains = ['.nohost.me', '.noho.st'];
|
||||||
})
|
})
|
||||||
.always(function() {
|
.always(function() {
|
||||||
data = {
|
var data = {
|
||||||
ddomains : c.params.ddomains,
|
ddomains: c.params.ddomains,
|
||||||
domains : c.params.domains,
|
domains: c.params.domains,
|
||||||
allowDyndnsDomain : true
|
allowDyndnsDomain: true
|
||||||
};
|
};
|
||||||
|
|
||||||
// Allow only 1 DynDns domain.
|
// Allow only 1 DynDns domain.
|
||||||
|
@ -60,17 +63,18 @@
|
||||||
|
|
||||||
// Add domain (POST)
|
// Add domain (POST)
|
||||||
app.post('#/domains/add', function (c) {
|
app.post('#/domains/add', function (c) {
|
||||||
|
var params = {};
|
||||||
|
var endurl = '';
|
||||||
if (c.params['domain'] === '') {
|
if (c.params['domain'] === '') {
|
||||||
if (c.params['ddomain'] === '') {
|
if (c.params['ddomain'] === '') {
|
||||||
c.flash('fail', y18n.t('error_select_domain'));
|
c.flash('fail', y18n.t('error_select_domain'));
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/domains/add');
|
c.redirect('#/domains/add');
|
||||||
}
|
}
|
||||||
params = {'domain': c.params['ddomain'] + c.params['ddomain-ext']};
|
params.domain = c.params['ddomain'] + c.params['ddomain-ext'];
|
||||||
endurl = 'dyndns';
|
endurl = 'dyndns';
|
||||||
} else {
|
} else {
|
||||||
params = { 'domain': c.params['domain'] };
|
params.domain = c.params['domain'];
|
||||||
endurl = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.api('/domains?'+endurl, function(data) { // http://api.yunohost.org/#!/domain/domain_add_post_1
|
c.api('/domains?'+endurl, function(data) { // http://api.yunohost.org/#!/domain/domain_add_post_1
|
||||||
|
@ -87,16 +91,15 @@
|
||||||
// for apps installed) should be removed once letsencrypt_ynh
|
// for apps installed) should be removed once letsencrypt_ynh
|
||||||
// is not used by many people anymore. Probably around 07/2017
|
// is not used by many people anymore. Probably around 07/2017
|
||||||
// or end of 2017...
|
// or end of 2017...
|
||||||
enable_cert_management_ = true;
|
var enable_cert_management_ = true;
|
||||||
$.each(data['apps'], function(k, v) {
|
$.each(data['apps'], function(k, v) {
|
||||||
if (v.id == "letsencrypt")
|
if (v.id == "letsencrypt") {
|
||||||
{
|
|
||||||
enable_cert_management_ = false;
|
enable_cert_management_ = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
domain = {
|
var domain = {
|
||||||
name: c.params['domain'],
|
name: c.params['domain'],
|
||||||
main: (c.params['domain'] == dataMain.current_main_domain) ? true : false,
|
main: (c.params['domain'] == dataMain.current_main_domain) ? true : false,
|
||||||
url: "https://"+c.params['domain'],
|
url: "https://"+c.params['domain'],
|
||||||
|
@ -110,10 +113,10 @@
|
||||||
// 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('/domains/' + c.params['domain'] + '/dns', function(data) {
|
||||||
domain = {
|
var domain = {
|
||||||
name: c.params['domain'],
|
name: c.params['domain'],
|
||||||
dns: data
|
dns: data
|
||||||
}
|
};
|
||||||
c.view('domain/domain_dns', domain);
|
c.view('domain/domain_dns', domain);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -122,16 +125,15 @@
|
||||||
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('/domains/cert-status/' + c.params['domain'] + '?full', function(data) {
|
||||||
|
|
||||||
s = data["certificates"][c.params['domain']]
|
var s = data["certificates"][c.params['domain']];
|
||||||
|
var status_ = {
|
||||||
status_ = {}
|
CA_type: s.CA_type.verbose,
|
||||||
status_.CA_type = s.CA_type.verbose
|
CA_name: s.CA_name,
|
||||||
status_.CA_name = s.CA_name
|
validity: s.validity,
|
||||||
status_.validity = s.validity
|
ACME_eligible: s.ACME_eligible
|
||||||
status_.ACME_eligible = s.ACME_eligible
|
};
|
||||||
|
|
||||||
switch (s.summary.code)
|
switch (s.summary.code) {
|
||||||
{
|
|
||||||
case "critical" :
|
case "critical" :
|
||||||
status_.alert_type = "danger";
|
status_.alert_type = "danger";
|
||||||
status_.alert_icon = "exclamation-circle" ;
|
status_.alert_icon = "exclamation-circle" ;
|
||||||
|
@ -143,14 +145,12 @@
|
||||||
status_.alert_message = y18n.t('certificate_alert_selfsigned');
|
status_.alert_message = y18n.t('certificate_alert_selfsigned');
|
||||||
break;
|
break;
|
||||||
case "attention" :
|
case "attention" :
|
||||||
if (status_.CA_type == "lets-encrypt")
|
if (status_.CA_type == "lets-encrypt") {
|
||||||
{
|
|
||||||
status_.alert_type = "warning";
|
status_.alert_type = "warning";
|
||||||
status_.alert_icon = "clock-o";
|
status_.alert_icon = "clock-o";
|
||||||
status_.alert_message = y18n.t('certificate_alert_letsencrypt_about_to_expire');
|
status_.alert_message = y18n.t('certificate_alert_letsencrypt_about_to_expire');
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
status_.alert_type = "danger";
|
status_.alert_type = "danger";
|
||||||
status_.alert_icon = "clock-o";
|
status_.alert_icon = "clock-o";
|
||||||
status_.alert_message = y18n.t('certificate_alert_about_to_expire');
|
status_.alert_message = y18n.t('certificate_alert_about_to_expire');
|
||||||
|
@ -173,14 +173,14 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
actions_enabled = {};
|
var actions_enabled = {
|
||||||
actions_enabled.install_letsencrypt = false;
|
install_letsencrypt: false,
|
||||||
actions_enabled.manual_renew_letsencrpt = false;
|
manual_renew_letsencrpt: false,
|
||||||
actions_enabled.regen_selfsigned = false;
|
regen_selfsigned: false,
|
||||||
actions_enabled.replace_with_selfsigned = false;
|
replace_with_selfsigned: false
|
||||||
|
};
|
||||||
|
|
||||||
switch (s.CA_type.code)
|
switch (s.CA_type.code) {
|
||||||
{
|
|
||||||
case "self-signed" :
|
case "self-signed" :
|
||||||
actions_enabled.install_letsencrypt = true;
|
actions_enabled.install_letsencrypt = true;
|
||||||
actions_enabled.regen_selfsigned = true;
|
actions_enabled.regen_selfsigned = true;
|
||||||
|
@ -305,14 +305,16 @@
|
||||||
y18n.t('domains'),
|
y18n.t('domains'),
|
||||||
y18n.t('confirm_change_maindomain'),
|
y18n.t('confirm_change_maindomain'),
|
||||||
function(){
|
function(){
|
||||||
params = {'new_domain': c.params['domain']};
|
var params = {
|
||||||
|
new_domain: c.params['domain']
|
||||||
|
};
|
||||||
c.api('/domains/main', function(data) { // http://api.yunohost.org/#!/tools/tools_maindomain_put_1
|
c.api('/domains/main', function(data) { // http://api.yunohost.org/#!/tools/tools_maindomain_put_1
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/domains');
|
c.redirect('#/domains');
|
||||||
}, 'PUT', params);
|
}, 'PUT', params);
|
||||||
|
|
||||||
// Wait 15s and refresh the page
|
// Wait 15s and refresh the page
|
||||||
refreshDomain = window.setTimeout(function(){
|
var refreshDomain = window.setTimeout(function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/domains');
|
c.redirect('#/domains');
|
||||||
}, 15000);
|
}, 15000);
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
app.get('#/tools/firewall', function (c) {
|
app.get('#/tools/firewall', function (c) {
|
||||||
c.api('/firewall?raw', function(data) {
|
c.api('/firewall?raw', function(data) {
|
||||||
var firewall = {
|
var firewall = {
|
||||||
ports : {},
|
ports: {},
|
||||||
upnp : false
|
upnp: false
|
||||||
};
|
};
|
||||||
|
|
||||||
// Reorganize ports
|
// Reorganize ports
|
||||||
|
@ -41,7 +41,9 @@
|
||||||
// confirm_upnp_enable and confirm_upnp_disable
|
// confirm_upnp_enable and confirm_upnp_disable
|
||||||
y18n.t('confirm_upnp_' + c.params['action'].toLowerCase()),
|
y18n.t('confirm_upnp_' + c.params['action'].toLowerCase()),
|
||||||
function(){
|
function(){
|
||||||
params = {'action' : c.params['action']};
|
var params = {
|
||||||
|
action : c.params['action']
|
||||||
|
};
|
||||||
c.api('/firewall/upnp', function(data) {
|
c.api('/firewall/upnp', function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/tools/firewall');
|
c.redirect('#/tools/firewall');
|
||||||
|
@ -57,8 +59,8 @@
|
||||||
// Toggle port status helper (available in every controller)
|
// Toggle port status helper (available in every controller)
|
||||||
app.helper('togglePort', function(port, protocol, connection, action) {
|
app.helper('togglePort', function(port, protocol, connection, action) {
|
||||||
var method = null,
|
var method = null,
|
||||||
endurl = [],
|
endurl = [],
|
||||||
c = this
|
c = this
|
||||||
;
|
;
|
||||||
|
|
||||||
if (port != parseInt(port) || port < 0 || port > 65535) {
|
if (port != parseInt(port) || port < 0 || port > 65535) {
|
||||||
|
@ -110,8 +112,8 @@
|
||||||
// --ipv6-only:
|
// --ipv6-only:
|
||||||
// --no-upnp:
|
// --no-upnp:
|
||||||
var params = {
|
var params = {
|
||||||
'port' : port,
|
port : port,
|
||||||
'protocol' : protocol,
|
protocol : protocol
|
||||||
};
|
};
|
||||||
c.api('/firewall/port?'+endurl, function(data) {
|
c.api('/firewall/port?'+endurl, function(data) {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
|
|
@ -35,9 +35,10 @@
|
||||||
|
|
||||||
// Loop through items in a reverse order (older first)
|
// Loop through items in a reverse order (older first)
|
||||||
$($('item', xml).get().reverse()).each(function(k, v) {
|
$($('item', xml).get().reverse()).each(function(k, v) {
|
||||||
var link=$('link', v).text();
|
var link = $('link', v).text();
|
||||||
if (typeof link == 'string' && link !== '' && link.charAt(0) == '/')
|
if (typeof link == 'string' && link !== '' && link.charAt(0) == '/') {
|
||||||
link=forumUrl+link;
|
link = forumUrl+link;
|
||||||
|
}
|
||||||
|
|
||||||
// var description=$('description', v).text();
|
// var description=$('description', v).text();
|
||||||
// description=description.replace('href="/','href="'+forumUrl+'/');
|
// description=description.replace('href="/','href="'+forumUrl+'/');
|
||||||
|
@ -138,8 +139,8 @@
|
||||||
// Store url from params, it could have change form 'run' state
|
// Store url from params, it could have change form 'run' state
|
||||||
store.set('url', c.params['domain'] +'/yunohost/api');
|
store.set('url', c.params['domain'] +'/yunohost/api');
|
||||||
|
|
||||||
params = {
|
var params = {
|
||||||
'password': c.params['password']
|
password: c.params['password']
|
||||||
};
|
};
|
||||||
c.api('/login', function(data) {
|
c.api('/login', function(data) {
|
||||||
store.set('connected', true);
|
store.set('connected', true);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// Server monitoring
|
// Server monitoring
|
||||||
app.get('#/tools/monitor', function (c) {
|
app.get('#/tools/monitor', function (c) {
|
||||||
monitorData = {};
|
var monitorData = {};
|
||||||
|
|
||||||
// Why this method ?
|
// Why this method ?
|
||||||
c.api('/services/glances', function(data) { // ?
|
c.api('/services/glances', function(data) { // ?
|
||||||
|
|
|
@ -25,10 +25,10 @@
|
||||||
$('#masthead').hide();
|
$('#masthead').hide();
|
||||||
$.get('https://dyndns.yunohost.org/domains', function() {})
|
$.get('https://dyndns.yunohost.org/domains', function() {})
|
||||||
.done(function(data){
|
.done(function(data){
|
||||||
c.params.ddomains = data.map(function(dom){return '.'+dom;});
|
c.params['ddomains'] = data.map(function(dom){return '.'+dom;});
|
||||||
})
|
})
|
||||||
.fail(function() {
|
.fail(function() {
|
||||||
c.params.ddomains = ['.nohost.me', '.noho.st'];
|
c.params['ddomains'] = ['.nohost.me', '.noho.st'];
|
||||||
})
|
})
|
||||||
.always(function() {
|
.always(function() {
|
||||||
c.view('postinstall/postinstall_2', c.params, function() {
|
c.view('postinstall/postinstall_2', c.params, function() {
|
||||||
|
@ -77,14 +77,16 @@
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/postinstall/domain');
|
c.redirect('#/postinstall/domain');
|
||||||
} else {
|
} else {
|
||||||
params = { 'domain': c.params['domain'].toLowerCase() };
|
var params = {
|
||||||
|
domain: c.params['domain'].toLowerCase()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
c.confirm(
|
c.confirm(
|
||||||
y18n.t('postinstall'),
|
y18n.t('postinstall'),
|
||||||
y18n.t('confirm_postinstall', [c.params['domain']]),
|
y18n.t('confirm_postinstall', [c.params['domain']]),
|
||||||
function(){
|
function(){
|
||||||
params['password'] = c.params['password'];
|
params.password = c.params['password'];
|
||||||
|
|
||||||
store.set('url', window.location.hostname +'/yunohost/api');
|
store.set('url', window.location.hostname +'/yunohost/api');
|
||||||
store.set('user', 'admin');
|
store.set('user', 'admin');
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
// All services status
|
// All services status
|
||||||
app.get('#/services', function (c) {
|
app.get('#/services', function (c) {
|
||||||
c.api('/services', function(data) { // ?
|
c.api('/services', function(data) { // ?
|
||||||
data2 = { 'services': [] };
|
var data2 = {
|
||||||
|
services: []
|
||||||
|
};
|
||||||
$.each(data, function(k, v) {
|
$.each(data, function(k, v) {
|
||||||
v.name = k;
|
v.name = k;
|
||||||
// Handlebars want booleans
|
// Handlebars want booleans
|
||||||
|
@ -29,7 +31,9 @@
|
||||||
// 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('/services/'+ c.params['service'], function(data) { // ?
|
||||||
data2 = { 'service': data };
|
var data2 = {
|
||||||
|
service: data
|
||||||
|
};
|
||||||
data2.service.name = c.params['service'];
|
data2.service.name = c.params['service'];
|
||||||
// Handlebars want booleans
|
// Handlebars want booleans
|
||||||
data2.service.is_loaded = (data.loaded=='enabled') ? true : false;
|
data2.service.is_loaded = (data.loaded=='enabled') ? true : false;
|
||||||
|
@ -44,7 +48,9 @@
|
||||||
|
|
||||||
// Service log
|
// Service log
|
||||||
app.get('#/services/:service/log', function (c) {
|
app.get('#/services/:service/log', function (c) {
|
||||||
params = { 'number': 50 };
|
var params = {
|
||||||
|
number: 50
|
||||||
|
};
|
||||||
c.api('/services/'+ c.params['service'] +'/log', function(data) { // ?
|
c.api('/services/'+ c.params['service'] +'/log', function(data) { // ?
|
||||||
data2 = { 'logs': [], 'name': c.params['service'] };
|
data2 = { 'logs': [], 'name': c.params['service'] };
|
||||||
$.each(data, function(k, v) {
|
$.each(data, function(k, v) {
|
||||||
|
@ -62,7 +68,8 @@
|
||||||
// confirm_service_start, confirm_service_stop, confirm_service_enable and confirm_service_disable
|
// confirm_service_start, confirm_service_stop, confirm_service_enable and confirm_service_disable
|
||||||
y18n.t('confirm_service_' + c.params['action'].toLowerCase(), [c.params['service']]),
|
y18n.t('confirm_service_' + c.params['action'].toLowerCase(), [c.params['service']]),
|
||||||
function(){
|
function(){
|
||||||
var method = null, endurl = c.params['service'];
|
var method = null,
|
||||||
|
endurl = c.params['service'];
|
||||||
|
|
||||||
switch (c.params['action']) {
|
switch (c.params['action']) {
|
||||||
case 'start':
|
case 'start':
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
// Update administration password (PUT)
|
// Update administration password (PUT)
|
||||||
app.put('#/tools/adminpw', function (c) {
|
app.put('#/tools/adminpw', function (c) {
|
||||||
params = {};
|
var params = {};
|
||||||
$.each(c.params.toHash(), function(key, value) {
|
$.each(c.params.toHash(), function(key, value) {
|
||||||
if (value !== '') { params[key] = value; }
|
if (value !== '') { params[key] = value; }
|
||||||
});
|
});
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
// System update & upgrade
|
// System update & upgrade
|
||||||
app.get('#/update', function (c) {
|
app.get('#/update', function (c) {
|
||||||
c.api('/update', function(data) {
|
c.api('/update', function(data) {
|
||||||
packagesLength = data.packages.length;
|
var packagesLength = data.packages.length;
|
||||||
for(var i = 0; i < packagesLength; i++) {
|
for(var i = 0; i < packagesLength; i++) {
|
||||||
data.packages[i].delayed = false;
|
data.packages[i].delayed = false;
|
||||||
data.packages[i].changelog = data.packages[i].changelog.replace(/\n/g, '<br />');
|
data.packages[i].changelog = data.packages[i].changelog.replace(/\n/g, '<br />');
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
// 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(){
|
||||||
endurl = '';
|
var endurl = '';
|
||||||
if (c.params['type'] == 'packages') {endurl = 'ignore_apps';}
|
if (c.params['type'] == 'packages') {endurl = 'ignore_apps';}
|
||||||
else if (c.params['type'] == 'apps') {endurl = 'ignore_packages';}
|
else if (c.params['type'] == 'apps') {endurl = 'ignore_packages';}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
|
|
||||||
// Security feed
|
// Security feed
|
||||||
app.get('#/tools/security-feed', function (c) {
|
app.get('#/tools/security-feed', function (c) {
|
||||||
data = {
|
var data = {
|
||||||
items: []
|
items: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,11 +125,12 @@
|
||||||
.done(function(xml){
|
.done(function(xml){
|
||||||
// Loop through items
|
// Loop through items
|
||||||
$('item', xml).each(function(k, v) {
|
$('item', xml).each(function(k, v) {
|
||||||
var link=$('link', v)[0].innerHTML;
|
var link = $('link', v)[0].innerHTML;
|
||||||
if (typeof link == 'string' && link !== '' && link.charAt(0) == '/')
|
if (typeof link == 'string' && link !== '' && link.charAt(0) == '/') {
|
||||||
link=forumUrl+link;
|
link = forumUrl+link;
|
||||||
var description=$('description', v)[0].textContent;
|
}
|
||||||
description=description.replace('href="/','href="'+forumUrl+'/');
|
var description = $('description', v)[0].textContent;
|
||||||
|
description = description.replace('href="/','href="'+forumUrl+'/');
|
||||||
|
|
||||||
var item = {
|
var item = {
|
||||||
guid: $('guid', v)[0].innerHTML,
|
guid: $('guid', v)[0].innerHTML,
|
||||||
|
@ -159,9 +160,9 @@
|
||||||
// Diagnosis
|
// Diagnosis
|
||||||
app.get('#/tools/diagnosis(/:private)?', function (c) {
|
app.get('#/tools/diagnosis(/:private)?', function (c) {
|
||||||
// See http://sammyjs.org/docs/routes for splat documentation
|
// See http://sammyjs.org/docs/routes for splat documentation
|
||||||
private = (c.params.splat[0] == 'private');
|
var private = (c.params.splat[0] == 'private');
|
||||||
|
|
||||||
endurl = (private) ? '?private' : '';
|
var endurl = (private) ? '?private' : '';
|
||||||
c.api('/diagnosis'+endurl, function(diagnosis) {
|
c.api('/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),
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
data.password_min_length = PASSWORD_MIN_LENGTH;
|
data.password_min_length = PASSWORD_MIN_LENGTH;
|
||||||
|
|
||||||
// User email use a fake splitted field
|
// User email use a fake splitted field
|
||||||
email = data.mail.split('@');
|
var email = data.mail.split('@');
|
||||||
data.email = {
|
data.email = {
|
||||||
username : email[0],
|
username : email[0],
|
||||||
domain : email[1]
|
domain : email[1]
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
c.params['mailalias'] = c.params['mailforward'] = '';
|
c.params['mailalias'] = c.params['mailforward'] = '';
|
||||||
|
|
||||||
// Remove empty inputs
|
// Remove empty inputs
|
||||||
params = {};
|
var params = {};
|
||||||
$.each(c.params.toHash(), function(key, value) {
|
$.each(c.params.toHash(), function(key, value) {
|
||||||
if (value.length > 0 && key !== 'user') { params[key] = value; }
|
if (value.length > 0 && key !== 'user') { params[key] = value; }
|
||||||
});
|
});
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
}, 1500);
|
}, 1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
loaded = false;
|
app.loaded = false;
|
||||||
if ($('div.loader').length === 0) {
|
if ($('div.loader').length === 0) {
|
||||||
$('#main').append('<div class="loader loader-content"></div>');
|
$('#main').append('<div class="loader loader-content"></div>');
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
if (websocket) {
|
if (websocket) {
|
||||||
|
|
||||||
// Open a WebSocket connection to retrieve live messages from the moulinette
|
// Open a WebSocket connection to retrieve live messages from the moulinette
|
||||||
ws = new WebSocket('wss://'+ store.get('url') +'/messages');
|
var ws = new WebSocket('wss://'+ store.get('url') +'/messages');
|
||||||
ws.onmessage = function(evt) {
|
ws.onmessage = function(evt) {
|
||||||
// console.log(evt.data);
|
// console.log(evt.data);
|
||||||
$.each($.parseJSON(evt.data), function(k, v) {
|
$.each($.parseJSON(evt.data), function(k, v) {
|
||||||
|
@ -189,14 +189,14 @@
|
||||||
callback = typeof callback !== 'undefined' ? callback : function() {};
|
callback = typeof callback !== 'undefined' ? callback : function() {};
|
||||||
enableSlide = (typeof enableSlide !== 'undefined') ? enableSlide : true; // Change to false to disable animation
|
enableSlide = (typeof enableSlide !== 'undefined') ? enableSlide : true; // Change to false to disable animation
|
||||||
|
|
||||||
loaded = true;
|
app.loaded = true;
|
||||||
|
|
||||||
// Hide loader and modal
|
// Hide loader and modal
|
||||||
$('div.loader').remove();
|
$('div.loader').remove();
|
||||||
$('#modal').modal('hide');
|
$('#modal').modal('hide');
|
||||||
|
|
||||||
// Render content
|
// Render content
|
||||||
rendered = this.render('views/'+ view +'.ms', data);
|
var rendered = this.render('views/'+ view +'.ms', data);
|
||||||
|
|
||||||
// Update content helper
|
// Update content helper
|
||||||
var leSwap = function() {
|
var leSwap = function() {
|
||||||
|
@ -254,7 +254,7 @@
|
||||||
cancelCallback = typeof cancelCallback !== 'undefined' ? cancelCallback : function() {};
|
cancelCallback = typeof cancelCallback !== 'undefined' ? cancelCallback : function() {};
|
||||||
|
|
||||||
// Get modal element
|
// Get modal element
|
||||||
box = $('#modal');
|
var box = $('#modal');
|
||||||
|
|
||||||
// Modal title
|
// Modal title
|
||||||
if (typeof title === 'string' && title.length) {
|
if (typeof title === 'string' && title.length) {
|
||||||
|
@ -312,8 +312,8 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
groupHooks: function(hooks) {
|
groupHooks: function(hooks) {
|
||||||
data={};
|
var data = {};
|
||||||
var rules=[
|
var rules = [
|
||||||
{
|
{
|
||||||
id:'configuration',
|
id:'configuration',
|
||||||
isIn:function (hook) {
|
isIn:function (hook) {
|
||||||
|
@ -350,7 +350,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
ungroupHooks: function(hooks,apps) {
|
ungroupHooks: function(hooks,apps) {
|
||||||
var data={};
|
var data = {};
|
||||||
data['apps'] = apps || [];
|
data['apps'] = apps || [];
|
||||||
data['hooks'] = hooks || [];
|
data['hooks'] = hooks || [];
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
defaultLocale: "en",
|
defaultLocale: "en",
|
||||||
locale: "en",
|
locale: "en",
|
||||||
placeholder: /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,
|
placeholder: /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,
|
||||||
translations: {},
|
translations: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue