From 7b9cd65c1e507affe1ccae75e651275ec432e65f Mon Sep 17 00:00:00 2001 From: UKDTOM Date: Thu, 29 Apr 2021 23:42:26 +0200 Subject: [PATCH 1/4] #349 Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fa6e84..2baeabc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * [#342 Rename "Export Arts"](https://github.com/WebTools-NG/WebTools-NG/issues/342) * [#345 Switch ET Export type selection](https://github.com/WebTools-NG/WebTools-NG/issues/345) * [#347 No Media Library is showing](https://github.com/WebTools-NG/WebTools-NG/issues/347) +* [#349 Simplify ET Custom screen](https://github.com/WebTools-NG/WebTools-NG/issues/349) ## V0.3.4 From d073e3d7a246f215d4597fac8a6d51ca19a60713 Mon Sep 17 00:00:00 2001 From: UKDTOM Date: Fri, 30 Apr 2021 01:28:23 +0200 Subject: [PATCH 2/4] #349 WIP --- public/locales/en.json | 20 ++++- .../modules/ExportTools/Custom/custom.vue | 85 ++++++++++--------- .../modules/ExportTools/scripts/et.js | 14 ++- 3 files changed, 74 insertions(+), 45 deletions(-) diff --git a/public/locales/en.json b/public/locales/en.json index cf70e94..12ad068 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -132,7 +132,7 @@ "ET": { "BuildInLevels": "*** Built-in levels ***", "Custom": { - "SelCustType": "Select the type of export you want to customize", + "selCustType": "Select type to customize", "Title": "Custom levels", "Description": "A custom level allows you to create your own export levels", "NewCustomLevel": "< Define new level >", @@ -150,7 +150,9 @@ "availFields": "Availible fields:", "customFields": "Custom fields:", "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", "ErrorBadSepTitle": "Column separator issue", @@ -161,6 +163,20 @@ "LevelInfo": "Export level determines which data are going to be exported.", "Name": "ExportTools", "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": { "lblBtnExportMedia": "Export Media", "lblExportLevel": "Export Level", diff --git a/src/components/modules/ExportTools/Custom/custom.vue b/src/components/modules/ExportTools/Custom/custom.vue index 2e56947..8422a00 100644 --- a/src/components/modules/ExportTools/Custom/custom.vue +++ b/src/components/modules/ExportTools/Custom/custom.vue @@ -7,17 +7,17 @@
- + - {{ $t('Modules.ET.TT-ETType') }} + {{ $t('Modules.ET.Custom.TT-CustType') }} - - + @change="changeType" + name="selCustLevel"> +
@@ -101,20 +101,19 @@ }, data() { return { - selMediaType: "movie", optionsMediaType: [ - { text: i18n.t('Modules.ET.RadioMovies'), value: 'movie', disabled: false }, - { text: i18n.t('Modules.ET.RadioTVSeries'), value: 'show', disabled: false }, - { text: i18n.t('Modules.ET.RadioTVEpisodes'), value: 'episode', disabled: false }, - { text: i18n.t('Modules.ET.RadioAudioArtist'), value: 'artist', disabled: false }, - { text: i18n.t('Modules.ET.RadioAudioAlbum'), value: 'album', disabled: false }, - { text: i18n.t('Modules.ET.RadioAudioTrack'), value: 'track', disabled: false }, - { text: i18n.t('Modules.ET.RadioPhotos'), value: 'photo', disabled: false }, - { text: i18n.t('Modules.ET.RadioPlayLists') + '-' + i18n.t('Modules.ET.PlistTypeAudio'), value: '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.RadioPlayLists') + '-' + i18n.t('Modules.ET.PlistTypeVideo'), value: 'playlist-video', disabled: false } + { text: i18n.t('Modules.ET.optCustExpType.Movies'), value: et.ETmediaType.Movie, disabled: false }, + { text: i18n.t('Modules.ET.optCustExpType.TVSeries'), value: et.ETmediaType.Show, disabled: false }, + { text: i18n.t('Modules.ET.optCustExpType.TVEpisodes'), value: et.ETmediaType.Episode, disabled: false }, + { text: i18n.t('Modules.ET.optCustExpType.AudioArtist'), value: et.ETmediaType.Artist, disabled: false }, + { text: i18n.t('Modules.ET.optCustExpType.AudioAlbum'), value: et.ETmediaType.Album, disabled: false }, + { text: i18n.t('Modules.ET.optCustExpType.AudioTrack'), value: et.ETmediaType.Track, disabled: false }, + { text: i18n.t('Modules.ET.optCustExpType.Photos'), value: et.ETmediaType.Photo, disabled: false }, + { text: i18n.t('Modules.ET.optCustExpType.PlaylistAudio'), value: et.ETmediaType.Playlist_Audio, disabled: false }, + { text: i18n.t('Modules.ET.optCustExpType.PlaylistPhoto'), value: et.ETmediaType.Playlist_Photo, 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'), customTitle: this.$t('Modules.ET.Custom.NewLevelTitle'), NewLevelInputTxt: this.$t('Modules.ET.Custom.NewLevelName'), @@ -163,14 +162,14 @@ log.debug(`Customlevel ${this.selCustLevel} selected`); if (this.selCustLevel != 'NewLevel'){ // 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? - 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"); } // 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"); } @@ -208,7 +207,8 @@ }, genExportLevels() { // 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 item = {}; let custLabel = {}; @@ -238,23 +238,23 @@ // Hide Modal box this.$refs['showNewLevel'].hide(); // 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 curLevels[this.NewLevelName] = this.NewLevelName; // Save - wtconfig.set(`ET.CustomLevels.${this.selMediaType}.levels`, curLevels); + wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.levels`, curLevels); // 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 curLevelCount[this.NewLevelName] = 0; // Save - wtconfig.set(`ET.CustomLevels.${this.selMediaType}.LevelCount`, curLevelCount); + wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.LevelCount`, curLevelCount); // 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 curLevel[this.NewLevelName] = []; // Save - wtconfig.set(`ET.CustomLevels.${this.selMediaType}.level`, curLevel); + wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.level`, curLevel); // Update combobox this.genExportLevels(); //this.exportLevels; @@ -266,7 +266,7 @@ var fields = def['fields']; // Release def memory again 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; levelFields.forEach(function (item) { // Get field level @@ -276,23 +276,24 @@ curLevel = count; } }); - log.info(`LevelCount for "${this.selCustLevel}" of the type "${this.selMediaType}" was calculated as:${curLevel}`); - wtconfig.set(`ET.CustomLevels.${this.selMediaType}.LevelCount.${this.selCustLevel}`, curLevel); + log.info(`LevelCount for "${this.selCustLevel}" of the type "${this.selCustLevel}" was calculated as:${curLevel}`); + wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.LevelCount.${this.selCustLevel}`, curLevel); }, changeType: function() { + console.log('Ged 1', arguments[0]) // Triggers when lib type is changed this.genExportLevels(); this.btnDeleteEnabled = false; this.resultList = []; - this.selCustLevel = ""; + //this.selCustLevel = ""; this.fieldList = []; }, deleteCustomLevel() { log.info(`User confirmed to delete custom level: ${this.selCustLevel}`); this.$refs['confirmDeleteLevel'].hide(); - wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.levels.${this.selCustLevel}`); - wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.LevelCount.${this.selCustLevel}`); - wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.level.${this.selCustLevel}`); + wtconfig.delete(`ET.CustomLevels.${this.selCustLevel}.levels.${this.selCustLevel}`); + wtconfig.delete(`ET.CustomLevels.${this.selCustLevel}.LevelCount.${this.selCustLevel}`); + wtconfig.delete(`ET.CustomLevels.${this.selCustLevel}.level.${this.selCustLevel}`); this.genExportLevels(); this.resultList = []; }, @@ -315,14 +316,14 @@ result.push(this.resultList[k].name); } } - wtconfig.set(`ET.CustomLevels.${this.selMediaType}.Posters.${this.selCustLevel}`, bExportPosters); - wtconfig.set(`ET.CustomLevels.${this.selMediaType}.Art.${this.selCustLevel}`, bExportArt); + wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.Posters.${this.selCustLevel}`, bExportPosters); + wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.Art.${this.selCustLevel}`, bExportArt); // 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 curLevel[this.selCustLevel] = 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 this.updateLevelCount(); alert( i18n.t("Modules.ET.Custom.AlertSaved")); @@ -345,7 +346,7 @@ } this.resultList = []; await this.genExportLevels(); - this.fieldList = et.getAllFields( {libType: this.selMediaType}); + this.fieldList = et.getAllFields( {libType: this.selCustLevel}); this.getCustomLevel(); } } diff --git a/src/components/modules/ExportTools/scripts/et.js b/src/components/modules/ExportTools/scripts/et.js index 3290c40..6a39c6a 100644 --- a/src/components/modules/ExportTools/scripts/et.js +++ b/src/components/modules/ExportTools/scripts/et.js @@ -453,9 +453,21 @@ const et = new class ET { } getCustomLevels(libType) { + console.log('Ged 33', libType) + console.log('Ged 34', et.RevETmediaType[libType]) 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' - 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)) return levels } From 2f693661aaa1cae373d5c5999e3d8e080ec04cb6 Mon Sep 17 00:00:00 2001 From: UKDTOM Date: Sat, 1 May 2021 00:13:12 +0200 Subject: [PATCH 3/4] #349 WIP --- public/locales/en.json | 30 +++---- .../modules/ExportTools/Custom/custom.vue | 90 ++++++++++--------- .../modules/ExportTools/scripts/et.js | 40 +++++---- 3 files changed, 89 insertions(+), 71 deletions(-) diff --git a/public/locales/en.json b/public/locales/en.json index 12ad068..3e4b462 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -132,7 +132,20 @@ "ET": { "BuildInLevels": "*** Built-in levels ***", "Custom": { - "selCustType": "Select type to customize", + "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" + }, + "SelCustType": "Select type to customize", "Title": "Custom levels", "Description": "A custom level allows you to create your own export levels", "NewCustomLevel": "< Define new level >", @@ -163,20 +176,7 @@ "LevelInfo": "Export level determines which data are going to be exported.", "Name": "ExportTools", "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": { "lblBtnExportMedia": "Export Media", "lblExportLevel": "Export Level", diff --git a/src/components/modules/ExportTools/Custom/custom.vue b/src/components/modules/ExportTools/Custom/custom.vue index 8422a00..e94f3cb 100644 --- a/src/components/modules/ExportTools/Custom/custom.vue +++ b/src/components/modules/ExportTools/Custom/custom.vue @@ -7,17 +7,17 @@
- + {{ $t('Modules.ET.Custom.TT-CustType') }} - + @change="changeType()" + name="mediaType"> +
@@ -101,19 +101,20 @@ }, data() { return { + selMediaType: "movie", optionsMediaType: [ - { text: i18n.t('Modules.ET.optCustExpType.Movies'), value: et.ETmediaType.Movie, disabled: false }, - { text: i18n.t('Modules.ET.optCustExpType.TVSeries'), value: et.ETmediaType.Show, disabled: false }, - { text: i18n.t('Modules.ET.optCustExpType.TVEpisodes'), value: et.ETmediaType.Episode, disabled: false }, - { text: i18n.t('Modules.ET.optCustExpType.AudioArtist'), value: et.ETmediaType.Artist, disabled: false }, - { text: i18n.t('Modules.ET.optCustExpType.AudioAlbum'), value: et.ETmediaType.Album, disabled: false }, - { text: i18n.t('Modules.ET.optCustExpType.AudioTrack'), value: et.ETmediaType.Track, disabled: false }, - { text: i18n.t('Modules.ET.optCustExpType.Photos'), value: et.ETmediaType.Photo, disabled: false }, - { text: i18n.t('Modules.ET.optCustExpType.PlaylistAudio'), value: et.ETmediaType.Playlist_Audio, disabled: false }, - { text: i18n.t('Modules.ET.optCustExpType.PlaylistPhoto'), value: et.ETmediaType.Playlist_Photo, disabled: false }, - { text: i18n.t('Modules.ET.optCustExpType.PlaylistVideo'), value: et.ETmediaType.Playlist_Video, disabled: false } + { text: i18n.t('Modules.ET.Custom.optCustExpType.Movies'), value: et.ETmediaType.Movie, disabled: false }, + { text: i18n.t('Modules.ET.Custom.optCustExpType.TVSeries'), value: et.ETmediaType.Show, disabled: false }, + { text: i18n.t('Modules.ET.Custom.optCustExpType.TVEpisodes'), value: et.ETmediaType.Episode, disabled: false }, + { text: i18n.t('Modules.ET.Custom.optCustExpType.AudioArtist'), value: et.ETmediaType.Album, disabled: false }, + { text: i18n.t('Modules.ET.Custom.optCustExpType.AudioAlbum'), value: et.ETmediaType.Album, disabled: false }, + { text: i18n.t('Modules.ET.Custom.optCustExpType.AudioTrack'), value: et.ETmediaType.Track, disabled: false }, + { text: i18n.t('Modules.ET.Custom.optCustExpType.Photos'), value: et.ETmediaType.Photo, disabled: false }, + { text: i18n.t('Modules.ET.Custom.optCustExpType.PlaylistAudio'), value: et.ETmediaType.Playlist_Audio, disabled: false }, + { text: i18n.t('Modules.ET.Custom.optCustExpType.PlaylistPhoto'), value: et.ETmediaType.Playlist_Photo, disabled: false }, + { text: i18n.t('Modules.ET.Custom.optCustExpType.PlaylistVideo'), value: et.ETmediaType.Playlist_Video, disabled: false } ], - selCustLevel: "episode", + selCustLevel: "", deleteLevel: this.$t('Modules.ET.Custom.DeleteLevel'), customTitle: this.$t('Modules.ET.Custom.NewLevelTitle'), NewLevelInputTxt: this.$t('Modules.ET.Custom.NewLevelName'), @@ -162,14 +163,15 @@ log.debug(`Customlevel ${this.selCustLevel} selected`); if (this.selCustLevel != 'NewLevel'){ // Get fields from config.json file - let custLevel = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.level.${this.selCustLevel}`) + const revType =(et.RevETmediaType[this.selMediaType]).toLowerCase(); + let custLevel = wtconfig.get(`ET.CustomLevels.${revType}.level.${this.selCustLevel}`) // Do we need to export posters? - if ( wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.Posters.${this.selCustLevel}`, false) ) + if ( wtconfig.get(`ET.CustomLevels.${revType}.Posters.${this.selCustLevel}`, false) ) { custLevel.push("Export Posters"); } // Do we need to export art? - if ( wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.Art.${this.selCustLevel}`, false) ) + if ( wtconfig.get(`ET.CustomLevels.${revType}.Art.${this.selCustLevel}`, false) ) { custLevel.push("Export Art"); } @@ -207,8 +209,7 @@ }, genExportLevels() { // Returns valid levels for selected media type - const etCustomLevel = et.getCustomLevels(this.selCustLevel); - console.log('Ged 2', JSON.stringify(etCustomLevel)) + const etCustomLevel = et.getCustomLevels(this.selMediaType); const options = []; const item = {}; let custLabel = {}; @@ -238,23 +239,24 @@ // Hide Modal box this.$refs['showNewLevel'].hide(); // Get current level names - let curLevels = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.levels`); + const revSelMediaType = (et.RevETmediaType[this.selMediaType]).toLowerCase(); + let curLevels = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.levels`); // Add new level to JSON curLevels[this.NewLevelName] = this.NewLevelName; // Save - wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.levels`, curLevels); + wtconfig.set(`ET.CustomLevels.${revSelMediaType}.levels`, curLevels); // Get current level counts - let curLevelCount = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.LevelCount`); + let curLevelCount = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.LevelCount`); // Add new level to JSON curLevelCount[this.NewLevelName] = 0; // Save - wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.LevelCount`, curLevelCount); + wtconfig.set(`ET.CustomLevels.${revSelMediaType}.LevelCount`, curLevelCount); // Get current level names - let curLevel = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.level`); + let curLevel = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.level`); // Add new level to JSON curLevel[this.NewLevelName] = []; // Save - wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.level`, curLevel); + wtconfig.set(`ET.CustomLevels.${revSelMediaType}.level`, curLevel); // Update combobox this.genExportLevels(); //this.exportLevels; @@ -266,7 +268,8 @@ var fields = def['fields']; // Release def memory again def = null; - const levelFields = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.level.${this.selCustLevel}`); + const revSelMediaType = (et.RevETmediaType[this.selMediaType]).toLowerCase(); + const levelFields = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.level.${this.selCustLevel}`); let curLevel = 0; levelFields.forEach(function (item) { // Get field level @@ -276,24 +279,28 @@ curLevel = count; } }); - log.info(`LevelCount for "${this.selCustLevel}" of the type "${this.selCustLevel}" was calculated as:${curLevel}`); - wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.LevelCount.${this.selCustLevel}`, curLevel); + log.info(`LevelCount for "${this.selCustLevel}" of the type "${revSelMediaType}" was calculated as:${curLevel}`); + wtconfig.set(`ET.CustomLevels.${revSelMediaType}.LevelCount.${this.selCustLevel}`, curLevel); }, changeType: function() { - console.log('Ged 1', arguments[0]) // Triggers when lib type is changed + console.log('Ged 22', this.selMediaType) + log.verbose(`Custom level type selected as ${(et.RevETmediaType[this.selMediaType]).toLowerCase()}`) this.genExportLevels(); this.btnDeleteEnabled = false; this.resultList = []; - //this.selCustLevel = ""; + this.selCustLevel = ""; this.fieldList = []; }, deleteCustomLevel() { + const revSelCustLevel = (et.RevETmediaType[this.selMediaType]).toLowerCase(); log.info(`User confirmed to delete custom level: ${this.selCustLevel}`); this.$refs['confirmDeleteLevel'].hide(); - wtconfig.delete(`ET.CustomLevels.${this.selCustLevel}.levels.${this.selCustLevel}`); - wtconfig.delete(`ET.CustomLevels.${this.selCustLevel}.LevelCount.${this.selCustLevel}`); - wtconfig.delete(`ET.CustomLevels.${this.selCustLevel}.level.${this.selCustLevel}`); + wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.levels.${this.selCustLevel}`); + wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.LevelCount.${this.selCustLevel}`); + wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.level.${this.selCustLevel}`); + wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.Posters.${this.selCustLevel}`); + wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.Art.${this.selCustLevel}`); this.genExportLevels(); this.resultList = []; }, @@ -316,14 +323,15 @@ result.push(this.resultList[k].name); } } - wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.Posters.${this.selCustLevel}`, bExportPosters); - wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.Art.${this.selCustLevel}`, bExportArt); + const revSelMediaType = (et.RevETmediaType[this.selMediaType]).toLowerCase(); + wtconfig.set(`ET.CustomLevels.${revSelMediaType}.Posters.${this.selCustLevel}`, bExportPosters); + wtconfig.set(`ET.CustomLevels.${revSelMediaType}.Art.${this.selCustLevel}`, bExportArt); // Get current level names - let curLevel = wtconfig.get(`ET.CustomLevels.${this.selCustLevel}.level`); + let curLevel = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.level`); // Add new level to JSON curLevel[this.selCustLevel] = result; log.info(`Saving custom level ${this.selCustLevel} as ${JSON.stringify(result)}`) - wtconfig.set(`ET.CustomLevels.${this.selCustLevel}.level`, curLevel); + wtconfig.set(`ET.CustomLevels.${revSelMediaType}.level`, curLevel); // Now we need to update levelcount for the level this.updateLevelCount(); alert( i18n.t("Modules.ET.Custom.AlertSaved")); @@ -346,7 +354,7 @@ } this.resultList = []; await this.genExportLevels(); - this.fieldList = et.getAllFields( {libType: this.selCustLevel}); + this.fieldList = et.getAllFields( {libType: this.selMediaType}); this.getCustomLevel(); } } diff --git a/src/components/modules/ExportTools/scripts/et.js b/src/components/modules/ExportTools/scripts/et.js index 6a39c6a..b29dda5 100644 --- a/src/components/modules/ExportTools/scripts/et.js +++ b/src/components/modules/ExportTools/scripts/et.js @@ -453,8 +453,6 @@ const et = new class ET { } getCustomLevels(libType) { - console.log('Ged 33', libType) - console.log('Ged 34', et.RevETmediaType[libType]) 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]) @@ -465,7 +463,6 @@ const et = new class ET { { libType = et.RevETmediaType[libType]; } - console.log('Ged 35', libType.toLowerCase()) // Returns an json of custom levels for a selected type og medias, like 'movie' const levels = wtconfig.get(`ET.CustomLevels.${libType.toLowerCase()}.levels`, notDefined) log.debug('ET Custom LevelNames: ' + JSON.stringify(levels)) @@ -557,44 +554,47 @@ const et = new class ET { getAllFields( {libType}) { // We need to load fields and defs into typeFields var let typeFields; - switch(libType) { - case 'movie': + console.log('Ged 1', et.RevETmediaType[libType].toLowerCase()) + console.log('Ged 2', libType) + //switch( et.RevETmediaType[libType].toLowerCase()) { + switch( libType ) { + case et.ETmediaType.Movie: // code block typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Movie.json'))); break; - case 'episode': + case et.ETmediaType.Episode: // code block typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Episode.json'))); break; - case 'show': + case et.ETmediaType.Show: // code block typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Show.json'))); break; - case 'artist': + case et.ETmediaType.Artist: // code block typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Artist.json'))); break; - case 'album': + case et.ETmediaType.Album: // code block typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Album.json'))); break; - case 'track': + case et.ETmediaType.Track: // code block typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Track.json'))); break; - case 'photo': + case et.ETmediaType.Photo: // code block typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Photo.json'))); break; - case 'playlist-audio': + case et.ETmediaType.Playlist_Audio: // code block typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Playlist-audio.json'))); break; - case 'playlist-photo': + case et.ETmediaType.Playlist_Photo: // code block typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Playlist-photo.json'))); break; - case 'playlist-video': + case et.ETmediaType.Playlist_Video: // code block typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Playlist-video.json'))); break; @@ -602,7 +602,17 @@ const et = new class ET { // code block } // Get all the fields keys - var filteredFields = JSONPath({path: '$.' + libType + '.level.all.*', json: typeFields}); + let filteredFields; + if ( [et.ETmediaType.Playlist_Audio, et.ETmediaType.Playlist_Photo, et.ETmediaType.Playlist_Video].includes(libType) ) + { + console.log('Ged 55 got playlist type') + filteredFields = JSONPath({path: '$.playlist-' + et.RevETmediaType[libType].toLowerCase() + '.level.all.*', json: typeFields}); + + } + else + { + filteredFields = JSONPath({path: '$.' + et.RevETmediaType[libType].toLowerCase() + '.level.all.*', json: typeFields}); + } // Sort them, and add an index as well, so drageble is happy return filteredFields.sort().map((name, index) => { return { name, order: index + 1 }; From 28b3ebb89b00b60f88db91ea1d006691778ffaa9 Mon Sep 17 00:00:00 2001 From: UKDTOM Date: Sat, 1 May 2021 01:35:18 +0200 Subject: [PATCH 4/4] Fixed #349 --- .../modules/ExportTools/Custom/custom.vue | 11 ++++----- .../modules/ExportTools/scripts/et.js | 23 +++++++++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/components/modules/ExportTools/Custom/custom.vue b/src/components/modules/ExportTools/Custom/custom.vue index e94f3cb..8873b3b 100644 --- a/src/components/modules/ExportTools/Custom/custom.vue +++ b/src/components/modules/ExportTools/Custom/custom.vue @@ -163,7 +163,7 @@ log.debug(`Customlevel ${this.selCustLevel} selected`); if (this.selCustLevel != 'NewLevel'){ // Get fields from config.json file - const revType =(et.RevETmediaType[this.selMediaType]).toLowerCase(); + const revType = et.getLibTypeName(this.selMediaType); let custLevel = wtconfig.get(`ET.CustomLevels.${revType}.level.${this.selCustLevel}`) // Do we need to export posters? if ( wtconfig.get(`ET.CustomLevels.${revType}.Posters.${this.selCustLevel}`, false) ) @@ -239,7 +239,7 @@ // Hide Modal box this.$refs['showNewLevel'].hide(); // Get current level names - const revSelMediaType = (et.RevETmediaType[this.selMediaType]).toLowerCase(); + const revSelMediaType = et.getLibTypeName(this.selMediaType); let curLevels = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.levels`); // Add new level to JSON curLevels[this.NewLevelName] = this.NewLevelName; @@ -268,7 +268,7 @@ var fields = def['fields']; // Release def memory again def = null; - const revSelMediaType = (et.RevETmediaType[this.selMediaType]).toLowerCase(); + const revSelMediaType = et.getLibTypeName(this.selMediaType); const levelFields = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.level.${this.selCustLevel}`); let curLevel = 0; levelFields.forEach(function (item) { @@ -284,7 +284,6 @@ }, changeType: function() { // Triggers when lib type is changed - console.log('Ged 22', this.selMediaType) log.verbose(`Custom level type selected as ${(et.RevETmediaType[this.selMediaType]).toLowerCase()}`) this.genExportLevels(); this.btnDeleteEnabled = false; @@ -293,7 +292,7 @@ this.fieldList = []; }, deleteCustomLevel() { - const revSelCustLevel = (et.RevETmediaType[this.selMediaType]).toLowerCase(); + const revSelCustLevel = et.getLibTypeName(this.selMediaType); log.info(`User confirmed to delete custom level: ${this.selCustLevel}`); this.$refs['confirmDeleteLevel'].hide(); wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.levels.${this.selCustLevel}`); @@ -323,7 +322,7 @@ result.push(this.resultList[k].name); } } - const revSelMediaType = (et.RevETmediaType[this.selMediaType]).toLowerCase(); + const revSelMediaType = et.getLibTypeName(this.selMediaType); wtconfig.set(`ET.CustomLevels.${revSelMediaType}.Posters.${this.selCustLevel}`, bExportPosters); wtconfig.set(`ET.CustomLevels.${revSelMediaType}.Art.${this.selCustLevel}`, bExportArt); // Get current level names diff --git a/src/components/modules/ExportTools/scripts/et.js b/src/components/modules/ExportTools/scripts/et.js index b29dda5..26a800e 100644 --- a/src/components/modules/ExportTools/scripts/et.js +++ b/src/components/modules/ExportTools/scripts/et.js @@ -550,13 +550,27 @@ const et = new class ET { return out } + // Returns the name of the libtype + getLibTypeName( libType) { + if (this.isPlaylist(libType)) + { + return 'playlist-' + (et.RevETmediaType[libType]).toLowerCase(); + } + else + { + return (et.RevETmediaType[libType]).toLowerCase(); + } + } + + // Returns true if libtype is a playlist + isPlaylist( libType ) { + return [et.ETmediaType.Playlist_Audio, et.ETmediaType.Playlist_Photo, et.ETmediaType.Playlist_Video].includes(libType) == true; + } + // Return all field keys defined for a lib type, in a sorted array of json, with an index getAllFields( {libType}) { // We need to load fields and defs into typeFields var let typeFields; - console.log('Ged 1', et.RevETmediaType[libType].toLowerCase()) - console.log('Ged 2', libType) - //switch( et.RevETmediaType[libType].toLowerCase()) { switch( libType ) { case et.ETmediaType.Movie: // code block @@ -603,9 +617,8 @@ const et = new class ET { } // Get all the fields keys let filteredFields; - if ( [et.ETmediaType.Playlist_Audio, et.ETmediaType.Playlist_Photo, et.ETmediaType.Playlist_Video].includes(libType) ) + if (this.isPlaylist(libType)) { - console.log('Ged 55 got playlist type') filteredFields = JSONPath({path: '$.playlist-' + et.RevETmediaType[libType].toLowerCase() + '.level.all.*', json: typeFields}); }