mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2024-11-23 11:33:14 +00:00
Merge pull request #274 from WebTools-NG/#271-Export-Filename-missing-type
Fixed #271
This commit is contained in:
commit
daddc57464
3 changed files with 42 additions and 40 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
* [#269 Levelcount broken for Custom levels](https://github.com/WebTools-NG/WebTools-NG/issues/269)
|
* [#269 Levelcount broken for Custom levels](https://github.com/WebTools-NG/WebTools-NG/issues/269)
|
||||||
* [#107 Allow export of Artist](https://github.com/WebTools-NG/WebTools-NG/issues/107)
|
* [#107 Allow export of Artist](https://github.com/WebTools-NG/WebTools-NG/issues/107)
|
||||||
|
* [#271 Export Filename missing type](https://github.com/WebTools-NG/WebTools-NG/issues/271)
|
||||||
|
|
||||||
## V0.1.16
|
## V0.1.16
|
||||||
|
|
||||||
|
|
|
@ -515,13 +515,14 @@ const excel2 = new class Excel {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getFileName({ Library, Level, Type, Module }){
|
async getFileName({ Library, Level, Type, Module, exType }){
|
||||||
const dateFormat = require('dateformat');
|
const dateFormat = require('dateformat');
|
||||||
const OutDir = wtconfig.get('General.ExportPath');
|
const OutDir = wtconfig.get('General.ExportPath');
|
||||||
const timeStamp=dateFormat(new Date(), "yyyy.mm.dd_h.MM.ss");
|
const timeStamp=dateFormat(new Date(), "yyyy.mm.dd_h.MM.ss");
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
let outFile = store.getters.getSelectedServer.name + '_';
|
let outFile = store.getters.getSelectedServer.name + '_';
|
||||||
outFile += Library + '_';
|
outFile += Library + '_';
|
||||||
|
outFile += exType + '_';
|
||||||
outFile += Level + '_';
|
outFile += Level + '_';
|
||||||
outFile += timeStamp + '.' + Type;
|
outFile += timeStamp + '.' + Type;
|
||||||
const targetDir = path.join(
|
const targetDir = path.join(
|
||||||
|
@ -533,18 +534,18 @@ const excel2 = new class Excel {
|
||||||
if (!fs.existsSync(targetDir)) {
|
if (!fs.existsSync(targetDir)) {
|
||||||
fs.mkdirSync(targetDir);
|
fs.mkdirSync(targetDir);
|
||||||
}
|
}
|
||||||
log.info(`OutFile is ${outFileWithPath}`)
|
log.info(`OutFile is ${outFileWithPath}`);
|
||||||
return outFileWithPath;
|
return outFileWithPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
async SaveWorkbook(Workbook, Library, Level, Type) {
|
async SaveWorkbook({ Workbook, Library, Level, Type, exType } ) {
|
||||||
const fs = require('fs')
|
const fs = require('fs');
|
||||||
const name = await this.getFileName( { Library: Library, Level: Level, Type: Type, Module: i18n.t('Modules.ET.Name') })
|
const name = await this.getFileName( { Library: Library, Level: Level, Type: Type, Module: i18n.t('Modules.ET.Name'), exType: exType });
|
||||||
log.info('Saving output file as: ' + name)
|
log.info('Saving output file as: ' + name);
|
||||||
// Save Excel on Hard Disk
|
// Save Excel on Hard Disk
|
||||||
Workbook.xlsx.writeBuffer()
|
Workbook.xlsx.writeBuffer()
|
||||||
.then(buffer => fs.writeFileSync(name, buffer))
|
.then(buffer => fs.writeFileSync(name, buffer))
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async postProcess( {name, val, title=""} ){
|
async postProcess( {name, val, title=""} ){
|
||||||
|
@ -918,15 +919,15 @@ const excel2 = new class Excel {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async createXLSXFile( {csvFile, level, libType, libName} )
|
async createXLSXFile( {csvFile, level, libType, libName, exType} )
|
||||||
{
|
{
|
||||||
// This will loop thru a csv file, and create xlsx file
|
// This will loop thru a csv file, and create xlsx file
|
||||||
// First create a WorkBook
|
// First create a WorkBook
|
||||||
const workBook = await excel2.NewExcelWorkBook()
|
const workBook = await excel2.NewExcelWorkBook();
|
||||||
// Create Sheet
|
// Create Sheet
|
||||||
let sheet = await excel2.NewSheet(workBook, libName, level)
|
let sheet = await excel2.NewSheet(workBook, libName, level);
|
||||||
// Add the header to the sheet
|
// Add the header to the sheet
|
||||||
await excel2.AddHeader(sheet, level, libType)
|
await excel2.AddHeader(sheet, level, libType);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
autoFilter sadly doesn't work :(
|
autoFilter sadly doesn't work :(
|
||||||
|
@ -980,19 +981,19 @@ const excel2 = new class Excel {
|
||||||
});
|
});
|
||||||
log.info('Setting xlsx column width ended')
|
log.info('Setting xlsx column width ended')
|
||||||
}
|
}
|
||||||
await excel2.SaveWorkbook(workBook, libName, level, "xlsx")
|
await excel2.SaveWorkbook( { Workbook: workBook, Library: libName, Level: level, Type: "xlsx", exType: exType});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async createOutFile( {libName, level, libType, baseURL, accessToken} )
|
async createOutFile( {libName, level, libType, baseURL, accessToken, exType} )
|
||||||
{
|
{
|
||||||
const header = excel2.GetHeader(level, libType)
|
const header = excel2.GetHeader(level, libType);
|
||||||
log.debug(`header: ${header}`);
|
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
|
// 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
|
// Open a file stream
|
||||||
const tmpFile = await excel2.getFileName({ Library: libName, Level: level, Type: 'tmp', Module: i18n.t('Modules.ET.Name') });
|
const tmpFile = await excel2.getFileName({ Library: libName, Level: level, Type: 'tmp', Module: i18n.t('Modules.ET.Name'), exType: exType });
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var stream = fs.createWriteStream(tmpFile, {flags:'a'});
|
var stream = fs.createWriteStream(tmpFile, {flags:'a'});
|
||||||
// Add the header
|
// Add the header
|
||||||
|
@ -1039,12 +1040,11 @@ const excel2 = new class Excel {
|
||||||
// Rename to real file name
|
// Rename to real file name
|
||||||
var newFile = tmpFile.replace('.tmp', '.csv')
|
var newFile = tmpFile.replace('.tmp', '.csv')
|
||||||
fs.renameSync(tmpFile, newFile);
|
fs.renameSync(tmpFile, newFile);
|
||||||
console.log('renamed complete');
|
|
||||||
// Need to export to xlsx as well?
|
// Need to export to xlsx as well?
|
||||||
if (wtconfig.get('ET.ExpExcel')){
|
if (wtconfig.get('ET.ExpExcel')){
|
||||||
log.info('We need to create an xlsx file as well')
|
log.info('We need to create an xlsx file as well');
|
||||||
store.commit("UPDATE_EXPORTSTATUS", i18n.t('Modules.ET.Status.CreateExlsFile'))
|
store.commit("UPDATE_EXPORTSTATUS", i18n.t('Modules.ET.Status.CreateExlsFile'));
|
||||||
await excel2.createXLSXFile( {csvFile: newFile, level: level, libType: libType, libName: libName})
|
await excel2.createXLSXFile( {csvFile: newFile, level: level, libType: libType, libName: libName, exType: exType});
|
||||||
}
|
}
|
||||||
store.commit("UPDATE_EXPORTSTATUS", `Export finished. File:"${newFile}" created`);
|
store.commit("UPDATE_EXPORTSTATUS", `Export finished. File:"${newFile}" created`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,10 @@ const actions = {
|
||||||
commit('UPDATE_SECTIONS', await et.getSections(baseURL, accessToken))
|
commit('UPDATE_SECTIONS', await et.getSections(baseURL, accessToken))
|
||||||
},
|
},
|
||||||
exportMedias({ getters }) {
|
exportMedias({ getters }) {
|
||||||
var baseURL = getters.getSelectedServerAddress
|
var baseURL = getters.getSelectedServerAddress;
|
||||||
var accessToken = getters.getSelectedServerToken
|
var accessToken = getters.getSelectedServerToken;
|
||||||
var libType = getters.getLibType
|
var libType = getters.getLibType;
|
||||||
|
var exType = getters.getLibType;
|
||||||
var levelName = et.getLevelDisplayName(getters.getSelectedExportLevel, libType);
|
var levelName = et.getLevelDisplayName(getters.getSelectedExportLevel, libType);
|
||||||
var libName = et.getLibDisplayName(getters.getSelectedSection, getters.getPmsSections);
|
var libName = et.getLibDisplayName(getters.getSelectedSection, getters.getPmsSections);
|
||||||
excel2.createOutFile( {
|
excel2.createOutFile( {
|
||||||
|
@ -57,7 +57,8 @@ const actions = {
|
||||||
level: levelName,
|
level: levelName,
|
||||||
libType: libType,
|
libType: libType,
|
||||||
baseURL: baseURL,
|
baseURL: baseURL,
|
||||||
accessToken: accessToken
|
accessToken: accessToken,
|
||||||
|
exType: exType
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue