Adding buttons to select all/no tickboxes in backup views.

This commit is contained in:
chateau 2019-01-12 17:07:16 +01:00
parent 4df9852a50
commit 445e1cdf29
6 changed files with 49 additions and 11 deletions

View file

@ -55,7 +55,7 @@
data['apps'] = {};
c.api('/apps?with_backup', function(apps_list) {
data['apps'] = apps_list.apps;
c.view('backup/backup_create', data);
c.view('backup/backup_create', data, c.selectAllOrNone);
});
});
});
@ -137,7 +137,7 @@
data.system_parts = c.groupHooks(Object.keys(data['system']));
data.items = (data['hooks']!={} || data['apps']!=[]);
data.locale = y18n.locale
c.view('backup/backup_info', data);
c.view('backup/backup_info', data, c.selectAllOrNone);
});
});

View file

@ -174,7 +174,7 @@
// Open a WebSocket connection to retrieve live messages from the moulinette
var ws = new WebSocket('wss://'+ store.get('url') +'/messages');
// Flag to avoid to call twice the API
// We need to set that in ws object as we need to use it in ws.onopen
// We need to set that in ws object as we need to use it in ws.onopen
// and several ws object could be running at the same time...
ws.api_called = false;
ws.onmessage = function(evt) {
@ -190,7 +190,7 @@
};
ws.onclose = function() { };
ws.onopen = function () {
if (!ws.api_called) {
ws.api_called = true;
@ -313,6 +313,19 @@
return box.modal('show');
},
selectAllOrNone: function () {
// Remove active style from buttons
$(".select_all-none input").click(function(){ $(this).toggleClass("active"); });
// Select all checkbox in this panel
$(".select_all").click(function(){
$(this).parents(".panel").children(".list-group").find("input").prop("checked", true);
});
// Deselect all checkbox in this panel
$(".select_none").click(function(){
$(this).parents(".panel").children(".list-group").find("input").prop("checked", false);
});
},
arraySortById: function(arr) {
arr.sort(function(a, b){
if (a.id > b.id) {
@ -367,15 +380,15 @@
description:(group_id==hook)?y18n.t('hook_'+hook+'_desc'):y18n.t('hook_'+hook)
};
}
});
});
return data;
},
ungroupHooks: function(system_parts,apps) {
var data = {};
data['apps'] = apps || [];
data['system'] = system_parts || [];
if (data['system'].constructor !== Array) {
data['system'] = [data['system']];
}

View file

@ -281,8 +281,10 @@
"run": "Run",
"running": "Running",
"save": "Save",
"search_for_apps": "Search for apps...",
"search_for_apps": "Search for apps...",
"select_user": "Select user",
"select_all": "Select all",
"select_none": "Select none",
"service_description": "Description:",
"service_log": "%s log",
"service_start_on_boot": "Start on boot: ",

View file

@ -221,6 +221,8 @@
"running": "En cours d'execution",
"save": "Sauvegarder",
"select_user": "Choisissez un utilisateur",
"select_all": "Tout sélectionner",
"select_none": "Tout déselectionner",
"service_log": "Journal de %s",
"service_start_on_boot": "Lancer au démarrage : ",
"service_status": "Statut : ",

View file

@ -10,7 +10,14 @@
<form action="#/backup/{{storage.id}}" method="POST" class="form-horizontal">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-cube"></span> {{t 'system'}}</h2>
<h2 class="panel-title">
<span class="fa-fw fa-cube"></span>
{{t 'system'}}
<span class="select_all-none pull-right">
<input type="button" role="select_all" class="btn btn-default slide back select_all" value="{{t 'select_all'}}" />
<input type="button" role="select_none" class="btn btn-default slide back select_none" value="{{t 'select_none'}}" />
</span>
</h2>
</div>
<div class="list-group">
{{#each hooks}}
@ -26,7 +33,14 @@
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-cubes"></span> {{t 'applications'}}</h2>
<h2 class="panel-title">
<span class="fa-fw fa-cubes"></span>
{{t 'applications'}}
<span class="select_all-none pull-right">
<input type="button" role="select_all" class="btn btn-default slide back select_all" value="{{t 'select_all'}}" />
<input type="button" role="select_none" class="btn btn-default slide back select_none" value="{{t 'select_none'}}" />
</span>
</h2>
</div>
<div class="list-group">
{{#each apps}}

View file

@ -25,7 +25,14 @@
<form action="#/backup/{{storage.id}}/{{name}}/restore" method="POST" class="form-horizontal">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-archive"></span> {{t 'backup_content'}}</h2>
<h2 class="panel-title">
<span class="fa-fw fa-archive"></span>
{{t 'backup_content'}}
<span class="select_all-none pull-right">
<input type="button" role="select_all" class="btn btn-default slide back select_all" value="{{t 'select_all'}}" />
<input type="button" role="select_none" class="btn btn-default slide back select_none" value="{{t 'select_none'}}" />
</span>
</h2>
</div>
{{#if items}}
<div class="list-group">