From 6cbd81f2e644e7784b6fdbf9100e0161466d89ff Mon Sep 17 00:00:00 2001 From: opi Date: Mon, 24 Jul 2017 17:03:39 +0200 Subject: [PATCH 01/42] [enh] Variable assignment code cleanup. (#161) --- src/js/yunohost/controllers/apps.js | 56 +++++++++++----- src/js/yunohost/controllers/backup.js | 51 +++++++------- src/js/yunohost/controllers/domains.js | 78 +++++++++++----------- src/js/yunohost/controllers/firewall.js | 16 +++-- src/js/yunohost/controllers/home.js | 11 +-- src/js/yunohost/controllers/monitor.js | 2 +- src/js/yunohost/controllers/postinstall.js | 10 +-- src/js/yunohost/controllers/services.js | 15 +++-- src/js/yunohost/controllers/tools.js | 23 ++++--- src/js/yunohost/controllers/users.js | 4 +- src/js/yunohost/helpers.js | 16 ++--- src/js/yunohost/y18n.js | 2 +- 12 files changed, 160 insertions(+), 124 deletions(-) diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index 717ea785..13c66b4c 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -11,7 +11,7 @@ // List installed apps app.get('#/apps', function (c) { 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.view('app/app_list', {apps: apps}); }); @@ -21,7 +21,7 @@ app.get('#/apps/install', function (c) { 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 - apps = []; + var apps = []; $.each(data['apps'], function(k, v) { // Keep only uninstalled apps, or multi-instance apps 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 app.helper('appInstallForm', function(appId, manifest, params) { - data = { + var data = { id: appId, manifest: manifest }; @@ -286,10 +286,11 @@ // Clone a hidden input with empty value // https://stackoverflow.com/questions/476426/submit-an-html-form-with-empty-checkboxes - inputClone = {}; - inputClone.name = data.manifest.arguments.install[k].name; - inputClone.inputType = 'hidden'; - inputClone.default = 0; + var inputClone = { + name : data.manifest.arguments.install[k].name, + inputType : 'hidden', + default : 0 + }; data.manifest.arguments.install.push(inputClone); } @@ -319,13 +320,11 @@ // App installation form app.get('#/apps/install/:app', function (c) { c.api('/apps?raw', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8 - c.appInstallForm( c.params['app'], data[c.params['app']].manifest, c.params ); - }); }); @@ -333,11 +332,14 @@ app.post('#/apps', function(c) { // 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']]))) { - params = { 'label': c.params['label'], 'app': c.params['app'] }; - delete c.params['label']; - delete c.params['app']; + var params = { + label: c.params['label'], + app: c.params['app'] + }; // Check for duplicate arg produced by empty checkbox. (See inputClone) + delete c.params['label']; + delete c.params['app']; $.each(c.params, function(k, v) { if (typeof(v) === 'object' && Array.isArray(v)) { // And return only first value @@ -346,6 +348,7 @@ }); params['args'] = c.serialize(c.params.toHash()); + // Do not pass empty args. if (params['args'] === "") { delete params['args']; @@ -365,7 +368,10 @@ // Install custom app from github 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['url']; @@ -475,7 +481,10 @@ y18n.t('applications'), y18n.t('confirm_access_remove_all', [c.params['app']]), 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 store.clear('slide'); c.redirect('#/apps/'+ c.params['app']+ '/access'); @@ -494,7 +503,10 @@ y18n.t('applications'), y18n.t('confirm_access_remove_user', [c.params['app'], c.params['user']]), 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 store.clear('slide'); c.redirect('#/apps/'+ c.params['app']+ '/access'); @@ -513,7 +525,10 @@ y18n.t('applications'), y18n.t('confirm_access_add', [c.params['app']]), 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 store.clear('slide'); c.redirect('#/apps/'+ c.params['app'] +'/access'); @@ -528,7 +543,10 @@ // Grant access for a specific user 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 store.clear('slide'); c.redirect('#/apps/'+ c.params['app'] +'/access'); @@ -541,7 +559,9 @@ y18n.t('applications'), y18n.t('confirm_access_clear', [c.params['app']]), function() { - params = {'apps': c.params['app']}; + var params = { + apps: c.params['app'] + }; c.api('/access', function() { // store.clear('slide'); c.redirect('#/apps/'+ c.params['app'] +'/access'); diff --git a/src/js/yunohost/controllers/backup.js b/src/js/yunohost/controllers/backup.js index dad40d4d..9511b6fc 100644 --- a/src/js/yunohost/controllers/backup.js +++ b/src/js/yunohost/controllers/backup.js @@ -18,14 +18,15 @@ 'system_yunohost', 'system_nginx' ]; + // Storage list app.get('#/backup', function (c) { var storages = []; var item = { - id: 'local', - name: y18n.t('local_archives'), - uri: '/home/yunohost.backup/' - }; + id: 'local', + name: y18n.t('local_archives'), + uri: '/home/yunohost.backup/' + }; storages.push(item); c.view('backup/backup', {'storages':storages}); @@ -44,14 +45,14 @@ // Create a backup app.get('#/backup/:storage/create', function (c) { - var data=[]; - data['storage']={ + var data = []; + data['storage'] = { id:c.params['storage'], name:y18n.t('local_archives') }; c.api('/hooks/backup', function(hooks) { - data['hooks']=c.groupHooks(hooks['hooks']); - data['apps']={}; + data['hooks'] = c.groupHooks(hooks['hooks']); + data['apps'] = {}; c.api('/apps?with_backup', function(apps_list) { data['apps'] = apps_list.apps; c.view('backup/backup_create', data); @@ -74,13 +75,13 @@ y18n.t('backup'), y18n.t('confirm_restore', [c.params['archive']]), $.proxy(function(c){ - var params=c.ungroupHooks(c.params['hooks'],c.params['apps']); - params['force']=''; + var params = c.ungroupHooks(c.params['hooks'],c.params['apps']); + params['force'] = ''; c.api('/backup/restore/'+c.params['archive'], function(data) { store.clear('slide'); c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']); }, 'POST', params); - },this,c), + }, this, c), function(){ store.clear('slide'); c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']); @@ -127,14 +128,14 @@ // Get archive info app.get('#/backup/:storage/:archive', function (c) { c.api('/backup/archives/'+c.params['archive']+'?with_details', function(data) { - data['storage']={ - id:c.params['storage'], - name:y18n.t('local_archives') + data.storage = { + id: c.params['storage'], + name: y18n.t('local_archives') }; - data['other_storages']=[]; - data['name']=c.params['archive']; - data['hooks']=c.groupHooks(Object.keys(data['system'])); - data['items']=(data['hooks']!={} || data['apps']!=[]); + data.other_storages = []; + data.name = c.params['archive']; + data.hooks = c.groupHooks(Object.keys(data['system'])); + data.items = (data['hooks']!={} || data['apps']!=[]); c.view('backup/backup_info', data); }); }); @@ -142,16 +143,16 @@ // Archive list app.get('#/backup/:storage', function (c) { c.api('/backup/archives?with_info', function(data) { - data['storage']={ - id:'local', - name:y18n.t('local_archives') + data.storage = { + id: 'local', + name: y18n.t('local_archives') }; - data['archives2']=[]; + data.archives2 = []; $.each(data['archives'], function(name, info) { - info['name']=name; - data['archives2'].unshift(info) + info.name = name; + data.archives2.unshift(info) }); - data['archives']=data['archives2']; + data.archives = data.archives2; c.view('backup/backup_list', data); }); }); diff --git a/src/js/yunohost/controllers/domains.js b/src/js/yunohost/controllers/domains.js index e201ef00..94096d4b 100644 --- a/src/js/yunohost/controllers/domains.js +++ b/src/js/yunohost/controllers/domains.js @@ -12,7 +12,7 @@ app.get('#/domains', function (c) { c.api('/domains', function(data) { // http://api.yunohost.org/#!/domain/domain_list_get_2 c.api('/domains/main', function(data2) { - domains = []; + var domains = []; $.each(data.domains, function(k, domain) { domains.push({ url: domain, @@ -21,11 +21,14 @@ }); // 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 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'); }); }); @@ -40,10 +43,10 @@ c.params.ddomains = ['.nohost.me', '.noho.st']; }) .always(function() { - data = { - ddomains : c.params.ddomains, - domains : c.params.domains, - allowDyndnsDomain : true + var data = { + ddomains: c.params.ddomains, + domains: c.params.domains, + allowDyndnsDomain: true }; // Allow only 1 DynDns domain. @@ -60,17 +63,18 @@ // Add domain (POST) app.post('#/domains/add', function (c) { + var params = {}; + var endurl = ''; if (c.params['domain'] === '') { if (c.params['ddomain'] === '') { c.flash('fail', y18n.t('error_select_domain')); store.clear('slide'); c.redirect('#/domains/add'); } - params = {'domain': c.params['ddomain'] + c.params['ddomain-ext']}; + params.domain = c.params['ddomain'] + c.params['ddomain-ext']; endurl = 'dyndns'; } else { - params = { 'domain': c.params['domain'] }; - endurl = ''; + params.domain = c.params['domain']; } 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 // is not used by many people anymore. Probably around 07/2017 // or end of 2017... - enable_cert_management_ = true; + var enable_cert_management_ = true; $.each(data['apps'], function(k, v) { - if (v.id == "letsencrypt") - { + if (v.id == "letsencrypt") { enable_cert_management_ = false; } }); - domain = { + var domain = { name: c.params['domain'], main: (c.params['domain'] == dataMain.current_main_domain) ? true : false, url: "https://"+c.params['domain'], @@ -110,10 +113,10 @@ // Domain DNS app.get('#/domains/:domain/dns', function (c) { c.api('/domains/' + c.params['domain'] + '/dns', function(data) { - domain = { + var domain = { name: c.params['domain'], dns: data - } + }; c.view('domain/domain_dns', domain); }); }); @@ -122,16 +125,15 @@ app.get('#/domains/:domain/cert-management', function (c) { c.api('/domains/cert-status/' + c.params['domain'] + '?full', function(data) { - s = data["certificates"][c.params['domain']] - - status_ = {} - status_.CA_type = s.CA_type.verbose - status_.CA_name = s.CA_name - status_.validity = s.validity - status_.ACME_eligible = s.ACME_eligible + var s = data["certificates"][c.params['domain']]; + var status_ = { + CA_type: s.CA_type.verbose, + CA_name: s.CA_name, + validity: s.validity, + ACME_eligible: s.ACME_eligible + }; - switch (s.summary.code) - { + switch (s.summary.code) { case "critical" : status_.alert_type = "danger"; status_.alert_icon = "exclamation-circle" ; @@ -143,14 +145,12 @@ status_.alert_message = y18n.t('certificate_alert_selfsigned'); break; case "attention" : - if (status_.CA_type == "lets-encrypt") - { + if (status_.CA_type == "lets-encrypt") { status_.alert_type = "warning"; status_.alert_icon = "clock-o"; status_.alert_message = y18n.t('certificate_alert_letsencrypt_about_to_expire'); } - else - { + else { status_.alert_type = "danger"; status_.alert_icon = "clock-o"; status_.alert_message = y18n.t('certificate_alert_about_to_expire'); @@ -173,14 +173,14 @@ break; } - actions_enabled = {}; - actions_enabled.install_letsencrypt = false; - actions_enabled.manual_renew_letsencrpt = false; - actions_enabled.regen_selfsigned = false; - actions_enabled.replace_with_selfsigned = false; + var actions_enabled = { + install_letsencrypt: false, + manual_renew_letsencrpt: false, + regen_selfsigned: false, + replace_with_selfsigned: false + }; - switch (s.CA_type.code) - { + switch (s.CA_type.code) { case "self-signed" : actions_enabled.install_letsencrypt = true; actions_enabled.regen_selfsigned = true; @@ -305,14 +305,16 @@ y18n.t('domains'), y18n.t('confirm_change_maindomain'), 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 store.clear('slide'); c.redirect('#/domains'); }, 'PUT', params); // Wait 15s and refresh the page - refreshDomain = window.setTimeout(function(){ + var refreshDomain = window.setTimeout(function(){ store.clear('slide'); c.redirect('#/domains'); }, 15000); diff --git a/src/js/yunohost/controllers/firewall.js b/src/js/yunohost/controllers/firewall.js index 01b90159..beeff865 100644 --- a/src/js/yunohost/controllers/firewall.js +++ b/src/js/yunohost/controllers/firewall.js @@ -12,8 +12,8 @@ app.get('#/tools/firewall', function (c) { c.api('/firewall?raw', function(data) { var firewall = { - ports : {}, - upnp : false + ports: {}, + upnp: false }; // Reorganize ports @@ -41,7 +41,9 @@ // confirm_upnp_enable and confirm_upnp_disable y18n.t('confirm_upnp_' + c.params['action'].toLowerCase()), function(){ - params = {'action' : c.params['action']}; + var params = { + action : c.params['action'] + }; c.api('/firewall/upnp', function(data) { store.clear('slide'); c.redirect('#/tools/firewall'); @@ -57,8 +59,8 @@ // Toggle port status helper (available in every controller) app.helper('togglePort', function(port, protocol, connection, action) { var method = null, - endurl = [], - c = this + endurl = [], + c = this ; if (port != parseInt(port) || port < 0 || port > 65535) { @@ -110,8 +112,8 @@ // --ipv6-only: // --no-upnp: var params = { - 'port' : port, - 'protocol' : protocol, + port : port, + protocol : protocol }; c.api('/firewall/port?'+endurl, function(data) { store.clear('slide'); diff --git a/src/js/yunohost/controllers/home.js b/src/js/yunohost/controllers/home.js index 8f9c78c0..052ea51f 100644 --- a/src/js/yunohost/controllers/home.js +++ b/src/js/yunohost/controllers/home.js @@ -35,9 +35,10 @@ // Loop through items in a reverse order (older first) $($('item', xml).get().reverse()).each(function(k, v) { - var link=$('link', v).text(); - if (typeof link == 'string' && link !== '' && link.charAt(0) == '/') - link=forumUrl+link; + var link = $('link', v).text(); + if (typeof link == 'string' && link !== '' && link.charAt(0) == '/') { + link = forumUrl+link; + } // var description=$('description', v).text(); // description=description.replace('href="/','href="'+forumUrl+'/'); @@ -138,8 +139,8 @@ // Store url from params, it could have change form 'run' state store.set('url', c.params['domain'] +'/yunohost/api'); - params = { - 'password': c.params['password'] + var params = { + password: c.params['password'] }; c.api('/login', function(data) { store.set('connected', true); diff --git a/src/js/yunohost/controllers/monitor.js b/src/js/yunohost/controllers/monitor.js index 3dbbd72d..a7e8c664 100644 --- a/src/js/yunohost/controllers/monitor.js +++ b/src/js/yunohost/controllers/monitor.js @@ -10,7 +10,7 @@ // Server monitoring app.get('#/tools/monitor', function (c) { - monitorData = {}; + var monitorData = {}; // Why this method ? c.api('/services/glances', function(data) { // ? diff --git a/src/js/yunohost/controllers/postinstall.js b/src/js/yunohost/controllers/postinstall.js index e775b778..8f9834be 100644 --- a/src/js/yunohost/controllers/postinstall.js +++ b/src/js/yunohost/controllers/postinstall.js @@ -25,10 +25,10 @@ $('#masthead').hide(); $.get('https://dyndns.yunohost.org/domains', function() {}) .done(function(data){ - c.params.ddomains = data.map(function(dom){return '.'+dom;}); + c.params['ddomains'] = data.map(function(dom){return '.'+dom;}); }) .fail(function() { - c.params.ddomains = ['.nohost.me', '.noho.st']; + c.params['ddomains'] = ['.nohost.me', '.noho.st']; }) .always(function() { c.view('postinstall/postinstall_2', c.params, function() { @@ -77,14 +77,16 @@ store.clear('slide'); c.redirect('#/postinstall/domain'); } else { - params = { 'domain': c.params['domain'].toLowerCase() }; + var params = { + domain: c.params['domain'].toLowerCase() + }; } c.confirm( y18n.t('postinstall'), y18n.t('confirm_postinstall', [c.params['domain']]), function(){ - params['password'] = c.params['password']; + params.password = c.params['password']; store.set('url', window.location.hostname +'/yunohost/api'); store.set('user', 'admin'); diff --git a/src/js/yunohost/controllers/services.js b/src/js/yunohost/controllers/services.js index 2a03c744..49a59dd4 100644 --- a/src/js/yunohost/controllers/services.js +++ b/src/js/yunohost/controllers/services.js @@ -11,7 +11,9 @@ // All services status app.get('#/services', function (c) { c.api('/services', function(data) { // ? - data2 = { 'services': [] }; + var data2 = { + services: [] + }; $.each(data, function(k, v) { v.name = k; // Handlebars want booleans @@ -29,7 +31,9 @@ // Status & actions for a service app.get('#/services/:service', function (c) { c.api('/services/'+ c.params['service'], function(data) { // ? - data2 = { 'service': data }; + var data2 = { + service: data + }; data2.service.name = c.params['service']; // Handlebars want booleans data2.service.is_loaded = (data.loaded=='enabled') ? true : false; @@ -44,7 +48,9 @@ // Service log app.get('#/services/:service/log', function (c) { - params = { 'number': 50 }; + var params = { + number: 50 + }; c.api('/services/'+ c.params['service'] +'/log', function(data) { // ? data2 = { 'logs': [], 'name': c.params['service'] }; $.each(data, function(k, v) { @@ -62,7 +68,8 @@ // confirm_service_start, confirm_service_stop, confirm_service_enable and confirm_service_disable y18n.t('confirm_service_' + c.params['action'].toLowerCase(), [c.params['service']]), function(){ - var method = null, endurl = c.params['service']; + var method = null, + endurl = c.params['service']; switch (c.params['action']) { case 'start': diff --git a/src/js/yunohost/controllers/tools.js b/src/js/yunohost/controllers/tools.js index 81d6f6d4..ae606a38 100644 --- a/src/js/yunohost/controllers/tools.js +++ b/src/js/yunohost/controllers/tools.js @@ -20,7 +20,7 @@ // Update administration password (PUT) app.put('#/tools/adminpw', function (c) { - params = {}; + var params = {}; $.each(c.params.toHash(), function(key, value) { if (value !== '') { params[key] = value; } }); @@ -49,7 +49,7 @@ // System update & upgrade app.get('#/update', function (c) { c.api('/update', function(data) { - packagesLength = data.packages.length; + var packagesLength = data.packages.length; for(var i = 0; i < packagesLength; i++) { data.packages[i].delayed = false; data.packages[i].changelog = data.packages[i].changelog.replace(/\n/g, '
'); @@ -77,7 +77,7 @@ // confirm_update_apps and confirm_update_packages y18n.t('confirm_update_' + c.params['type'].toLowerCase()), function(){ - endurl = ''; + var endurl = ''; if (c.params['type'] == 'packages') {endurl = 'ignore_apps';} else if (c.params['type'] == 'apps') {endurl = 'ignore_packages';} @@ -103,7 +103,7 @@ // Security feed app.get('#/tools/security-feed', function (c) { - data = { + var data = { items: [] }; @@ -125,11 +125,12 @@ .done(function(xml){ // Loop through items $('item', xml).each(function(k, v) { - var link=$('link', v)[0].innerHTML; - if (typeof link == 'string' && link !== '' && link.charAt(0) == '/') - link=forumUrl+link; - var description=$('description', v)[0].textContent; - description=description.replace('href="/','href="'+forumUrl+'/'); + var link = $('link', v)[0].innerHTML; + if (typeof link == 'string' && link !== '' && link.charAt(0) == '/') { + link = forumUrl+link; + } + var description = $('description', v)[0].textContent; + description = description.replace('href="/','href="'+forumUrl+'/'); var item = { guid: $('guid', v)[0].innerHTML, @@ -159,9 +160,9 @@ // Diagnosis app.get('#/tools/diagnosis(/:private)?', function (c) { // 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.view('tools/tools_diagnosis', { 'diagnosis' : JSON.stringify(diagnosis, undefined, 4), diff --git a/src/js/yunohost/controllers/users.js b/src/js/yunohost/controllers/users.js index 8b029eba..ebfa61fe 100644 --- a/src/js/yunohost/controllers/users.js +++ b/src/js/yunohost/controllers/users.js @@ -79,7 +79,7 @@ data.password_min_length = PASSWORD_MIN_LENGTH; // User email use a fake splitted field - email = data.mail.split('@'); + var email = data.mail.split('@'); data.email = { username : email[0], domain : email[1] @@ -156,7 +156,7 @@ c.params['mailalias'] = c.params['mailforward'] = ''; // Remove empty inputs - params = {}; + var params = {}; $.each(c.params.toHash(), function(key, value) { if (value.length > 0 && key !== 'user') { params[key] = value; } }); diff --git a/src/js/yunohost/helpers.js b/src/js/yunohost/helpers.js index 1c9e2a6a..bf41c86f 100644 --- a/src/js/yunohost/helpers.js +++ b/src/js/yunohost/helpers.js @@ -80,7 +80,7 @@ }, 1500); } - loaded = false; + app.loaded = false; if ($('div.loader').length === 0) { $('#main').append('
'); } @@ -161,7 +161,7 @@ if (websocket) { // 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) { // console.log(evt.data); $.each($.parseJSON(evt.data), function(k, v) { @@ -189,14 +189,14 @@ callback = typeof callback !== 'undefined' ? callback : function() {}; enableSlide = (typeof enableSlide !== 'undefined') ? enableSlide : true; // Change to false to disable animation - loaded = true; + app.loaded = true; // Hide loader and modal $('div.loader').remove(); $('#modal').modal('hide'); // Render content - rendered = this.render('views/'+ view +'.ms', data); + var rendered = this.render('views/'+ view +'.ms', data); // Update content helper var leSwap = function() { @@ -254,7 +254,7 @@ cancelCallback = typeof cancelCallback !== 'undefined' ? cancelCallback : function() {}; // Get modal element - box = $('#modal'); + var box = $('#modal'); // Modal title if (typeof title === 'string' && title.length) { @@ -312,8 +312,8 @@ }, groupHooks: function(hooks) { - data={}; - var rules=[ + var data = {}; + var rules = [ { id:'configuration', isIn:function (hook) { @@ -350,7 +350,7 @@ }, ungroupHooks: function(hooks,apps) { - var data={}; + var data = {}; data['apps'] = apps || []; data['hooks'] = hooks || []; diff --git a/src/js/yunohost/y18n.js b/src/js/yunohost/y18n.js index 3d8c6848..daa128bd 100644 --- a/src/js/yunohost/y18n.js +++ b/src/js/yunohost/y18n.js @@ -6,7 +6,7 @@ defaultLocale: "en", locale: "en", placeholder: /(?:\{\{|%\{)(.*?)(?:\}\}?)/gm, - translations: {}, + translations: {} }; /** From cb4df135d85e4d2ef621d9147e68eb47c1462986 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 8 Jul 2017 12:39:24 +0200 Subject: [PATCH 02/42] [fix] 'hooks' key is now 'system' in backup info (#165) --- src/js/yunohost/controllers/backup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/yunohost/controllers/backup.js b/src/js/yunohost/controllers/backup.js index 389e81d1..dad40d4d 100644 --- a/src/js/yunohost/controllers/backup.js +++ b/src/js/yunohost/controllers/backup.js @@ -133,7 +133,7 @@ }; data['other_storages']=[]; data['name']=c.params['archive']; - data['hooks']=c.groupHooks(Object.keys(data['hooks'])); + data['hooks']=c.groupHooks(Object.keys(data['system'])); data['items']=(data['hooks']!={} || data['apps']!=[]); c.view('backup/backup_info', data); }); @@ -156,4 +156,4 @@ }); }); -})(); \ No newline at end of file +})(); From 75ef1ab156d08ec0f75f8cdede2a21364d1d6c03 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 26 Jul 2017 12:09:44 -0400 Subject: [PATCH 03/42] Update changelog for 2.6.2 release --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index 5051420c..c4ab2d88 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +yunohost-admin (2.6.2) stable; urgency=low + +## Minor fix + + * 'hooks' key is now 'system' in backup info (#165) + + -- Alexandre Aubin Wed, 26 Jul 2017 12:09:03 -0400 + yunohost-admin (2.6.1) stable; urgency=low Major changes since 2.6.0 From 382b81a6648f06a1f0b7545ad140d17d2a2f53d0 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 27 Jul 2017 16:30:15 +0200 Subject: [PATCH 04/42] [fix] Correctly handle error 500 (#166) * [fix] Correctly handle error 500 * [fix] Use 'em' instead of 'emph' --- src/js/yunohost/helpers.js | 7 +++++++ src/locales/en.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/js/yunohost/helpers.js b/src/js/yunohost/helpers.js index bf41c86f..98fe5236 100644 --- a/src/js/yunohost/helpers.js +++ b/src/js/yunohost/helpers.js @@ -133,6 +133,13 @@ c.redirect('#/login'); } } + // 500 + else if (xhr.status == 500) { + error_log = JSON.parse(xhr.responseText); + error_log.route = error_log.route.join(' ') + '\n'; + error_log.arguments = JSON.stringify(error_log.arguments); + c.flash('fail', y18n.t('internal_exception', [error_log.route, error_log.arguments, error_log.traceback])); + } // 502 Bad gateway means API is down else if (xhr.status == 502) { c.flash('fail', y18n.t('api_not_responding')); diff --git a/src/locales/en.json b/src/locales/en.json index 44786813..d7ebf65f 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -159,6 +159,7 @@ "installed_apps": "Installed apps", "installing": "Installing", "interface": "Interface", + "internal_exception": "Yunohost encountered an internal error :/
Really sorry about that.
You should look for help on the forum or the chat to fix the situation, or report the bug on the bugtracker.

The following information might be useful for the person helping you :

Action

%s%s

Traceback

%s
", "io": "I/O", "ipv4": "IPv4", "ipv6": "IPv6", @@ -345,4 +346,3 @@ "install_community_appslists_warning" : "Note that these applications packages are not official and not maintained by the YunoHost team.
Installing these applications is at your own risk and could break your system.", "install_custom_app_appslists_info" : "Note that you can use alternative applications lists to install some other apps maintained by the YunoHost community." } - From feade1da7b7c2cf42613e6f09a6138a4375641c6 Mon Sep 17 00:00:00 2001 From: Ozhiganov Date: Fri, 21 Jul 2017 04:06:12 +0200 Subject: [PATCH 05/42] Added translation using Weblate (Russian) --- src/locales/ru.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/locales/ru.json diff --git a/src/locales/ru.json b/src/locales/ru.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/src/locales/ru.json @@ -0,0 +1 @@ +{} From a496d02e8d5804a81a24f853c27121c22430df6d Mon Sep 17 00:00:00 2001 From: Evgeniy Ozhiganov Date: Fri, 21 Jul 2017 05:25:10 +0200 Subject: [PATCH 06/42] [i18n] Translated using Weblate (Russian) Currently translated at 8.4% (29 of 345 strings) --- src/locales/ru.json | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/locales/ru.json b/src/locales/ru.json index 0967ef42..353fe5e5 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -1 +1,31 @@ -{} +{ + "action": "Действие", + "add": "Добавить", + "administration_password": "Пароль администратора", + "allowed_users": "Разрешенные пользователи", + "api_not_responding": "API не отвечает", + "app_access": "Доступ", + "app_access_addall_btn": "Включить доступ ко всем", + "app_access_addall_desc": "Все существующие пользователи будут иметь доступ к %s.", + "app_access_clearall_btn": "Очистить доступы", + "app_access_clearall_desc": "Каждый пользователь будет иметь доступ к %s.", + "app_access_removeall_btn": "Удалить все доступы", + "app_access_removeall_desc": "Пользователи не получат доступа к %s.", + "app_access_title": "%s доступ", + "app_debug_no_logs": "Журналы приложений недоступны", + "app_debug_tab": "Отображать отладочную информацию", + "app_info_access_desc": "Управление доступом пользователей. Разрешенные пользователи: %s", + "remove": "Удалить", + "app_info_default_desc": "Перенаправить домен root в это приложение (%s).", + "app_info_uninstall_desc": "Удалите это приложение.", + "app_install_cancel": "Установка отменена.", + "app_install_custom_no_manifest": "Нет файла manifest.json", + "app_list": "Нет файла manifest.json", + "app_make_default": "Использовать по умолчанию", + "app_repository": "Происхождение приложения: ", + "app_state": "Состояние приложения: ", + "app_state_inprogress": "Выполняется", + "app_state_validated": "Проверенный", + "app_state_working": "Работает", + "password": "Пароль" +} From 428081922725f127cadc224c020d8392ef57d65d Mon Sep 17 00:00:00 2001 From: YunoHost Bot Date: Mon, 7 Aug 2017 18:24:08 +0200 Subject: [PATCH 07/42] Update from Weblate. (#167) * Added translation using Weblate (Russian) * [i18n] Translated using Weblate (Russian) Currently translated at 8.4% (29 of 345 strings) --- src/locales/ru.json | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/locales/ru.json diff --git a/src/locales/ru.json b/src/locales/ru.json new file mode 100644 index 00000000..353fe5e5 --- /dev/null +++ b/src/locales/ru.json @@ -0,0 +1,31 @@ +{ + "action": "Действие", + "add": "Добавить", + "administration_password": "Пароль администратора", + "allowed_users": "Разрешенные пользователи", + "api_not_responding": "API не отвечает", + "app_access": "Доступ", + "app_access_addall_btn": "Включить доступ ко всем", + "app_access_addall_desc": "Все существующие пользователи будут иметь доступ к %s.", + "app_access_clearall_btn": "Очистить доступы", + "app_access_clearall_desc": "Каждый пользователь будет иметь доступ к %s.", + "app_access_removeall_btn": "Удалить все доступы", + "app_access_removeall_desc": "Пользователи не получат доступа к %s.", + "app_access_title": "%s доступ", + "app_debug_no_logs": "Журналы приложений недоступны", + "app_debug_tab": "Отображать отладочную информацию", + "app_info_access_desc": "Управление доступом пользователей. Разрешенные пользователи: %s", + "remove": "Удалить", + "app_info_default_desc": "Перенаправить домен root в это приложение (%s).", + "app_info_uninstall_desc": "Удалите это приложение.", + "app_install_cancel": "Установка отменена.", + "app_install_custom_no_manifest": "Нет файла manifest.json", + "app_list": "Нет файла manifest.json", + "app_make_default": "Использовать по умолчанию", + "app_repository": "Происхождение приложения: ", + "app_state": "Состояние приложения: ", + "app_state_inprogress": "Выполняется", + "app_state_validated": "Проверенный", + "app_state_working": "Работает", + "password": "Пароль" +} From e2a8b8f7cfdfaf9c49b1d5ad363ee866ce12abf9 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 7 Aug 2017 12:52:34 -0400 Subject: [PATCH 08/42] Update changelog for 2.7.0 release --- debian/changelog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/debian/changelog b/debian/changelog index c4ab2d88..ac5782ed 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +yunohost-admin (2.7.0) testing; urgency=low + + * [enh] Variable assignment code cleanup. (#161) + * [fix] Friendlier and more meaningful 'error 500' (#166) + * [i18n] Started Russian translation (#167) + +Thanks to all contributors (opi, Aleks, Ozhiganov) <3 ! + + -- Alexandre Aubin Mon, 07 Aug 2017 12:49:55 -0400 + yunohost-admin (2.6.2) stable; urgency=low ## Minor fix From c3062ba3576bf1d4c173891eae53808ea2877602 Mon Sep 17 00:00:00 2001 From: MCMic Date: Thu, 10 Aug 2017 18:04:39 +0200 Subject: [PATCH 09/42] [i18n] Translated using Weblate (Esperanto) Currently translated at 1.1% (4 of 346 strings) --- src/locales/eo.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/locales/eo.json b/src/locales/eo.json index 0967ef42..d15d9873 100644 --- a/src/locales/eo.json +++ b/src/locales/eo.json @@ -1 +1,6 @@ -{} +{ + "password": "Pasvorto", + "login": "Ensaluti", + "logout": "Elsaluti", + "cancel": "Nuligi" +} From 108d24cdaa29025deec9673ae1e382ca5a265f2e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 13 Aug 2017 14:07:31 -0400 Subject: [PATCH 10/42] [fix] Tell user that domain dns-conf shows a recommendation only --- src/locales/en.json | 1 + src/views/domain/domain_dns.ms | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/locales/en.json b/src/locales/en.json index d7ebf65f..dbccaf85 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -89,6 +89,7 @@ "default": "Default", "delete": "Delete", "description": "Description", + "domain_dns_conf_is_just_a_recommendation": "This page shows you the *recommended* configuration. It does *not* configure the DNS for you. It is your responsability to configure your DNS zone in your DNS registrar according to this recommendation.", "diagnosis": "Diagnosis", "diagnosis_hide_private": "Show diagnostic information without private data", "diagnosis_view_private": "Show diagnostic information including private data", diff --git a/src/views/domain/domain_dns.ms b/src/views/domain/domain_dns.ms index afe0e8a3..e4260837 100644 --- a/src/views/domain/domain_dns.ms +++ b/src/views/domain/domain_dns.ms @@ -4,9 +4,12 @@ {{name}} {{t 'dns'}} -
+
+ {{t 'domain_dns_conf_is_just_a_recommendation' }} +
+

From 4256413eee0c07b486c0a35b85112cb1612a3375 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 19 Aug 2017 22:44:42 +0000 Subject: [PATCH 11/42] Update changelog for 2.7.1 release --- debian/changelog | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/debian/changelog b/debian/changelog index ac5782ed..1f280b96 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +yunohost-admin (2.7.1) testing; urgency=low + + [ Alexandre Aubin ] + * [fix] Tell user that domain dns-conf shows a recommendation only + + [ Translations ] + * Added translation using Weblate (Russian) (Evgeniy Ozhiganov) + * [i18n] Translated using Weblate (Esperanto) (MCMic) + +Thanks to all contributors (MCMic, Aleks, Ozhiganov) <3 ! + + -- Laurent Peuch Sat, 19 Aug 2017 22:43:15 +0000 + yunohost-admin (2.7.0) testing; urgency=low * [enh] Variable assignment code cleanup. (#161) From 265f679e81874efb95b3f0c366b44185bed5562e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 22 Aug 2017 15:35:00 +0200 Subject: [PATCH 12/42] [fix] Update yunohost version requirement --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 8d196903..5f02cf87 100644 --- a/debian/control +++ b/debian/control @@ -12,7 +12,7 @@ Architecture: all Conflicts: yunohost-apps-admin Replaces: yunohost-apps-admin Depends: ${misc:Depends} - , yunohost (>= 2.3.6) + , yunohost (>= 2.7.1) Description: web administration interface for yunohost YunoHost aims to make self-hosting accessible to everyone. It configures an email, Web and IM server alongside a LDAP base. It also provides From 6e66cc56758db14dda5b1003c48f0b72976cbb00 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 22 Aug 2017 21:36:51 -0400 Subject: [PATCH 13/42] Update changelog for 2.7.2 release --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 1f280b96..1c90fb4f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +yunohost-admin (2.7.2) stable; urgency=low + +Releasing as stable + + -- Alexandre Aubin Tue, 22 Aug 2017 21:36:35 -0400 + yunohost-admin (2.7.1) testing; urgency=low [ Alexandre Aubin ] From f2adc258b0c88fc3929300db86f665918723ee18 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Fri, 25 Aug 2017 16:09:40 +0200 Subject: [PATCH 14/42] [i18n] Translated using Weblate (French) Currently translated at 100.0% (347 of 347 strings) --- src/locales/fr.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/locales/fr.json b/src/locales/fr.json index a7669bb7..f333f988 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -349,5 +349,7 @@ "name": "Nom", "install_community_appslists_info": "La liste des applications communautaires vous permet d’installer les applications maintenues par la communauté.
Parcourez la liste complète sur yunohost.org/apps_in_progress_fr.", "install_community_appslists_warning": "Ces applications ne sont ni officielles, ni maintenues par l’équipe YunoHost.
Installer ces applications est à vos risques et périls, et peut casser votre système.", - "install_custom_app_appslists_info": "Vous pouvez utiliser des listes alternatives d’applications pour installer d’autres applications maintenues par la communauté YunoHost." + "install_custom_app_appslists_info": "Vous pouvez utiliser des listes alternatives d’applications pour installer d’autres applications maintenues par la communauté YunoHost.", + "domain_dns_conf_is_just_a_recommendation": "Cette page montre la configuration *recommandée*. Elle ne configure *pas* le DNS pour vous. Il est de votre responsabilité que de configurer votre zone DNS chez votre registrar DNS avec cette recommandation.", + "internal_exception": "YunoHost a rencontré une erreur interne :/
Vraiment navré.
Vous devriez chercher de l’aide sur le forum ou le salon pour résoudre le problème, ou rapporter le bogue sur l’outil de suivi.

Les informations suivantes peuvent être utile à l’interlocuteur vous aidant :

Action

%s 1%s 2

Trace

%s 3
" } From ab41974005cacad9acc55e0863e1328ec2845872 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Fri, 25 Aug 2017 16:12:56 +0200 Subject: [PATCH 15/42] [i18n] Translated using Weblate (French) Currently translated at 100.0% (347 of 347 strings) --- src/locales/fr.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/fr.json b/src/locales/fr.json index f333f988..e8cea374 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -351,5 +351,5 @@ "install_community_appslists_warning": "Ces applications ne sont ni officielles, ni maintenues par l’équipe YunoHost.
Installer ces applications est à vos risques et périls, et peut casser votre système.", "install_custom_app_appslists_info": "Vous pouvez utiliser des listes alternatives d’applications pour installer d’autres applications maintenues par la communauté YunoHost.", "domain_dns_conf_is_just_a_recommendation": "Cette page montre la configuration *recommandée*. Elle ne configure *pas* le DNS pour vous. Il est de votre responsabilité que de configurer votre zone DNS chez votre registrar DNS avec cette recommandation.", - "internal_exception": "YunoHost a rencontré une erreur interne :/
Vraiment navré.
Vous devriez chercher de l’aide sur le forum ou le salon pour résoudre le problème, ou rapporter le bogue sur l’outil de suivi.

Les informations suivantes peuvent être utile à l’interlocuteur vous aidant :

Action

%s 1%s 2

Trace

%s 3
" + "internal_exception": "YunoHost a rencontré une erreur interne :/
Vraiment navré.
Vous devriez chercher de l’aide sur le forum ou le salon pour résoudre le problème, ou rapporter le bogue sur l’outil de suivi.

Les informations suivantes peuvent être utile à l’interlocuteur vous aidant :

Action

%s %s

Trace

%s
" } From b3a4419a3d1bf6fc7104ce8524430f4b7a492d79 Mon Sep 17 00:00:00 2001 From: ariasuni Date: Sat, 26 Aug 2017 23:48:43 +0200 Subject: [PATCH 16/42] [fix] Add "OK" in translatable strings (modal dialog for system upgrade) (#171) --- src/locales/en.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locales/en.json b/src/locales/en.json index dbccaf85..13e1ab1c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -197,6 +197,7 @@ "no_log": "No log.", "no_user_to_add": "No more users to add.", "non_compatible_api": "Non-compatible API", + "ok": "OK", "open": "Open", "operations": "Operations", "os": "OS", From 8b726186ea05aea5d1b9170e16f6913a52994310 Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 28 Aug 2017 17:35:21 +0200 Subject: [PATCH 17/42] [enh] Upgrade just one app --- src/js/yunohost/controllers/tools.js | 25 ++++++++++++++++++++++++- src/locales/en.json | 1 + src/views/update/update.ms | 11 ++++++++--- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/js/yunohost/controllers/tools.js b/src/js/yunohost/controllers/tools.js index ae606a38..7ae0a468 100644 --- a/src/js/yunohost/controllers/tools.js +++ b/src/js/yunohost/controllers/tools.js @@ -95,6 +95,29 @@ ); } }); + + // Upgrade a specific apps + app.get('#/upgrade/apps/:app', function (c) { + c.confirm( + y18n.t('tools'), + // confirm_update_apps and confirm_update_packages + y18n.t('confirm_update_specific_app'), + function(){ + c.api('/upgrade/apps?app='+c.params['app'].toLowerCase(), + function(data) { + // 'log' is a reserved name, maybe in handlebars + data.logs = data.log; + c.view('upgrade/upgrade', data); + }, 'PUT'); + + }, + function(){ + store.clear('slide'); + c.redirect('#/update'); + } + ); + }); + // Download SSL Certificate Authority app.get('#/tools/ca', function (c) { @@ -172,4 +195,4 @@ }); }); -})(); \ No newline at end of file +})(); diff --git a/src/locales/en.json b/src/locales/en.json index 13e1ab1c..7071d9dc 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -76,6 +76,7 @@ "confirm_uninstall": "Are you sure you want to uninstall %s ?", "confirm_update_apps": "Are you sure you want to update all applications?", "confirm_update_packages": "Are you sure you want to update all packages?", + "confirm_update_specific_app": "Are you sure you want to update this application ?", "confirm_upnp_enable": "Are you sure you want to enable UPnP?", "confirm_upnp_disable": "Are you sure you want to disable UPnP?", "connection": "Connection", diff --git a/src/views/update/update.ms b/src/views/update/update.ms index 1dd7d6e9..24c81be2 100644 --- a/src/views/update/update.ms +++ b/src/views/update/update.ms @@ -42,9 +42,14 @@ {{#if apps}}
{{#apps}} -
-

{{label}} {{id}}

-
+
+
+

{{label}} {{id}}

+
+ +
{{/apps}}