New: Backup drone's database and configuration from the UI
New: Download Backup files from the UI

Fixed: Run a database backup before upgrade
This commit is contained in:
Mark McDowall 2014-05-30 10:34:38 -07:00
parent d74e461aea
commit c5bd8b27fb
32 changed files with 552 additions and 27 deletions

View file

@ -0,0 +1,19 @@
'use strict';
define(
[
'backbone.pageable',
'System/Backup/BackupModel'
], function (PageableCollection, BackupModel) {
return PageableCollection.extend({
url : window.NzbDrone.ApiRoot + '/system/backup',
model: BackupModel,
state: {
sortKey : 'time',
order : 1,
pageSize : 100000
},
mode: 'client'
});
});

View file

@ -0,0 +1,10 @@
'use strict';
define(
[
'marionette'
], function (Marionette) {
return Marionette.ItemView.extend({
template: 'System/Backup/BackupEmptyViewTemplate'
});
});

View file

@ -0,0 +1 @@
<div>No backups are available</div>

View file

@ -0,0 +1,12 @@
'use strict';
define(
[
'Cells/TemplatedCell'
], function (TemplatedCell) {
return TemplatedCell.extend({
className: 'series-title',
template : 'System/Backup/BackupFilenameCellTemplate'
});
});

View file

@ -0,0 +1,2 @@
<a href="{{urlBack}}/backup/{{type}}/{{name}}" class="no-router">{{name}}</a>

View file

@ -0,0 +1,106 @@
'use strict';
define(
[
'vent',
'marionette',
'backgrid',
'System/Backup/BackupCollection',
'Cells/RelativeDateCell',
'System/Backup/BackupFilenameCell',
'System/Backup/BackupTypeCell',
'System/Backup/BackupEmptyView',
'Shared/LoadingView',
'Shared/Toolbar/ToolbarLayout'
], function (vent, Marionette, Backgrid, BackupCollection, RelativeDateCell, BackupFilenameCell, BackupTypeCell, EmptyView, LoadingView, ToolbarLayout) {
return Marionette.Layout.extend({
template: 'System/Backup/BackupLayoutTemplate',
regions: {
backups : '#x-backups',
toolbar : '#x-backup-toolbar'
},
columns: [
{
name : 'type',
label : '',
sortable : false,
cell : BackupTypeCell
},
{
name : 'this',
label : 'Name',
sortable : false,
cell : BackupFilenameCell
},
{
name : 'time',
label : 'Time',
sortable : false,
cell : RelativeDateCell
}
],
leftSideButtons: {
type : 'default',
storeState: false,
collapse : false,
items :
[
{
title : 'Backup',
icon : 'icon-file-text',
command : 'backup',
properties : { type: 'manual' },
successMessage: 'Database and settings were backed up successfully',
errorMessage : 'Backup Failed!'
}
]
},
initialize: function () {
this.backupCollection = new BackupCollection();
this.listenTo(this.backupCollection, 'sync', this._showBackups);
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
},
onRender: function () {
this._showToolbar();
this.backups.show(new LoadingView());
this.backupCollection.fetch();
},
_showBackups: function () {
if (this.backupCollection.length === 0) {
this.backups.show(new EmptyView());
}
else {
this.backups.show(new Backgrid.Grid({
columns : this.columns,
collection: this.backupCollection,
className : 'table table-hover'
}));
}
},
_showToolbar : function () {
this.toolbar.show(new ToolbarLayout({
left :
[
this.leftSideButtons
],
context: this
}));
},
_commandComplete: function (options) {
if (options.command.get('name') === 'backup') {
this.backupCollection.fetch();
}
}
});
});

View file

@ -0,0 +1,10 @@
<div class="row">
<div class="col-md-12">
<div id="x-backup-toolbar"/>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div id="x-backups" class="table-responsive"/>
</div>
</div>

View file

@ -0,0 +1,9 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
});
});

View file

@ -0,0 +1,33 @@
'use strict';
define(
[
'Cells/NzbDroneCell'
], function (NzbDroneCell) {
return NzbDroneCell.extend({
className: 'backup-type-cell',
render: function () {
this.$el.empty();
var icon = 'icon-time';
var title = 'Scheduled';
var type = this.model.get(this.column.get('name'));
if (type === 'manual') {
icon = 'icon-book';
title = 'Manual';
}
else if (type === 'update') {
icon = 'icon-retweet';
title = 'Before update';
}
this.$el.html('<i class="{0}" title="{1}"></i>'.format(icon, title));
return this;
}
});
});