New: Backup drone's database and configuration from the UI New: Download Backup files from the UI Fixed: Run a database backup before upgradepull/3113/head
parent
d74e461aea
commit
c5bd8b27fb
@ -0,0 +1,31 @@
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Api.Frontend.Mappers
|
||||
{
|
||||
public class BackupFileMapper : StaticResourceMapperBase
|
||||
{
|
||||
private readonly IAppFolderInfo _appFolderInfo;
|
||||
|
||||
public BackupFileMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger)
|
||||
: base(diskProvider, logger)
|
||||
{
|
||||
_appFolderInfo = appFolderInfo;
|
||||
}
|
||||
|
||||
protected override string Map(string resourceUrl)
|
||||
{
|
||||
var path = resourceUrl.Replace("/backup/", "").Replace('/', Path.DirectorySeparatorChar);
|
||||
|
||||
return Path.Combine(_appFolderInfo.GetBackupFolder(), path);
|
||||
}
|
||||
|
||||
public override bool CanHandle(string resourceUrl)
|
||||
{
|
||||
return resourceUrl.StartsWith("/backup/") && resourceUrl.ContainsIgnoreCase("nzbdrone_backup_") && resourceUrl.EndsWith(".zip");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'System/Backup/BackupEmptyViewTemplate'
|
||||
});
|
||||
});
|
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/TemplatedCell'
|
||||
], function (TemplatedCell) {
|
||||
return TemplatedCell.extend({
|
||||
|
||||
className: 'series-title',
|
||||
template : 'System/Backup/BackupFilenameCellTemplate'
|
||||
|
||||
});
|
||||
});
|
@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -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;
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in new issue