mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-26 17:57:43 +00:00
New: Store last 5 used folders from manual import
This commit is contained in:
parent
f1a5261e0a
commit
f57dea7f1f
6 changed files with 95 additions and 9 deletions
|
@ -184,14 +184,14 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
|
|||
|
||||
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 importedTrackedDownload = new List<ManuallyImportedFile>();
|
||||
|
||||
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 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())
|
||||
{
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
var $ = require('jquery');
|
||||
var vent = require('./vent');
|
||||
|
||||
module.exports = {
|
||||
|
@ -14,6 +15,18 @@ module.exports = {
|
|||
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) {
|
||||
defaultValue = defaultValue || false;
|
||||
|
||||
|
@ -30,6 +43,10 @@ module.exports = {
|
|||
return storeValue.toString();
|
||||
},
|
||||
|
||||
setValueJson : function(key, value) {
|
||||
return this.setValue(key, JSON.stringify(value));
|
||||
},
|
||||
|
||||
setValue : function(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 moment = require('moment');
|
||||
require('../../Mixins/FileBrowser');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
|
@ -13,7 +17,14 @@ module.exports = Marionette.ItemView.extend({
|
|||
'click .x-manual-import' : '_manualImport',
|
||||
'click .x-automatic-import' : '_automaticImport',
|
||||
'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() {
|
||||
|
@ -26,14 +37,20 @@ module.exports = Marionette.ItemView.extend({
|
|||
},
|
||||
|
||||
_manualImport : function () {
|
||||
if (this.ui.path.val()) {
|
||||
this.trigger('manualImport', { folder: this.ui.path.val() });
|
||||
var path = this.ui.path.val();
|
||||
|
||||
if (path) {
|
||||
this._setRecentFolders(path);
|
||||
this.trigger('manualImport', { folder: path });
|
||||
}
|
||||
},
|
||||
|
||||
_automaticImport : function () {
|
||||
if (this.ui.path.val()) {
|
||||
this.trigger('automaticImport', { folder: this.ui.path.val() });
|
||||
var path = this.ui.path.val();
|
||||
|
||||
if (path) {
|
||||
this._setRecentFolders(path);
|
||||
this.trigger('automaticImport', { folder: path });
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -45,5 +62,23 @@ module.exports = Marionette.ItemView.extend({
|
|||
else {
|
||||
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 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="row">
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
|
|
12
src/UI/ManualImport/manualimport.less
vendored
12
src/UI/ManualImport/manualimport.less
vendored
|
@ -43,9 +43,21 @@
|
|||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.recent-folders {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.recent-folder {
|
||||
.clickable();
|
||||
}
|
||||
}
|
||||
|
||||
.manual-import-error {
|
||||
background-color : #fdefef;
|
||||
}
|
||||
|
||||
.recent-folder {
|
||||
.clickable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ $.fn.fileBrowser = function(options) {
|
|||
var input = $(this);
|
||||
var inputOptions = $.extend({ input : input }, options);
|
||||
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>');
|
||||
|
||||
|
|
Loading…
Reference in a new issue