This code is commented / not useful for now ... we'll see when this is actually implemented.

This commit is contained in:
Alexandre Aubin 2019-10-29 20:39:01 +01:00
parent 7ea2f37b89
commit 4f544de332
4 changed files with 33 additions and 149 deletions

View file

@ -32,17 +32,25 @@
c.view('backup/backup', {'storages':storages});
});
// Storage list
app.get('#/storages/create', function (c) {
c.view('backup/storage_create', {});
// Archive list
app.get('#/backup/:storage', function (c) {
c.api('GET', '/backup/archives?with_info', {}, function(data) {
data.storage = {
id: 'local',
name: y18n.t('local_archives')
};
data.archives2 = [];
$.each(data['archives'], function(name, info) {
info.name = name;
data.archives2.unshift(info)
});
data.archives = data.archives2;
data.locale = y18n.locale
c.view('backup/backup_list', data);
});
});
// Create a storage
app.post('#/storages', function (c) {
c.redirect_to('#/storages');
});
// Create a backup
// View to create a backup
app.get('#/backup/:storage/create', function (c) {
var data = [];
data['storage'] = {
@ -59,7 +67,7 @@
});
});
// Actually creating the backup
app.post('#/backup/:storage', function (c) {
var params = ungroupHooks(c.params['system_parts'],c.params['apps']);
c.api('POST', '/backup', params, function() {
@ -67,6 +75,21 @@
});
});
// Get archive info
app.get('#/backup/:storage/:archive', function (c) {
c.api('GET', '/backup/archives/'+c.params['archive']+'?with_details', {}, function(data) {
data.storage = {
id: c.params['storage'],
name: y18n.t('local_archives')
};
data.name = c.params['archive'];
data.system_parts = groupHooks(Object.keys(data['system']),data['system']);
data.items = (data['system']!={} || data['apps']!=[]);
data.locale = y18n.locale;
c.view('backup/backup_info', data, c.selectAllOrNone);
});
});
// Restore a backup
app.post('#/backup/:storage/:archive/restore', function (c) {
c.confirm(
@ -95,57 +118,6 @@
);
});
// Download a backup
app.get('#/backup/:storage/:archive/download', function (c) {
c.api('GET', '/backup/'+c.params['archive']+'/download', {}, function(data) {
c.redirect_to('#/backup/'+ c.params['storage']+'/'+c.params['archive'], {slide: false});
});
});
// Copy a backup
app.get('#/backup/:storage/:archive/copy', function (c) {
c.redirect_to('#/backup/'+ c.params['storage']+'/'+c.params['archive'], {slide: false});
});
// Upload a backup
app.get('#/backup/:storage/:archive/upload', function (c) {
c.redirect_to('#/backup/'+ c.params['storage']+'/'+c.params['archive'], {slide: false});
});
// Get archive info
app.get('#/backup/:storage/:archive', function (c) {
c.api('GET', '/backup/archives/'+c.params['archive']+'?with_details', {}, function(data) {
data.storage = {
id: c.params['storage'],
name: y18n.t('local_archives')
};
data.other_storages = [];
data.name = c.params['archive'];
data.system_parts = groupHooks(Object.keys(data['system']),data['system']);
data.items = (data['system']!={} || data['apps']!=[]);
data.locale = y18n.locale
c.view('backup/backup_info', data, c.selectAllOrNone);
});
});
// Archive list
app.get('#/backup/:storage', function (c) {
c.api('GET', '/backup/archives?with_info', {}, function(data) {
data.storage = {
id: 'local',
name: y18n.t('local_archives')
};
data.archives2 = [];
$.each(data['archives'], function(name, info) {
info.name = name;
data.archives2.unshift(info)
});
data.archives = data.archives2;
data.locale = y18n.locale
c.view('backup/backup_list', data);
});
});
function groupHooks(hooks, raw_infos) {
var data = {};
var rules = [

View file

@ -3,12 +3,6 @@
<a href="#/backup">{{t 'backup'}}</a>
</div>
<div class="actions-group">
<!--<a role="button" href="#/storages/create" class="btn btn-success slide">
<span class="fa-plus"></span> {{t 'storages_new'}}
</a>-->
</div>
<div class="separator"></div>
<div class="list-group">

View file

@ -83,41 +83,11 @@
</h2>
</div>
<div class="panel-body">
<!--<div class="container">
<p>{{t 'backup_archive_download'}}</p>
<a role="button" class="btn btn-info slide" href="#/backup/{{storage.id}}/{{name}}/download">
<span class="fa-download"></span> {{t 'download'}}
</a>
</div>
<hr>-->
<div class="container">
<p>{{t 'backup_archive_delete'}}</p>
<a href="#/backup/{{storage.id}}/{{name}}/delete" role="button" class="btn btn-danger slide">
<span class="fa-trash-o"></span> {{t 'delete'}}
</a>
</div>
{{#if other_storages}}
<hr>
<div class="container">
<p>{{t 'backup_archive_copy'}}</p>
<form action="#/backup/{{storage.id}}/{{name}}/copy" method="POST" class="form-horizontal">
<div class="form-group has-feedback">
<label for="label" class="col-sm-12">{{t 'url'}}</label>
<div class="col-sm-12">
<select id="storage" name="storage" class="form-control" required>
{{#each storages}}
<option value="{{id}}">{{name}} ({{uri}})</option>
{{/each}}
</select>
</div>
</div>
<div class="form-group">
<div class="text-center">
<input type="submit" role="button" class="btn btn-success slide" value="{{t 'copy'}}">
</div>
</div>
</form>
</div>
{{/if}}
</div>
</div>

View file

@ -1,52 +0,0 @@
<div class="btn-breadcrumb">
<a href="#/"><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
<a href="#/backup">{{t 'backup'}}</a>
<a href="#/backup/{{storage.id}}/create">{{t 'storage_create'}}</a>
</div>
<div class="separator"></div>
<form action="#/storages" method="POST" class="form-horizontal">
<div class="panel panel-default">
<div class="panel-body">
<div class="form-group">
<label for="type" class="col-sm-3 control-label">{{t 'backup_type'}}</label>
<div class="col-sm-9">
<select class="form-control" name="type">
<option>sftp</option>
<option>ftp</option>
<option>rsync</option>
</select>
</div>
</div>
<div class="form-group">
<label for="domain" class="col-sm-3 control-label">{{t 'domain'}}</label>
<div class="col-sm-9">
<input type="text" id="domain" name="domain" class="form-control" placeholder="monserver.fr" required>
</div>
</div>
<div class="form-group">
<label for="username" class="col-sm-3 control-label">{{t 'user_username'}}</label>
<div class="col-sm-9">
<input type="text" id="username" name="username" class="form-control" placeholder="johndoe" required>
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">{{t 'password'}}</label>
<div class="col-sm-9">
<input type="password" id="password" name="password" class="form-control" placeholder="•••••" required>
</div>
</div>
<div class="form-group">
<label for="path" class="col-sm-3 control-label">{{t 'path'}}</label>
<div class="col-sm-9">
<input type="text" id="path" name="path" class="form-control" placeholder="~/" required>
</div>
</div>
</div>
</div>
<div class="text-center">
<input type="submit" role="button" class="btn btn-success slide back" value="{{t 'save'}}">
</div>
</form>