mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Rename 'hooks' to system or system_parts in backup stuff (#196)
* Fix a bug when trying to uncheck boxes of apps (id key does not exists) * Rename 'hooks' to system or system_parts to be more semantic and match new option --system
This commit is contained in:
parent
f9173548fa
commit
739bb08f4b
4 changed files with 21 additions and 22 deletions
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
|
|
||||||
app.post('#/backup/:storage', function (c) {
|
app.post('#/backup/:storage', function (c) {
|
||||||
var params = c.ungroupHooks(c.params['hooks'],c.params['apps']);
|
var params = c.ungroupHooks(c.params['system_parts'],c.params['apps']);
|
||||||
c.api('/backup', function() {
|
c.api('/backup', function() {
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/backup/'+ c.params['storage']);
|
c.redirect('#/backup/'+ c.params['storage']);
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
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['system_parts'],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');
|
||||||
|
@ -134,7 +134,7 @@
|
||||||
};
|
};
|
||||||
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.system_parts = 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);
|
||||||
});
|
});
|
||||||
|
|
|
@ -359,32 +359,31 @@
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
ungroupHooks: function(hooks,apps) {
|
ungroupHooks: function(system_parts,apps) {
|
||||||
var data = {};
|
var data = {};
|
||||||
data['apps'] = apps || [];
|
data['apps'] = apps || [];
|
||||||
data['hooks'] = hooks || [];
|
data['system'] = system_parts || [];
|
||||||
|
|
||||||
if (data['hooks'].constructor !== Array) {
|
if (data['system'].constructor !== Array) {
|
||||||
data['hooks'] = [data['hooks']];
|
data['system'] = [data['system']];
|
||||||
}
|
}
|
||||||
if (data['apps'].constructor !== Array) {
|
if (data['apps'].constructor !== Array) {
|
||||||
data['apps'] = [data['apps']];
|
data['apps'] = [data['apps']];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data['hooks'].length == 0) {
|
|
||||||
data['ignore_hooks'] = '';
|
|
||||||
}
|
|
||||||
if (data['apps'].length == 0) {
|
|
||||||
data['ignore_apps'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some hook value contains multiple hooks separated by commas
|
// Some hook value contains multiple hooks separated by commas
|
||||||
var split_hooks = [];
|
var split_hooks = [];
|
||||||
$.each(data['hooks'], function(i, hook) {
|
$.each(data['system'], function(i, hook) {
|
||||||
split_hooks = split_hooks.concat(hook.split(','));
|
split_hooks = split_hooks.concat(hook.split(','));
|
||||||
});
|
});
|
||||||
data['hooks'] = split_hooks;
|
data['system'] = split_hooks;
|
||||||
|
|
||||||
|
if (data['system'].length == 0) {
|
||||||
|
delete data['system'];
|
||||||
|
}
|
||||||
|
if (data['apps'].length == 0) {
|
||||||
|
delete data['apps'];
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
{{#each hooks}}
|
{{#each hooks}}
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<input type="checkbox" id="{{@key}}" name="hooks" value="{{value}}" checked class="nice-checkbox">
|
<input type="checkbox" id="{{@key}}" name="system_parts" value="{{value}}" checked class="nice-checkbox">
|
||||||
<label for="{{@key}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label>
|
<label for="{{@key}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label>
|
||||||
<h2 class="list-group-item-heading">{{name}}</h2>
|
<h2 class="list-group-item-heading">{{name}}</h2>
|
||||||
<p class="list-group-item-text">{{description}}</p>
|
<p class="list-group-item-text">{{description}}</p>
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
</div>
|
</div>
|
||||||
{{#if items}}
|
{{#if items}}
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
{{#each hooks}}
|
{{#each system_parts}}
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<input type="checkbox" id="{{@key}}" name="hooks" value="{{value}}" checked class="nice-checkbox">
|
<input type="checkbox" id="{{@key}}" name="system_parts" value="{{value}}" checked class="nice-checkbox">
|
||||||
<label for="{{@key}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label>
|
<label for="{{@key}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label>
|
||||||
<h2 class="list-group-item-heading">{{name}}</h2>
|
<h2 class="list-group-item-heading">{{name}}</h2>
|
||||||
<p class="list-group-item-text">{{description}}</p>
|
<p class="list-group-item-text">{{description}}</p>
|
||||||
|
@ -39,9 +39,9 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#each apps}}
|
{{#each apps}}
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<input type="checkbox" id="{{id}}" name="apps" value="{{id}}" checked class="nice-checkbox">
|
<input type="checkbox" id="{{@key}}" name="apps" value="{{@key}}" checked class="nice-checkbox">
|
||||||
<label for="{{id}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label>
|
<label for="{{@key}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label>
|
||||||
<h2 class="list-group-item-heading">{{name}} <small>{{id}}</small></h2>
|
<h2 class="list-group-item-heading">{{name}} <small>{{@key}}</small></h2>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<div class="list-group-item clearfix">
|
<div class="list-group-item clearfix">
|
||||||
|
|
Loading…
Reference in a new issue