New: Store last 5 used folders from manual import

pull/4/head
Mark McDowall 10 years ago
parent f1a5261e0a
commit f57dea7f1f

@ -184,14 +184,14 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
public void Execute(ManualImportCommand message) public void Execute(ManualImportCommand message)
{ {
_logger.ProgressInfo("Manually importing {0} files", message.Files.Count); _logger.ProgressTrace("Manually importing {0} files", message.Files.Count);
var imported = new List<ImportResult>(); var imported = new List<ImportResult>();
var importedTrackedDownload = new List<ManuallyImportedFile>(); var importedTrackedDownload = new List<ManuallyImportedFile>();
for (int i = 0; i < message.Files.Count; i++) for (int i = 0; i < message.Files.Count; i++)
{ {
_logger.ProgressInfo("Processing file {0} of {1}", i + 1, message.Files.Count); _logger.ProgressTrace("Processing file {0} of {1}", i + 1, message.Files.Count);
var file = message.Files[i]; var file = message.Files[i];
var series = _seriesService.GetSeries(file.SeriesId); var series = _seriesService.GetSeries(file.SeriesId);
@ -237,7 +237,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
} }
} }
_logger.ProgressInfo("Manually imported {0}", imported.Count); _logger.ProgressTrace("Manually imported {0} files", imported.Count);
foreach (var groupedTrackedDownload in importedTrackedDownload.GroupBy(i => i.TrackedDownload.DownloadItem.DownloadId).ToList()) foreach (var groupedTrackedDownload in importedTrackedDownload.GroupBy(i => i.TrackedDownload.DownloadItem.DownloadId).ToList())
{ {

@ -1,3 +1,4 @@
var $ = require('jquery');
var vent = require('./vent'); var vent = require('./vent');
module.exports = { module.exports = {
@ -14,6 +15,18 @@ module.exports = {
AdvancedSettings : 'advancedSettings' AdvancedSettings : 'advancedSettings'
}, },
getValueJson : function (key, defaultValue) {
defaultValue = defaultValue || {};
var storeValue = window.localStorage.getItem(key);
if (!storeValue) {
return defaultValue;
}
return $.parseJSON(storeValue);
},
getValueBoolean : function(key, defaultValue) { getValueBoolean : function(key, defaultValue) {
defaultValue = defaultValue || false; defaultValue = defaultValue || false;
@ -30,6 +43,10 @@ module.exports = {
return storeValue.toString(); return storeValue.toString();
}, },
setValueJson : function(key, value) {
return this.setValue(key, JSON.stringify(value));
},
setValue : function(key, value) { setValue : function(key, value) {
console.log('Config: [{0}] => [{1}]'.format(key, value)); console.log('Config: [{0}] => [{1}]'.format(key, value));

@ -1,4 +1,8 @@
var _ = require('underscore');
var $ = require('jquery');
var Config = require('../../Config');
var Marionette = require('marionette'); var Marionette = require('marionette');
var moment = require('moment');
require('../../Mixins/FileBrowser'); require('../../Mixins/FileBrowser');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
@ -13,7 +17,14 @@ module.exports = Marionette.ItemView.extend({
'click .x-manual-import' : '_manualImport', 'click .x-manual-import' : '_manualImport',
'click .x-automatic-import' : '_automaticImport', 'click .x-automatic-import' : '_automaticImport',
'change .x-path' : '_updateButtons', 'change .x-path' : '_updateButtons',
'keyup .x-path' : '_updateButtons' 'keyup .x-path' : '_updateButtons',
'click .x-recent-folder' : '_selectRecentFolder'
},
initialize : function () {
this.templateHelpers = {
recentFolders: Config.getValueJson('manualimport.recentfolders', [])
};
}, },
onRender : function() { onRender : function() {
@ -26,14 +37,20 @@ module.exports = Marionette.ItemView.extend({
}, },
_manualImport : function () { _manualImport : function () {
if (this.ui.path.val()) { var path = this.ui.path.val();
this.trigger('manualImport', { folder: this.ui.path.val() });
if (path) {
this._setRecentFolders(path);
this.trigger('manualImport', { folder: path });
} }
}, },
_automaticImport : function () { _automaticImport : function () {
if (this.ui.path.val()) { var path = this.ui.path.val();
this.trigger('automaticImport', { folder: this.ui.path.val() });
if (path) {
this._setRecentFolders(path);
this.trigger('automaticImport', { folder: path });
} }
}, },
@ -45,5 +62,23 @@ module.exports = Marionette.ItemView.extend({
else { else {
this.ui.buttons.attr('disabled', 'disabled'); this.ui.buttons.attr('disabled', 'disabled');
} }
},
_selectRecentFolder : function (e) {
var path = $(e.target).closest('tr').data('path');
this.ui.path.val(path);
this.ui.path.trigger('change');
},
_setRecentFolders : function (path) {
var recentFolders = Config.getValueJson('manualimport.recentfolders', []);
recentFolders = _.filter(recentFolders, function (folder) {
return folder.path.toLowerCase() !== path.toLowerCase();
});
recentFolders.unshift({ path: path, lastUsed: moment.utc().toISOString() });
Config.setValueJson('manualimport.recentfolders', _.take(recentFolders, 5));
} }
}); });

@ -6,6 +6,28 @@
</div> </div>
</div> </div>
</div> </div>
<div class="recent-folders">
{{#if recentFolders}}
<h4>Recent Folders</h4>
<table class="table table-hover">
<thead>
<tr>
<th>Path</th>
<th>Last Used</th>
</tr>
</thead>
<tbody>
{{#each recentFolders}}
<tr class="recent-folder x-recent-folder" data-path="{{path}}">
<td>{{path}}</td>
<td>{{RelativeDate lastUsed}}</td>
</tr>
{{/each}}
</tbody>
</table>
{{/if}}
</div>
<div class="buttons"> <div class="buttons">
<div class="row"> <div class="row">
<div class="col-md-4 col-md-offset-4"> <div class="col-md-4 col-md-offset-4">

@ -43,9 +43,21 @@
margin-top: 10px; margin-top: 10px;
} }
} }
.recent-folders {
margin-top: 20px;
}
.recent-folder {
.clickable();
}
} }
.manual-import-error { .manual-import-error {
background-color : #fdefef; background-color : #fdefef;
} }
.recent-folder {
.clickable();
}
} }

@ -10,7 +10,7 @@ $.fn.fileBrowser = function(options) {
var input = $(this); var input = $(this);
var inputOptions = $.extend({ input : input }, options); var inputOptions = $.extend({ input : input }, options);
var inputGroup = $('<div class="input-group"></div>'); var inputGroup = $('<div class="input-group"></div>');
var inputGroupButton = $('<span class="input-group-btn "></span>'); var inputGroupButton = $('<span class="input-group-btn"></span>');
var button = $('<button class="btn btn-primary x-file-browser" title="Browse"><i class="icon-sonarr-folder-open"/></button>'); var button = $('<button class="btn btn-primary x-file-browser" title="Browse"><i class="icon-sonarr-folder-open"/></button>');

Loading…
Cancel
Save