This commit is contained in:
UKDTOM 2021-04-30 01:28:23 +02:00
parent 7b9cd65c1e
commit d073e3d7a2
3 changed files with 74 additions and 45 deletions

View file

@ -132,7 +132,7 @@
"ET": { "ET": {
"BuildInLevels": "*** Built-in levels ***", "BuildInLevels": "*** Built-in levels ***",
"Custom": { "Custom": {
"SelCustType": "Select the type of export you want to customize", "selCustType": "Select type to customize",
"Title": "Custom levels", "Title": "Custom levels",
"Description": "A custom level allows you to create your own export levels", "Description": "A custom level allows you to create your own export levels",
"NewCustomLevel": "< Define new level >", "NewCustomLevel": "< Define new level >",
@ -150,7 +150,9 @@
"availFields": "Availible fields:", "availFields": "Availible fields:",
"customFields": "Custom fields:", "customFields": "Custom fields:",
"AlertSaved": "Custom level saved", "AlertSaved": "Custom level saved",
"TT-ETEditLevel": "Here you select the level to create/delete/edit" "TT-ETEditLevel": "Here you select the level to create/delete/edit",
"TT-CustType": "Here you select the type of export you want to customize"
}, },
"Description": "@:Modules.ET.Name allows you to export detail information about the media in your libraries", "Description": "@:Modules.ET.Name allows you to export detail information about the media in your libraries",
"ErrorBadSepTitle": "Column separator issue", "ErrorBadSepTitle": "Column separator issue",
@ -161,6 +163,20 @@
"LevelInfo": "Export level determines which data are going to be exported.", "LevelInfo": "Export level determines which data are going to be exported.",
"Name": "ExportTools", "Name": "ExportTools",
"NoLevelFound": "N/A", "NoLevelFound": "N/A",
"optCustExpType": {
"AudioAlbum": "Audio Album",
"AudioArtist": "Audio Artist",
"AudioTrack": "Audio Track",
"Libraries": "Libraries",
"Movies": "Movies",
"Photos": "Photos",
"PlaylistAudio": "Playlist Audio",
"PlaylistVideo": "Playlist Video",
"PlaylistPhoto": "Playlist Photo",
"TVEpisodes": "TV Episodes",
"TVSeries": "TV Shows"
},
"optExpType": { "optExpType": {
"lblBtnExportMedia": "Export Media", "lblBtnExportMedia": "Export Media",
"lblExportLevel": "Export Level", "lblExportLevel": "Export Level",

View file

@ -7,17 +7,17 @@
<br /> <br />
<!-- Media type to export --> <!-- Media type to export -->
<b-form-group id="etTypeGroup" v-bind:label="$t('Modules.ET.Custom.SelCustType')" label-size="lg" label-class="font-weight-bold pt-0"> <b-form-group id="etTypeGroup" v-bind:label="$t('Modules.ET.Custom.selCustType')" label-size="lg" label-class="font-weight-bold pt-0">
<b-tooltip target="etTypeGroup" triggers="hover"> <b-tooltip target="etTypeGroup" triggers="hover">
{{ $t('Modules.ET.TT-ETType') }} {{ $t('Modules.ET.Custom.TT-CustType') }}
</b-tooltip> </b-tooltip>
<b-form-radio-group <b-form-select
id="mediaType" v-model="selCustLevel"
v-model="selMediaType" id="selCustLevel"
@change.native="changeType()"
:options="optionsMediaType" :options="optionsMediaType"
name="mediaType"> @change="changeType"
</b-form-radio-group> name="selCustLevel">
</b-form-select>
</b-form-group> </b-form-group>
<div> <!-- Select Custom Level --> <div> <!-- Select Custom Level -->
@ -101,20 +101,19 @@
}, },
data() { data() {
return { return {
selMediaType: "movie",
optionsMediaType: [ optionsMediaType: [
{ text: i18n.t('Modules.ET.RadioMovies'), value: 'movie', disabled: false }, { text: i18n.t('Modules.ET.optCustExpType.Movies'), value: et.ETmediaType.Movie, disabled: false },
{ text: i18n.t('Modules.ET.RadioTVSeries'), value: 'show', disabled: false }, { text: i18n.t('Modules.ET.optCustExpType.TVSeries'), value: et.ETmediaType.Show, disabled: false },
{ text: i18n.t('Modules.ET.RadioTVEpisodes'), value: 'episode', disabled: false }, { text: i18n.t('Modules.ET.optCustExpType.TVEpisodes'), value: et.ETmediaType.Episode, disabled: false },
{ text: i18n.t('Modules.ET.RadioAudioArtist'), value: 'artist', disabled: false }, { text: i18n.t('Modules.ET.optCustExpType.AudioArtist'), value: et.ETmediaType.Artist, disabled: false },
{ text: i18n.t('Modules.ET.RadioAudioAlbum'), value: 'album', disabled: false }, { text: i18n.t('Modules.ET.optCustExpType.AudioAlbum'), value: et.ETmediaType.Album, disabled: false },
{ text: i18n.t('Modules.ET.RadioAudioTrack'), value: 'track', disabled: false }, { text: i18n.t('Modules.ET.optCustExpType.AudioTrack'), value: et.ETmediaType.Track, disabled: false },
{ text: i18n.t('Modules.ET.RadioPhotos'), value: 'photo', disabled: false }, { text: i18n.t('Modules.ET.optCustExpType.Photos'), value: et.ETmediaType.Photo, disabled: false },
{ text: i18n.t('Modules.ET.RadioPlayLists') + '-' + i18n.t('Modules.ET.PlistTypeAudio'), value: 'playlist-audio', disabled: false }, { text: i18n.t('Modules.ET.optCustExpType.PlaylistAudio'), value: et.ETmediaType.Playlist_Audio, disabled: false },
{ text: i18n.t('Modules.ET.RadioPlayLists') + '-' + i18n.t('Modules.ET.PlistTypePhoto'), value: 'playlist-photo', disabled: false }, { text: i18n.t('Modules.ET.optCustExpType.PlaylistPhoto'), value: et.ETmediaType.Playlist_Photo, disabled: false },
{ text: i18n.t('Modules.ET.RadioPlayLists') + '-' + i18n.t('Modules.ET.PlistTypeVideo'), value: 'playlist-video', disabled: false } { text: i18n.t('Modules.ET.optCustExpType.PlaylistVideo'), value: et.ETmediaType.Playlist_Video, disabled: false }
], ],
selCustLevel: "", selCustLevel: "episode",
deleteLevel: this.$t('Modules.ET.Custom.DeleteLevel'), deleteLevel: this.$t('Modules.ET.Custom.DeleteLevel'),
customTitle: this.$t('Modules.ET.Custom.NewLevelTitle'), customTitle: this.$t('Modules.ET.Custom.NewLevelTitle'),
NewLevelInputTxt: this.$t('Modules.ET.Custom.NewLevelName'), NewLevelInputTxt: this.$t('Modules.ET.Custom.NewLevelName'),
@ -163,14 +162,14 @@
log.debug(`Customlevel ${this.selCustLevel} selected`); log.debug(`Customlevel ${this.selCustLevel} selected`);
if (this.selCustLevel != 'NewLevel'){ if (this.selCustLevel != 'NewLevel'){
// Get fields from config.json file // Get fields from config.json file
let custLevel = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level.${this.selCustLevel}`) let custLevel = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.level.${this.selCustLevel}`)
// Do we need to export posters? // Do we need to export posters?
if ( wtconfig.get(`ET.CustomLevels.${this.selMediaType}.Posters.${this.selCustLevel}`, false) ) if ( wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.Posters.${this.selCustLevel}`, false) )
{ {
custLevel.push("Export Posters"); custLevel.push("Export Posters");
} }
// Do we need to export art? // Do we need to export art?
if ( wtconfig.get(`ET.CustomLevels.${this.selMediaType}.Art.${this.selCustLevel}`, false) ) if ( wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.Art.${this.selCustLevel}`, false) )
{ {
custLevel.push("Export Art"); custLevel.push("Export Art");
} }
@ -208,7 +207,8 @@
}, },
genExportLevels() { genExportLevels() {
// Returns valid levels for selected media type // Returns valid levels for selected media type
const etCustomLevel = et.getCustomLevels(this.selMediaType); const etCustomLevel = et.getCustomLevels(this.selCustLevel);
console.log('Ged 2', JSON.stringify(etCustomLevel))
const options = []; const options = [];
const item = {}; const item = {};
let custLabel = {}; let custLabel = {};
@ -238,23 +238,23 @@
// Hide Modal box // Hide Modal box
this.$refs['showNewLevel'].hide(); this.$refs['showNewLevel'].hide();
// Get current level names // Get current level names
let curLevels = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.levels`); let curLevels = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.levels`);
// Add new level to JSON // Add new level to JSON
curLevels[this.NewLevelName] = this.NewLevelName; curLevels[this.NewLevelName] = this.NewLevelName;
// Save // Save
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.levels`, curLevels); wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.levels`, curLevels);
// Get current level counts // Get current level counts
let curLevelCount = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.LevelCount`); let curLevelCount = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.LevelCount`);
// Add new level to JSON // Add new level to JSON
curLevelCount[this.NewLevelName] = 0; curLevelCount[this.NewLevelName] = 0;
// Save // Save
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.LevelCount`, curLevelCount); wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.LevelCount`, curLevelCount);
// Get current level names // Get current level names
let curLevel = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level`); let curLevel = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.level`);
// Add new level to JSON // Add new level to JSON
curLevel[this.NewLevelName] = []; curLevel[this.NewLevelName] = [];
// Save // Save
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.level`, curLevel); wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.level`, curLevel);
// Update combobox // Update combobox
this.genExportLevels(); this.genExportLevels();
//this.exportLevels; //this.exportLevels;
@ -266,7 +266,7 @@
var fields = def['fields']; var fields = def['fields'];
// Release def memory again // Release def memory again
def = null; def = null;
const levelFields = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level.${this.selCustLevel}`); const levelFields = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.level.${this.selCustLevel}`);
let curLevel = 0; let curLevel = 0;
levelFields.forEach(function (item) { levelFields.forEach(function (item) {
// Get field level // Get field level
@ -276,23 +276,24 @@
curLevel = count; curLevel = count;
} }
}); });
log.info(`LevelCount for "${this.selCustLevel}" of the type "${this.selMediaType}" was calculated as:${curLevel}`); log.info(`LevelCount for "${this.selCustLevel}" of the type "${this.selCustLevel}" was calculated as:${curLevel}`);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.LevelCount.${this.selCustLevel}`, curLevel); wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.LevelCount.${this.selCustLevel}`, curLevel);
}, },
changeType: function() { changeType: function() {
console.log('Ged 1', arguments[0])
// Triggers when lib type is changed // Triggers when lib type is changed
this.genExportLevels(); this.genExportLevels();
this.btnDeleteEnabled = false; this.btnDeleteEnabled = false;
this.resultList = []; this.resultList = [];
this.selCustLevel = ""; //this.selCustLevel = "";
this.fieldList = []; this.fieldList = [];
}, },
deleteCustomLevel() { deleteCustomLevel() {
log.info(`User confirmed to delete custom level: ${this.selCustLevel}`); log.info(`User confirmed to delete custom level: ${this.selCustLevel}`);
this.$refs['confirmDeleteLevel'].hide(); this.$refs['confirmDeleteLevel'].hide();
wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.levels.${this.selCustLevel}`); wtconfig.delete(`ET.CustomLevels.${this.selCustLevel}.levels.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.LevelCount.${this.selCustLevel}`); wtconfig.delete(`ET.CustomLevels.${this.selCustLevel}.LevelCount.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.level.${this.selCustLevel}`); wtconfig.delete(`ET.CustomLevels.${this.selCustLevel}.level.${this.selCustLevel}`);
this.genExportLevels(); this.genExportLevels();
this.resultList = []; this.resultList = [];
}, },
@ -315,14 +316,14 @@
result.push(this.resultList[k].name); result.push(this.resultList[k].name);
} }
} }
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.Posters.${this.selCustLevel}`, bExportPosters); wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.Posters.${this.selCustLevel}`, bExportPosters);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.Art.${this.selCustLevel}`, bExportArt); wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.Art.${this.selCustLevel}`, bExportArt);
// Get current level names // Get current level names
let curLevel = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level`); let curLevel = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.level`);
// Add new level to JSON // Add new level to JSON
curLevel[this.selCustLevel] = result; curLevel[this.selCustLevel] = result;
log.info(`Saving custom level ${this.selCustLevel} as ${JSON.stringify(result)}`) log.info(`Saving custom level ${this.selCustLevel} as ${JSON.stringify(result)}`)
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.level`, curLevel); wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.level`, curLevel);
// Now we need to update levelcount for the level // Now we need to update levelcount for the level
this.updateLevelCount(); this.updateLevelCount();
alert( i18n.t("Modules.ET.Custom.AlertSaved")); alert( i18n.t("Modules.ET.Custom.AlertSaved"));
@ -345,7 +346,7 @@
} }
this.resultList = []; this.resultList = [];
await this.genExportLevels(); await this.genExportLevels();
this.fieldList = et.getAllFields( {libType: this.selMediaType}); this.fieldList = et.getAllFields( {libType: this.selCustLevel});
this.getCustomLevel(); this.getCustomLevel();
} }
} }

View file

@ -453,9 +453,21 @@ const et = new class ET {
} }
getCustomLevels(libType) { getCustomLevels(libType) {
console.log('Ged 33', libType)
console.log('Ged 34', et.RevETmediaType[libType])
const notDefined = {"No Level Yet": ""} const notDefined = {"No Level Yet": ""}
if ([ et.ETmediaType.Playlist_Audio, et.ETmediaType.Playlist_Photo, et.ETmediaType.Playlist_Video].includes(libType))
//if (libType in [ et.ETmediaType.Playlist_Audio, et.ETmediaType.Playlist_Photo, et.ETmediaType.Playlist_Video])
{
libType = 'playlist-' + et.RevETmediaType[libType];
}
else
{
libType = et.RevETmediaType[libType];
}
console.log('Ged 35', libType.toLowerCase())
// Returns an json of custom levels for a selected type og medias, like 'movie' // Returns an json of custom levels for a selected type og medias, like 'movie'
const levels = wtconfig.get(`ET.CustomLevels.${libType}.levels`, notDefined) const levels = wtconfig.get(`ET.CustomLevels.${libType.toLowerCase()}.levels`, notDefined)
log.debug('ET Custom LevelNames: ' + JSON.stringify(levels)) log.debug('ET Custom LevelNames: ' + JSON.stringify(levels))
return levels return levels
} }