mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2024-11-22 02:53:05 +00:00
#507 Queue WIP
This commit is contained in:
parent
38844507dd
commit
efb0740cd1
5 changed files with 103 additions and 145 deletions
|
@ -203,7 +203,11 @@
|
|||
"SelSrv": "Select Server",
|
||||
"TT-Server": "Select the server to download from. If a server can't be selected, you have not been granted download rights from it",
|
||||
"MediaInfoTitle": "Media Info",
|
||||
"ShowQueue": "Show Queue"
|
||||
"ShowQueue": "Show Queue",
|
||||
"Queue":{
|
||||
"Name": "Download Queue",
|
||||
"Description": "Here you see the items in the download queue, as well as start/stop the queue"
|
||||
}
|
||||
},
|
||||
"ET": {
|
||||
"Description": "@:Modules.ET.Name allows you to export detail information about the media in your libraries",
|
||||
|
|
|
@ -42,7 +42,15 @@
|
|||
href: { path: '/download' },
|
||||
title: this.$t("Modules.Download.Name"),
|
||||
hidden: wtutils.hideMenu('download'),
|
||||
icon: 'fas fa-download'
|
||||
icon: 'fas fa-download',
|
||||
child: [
|
||||
{
|
||||
href: 'queue',
|
||||
title: this.$t("Modules.Download.Queue.Name"),
|
||||
hidden: wtutils.hideMenu('queue'),
|
||||
icon: 'fa fa-cog'
|
||||
}
|
||||
],
|
||||
},
|
||||
// Export Tools
|
||||
{
|
||||
|
|
|
@ -169,6 +169,7 @@
|
|||
methods: {
|
||||
showQueue(){
|
||||
console.log('Ged 87-3 Show Queue')
|
||||
this.$router.push({ name: 'queue' })
|
||||
},
|
||||
createHash(str){
|
||||
return require('crypto').createHash('md5').update(str).digest("hex")
|
||||
|
@ -184,18 +185,21 @@
|
|||
details['mediaDir'] = this.selMediaDir;
|
||||
details['title'] = this.selMediaTitle;
|
||||
details['type'] = row['Type'];
|
||||
const key = this.createHash(`${this.srvName}-${row['Key']}`);
|
||||
const key = this.createHash(`${this.selSrv}-${row['Key']}`); // Hashed with ServerID-Filename
|
||||
details['hash'] = key;
|
||||
log.debug(`[Download.vue] (Select) - Adding ${key} with a value of: ${JSON.stringify(details)}`)
|
||||
wtconfig.set(`Download.${key}`, details);
|
||||
wtconfig.set(`Download.Queue.${key}`, details);
|
||||
let arr = []
|
||||
arr.push(details)
|
||||
wtconfig.set(`Download.Queue23`, arr);
|
||||
}
|
||||
else {
|
||||
const key = this.createHash(`${this.srvName}-${row['Key']}`);
|
||||
log.debug(`[Download.vue] (Select) - Deleting ${key}`)
|
||||
wtconfig.delete(`Download.${key}`);
|
||||
wtconfig.delete(`Download.Queue.${key}`);
|
||||
}
|
||||
},
|
||||
async getMediaInfo(key){
|
||||
console.log('Ged 44-3', JSON.stringify(this.MItableData))
|
||||
const url = `${this.srvBaseAddress}/library/metadata/${key}?${this.uriExclude}`;
|
||||
let header = wtutils.PMSHeader;
|
||||
header['X-Plex-Token'] = this.srvToken;
|
||||
|
@ -254,9 +258,11 @@
|
|||
},
|
||||
async rowClicked(myarg){
|
||||
this.MItableData = [];
|
||||
// Start Spinner
|
||||
await this.getMediaInfo(myarg['Key']);
|
||||
this.selMediaTitle = myarg['Title'];
|
||||
this.mediaInfoTitle = `${i18n.t("Modules.Download.MediaInfoTitle")} - ${myarg['Title']}`
|
||||
// Stop Spinner
|
||||
this.$refs['MediaInfo'].show();
|
||||
},
|
||||
async selSrvChanged() {
|
||||
|
|
|
@ -2,165 +2,98 @@
|
|||
<b-container class="m-2 mt-2">
|
||||
<div> <!-- Title and desc -->
|
||||
<h2>
|
||||
{{ $t(`Common.Settings.LibMapping.Name`) }}
|
||||
{{ $t(`Modules.Download.Queue.Name`) }}
|
||||
</h2>
|
||||
<h5>{{ $t(`Common.Settings.LibMapping.Description`) }}</h5>
|
||||
<h5>{{ $t(`Modules.Download.Queue.Description`) }}</h5>
|
||||
</div>
|
||||
<br>
|
||||
<!-- Select Lib -->
|
||||
<div class="d-flex align-items-center">
|
||||
<b-form-group id="SelLibGroup" v-bind:label="$t('Modules.ET.optExpType.lblSelectSelection')" label-size="lg" label-class="font-weight-bold pt-0">
|
||||
<b-tooltip target="SelLibGroup" triggers="hover">
|
||||
{{ $t('Common.Settings.LibMapping.ttSelectLibrary') }}
|
||||
</b-tooltip>
|
||||
<b-form-select
|
||||
v-model="selLib"
|
||||
id="selLib"
|
||||
:options="selLibOptions"
|
||||
@change="getLibPath"
|
||||
name="selLib">
|
||||
</b-form-select>
|
||||
</b-form-group>
|
||||
</div>
|
||||
<br>
|
||||
<!-- Table of section path -->
|
||||
<b-table ref="table"
|
||||
striped
|
||||
hover
|
||||
:items="items"
|
||||
@row-clicked="pathRowClickHandler"
|
||||
>
|
||||
</b-table>
|
||||
<br>
|
||||
<!-- Buttons -->
|
||||
<div class="buttons">
|
||||
<!-- Buttons -->
|
||||
<div id="buttons" class="text-center">
|
||||
<b-button-group >
|
||||
<b-button variant="success" class="mr-1" @click="jumpToSettings"> {{ $t('Common.Settings.Return') }} </b-button>
|
||||
</b-button-group>
|
||||
</div>
|
||||
</div>
|
||||
<vue-virtual-table
|
||||
@click="rowClicked"
|
||||
:key="idx"
|
||||
:config="tableConfig"
|
||||
:data="tableData"
|
||||
:bordered="tableAttribute.bordered"
|
||||
:minWidth="tableAttribute.minWidth"
|
||||
:language="tableAttribute.language"
|
||||
:selectable="tableAttribute.selectable"
|
||||
:itemHeight="tableAttribute.itemHeight">
|
||||
</vue-virtual-table>
|
||||
|
||||
</b-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import i18n from '../../../../i18n';
|
||||
import store from '../../../../store';
|
||||
import { wtconfig, dialog } from '../../General/wtutils';
|
||||
import { pms } from '../../General/pms';
|
||||
//import i18n from '../../../../i18n';
|
||||
//import store from '../../../../store';
|
||||
import { wtconfig } from '../../General/wtutils';
|
||||
//import { pms } from '../../General/pms';
|
||||
import VueVirtualTable from 'vue-virtual-table';
|
||||
|
||||
const log = require("electron-log");
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
serverIsSelected: false,
|
||||
selLibOptions: [],
|
||||
selLib: "",
|
||||
selLibraryWait: true,
|
||||
items: []
|
||||
};
|
||||
components: {
|
||||
VueVirtualTable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableConfig: [
|
||||
{ prop: 'Title',searchable: true,sortable: true, width: 80 },
|
||||
{ prop: 'File',searchable: true,sortable: true, width: 80 },
|
||||
{ prop: 'Type',searchable: true,sortable: true, width: 30 },
|
||||
{ prop: 'Status',searchable: true,sortable: true, width: 30 },
|
||||
{ prop: 'Hash', isHidden: true }
|
||||
],
|
||||
tableData: [],
|
||||
tableAttribute: {
|
||||
height: 1000,
|
||||
itemHeight: 50,
|
||||
minWidth: 10,
|
||||
selectable: true,
|
||||
enableExport: false,
|
||||
bordered: true,
|
||||
hoverHighlight: true,
|
||||
language: "en"
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
log.info("LibraryMapping Created");
|
||||
this.serverSelected();
|
||||
this.getPMSSections();
|
||||
log.info(`[Queue.vue] (created) - Download Queue Created`);
|
||||
this.GetQueue();
|
||||
},
|
||||
watch: {
|
||||
// Watch for when selected server address is updated
|
||||
selectedServerAddress: async function(){
|
||||
// Changed, so we need to update the libraries
|
||||
this.selLibraryWait = true;
|
||||
await this.getPMSSections();
|
||||
this.selLibraryWait = true;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// We need this computed, for watching for changes to selected server
|
||||
selectedServerAddress: function(){
|
||||
return this.$store.getters.getSelectedServerAddress
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// Return to main Settings
|
||||
jumpToSettings(){
|
||||
this.$router.push({ name: 'settingsGlobal' })
|
||||
},
|
||||
// Update mapped path
|
||||
pathRowClickHandler: async function( record, index ){
|
||||
log.debug(`[LibraryMapping.vue] (pathRowClickHandler) - Start to browse for directory`);
|
||||
log.debug(`[LibraryMapping.vue] (pathRowClickHandler) - Defined path is ${JSON.stringify(record)} with an index of: ${index}`);
|
||||
const mapDir = dialog.OpenDirectory( i18n.t("Common.Settings.LibMapping.SelectMapDirPath"), i18n.t("Common.Ok"));
|
||||
if (mapDir)
|
||||
{
|
||||
let curVal = {};
|
||||
curVal['PMS'] = this.items[index]['PMS'];
|
||||
// If a dot is present in the path, we need to escape it
|
||||
curVal['PMS'] = curVal['PMS'].replace('.', '\\.');
|
||||
curVal['Workstation'] = mapDir[0];
|
||||
curVal['_rowVariant'] = "success";
|
||||
// Get ServerID
|
||||
const serverID = store.getters.getSelectedServer.clientIdentifier;
|
||||
// Save setting
|
||||
wtconfig.set(`PMS.LibMapping.${serverID}.${curVal['PMS']}`, curVal['Workstation']);
|
||||
// Remove escape char for viewing
|
||||
curVal['PMS'] = curVal['PMS'].replace('\\.', '.');
|
||||
this.items[index] = curVal;
|
||||
// Update view
|
||||
this.$refs.table.refresh();
|
||||
GetQueue(){
|
||||
log.info(`[Queue.vue] (GetQueue) - Get the queue`);
|
||||
|
||||
console.log('Ged 41-3', wtconfig.get('Download.Queue'))
|
||||
const arrQueue = wtconfig.get('Download.Queue');
|
||||
for (var qItem in arrQueue){
|
||||
console.log('Ged 42-3', JSON.stringify(qItem));
|
||||
let entry = {};
|
||||
entry['Title'] = arrQueue[qItem]['title'];
|
||||
entry['File'] = arrQueue[qItem]['file'];
|
||||
entry['Type'] = arrQueue[qItem]['type'];
|
||||
entry['Status'] = 'GED Idle';
|
||||
entry['Hash'] = arrQueue[qItem];
|
||||
this.tableData.push(entry); //Add qItem
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
{ prop: 'File',searchable: true,sortable: true, width: 80 },
|
||||
{ prop: 'Type',searchable: true,sortable: true, width: 30 },
|
||||
{ prop: 'Status',searchable: true,sortable: true, width: 30 },
|
||||
{ prop: 'Hash'
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
getPMSSections: async function(){
|
||||
this.selLibrary = "";
|
||||
this.selLibOptions = await pms.getPMSSections(['movie', 'show']);
|
||||
},
|
||||
/* Check if a server is selected, and if not
|
||||
tell user, and disable backup */
|
||||
async serverSelected() {
|
||||
let serverCheck = this.$store.getters.getSelectedServer;
|
||||
this.serverIsSelected = ( this.$store.getters.getSelectedServer != "none" );
|
||||
if (serverCheck == "none") {
|
||||
log.debug("[LibraryMapping.vue] (serverSelected) - serverCheck is none");
|
||||
this.$bvToast.toast(this.$t("Modules.PMS.ErrorNoServerSelectedMsg"), {
|
||||
title: this.$t("Modules.PMS.ErrorNoServerSelectedTitle"),
|
||||
autoHideDelay: 4000,
|
||||
solid: true,
|
||||
variant: 'primary',
|
||||
toaster: 'b-toaster-bottom-right'
|
||||
});
|
||||
}
|
||||
},
|
||||
/* Present user with both PMS path, as well as defined mappings */
|
||||
getLibPath: async function(){
|
||||
let arrPath = [];
|
||||
const serverID = store.getters.getSelectedServer.clientIdentifier;
|
||||
log.info(`[LibraryMapping.vue] (getLibPath) ServerID is: ${serverID}`);
|
||||
const fs = require("fs");
|
||||
arguments[0]['location'].forEach(element => {
|
||||
let entry, virtualElement;
|
||||
virtualElement = element.replace('.', '\\.');
|
||||
const wkstnPath = wtconfig.get(`PMS.LibMapping.${serverID}.${virtualElement}`, this.$t("Common.Settings.LibMapping.ClickToDefine"));
|
||||
log.info(`[LibraryMapping.vue] (getLibPath) Saved path is: ${wkstnPath}`);
|
||||
// Check if path exists
|
||||
if (fs.existsSync(wkstnPath)) {
|
||||
log.debug(`[LibraryMapping.vue] (getLibPath) Saved path existed`);
|
||||
entry = {PMS: element, Workstation: wkstnPath, _rowVariant: 'success'};
|
||||
} else {
|
||||
log.debug(`[LibraryMapping.vue] (getLibPath) Saved path not defined`);
|
||||
if (fs.existsSync(element)) {
|
||||
log.debug(`[LibraryMapping.vue] (getLibPath) PMS path existed`);
|
||||
wtconfig.set(`PMS.LibMapping.${serverID}.${element}`, element);
|
||||
entry = {PMS: element, Workstation: element, _rowVariant: 'success'};
|
||||
}
|
||||
else {
|
||||
log.error(`[LibraryMapping.vue] (getLibPath) PMS path unknown`);
|
||||
entry = {PMS: element, Workstation: wkstnPath, _rowVariant: 'danger'};
|
||||
}
|
||||
}
|
||||
arrPath.push(entry);
|
||||
});
|
||||
this.items = arrPath;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import VueRouter from 'vue-router';
|
|||
import Login from '../components/modules/Main/Login';
|
||||
import Home from '../components/modules/Main/Home.vue';
|
||||
import Download from '../components/modules/Download/Download';
|
||||
import Queue from '../components/modules/Download/Queue/Queue';
|
||||
import Export from '../components/modules/ExportTools/Export';
|
||||
import ExportSettings from '../components/modules/ExportTools/Settings/settings';
|
||||
import ExportCustom from '../components/modules/ExportTools/Custom/custom';
|
||||
|
@ -53,6 +54,12 @@ Vue.use(VueRouter)
|
|||
component: Download,
|
||||
meta: {requiresAuth: true}
|
||||
},
|
||||
{
|
||||
path: '/queue',
|
||||
name: "queue",
|
||||
component: Queue,
|
||||
meta: {requiresAuth: true}
|
||||
},
|
||||
{
|
||||
path: '/export',
|
||||
name: "export",
|
||||
|
|
Loading…
Reference in a new issue