mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2024-11-23 03:23:05 +00:00
Merge pull request #351 from WebTools-NG/#349-Simplify-ET-Custom-screen
#349 simplify et custom screen
This commit is contained in:
commit
587be9ead7
4 changed files with 109 additions and 49 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -132,7 +132,20 @@
|
|||
"ET": {
|
||||
"BuildInLevels": "*** Built-in levels ***",
|
||||
"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",
|
||||
"Description": "A custom level allows you to create your own export levels",
|
||||
"NewCustomLevel": "< Define new level >",
|
||||
|
@ -150,7 +163,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 +176,7 @@
|
|||
"LevelInfo": "Export level determines which data are going to be exported.",
|
||||
"Name": "ExportTools",
|
||||
"NoLevelFound": "N/A",
|
||||
|
||||
"optExpType": {
|
||||
"lblBtnExportMedia": "Export Media",
|
||||
"lblExportLevel": "Export Level",
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
<!-- 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-tooltip target="etTypeGroup" triggers="hover">
|
||||
{{ $t('Modules.ET.TT-ETType') }}
|
||||
{{ $t('Modules.ET.Custom.TT-CustType') }}
|
||||
</b-tooltip>
|
||||
<b-form-radio-group
|
||||
id="mediaType"
|
||||
<b-form-select
|
||||
v-model="selMediaType"
|
||||
@change.native="changeType()"
|
||||
id="mediaType"
|
||||
:options="optionsMediaType"
|
||||
@change="changeType()"
|
||||
name="mediaType">
|
||||
</b-form-radio-group>
|
||||
</b-form-select>
|
||||
</b-form-group>
|
||||
|
||||
<div> <!-- Select Custom Level -->
|
||||
|
@ -103,16 +103,16 @@
|
|||
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.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: "",
|
||||
deleteLevel: this.$t('Modules.ET.Custom.DeleteLevel'),
|
||||
|
@ -163,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.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?
|
||||
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");
|
||||
}
|
||||
// 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");
|
||||
}
|
||||
|
@ -238,23 +239,24 @@
|
|||
// Hide Modal box
|
||||
this.$refs['showNewLevel'].hide();
|
||||
// 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
|
||||
curLevels[this.NewLevelName] = this.NewLevelName;
|
||||
// Save
|
||||
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.levels`, curLevels);
|
||||
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.levels`, curLevels);
|
||||
// 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
|
||||
curLevelCount[this.NewLevelName] = 0;
|
||||
// Save
|
||||
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.LevelCount`, curLevelCount);
|
||||
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.LevelCount`, curLevelCount);
|
||||
// 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
|
||||
curLevel[this.NewLevelName] = [];
|
||||
// Save
|
||||
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.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.selMediaType}.level.${this.selCustLevel}`);
|
||||
const revSelMediaType = et.getLibTypeName(this.selMediaType);
|
||||
const levelFields = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.level.${this.selCustLevel}`);
|
||||
let curLevel = 0;
|
||||
levelFields.forEach(function (item) {
|
||||
// Get field level
|
||||
|
@ -276,11 +279,12 @@
|
|||
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 "${revSelMediaType}" was calculated as:${curLevel}`);
|
||||
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.LevelCount.${this.selCustLevel}`, curLevel);
|
||||
},
|
||||
changeType: function() {
|
||||
// Triggers when lib type is changed
|
||||
log.verbose(`Custom level type selected as ${(et.RevETmediaType[this.selMediaType]).toLowerCase()}`)
|
||||
this.genExportLevels();
|
||||
this.btnDeleteEnabled = false;
|
||||
this.resultList = [];
|
||||
|
@ -288,11 +292,14 @@
|
|||
this.fieldList = [];
|
||||
},
|
||||
deleteCustomLevel() {
|
||||
const revSelCustLevel = et.getLibTypeName(this.selMediaType);
|
||||
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.${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 = [];
|
||||
},
|
||||
|
@ -315,14 +322,15 @@
|
|||
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);
|
||||
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
|
||||
let curLevel = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.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.selMediaType}.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"));
|
||||
|
|
|
@ -454,8 +454,17 @@ const et = new class ET {
|
|||
|
||||
getCustomLevels(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];
|
||||
}
|
||||
// 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
|
||||
}
|
||||
|
@ -541,48 +550,65 @@ 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;
|
||||
switch(libType) {
|
||||
case 'movie':
|
||||
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;
|
||||
|
@ -590,7 +616,16 @@ const et = new class ET {
|
|||
// code block
|
||||
}
|
||||
// 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
|
||||
return filteredFields.sort().map((name, index) => {
|
||||
return { name, order: index + 1 };
|
||||
|
|
Loading…
Reference in a new issue