mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2025-03-09 00:37:20 +00:00
XLSX
exports, removed buefy toest from export.vue
This commit is contained in:
parent
8accb04de7
commit
5f3a40b133
6 changed files with 102 additions and 62 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "webtools-ng",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"description": "WebTools Next Generation 4 Plex",
|
||||
"author": "dane22 & CPSO",
|
||||
"private": true,
|
||||
|
|
|
@ -142,7 +142,9 @@
|
|||
"GetSectionItems": "Fetching items {idx} in chunks of {chunck}"
|
||||
},
|
||||
"ErrorNoOutDirTitle": "No output directory defined",
|
||||
"ErrorNoOutDirMsg": "You need to define an output directory in the settings page first"
|
||||
"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"
|
||||
},
|
||||
"About": {
|
||||
"Description": "@:Modules.About.Name",
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
<h1 class="title is-3">{{ $t("Modules.ET.Name") }}</h1>
|
||||
<h2 class="subtitle">{{ $t("Modules.ET.Description") }}</h2>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
<div> <!-- Media type to export -->
|
||||
<b-form-group id="etTypeGroup" v-bind:label="$t('Modules.ET.HSelectMedia')" label-size="lg" label-class="font-weight-bold pt-0">
|
||||
|
@ -248,11 +250,13 @@
|
|||
//await this.$store.dispatch("fetchSections");
|
||||
} else {
|
||||
log.debug("serverCheck is none");
|
||||
this.$buefy.toast.open({
|
||||
duration: 3000,
|
||||
message: this.$t("Modules.ET.ErrorNoServerSelected"),
|
||||
type: "is-danger"
|
||||
});
|
||||
this.$bvToast.toast(this.$t("Modules.ET.ErrorNoServerSelected"), {
|
||||
// title: this.$t("Modules.ET.ErrorNoServerSelected"),
|
||||
autoHideDelay: 3000,
|
||||
solid: true,
|
||||
variant: 'danger',
|
||||
//toaster: 'b-toaster-bottom-center'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
</div>
|
||||
<b-input-group id="ArraySep" :prepend="$t('Modules.ET.Settings.ArraySep')" class="mt-3">
|
||||
<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>
|
||||
<b-input-group id="ColumnSep" :prepend="$t('Modules.ET.Settings.ColumnSep')" class="mt-3">
|
||||
<b-form-input id="ColumnSep" name="ColumnSep" type="text" class="form-control" v-model="ColumnSep" :disabled=false :maxlength=1 @change="setColumnSep()"></b-form-input>
|
||||
<b-input-group id="ColumnSepGrp" :prepend="$t('Modules.ET.Settings.ColumnSep')" class="mt-3">
|
||||
<b-form-input id="ColumnSep" name="ColumnSep" type="text" class="form-control" v-model="ColumnSep" :disabled=false :maxlength=1 @change="setColumnSep"></b-form-input>
|
||||
</b-input-group>
|
||||
<b-input-group id="TimeOut" :prepend="$t('Modules.ET.Settings.TimeOut')" class="mt-3">
|
||||
<b-input-group id="TimeOutGrp" :prepend="$t('Modules.ET.Settings.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>
|
||||
<b-form-group id="b-form-group">
|
||||
|
@ -36,13 +36,23 @@
|
|||
import i18n from '../../../../i18n'
|
||||
export default {
|
||||
created() {
|
||||
this.getcbDefaults()
|
||||
this.getcbDefaults();
|
||||
if (wtconfig.get('ET.ColumnSep') == '\t')
|
||||
{
|
||||
this.ColumnSep = '{TAB}';
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ColumnSep = wtconfig.get('ET.ColumnSep');
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
outDirVal: wtconfig.get('ET.OutPath', i18n.t('Modules.ET.Settings.SelectOutDir')),
|
||||
ArraySep: wtconfig.get('ET.ArraySep'),
|
||||
ColumnSep: wtconfig.get('ET.ColumnSep'),
|
||||
// ColumnSep: wtconfig.get('ET.ColumnSep'),
|
||||
ColumnSep: '',
|
||||
//ColumnSep1: this.computedColumnSep,
|
||||
TimeOut: wtconfig.get('PMS.TimeOut'),
|
||||
cbSelected: [],
|
||||
cbOptions: [
|
||||
|
@ -54,6 +64,39 @@
|
|||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
ColumnSep22: {
|
||||
// getter
|
||||
get: function () {
|
||||
if ( wtconfig.get('ET.ColumnSep') != '\t' ){
|
||||
console.log('Ged normal retur')
|
||||
return wtconfig.get('ET.ColumnSep')
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('Ged tab retur')
|
||||
return '{TAB}'
|
||||
}
|
||||
},
|
||||
// setter
|
||||
set: function (newValue) {
|
||||
wtconfig.set('ET.ColumnSep', newValue)
|
||||
}
|
||||
},
|
||||
computedColumnSep123: function(){
|
||||
if ( wtconfig.get('ET.ColumnSep') != '\t' ){
|
||||
console.log('Ged normal retur')
|
||||
return wtconfig.get('ET.ColumnSep')
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('Ged tab retur')
|
||||
return '{TAB}'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
getcbDefaults(){
|
||||
const cbItems = ["ExpExcel", "OrgTitleNull", "SortTitleNull", "AutoXLSCol", "AutoXLSRow"];
|
||||
|
@ -80,23 +123,36 @@
|
|||
log.debug(`Selected Directory is ${outDir}`);
|
||||
}
|
||||
},
|
||||
setColumnSep: function(){
|
||||
if (this.ColumnSep == '9')
|
||||
setColumnSep(val){
|
||||
if (val.length > 1)
|
||||
{
|
||||
wtconfig.set('ET.ColumnSep', '\t')
|
||||
this.$bvToast.toast(this.$t("Modules.ET.ErrorBadSep"), {
|
||||
title: this.$t("Modules.ET.ErrorBadSepTitle"),
|
||||
autoHideDelay: 3000,
|
||||
solid: true,
|
||||
variant: 'primary',
|
||||
toaster: 'b-toaster-bottom-center'
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
wtconfig.set('ET.ColumnSep', this.ColumnSep)
|
||||
{
|
||||
if (val == '9')
|
||||
{
|
||||
wtconfig.set('ET.ColumnSep', '\t')
|
||||
this.ColumnSep = '{TAB}'
|
||||
}
|
||||
else
|
||||
{
|
||||
wtconfig.set('ET.ColumnSep', this.ColumnSep)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
setArraySep: function(){
|
||||
wtconfig.set('ET.ArraySep', this.ArraySep)
|
||||
},
|
||||
setTimeOut: function(){
|
||||
wtconfig.set('PMS.TimeOut', this.TimeOut)
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -740,6 +740,14 @@ const excel2 = new class Excel {
|
|||
let sheet = await excel2.NewSheet(workBook, libName, level)
|
||||
// Add the header to the sheet
|
||||
await excel2.AddHeader(sheet, level, libType)
|
||||
|
||||
/*
|
||||
autoFilter sadly doesn't work :(
|
||||
sheet.autoFilter = {
|
||||
from: 'A1',
|
||||
to: 'E1',
|
||||
exclude: [1, 2] // excludes columns B and C from showing the AutoFilter button
|
||||
} */
|
||||
// Read the csv file line by line
|
||||
var lineReader = require('readline').createInterface({
|
||||
input: require('fs').createReadStream(csvFile)
|
||||
|
@ -775,45 +783,23 @@ const excel2 = new class Excel {
|
|||
});
|
||||
log.info('Setting xlsx column width ended')
|
||||
}
|
||||
sheet.autoFilter = {
|
||||
from: 'A1',
|
||||
to: 'H1'
|
||||
}
|
||||
console.log('Ged wait')
|
||||
await excel2.sleep(2000)
|
||||
console.log('Ged wait done')
|
||||
await excel2.SaveWorkbook(workBook, libName, level, "xlsx")
|
||||
});
|
||||
}
|
||||
|
||||
async createOutFile( {libName, level, libType, outType, baseURL, accessToken} )
|
||||
{
|
||||
// First create a WorkBook
|
||||
// const workBook = await excel2.NewExcelWorkBook()
|
||||
// Create Sheet
|
||||
// let sheet = await excel2.NewSheet(workBook, libName, level)
|
||||
// Add the header to the sheet
|
||||
//const header = await excel2.AddHeader(sheet, level, libType)
|
||||
async createOutFile( {libName, level, libType, baseURL, accessToken} )
|
||||
{
|
||||
const header = excel2.GetHeader(level, libType)
|
||||
log.debug(`header: ${header}`);
|
||||
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)
|
||||
|
||||
outType
|
||||
//outType, call
|
||||
|
||||
|
||||
const call = await et.getLevelCall(libType, level)
|
||||
// Open a file stream
|
||||
const tmpFile = await excel2.getFileName({ Library: libName, Level: level, Type: 'tmp' })
|
||||
var fs = require('fs');
|
||||
var stream = fs.createWriteStream(tmpFile, {flags:'a'});
|
||||
|
||||
|
||||
stream.write( strHeader + "\n");
|
||||
|
||||
|
||||
|
||||
// Add the header
|
||||
stream.write( strHeader + "\n");
|
||||
// Get all the items in small chuncks
|
||||
var sectionData = await et.getSectionData({sectionName: libName, baseURL: baseURL, accessToken: accessToken, libType: libType})
|
||||
log.verbose(`Amount of chunks in sectionData are: ${sectionData.length}`)
|
||||
|
@ -832,12 +818,11 @@ const excel2 = new class Excel {
|
|||
{
|
||||
// Get ratingKeys in the chunk
|
||||
const urls = await JSONPath({path: '$..ratingKey', json: sectionChunk});
|
||||
let urlStr = urls.join(',')
|
||||
let urlStr = urls.join(',');
|
||||
log.verbose(`Items to lookup are: ${urlStr}`)
|
||||
store.commit("UPDATE_EXPORTSTATUS", i18n.t('Modules.ET.Status.Processing-Chunk-Detailed', {current: x, total: sectionData.length, urlStr: urlStr}))
|
||||
//store.commit("UPDATE_EXPORTSTATUS", `Processing chunk ${x} of ${sectionData.length}.\nItems to export: \n${urlStr}`)
|
||||
store.commit("UPDATE_EXPORTSTATUS", i18n.t('Modules.ET.Status.Processing-Chunk-Detailed', {current: x, total: sectionData.length, urlStr: urlStr}))
|
||||
const urlWIthPath = '/library/metadata/' + urlStr
|
||||
log.verbose(`Items retrieved`)
|
||||
log.verbose(`Items retrieved`);
|
||||
const contents = await et.getItemData({baseURL: baseURL, accessToken: accessToken, element: urlWIthPath});
|
||||
const contentsItems = await JSONPath({path: '$.MediaContainer.Metadata[*]', json: contents});
|
||||
for (item of contentsItems){
|
||||
|
@ -851,18 +836,11 @@ const excel2 = new class Excel {
|
|||
fs.renameSync(tmpFile, newFile);
|
||||
console.log('renamed complete');
|
||||
// Need to export to xlsx as well?
|
||||
if (wtconfig.get('ET.ExpExcel')){
|
||||
console.log('Ged export to excel')
|
||||
if (wtconfig.get('ET.ExpExcel')){
|
||||
log.info('We need to create an xlsx file as well')
|
||||
await excel2.createXLSXFile( {csvFile: newFile, level: level, libType: libType, libName: libName})
|
||||
}
|
||||
store.commit("UPDATE_EXPORTSTATUS", `Export finished. File:"${newFile}" created`)
|
||||
|
||||
|
||||
|
||||
|
||||
// Save Excel file
|
||||
// const result = await excel2.SaveWorkbook(workBook, libName, level, outType)
|
||||
// return result
|
||||
store.commit("UPDATE_EXPORTSTATUS", `Export finished. File:"${newFile}" created`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ const actions = {
|
|||
libName, levelName, libType, 'xlsx', baseURL, accessToken
|
||||
excel2
|
||||
axios, commit, key, mediaSize, calcSize
|
||||
excel2.createOutFile( {libName: libName, level: levelName, libType: libType, outType: 'xlsx', baseURL: baseURL, accessToken: accessToken} );
|
||||
excel2.createOutFile( {libName: libName, level: levelName, libType: libType, baseURL: baseURL, accessToken: accessToken} );
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue