Merge pull request #241 from WebTools-NG/#239-Does-not-output-if-the-output-folder-does-NOT-exist

#239 does not output if the output folder does not exist
This commit is contained in:
Tommy Mikkelsen 2021-02-15 01:26:16 +01:00 committed by GitHub
commit 486b39102c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 113 additions and 50 deletions

View file

@ -11,6 +11,7 @@
* [#233 Electron errors after updating](https://github.com/WebTools-NG/WebTools-NG/pull/233)
* [#234 Editing a custom level](https://github.com/WebTools-NG/WebTools-NG/pull/234)
* [#238 We need a Text qualifier](https://github.com/WebTools-NG/WebTools-NG/pull/238)
* [#239 Does not output if the output folder does NOT exist](https://github.com/WebTools-NG/WebTools-NG/pull/239)
## V0.1.13

View file

@ -121,7 +121,11 @@
"Body": "{0} was released on Github on: {1}.",
"Body2": "Click here for more info",
"Skip": "Don't show notification for this version anymore"
}
},
"ExportDir": "Select Export Directory",
"Browse": "Browse",
"ErrorNoOutDirMsg": "You need to define an output directory in the global settings page first",
"ErrorNoOutDirTitle": "No output directory defined"
},
"Modules": {
"PlexTV": {
@ -207,9 +211,7 @@
"ErrorNoServerSelectedMsg": "You need to select a server to extract from",
"Settings": {
"Settings": "Settings",
"Description": "Here you can define the settings for @:Modules.ET.Name",
"Browse": "Browse",
"SelectOutDir": "Select Output Directory",
"Description": "Here you can define the settings for @:Modules.ET.Name",
"ArraySep": "Delimiter for multiple info in same field",
"ColumnSep": "Delimiter between columns in CSV file (Use 9 for TAB)",
"TimeOut": "Timeout when requesting info from PMS in sec (Global setting)",
@ -238,9 +240,7 @@
"CreateExlsFile": "Creating Excel file",
"ProcessItem": "Processing item {count} of {total}",
"GetSectionItems": "Fetching items {idx} in chunks of {chunck} with a total of {totalSize}"
},
"ErrorNoOutDirTitle": "No output directory defined",
"ErrorNoOutDirMsg": "You need to define an output directory in the settings page first",
},
"ErrorBadSepTitle": "Column separator issue",
"ErrorBadSep": "Column separator can only be one character"
},

View file

@ -241,11 +241,11 @@
},
getMedia() {
log.info("getMedia Called");
if (wtconfig.get('ET.OutPath', "") == "")
if (wtconfig.get('General.ExportPath', "") == "")
{
log.info('ET: No output dir defined')
this.$bvToast.toast(this.$t("Modules.ET.ErrorNoOutDirMsg"), {
title: this.$t("Modules.ET.ErrorNoOutDirTitle"),
this.$bvToast.toast(this.$t("Common.ErrorNoOutDirMsg"), {
title: this.$t("Common.ErrorNoOutDirTitle"),
autoHideDelay: 3000,
solid: true,
variant: 'primary',

View file

@ -2,15 +2,7 @@
<b-container fluid>
<div class="col-lg-10 col-md-12 col-xs-12">
<h1>{{ $t("Modules.ET.Settings.Settings") }}</h1>
<p>{{ $t("Modules.ET.Settings.Description") }}</p>
<div>
<b-input-group id="outDir" :prepend="$t('Modules.ET.Settings.SelectOutDir')" class="mt-3">
<b-form-input id="outDirbox" name="outDirbox" v-model="outDirVal" :disabled=true v-bind:placeholder="$t('Modules.ET.Settings.SelectOutDir')" />
<b-input-group-append>
<b-button variant="info" v-on:click="browse">{{ $t("Modules.ET.Settings.Browse") }}</b-button>
</b-input-group-append>
</b-input-group>
</div>
<p>{{ $t("Modules.ET.Settings.Description") }}</p>
<b-input-group id="ArraySepGrp" :prepend="$t('Modules.ET.Settings.ArraySep')" class="mt-3">
<b-form-input id="ArraySep" name="ArraySep" type="text" class="form-control" v-model="ArraySep" :disabled=false :maxlength=1 @change="setArraySep()"></b-form-input>
</b-input-group>
@ -57,8 +49,7 @@
}
},
data() {
return {
outDirVal: wtconfig.get('ET.OutPath', i18n.t('Modules.ET.Settings.SelectOutDir')),
return {
ArraySep: wtconfig.get('ET.ArraySep'),
TextQualifierCSV: wtconfig.get('ET.TextQualifierCSV', '"'),
NotAvailIndicator: wtconfig.get('ET.NotAvail', 'N/A'),
@ -89,17 +80,6 @@
wtconfig.set("ET." + cbItem, (this.cbSelected.includes(cbItem)))
}
},
browse: function(){
log.debug('Start browsing for Output Directory');
const outDir = dialog.OpenDirectory( i18n.t("Modules.ET.Settings.SelectOutDir"), i18n.t("Common.Ok"));
//const outDir = dialog.OpenDirectory('Title', 'OK');
if (outDir)
{
wtconfig.set('ET.OutPath', outDir[0]);
this.outDirVal = outDir[0];
log.debug(`Selected Directory is ${outDir}`);
}
},
setColumnSep(val){
if (val.length > 1)
{

View file

@ -482,23 +482,31 @@ const excel2 = new class Excel {
return true;
}
async getFileName({ Library, Level, Type }){
async getFileName({ Library, Level, Type, Module }){
const dateFormat = require('dateformat');
const OutDir = wtconfig.get('ET.OutPath', wtutils.UserHomeDir)
const OutDir = wtconfig.get('General.ExportPath');
const timeStamp=dateFormat(new Date(), "yyyy.mm.dd_h.MM.ss");
const path = require('path');
let outFile = store.getters.getSelectedServer.name + '_';
outFile += Library + '_';
outFile += Level + '_';
outFile += timeStamp + '.' + Type;
const targetDir = path.join(
OutDir, wtutils.AppName, Module);
const outFileWithPath = path.join(
OutDir, outFile);
targetDir, outFile);
// Make sure target dir exists
const fs = require('fs')
if (!fs.existsSync(targetDir)) {
fs.mkdirSync(targetDir);
}
log.info(`OutFile is ${outFileWithPath}`)
return outFileWithPath;
}
async SaveWorkbook(Workbook, Library, Level, Type) {
const fs = require('fs')
const name = await this.getFileName( { Library: Library, Level: Level, Type: Type })
const name = await this.getFileName( { Library: Library, Level: Level, Type: Type, Module: i18n.t('Modules.ET.Name') })
log.info('Saving output file as: ' + name)
// Save Excel on Hard Disk
Workbook.xlsx.writeBuffer()
@ -825,11 +833,11 @@ const excel2 = new class Excel {
{
const header = excel2.GetHeader(level, libType)
log.debug(`header: ${header}`);
const strHeader = header.join(wtconfig.get('ET.ColumnSep', ','))
const strHeader = header.join(wtconfig.get('ET.ColumnSep', ','));
// Now we need to find out how many calls to make
const call = await et.getLevelCall(libType, level)
const call = await et.getLevelCall(libType, level);
// Open a file stream
const tmpFile = await excel2.getFileName({ Library: libName, Level: level, Type: 'tmp' })
const tmpFile = await excel2.getFileName({ Library: libName, Level: level, Type: 'tmp', Module: i18n.t('Modules.ET.Name') });
var fs = require('fs');
var stream = fs.createWriteStream(tmpFile, {flags:'a'});
// Add the header

View file

@ -23,6 +23,42 @@ const wtutils = new class WTUtils {
return configFileName;
}
get ExportDirPresent(){
log.info('Checking ExportPath')
const ExportPath = wtconfig.get('General.ExportPath', 'N/A');
if ( ExportPath == 'N/A' ){
log.error('ExportPath not defined');
return false;
}
const fs = require("fs");
if (fs.existsSync(ExportPath)) {
const path = require('path');
const appExportDir = path.join(ExportPath, wtutils.AppName);
if (!fs.existsSync(appExportDir))
{
log.debug('Export dir existed, but AppDir didnt')
fs.mkdirSync(appExportDir)
if (fs.existsSync(appExportDir))
{
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
return false;
}
get RunningOS(){
return process.platform;
}
@ -245,9 +281,6 @@ const wtutils = new class WTUtils {
if ( wtconfig.get('ET.ColumnSep', 'N/A') == 'N/A' ){
wtconfig.set('ET.ColumnSep', ',')
}
if ( wtconfig.get('ET.OutPath', 'N/A') == 'N/A' ){
wtconfig.set('ET.OutPath', '')
}
if ( wtconfig.get('ET.NotAvail', 'N/A') == 'N/A' ){
wtconfig.set('ET.NotAvail', 'N/A')
}

View file

@ -3,7 +3,18 @@
<div class="col-lg-10 col-md-12 col-xs-12">
<h1>{{ $t("Modules.GlobalSettings.Title") }}</h1>
<p>{{ $t("Modules.GlobalSettings.Description") }}</p>
<div>
<b-input-group id="exportDir" :prepend="$t('Common.ExportDir')" class="mt-3">
<b-form-input id="exportDirbox" type="text" name="exportDirbox" v-model="ExportDirVal" :disabled=true v-bind:placeholder="$t('Common.ExportDir')" />
<b-input-group-append>
<b-button variant="info" v-on:click="browse">{{ $t("Common.Browse") }}</b-button>
</b-input-group-append>
</b-input-group>
</div>
<b-input-group id="TimeOutGrp" :prepend="$t('Modules.GlobalSettings.TimeOut')" class="mt-3">
<b-form-input id="TimeOut" name="TimeOut" type="text" class="form-control" v-model="TimeOut" :disabled=false :maxlength=2 @change="setTimeOut()"></b-form-input>
</b-input-group>
@ -57,9 +68,10 @@
wtutils, dialog, i18n
export default {
export default {
data() {
return {
ExportDirVal: wtconfig.get('General.ExportPath', i18n.t('Common.ExportDir')),
TimeOut: wtconfig.get('PMS.TimeOut'),
LogLevel: wtconfig.get('Log.fileLevel'),
LogLevelConsole: wtconfig.get('Log.consoleLevel'),
@ -69,6 +81,20 @@
}
},
methods: {
browse: function(){
log.debug('Start browsing for Export Directory');
const exportDir = dialog.OpenDirectory( i18n.t("Common.ExportDir"), i18n.t("Common.Ok"));
if (exportDir)
{
wtconfig.set('General.ExportPath', exportDir[0]);
this.ExportDirVal = exportDir[0];
log.debug(`Selected Directory is ${exportDir}`);
if (!wtutils.ExportDirPresent)
{
this.ExportDirVal = '*** ERROR ***';
}
}
},
factoryReset() {
// Doing a factory reset
log.warn('Doing a factory reset');
@ -167,7 +193,7 @@
}
},
computed: {
computed: {
logLevels: function() {
const options = ['error', 'warn', 'info', 'verbose', 'debug', 'silly'];
return options;

View file

@ -68,7 +68,8 @@ export default {
mounted() {
log.info("Home Created");
this.checkLangUpdates();
this.UpdatePresent();
this.UpdatePresent();
this.CheckExportDir();
},
methods: {
// Visit GitHub release page
@ -152,11 +153,26 @@ export default {
}
}
}
selLang, wtutils, selLangUpdated
},
async CheckExportDir() {
if ( wtutils.ExportDirPresent )
{
log.info('ExportDir OK');
}
else
{
log.error('ExportDir missing');
const bodyStr = i18n.t("Common.ErrorNoOutDirMsg");
this.$bvToast.toast(bodyStr, {
title: this.$t("Common.ErrorNoOutDirTitle"),
autoHideDelay: 400000,
solid: true,
variant: 'primary',
toaster: 'b-toaster-bottom-right'
});
selLang, i18n, wtutils, selLangUpdated
}
}
}
}

View file

@ -249,7 +249,6 @@
this.updateTbl(this.selSection);
},
getFilterSettings() {
console.log('Ged get filter settings')
this.selFilterSetting = wtconfig.get('PMS.FilterSetting', 'AllSettings');
}
}