Merge pull request #351 from WebTools-NG/#349-Simplify-ET-Custom-screen

#349 simplify et custom screen
This commit is contained in:
Tommy Mikkelsen 2021-05-01 01:39:28 +02:00 committed by GitHub
commit 587be9ead7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 109 additions and 49 deletions

View file

@ -6,6 +6,7 @@
* [#342 Rename "Export Arts"](https://github.com/WebTools-NG/WebTools-NG/issues/342) * [#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) * [#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) * [#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 ## V0.3.4

View file

@ -132,7 +132,20 @@
"ET": { "ET": {
"BuildInLevels": "*** Built-in levels ***", "BuildInLevels": "*** Built-in levels ***",
"Custom": { "Custom": {
"SelCustType": "Select the type of export you want 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", "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 +163,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 +176,7 @@
"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",
"optExpType": { "optExpType": {
"lblBtnExportMedia": "Export Media", "lblBtnExportMedia": "Export Media",
"lblExportLevel": "Export Level", "lblExportLevel": "Export Level",

View file

@ -9,15 +9,15 @@
<!-- 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="selMediaType" v-model="selMediaType"
@change.native="changeType()" id="mediaType"
:options="optionsMediaType" :options="optionsMediaType"
@change="changeType()"
name="mediaType"> name="mediaType">
</b-form-radio-group> </b-form-select>
</b-form-group> </b-form-group>
<div> <!-- Select Custom Level --> <div> <!-- Select Custom Level -->
@ -103,16 +103,16 @@
return { return {
selMediaType: "movie", selMediaType: "movie",
optionsMediaType: [ optionsMediaType: [
{ text: i18n.t('Modules.ET.RadioMovies'), value: 'movie', disabled: false }, { text: i18n.t('Modules.ET.Custom.optCustExpType.Movies'), value: et.ETmediaType.Movie, disabled: false },
{ text: i18n.t('Modules.ET.RadioTVSeries'), value: 'show', disabled: false }, { text: i18n.t('Modules.ET.Custom.optCustExpType.TVSeries'), value: et.ETmediaType.Show, disabled: false },
{ text: i18n.t('Modules.ET.RadioTVEpisodes'), value: 'episode', disabled: false }, { text: i18n.t('Modules.ET.Custom.optCustExpType.TVEpisodes'), value: et.ETmediaType.Episode, disabled: false },
{ text: i18n.t('Modules.ET.RadioAudioArtist'), value: 'artist', disabled: false }, { text: i18n.t('Modules.ET.Custom.optCustExpType.AudioArtist'), value: et.ETmediaType.Album, disabled: false },
{ text: i18n.t('Modules.ET.RadioAudioAlbum'), value: 'album', disabled: false }, { text: i18n.t('Modules.ET.Custom.optCustExpType.AudioAlbum'), value: et.ETmediaType.Album, disabled: false },
{ text: i18n.t('Modules.ET.RadioAudioTrack'), value: 'track', disabled: false }, { text: i18n.t('Modules.ET.Custom.optCustExpType.AudioTrack'), value: et.ETmediaType.Track, disabled: false },
{ text: i18n.t('Modules.ET.RadioPhotos'), value: 'photo', disabled: false }, { text: i18n.t('Modules.ET.Custom.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.Custom.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.Custom.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.Custom.optCustExpType.PlaylistVideo'), value: et.ETmediaType.Playlist_Video, disabled: false }
], ],
selCustLevel: "", selCustLevel: "",
deleteLevel: this.$t('Modules.ET.Custom.DeleteLevel'), deleteLevel: this.$t('Modules.ET.Custom.DeleteLevel'),
@ -163,14 +163,15 @@
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}`) const revType = et.getLibTypeName(this.selMediaType);
let custLevel = wtconfig.get(`ET.CustomLevels.${revType}.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.${revType}.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.${revType}.Art.${this.selCustLevel}`, false) )
{ {
custLevel.push("Export Art"); custLevel.push("Export Art");
} }
@ -238,23 +239,24 @@
// 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`); const revSelMediaType = et.getLibTypeName(this.selMediaType);
let curLevels = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.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.${revSelMediaType}.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.${revSelMediaType}.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.${revSelMediaType}.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.${revSelMediaType}.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.${revSelMediaType}.level`, curLevel);
// Update combobox // Update combobox
this.genExportLevels(); this.genExportLevels();
//this.exportLevels; //this.exportLevels;
@ -266,7 +268,8 @@
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 revSelMediaType = et.getLibTypeName(this.selMediaType);
const levelFields = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.level.${this.selCustLevel}`);
let curLevel = 0; let curLevel = 0;
levelFields.forEach(function (item) { levelFields.forEach(function (item) {
// Get field level // Get field level
@ -276,11 +279,12 @@
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 "${revSelMediaType}" was calculated as:${curLevel}`);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.LevelCount.${this.selCustLevel}`, curLevel); wtconfig.set(`ET.CustomLevels.${revSelMediaType}.LevelCount.${this.selCustLevel}`, curLevel);
}, },
changeType: function() { changeType: function() {
// Triggers when lib type is changed // Triggers when lib type is changed
log.verbose(`Custom level type selected as ${(et.RevETmediaType[this.selMediaType]).toLowerCase()}`)
this.genExportLevels(); this.genExportLevels();
this.btnDeleteEnabled = false; this.btnDeleteEnabled = false;
this.resultList = []; this.resultList = [];
@ -288,11 +292,14 @@
this.fieldList = []; this.fieldList = [];
}, },
deleteCustomLevel() { deleteCustomLevel() {
const revSelCustLevel = et.getLibTypeName(this.selMediaType);
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.${revSelCustLevel}.levels.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.LevelCount.${this.selCustLevel}`); wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.LevelCount.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.level.${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.genExportLevels();
this.resultList = []; this.resultList = [];
}, },
@ -315,14 +322,15 @@
result.push(this.resultList[k].name); result.push(this.resultList[k].name);
} }
} }
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.Posters.${this.selCustLevel}`, bExportPosters); const revSelMediaType = et.getLibTypeName(this.selMediaType);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.Art.${this.selCustLevel}`, bExportArt); wtconfig.set(`ET.CustomLevels.${revSelMediaType}.Posters.${this.selCustLevel}`, bExportPosters);
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.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.${revSelMediaType}.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.${revSelMediaType}.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"));

View file

@ -454,8 +454,17 @@ const et = new class ET {
getCustomLevels(libType) { getCustomLevels(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];
}
// 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
} }
@ -541,48 +550,65 @@ const et = new class ET {
return out 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 // Return all field keys defined for a lib type, in a sorted array of json, with an index
getAllFields( {libType}) { getAllFields( {libType}) {
// We need to load fields and defs into typeFields var // We need to load fields and defs into typeFields var
let typeFields; let typeFields;
switch(libType) { switch( libType ) {
case 'movie': case et.ETmediaType.Movie:
// code block // code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Movie.json'))); typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Movie.json')));
break; break;
case 'episode': case et.ETmediaType.Episode:
// code block // code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Episode.json'))); typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Episode.json')));
break; break;
case 'show': case et.ETmediaType.Show:
// code block // code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Show.json'))); typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Show.json')));
break; break;
case 'artist': case et.ETmediaType.Artist:
// code block // code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Artist.json'))); typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Artist.json')));
break; break;
case 'album': case et.ETmediaType.Album:
// code block // code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Album.json'))); typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Album.json')));
break; break;
case 'track': case et.ETmediaType.Track:
// code block // code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Track.json'))); typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Track.json')));
break; break;
case 'photo': case et.ETmediaType.Photo:
// code block // code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Photo.json'))); typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Photo.json')));
break; break;
case 'playlist-audio': case et.ETmediaType.Playlist_Audio:
// code block // code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Playlist-audio.json'))); typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Playlist-audio.json')));
break; break;
case 'playlist-photo': case et.ETmediaType.Playlist_Photo:
// code block // code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Playlist-photo.json'))); typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Playlist-photo.json')));
break; break;
case 'playlist-video': case et.ETmediaType.Playlist_Video:
// code block // code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Playlist-video.json'))); typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Playlist-video.json')));
break; break;
@ -590,7 +616,16 @@ const et = new class ET {
// code block // code block
} }
// Get all the fields keys // Get all the fields keys
var filteredFields = JSONPath({path: '$.' + libType + '.level.all.*', json: typeFields}); let filteredFields;
if (this.isPlaylist(libType))
{
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 // Sort them, and add an index as well, so drageble is happy
return filteredFields.sort().map((name, index) => { return filteredFields.sort().map((name, index) => {
return { name, order: index + 1 }; return { name, order: index + 1 };