mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-21 22:04:31 -04:00
d9eab04029
Add, new setting "Set File Date to Airdate" on the Media Management tab of the Settings page to toggle this feature for new, imported and auto updating media files. Change, home page "Series Editor" - "Rename" button to "Update Files" and add "Set File Date To Air Date" action button to this modal to add capability of updating legacy media. Add, non UTC functions given that Windows undesirably adds time to file times set when using UTC. Fix, the Trakt API response show.air_time_utc contains erroneous data, this is replaced with show.air_time.
174 lines
6.4 KiB
JavaScript
174 lines
6.4 KiB
JavaScript
'use strict';
|
|
define(
|
|
[
|
|
'underscore',
|
|
'marionette',
|
|
'backgrid',
|
|
'vent',
|
|
'Series/SeriesCollection',
|
|
'Quality/QualityProfileCollection',
|
|
'AddSeries/RootFolders/RootFolderCollection',
|
|
'Shared/Toolbar/ToolbarLayout',
|
|
'AddSeries/RootFolders/RootFolderLayout',
|
|
'Series/Editor/UpdateFiles/UpdateFilesSeriesView',
|
|
'Config'
|
|
], function (_,
|
|
Marionette,
|
|
Backgrid,
|
|
vent,
|
|
SeriesCollection,
|
|
QualityProfiles,
|
|
RootFolders,
|
|
ToolbarLayout,
|
|
RootFolderLayout,
|
|
UpdateFilesSeriesView,
|
|
Config) {
|
|
return Marionette.ItemView.extend({
|
|
template: 'Series/Editor/SeriesEditorFooterViewTemplate',
|
|
|
|
ui: {
|
|
monitored : '.x-monitored',
|
|
qualityProfile : '.x-quality-profiles',
|
|
seasonFolder : '.x-season-folder',
|
|
rootFolder : '.x-root-folder',
|
|
selectedCount : '.x-selected-count',
|
|
saveButton : '.x-save',
|
|
updateFilesButton: '.x-update-files',
|
|
container : '.series-editor-footer'
|
|
},
|
|
|
|
events: {
|
|
'click .x-save' : '_updateAndSave',
|
|
'change .x-root-folder': '_rootFolderChanged',
|
|
'click .x-update-files': '_updateFiles'
|
|
},
|
|
|
|
templateHelpers: function () {
|
|
return {
|
|
qualityProfiles: QualityProfiles,
|
|
rootFolders : RootFolders.toJSON()
|
|
};
|
|
},
|
|
|
|
initialize: function (options) {
|
|
RootFolders.fetch().done(function () {
|
|
RootFolders.synced = true;
|
|
});
|
|
|
|
this.editorGrid = options.editorGrid;
|
|
this.listenTo(SeriesCollection, 'backgrid:selected', this._updateInfo);
|
|
this.listenTo(RootFolders, 'all', this.render);
|
|
},
|
|
|
|
onRender: function () {
|
|
this._updateInfo();
|
|
},
|
|
|
|
_updateAndSave: function () {
|
|
var selected = this.editorGrid.getSelectedModels();
|
|
|
|
var monitored = this.ui.monitored.val();
|
|
var profile = this.ui.qualityProfile.val();
|
|
var seasonFolder = this.ui.seasonFolder.val();
|
|
var rootFolder = this.ui.rootFolder.val();
|
|
|
|
_.each(selected, function (model) {
|
|
if (monitored === 'true') {
|
|
model.set('monitored', true);
|
|
}
|
|
|
|
else if (monitored === 'false') {
|
|
model.set('monitored', false);
|
|
}
|
|
|
|
if (profile !== 'noChange') {
|
|
model.set('qualityProfileId', parseInt(profile, 10));
|
|
}
|
|
|
|
if (seasonFolder === 'true') {
|
|
model.set('seasonFolder', true);
|
|
}
|
|
|
|
else if (seasonFolder === 'false') {
|
|
model.set('seasonFolder', false);
|
|
}
|
|
|
|
if (rootFolder !== 'noChange') {
|
|
var rootFolderPath = RootFolders.get(parseInt(rootFolder, 10));
|
|
|
|
model.set('rootFolderPath', rootFolderPath.get('path'));
|
|
}
|
|
|
|
model.edited = true;
|
|
});
|
|
|
|
SeriesCollection.save();
|
|
|
|
this.listenTo(SeriesCollection, 'save', this._afterSave);
|
|
},
|
|
|
|
_updateInfo: function () {
|
|
var selected = this.editorGrid.getSelectedModels();
|
|
var selectedCount = selected.length;
|
|
|
|
this.ui.selectedCount.html('{0} series selected'.format(selectedCount));
|
|
|
|
if (selectedCount === 0) {
|
|
this.ui.monitored.attr('disabled', '');
|
|
this.ui.qualityProfile.attr('disabled', '');
|
|
this.ui.seasonFolder.attr('disabled', '');
|
|
this.ui.rootFolder.attr('disabled', '');
|
|
this.ui.saveButton.attr('disabled', '');
|
|
this.ui.updateFilesButton.attr('disabled', '');
|
|
}
|
|
|
|
else {
|
|
this.ui.monitored.removeAttr('disabled', '');
|
|
this.ui.qualityProfile.removeAttr('disabled', '');
|
|
this.ui.seasonFolder.removeAttr('disabled', '');
|
|
this.ui.rootFolder.removeAttr('disabled', '');
|
|
this.ui.saveButton.removeAttr('disabled', '');
|
|
this.ui.updateFilesButton.removeAttr('disabled', '');
|
|
}
|
|
},
|
|
|
|
_rootFolderChanged: function () {
|
|
var rootFolderValue = this.ui.rootFolder.val();
|
|
if (rootFolderValue === 'addNew') {
|
|
var rootFolderLayout = new RootFolderLayout();
|
|
this.listenToOnce(rootFolderLayout, 'folderSelected', this._setRootFolder);
|
|
vent.trigger(vent.Commands.OpenModalCommand, rootFolderLayout);
|
|
}
|
|
else {
|
|
Config.setValue(Config.Keys.DefaultRootFolderId, rootFolderValue);
|
|
}
|
|
},
|
|
|
|
_setRootFolder: function (options) {
|
|
vent.trigger(vent.Commands.CloseModalCommand);
|
|
this.ui.rootFolder.val(options.model.id);
|
|
this._rootFolderChanged();
|
|
},
|
|
|
|
_afterSave: function () {
|
|
this.ui.monitored.val('noChange');
|
|
this.ui.qualityProfile.val('noChange');
|
|
this.ui.seasonFolder.val('noChange');
|
|
this.ui.rootFolder.val('noChange');
|
|
|
|
SeriesCollection.each(function (model) {
|
|
model.trigger('backgrid:select', model, false);
|
|
model.edited = false;
|
|
});
|
|
},
|
|
|
|
_updateFiles: function () {
|
|
var selected = this.editorGrid.getSelectedModels();
|
|
var updateFilesSeriesView = new UpdateFilesSeriesView({ series: selected });
|
|
this.listenToOnce(updateFilesSeriesView, 'updatingFiles', this._afterSave);
|
|
|
|
vent.trigger(vent.Commands.OpenModalCommand, updateFilesSeriesView);
|
|
}
|
|
});
|
|
});
|