#476-2 WIP

This commit is contained in:
Tommy Mikkelsen 2022-05-06 02:45:12 +02:00
parent d25db81e57
commit 55c8a66e6c
9 changed files with 163 additions and 93 deletions

View file

@ -136,20 +136,30 @@
"Global": { "Global": {
"Status": "Status", "Status": "Status",
"Chuncks": "Chunks", "Chuncks": "Chunks",
"Item": "Item",
"Items": "Items", "Items": "Items",
"Info": "Info", "Info": "Info",
"OutFile": "Output File", "OutFile": "Output File",
"StartTime": "Start time", "StartTime": "Start time",
"EndTime": "End Time", "EndTime": "End Time",
"TimeElapsed": "Time Elapsed", "TimeElapsed": "Time Elapsed",
"RunningTime": "Running time" "RunningTime": "Running time",
"LibsToProcess": "Libraries to process",
"CurrentLib": "Current Library"
}, },
"Modules": {} "Modules": {}
}, },
"Msg": { "Msg": {
"Processing_Lib_1_2": "Processing library {0} of {1} - {2}",
"Global": { "Global": {
"Idle": "Idle",
"Processing": "Processing"
}, },
"Modules": {} "Modules": {
"viewState": {
}
}
} }
} }
}, },
@ -442,18 +452,15 @@
"Status": { "Status": {
"Msg": { "Msg": {
"CollectUserInfo": "Collecting user info...Please wait", "CollectUserInfo": "Collecting user info...Please wait",
"Processing": "Processing",
"Processing2": "Processing library {0} of {1} - {2}", "GEDDELProcessing2": "Processing library {0} of {1} - {2}",
"Idle": "Idle",
"GatheringLibs": "Gathering libraries to process", "GatheringLibs": "Gathering libraries to process",
"ProcessItem1": "Processing: ({1} - {2}) - {0}" "ProcessItem1": "Processing: ({1} - {2}) - {0}"
}, },
"Names": { "Names": {
"Status": "Status",
"LibsToProcess": "Libraries to process",
"StartTime": "Start time",
"CurrentLib": "Current Library",
"Item": "Item"
} }
} }
} }

View file

@ -0,0 +1,71 @@
import store from '../../../store';
import i18n from '../../../i18n';
const status = new class Status {
constructor() {
this.statusmsg = {};
this.msgType = {
// Global stuff range up to 200
1: i18n.t("Common.Status.Name.Global.Status"),
2: i18n.t("Common.Status.Name.Global.Info"),
3: i18n.t("Common.Status.Name.Global.LibsToProcess"),
8: i18n.t("Common.Status.Name.Global.CurrentLib"),
9: i18n.t("Common.Status.Name.Global.Item"),
10: i18n.t("Common.Status.Name.Global.Items"),
// Time related stuff 201 -> 250
201: i18n.t("Common.Status.Name.Global.StartTime"),
202: i18n.t("Common.Status.Name.Global.EndTime"),
203: i18n.t("Common.Status.Name.Global.TimeElapsed"),
204: i18n.t("Common.Status.Name.Global.RunningTime")
// Module ViewState range is 1000 => 1200
// Module ET range is 1201 => 2400
};
this.RevMsgType = {
// Global stuff
"Status": 1,
"Info": 2,
"LibsToProcess" : 3,
"StartTime": 201,
"EndTime":202,
"TimeElapsed": 203,
"RunningTime": 204,
"CurrentLib": 8,
"Item": 9,
"Items": 10
}
}
// Clear Status Window
async clearStatus()
{
this.statusmsg = {};
store.commit("UPDATE_Status", '');
return;
}
// Update status msg
async updateStatusMsg(msgType, msg)
{
console.log('Ged 55-0 msgType: ' + msgType)
console.log('Ged 55-1 msg: ' + msg)
// Update relevant key
//const translatedMsgType =
this.statusmsg[msgType] = msg;
// Tmp store of new msg
let newMsg = '';
// Walk each current msg keys
Object.entries(this.statusmsg).forEach(([key, value]) => {
if ( value != '')
{
newMsg += this.msgType[key] + ': ' + value + '\n';
}
})
store.commit("UPDATE_Status", newMsg);
}
}
export { status };

View file

@ -0,0 +1,40 @@
<script>
export default {
data() {
return {
statusMsg: this.$t("Common.Status.Msg.Global.Idle")
}
},
watch: {
// Watch for status update
viewStateStatus: function() {
this.statusMsg = this.$store.getters.getStatus;
}
},
computed: {
viewStateStatus: function(){
return this.$store.getters.getStatus;
}
}
};
</script>
<template>
<b-container fluid> <!-- Status -->
<b-row>
<b-col sm="2">
<label for="status">{{ $t('Common.Status.Name.Global.Status') }}:</label>
</b-col>
<b-col sm="10">
<b-form-textarea
id="status"
v-bind:placeholder="$t('Common.Status.Name.Global.Status')"
v-model="statusMsg"
:disabled=true
rows="1"
max-rows="8">
</b-form-textarea>
</b-col>
</b-row>
</b-container>
</template>

View file

@ -5,6 +5,10 @@ that we use in our solution.
//import i18n from '../../../i18n'; //import i18n from '../../../i18n';
//import storeStatus from '../../store';
//storeStatus
const log = require('electron-log'); const log = require('electron-log');
console.log = log.log; console.log = log.log;
const electron = require('electron'); const electron = require('electron');
@ -713,5 +717,4 @@ const github = new class GitHub {
} }
} }
export {wtutils, wtconfig, dialog, github}; export {wtutils, wtconfig, dialog, github};

View file

@ -57,25 +57,7 @@
</div> </div>
</div> </div>
<br> <br>
<b-container fluid> <!-- Status --> <statusDiv /> <!-- Status Div -->
<b-row>
<b-col sm="2">
<label for="status">{{ $t('Modules.PMS.ViewState.Status.Names.Status') }}:</label>
</b-col>
<b-col sm="10">
<b-form-textarea
id="status"
v-bind:placeholder="$t('Modules.PMS.ViewState.Status.Names.Status')"
v-model="statusMsg"
:disabled=true
rows="1"
max-rows="8">
</b-form-textarea>
</b-col>
</b-row>
</b-container>
</b-container> </b-container>
</template> </template>
@ -83,11 +65,15 @@
<script> <script>
import i18n from '../../../../i18n'; import i18n from '../../../../i18n';
import store from '../../../../store'; import store from '../../../../store';
//import { wtconfig } from '../General/wtutils'; //import { status } from '../../../own/status/status';
import { status } from '../../General/status';
import { viewstate } from "./scripts/viewstate"; import { viewstate } from "./scripts/viewstate";
import statusDiv from '../../General/status.vue'
const log = require("electron-log"); const log = require("electron-log");
export default { export default {
components: {
statusDiv
},
data() { data() {
return { return {
optselSrcUsr: [], optselSrcUsr: [],
@ -114,9 +100,9 @@
// Watch for when selected server address is updated // Watch for when selected server address is updated
selectedServerAddress: async function(){ selectedServerAddress: async function(){
log.info("ViewState selected server changed"); log.info("ViewState selected server changed");
viewstate.clearStatus(); status.clearStatus();
console.log('Ged 1-2: ' + JSON.stringify(this.$store.getters.getViewStateStatus)) console.log('Ged 1-2: ' + JSON.stringify(this.$store.getters.getViewStateStatus))
viewstate.updateStatusMsg(1, i18n.t("Modules.PMS.ViewState.Status.Msg.CollectUserInfo")); status.updateStatusMsg(1, i18n.t("Modules.PMS.ViewState.Status.Msg.CollectUserInfo"));
viewstate.SrcUsr = null; viewstate.SrcUsr = null;
viewstate.TargetUsr = null; viewstate.TargetUsr = null;
console.log('Ged 1-3: ' + JSON.stringify(this.$store.getters.getViewStateStatus)) console.log('Ged 1-3: ' + JSON.stringify(this.$store.getters.getViewStateStatus))
@ -131,7 +117,7 @@
this.selSrcUsr = ''; this.selSrcUsr = '';
this.selTargetUsr = '', this.selTargetUsr = '',
this.WaitForUsers = true; this.WaitForUsers = true;
viewstate.updateStatusMsg(1, i18n.t("Modules.PMS.ViewState.Status.Msg.Idle")); status.updateStatusMsg(1, i18n.t("Common.Status.Msg.Global.Idle"));
console.log('Ged 1-6: ' + JSON.stringify(this.$store.getters.getViewStateStatus)) console.log('Ged 1-6: ' + JSON.stringify(this.$store.getters.getViewStateStatus))
}, },
// Watch for status update // Watch for status update

View file

@ -5,6 +5,7 @@ console.log = log.log;
import {wtutils, wtconfig} from '../../../General/wtutils'; import {wtutils, wtconfig} from '../../../General/wtutils';
import { status } from '../../../General/status';
import i18n from '../../../../../i18n'; import i18n from '../../../../../i18n';
import store from '../../../../../store'; import store from '../../../../../store';
import axios from 'axios'; import axios from 'axios';
@ -15,17 +16,6 @@ const viewstate = new class ViewState {
#_StartTime = null; #_StartTime = null;
#_EndTime = null; #_EndTime = null;
#_statusmsg = {}; #_statusmsg = {};
#_msgType = {
1: i18n.t("Modules.PMS.ViewState.Status.Names.Status"),
2: i18n.t("Modules.PMS.ViewState.Status.Names.LibsToProcess"),
3: i18n.t("Modules.PMS.ViewState.Status.Names.StartTime"),
4: i18n.t("Modules.PMS.ViewState.Status.Names.CurrentLib"),
5: i18n.t("Modules.PMS.ViewState.Status.Names.Item"),
6: i18n.t("Modules.ET.Status.Names.StartTime"),
7: i18n.t("Modules.ET.Status.Names.EndTime"),
8: i18n.t("Modules.ET.Status.Names.TimeElapsed"),
9: i18n.t("Modules.ET.Status.Names.RunningTime")
}
constructor() { constructor() {
this.selServerServerToken = '', this.selServerServerToken = '',
@ -210,7 +200,7 @@ const viewstate = new class ViewState {
listProcess[JSONPath({path: `$..ratingKey`, json: medias[media]})[0]] = listProcessDetails; listProcess[JSONPath({path: `$..ratingKey`, json: medias[media]})[0]] = listProcessDetails;
index += 1; index += 1;
this.bumpViewCount( listProcessDetails ); this.bumpViewCount( listProcessDetails );
this.updateStatusMsg(5, i18n.t("Modules.PMS.ViewState.Status.Msg.ProcessItem1", [listProcessDetails['title'], index, totalSize])); status.updateStatusMsg(5, i18n.t("Modules.PMS.ViewState.Status.Msg.ProcessItem1", [listProcessDetails['title'], index, totalSize]));
} }
}) })
.catch(function (error) { .catch(function (error) {
@ -232,7 +222,7 @@ const viewstate = new class ViewState {
var keyCount = Object.keys(this.libs).length; var keyCount = Object.keys(this.libs).length;
let index = 1; let index = 1;
for (var libKey in this.libs){ for (var libKey in this.libs){
this.updateStatusMsg(4, i18n.t("Modules.PMS.ViewState.Status.Msg.Processing2", [index, keyCount, this.libs[libKey]['title']])); status.updateStatusMsg( status.RevMsgType.LibsToProcess, i18n.t("Common.Status.Msg.Processing_Lib_1_2", [index, keyCount, this.libs[libKey]['title']]));
await this.processWatchedList( libKey ); await this.processWatchedList( libKey );
index += 1; index += 1;
} }
@ -307,39 +297,14 @@ const viewstate = new class ViewState {
async copyViewState( SrcUsr, TargetUsr ){ async copyViewState( SrcUsr, TargetUsr ){
log.info('[viewstate.js] Starting copyViewState'); log.info('[viewstate.js] Starting copyViewState');
const startTime = await this.getNowTime('start'); const startTime = await this.getNowTime('start');
//this.updateStatusMsg( this.RawMsgType.TimeElapsed, await this.getRunningTimeElapsed()); //status.updateStatusMsg( this.RawMsgType.TimeElapsed, await this.getRunningTimeElapsed());
await this.getLibs( SrcUsr, TargetUsr ); await this.getLibs( SrcUsr, TargetUsr );
//this.updateStatusMsg(3, startTime); //status.updateStatusMsg(3, startTime);
startTime startTime
this.updateStatusMsg(1, i18n.t("Modules.PMS.ViewState.Status.Msg.Processing")); status.updateStatusMsg(status.RevMsgType.Status, i18n.t("Common.Status.Msg.Global.Processing"));
await this.getUsrTokens(); await this.getUsrTokens();
await this.walkSourceUsr(); await this.walkSourceUsr();
this.updateStatusMsg(1, i18n.t("Modules.PMS.ViewState.Status.Msg.Idle")); status.updateStatusMsg(status.RevMsgType.Status, i18n.t("Common.Status.Msg.Global.Idle"));
}
// Update status msg
async updateStatusMsg(msgType, msg)
{
// Update relevant key
this.#_statusmsg[msgType] = msg;
// Tmp store of new msg
let newMsg = '';
// Walk each current msg keys
Object.entries(this.#_statusmsg).forEach(([key, value]) => {
if ( value != '')
{
newMsg += this.#_msgType[key] + ': ' + value + '\n';
}
})
store.commit("UPDATE_viewStateStatus", newMsg);
}
// Clear Status Window
async clearStatus()
{
this.#_statusmsg = {};
store.commit("UPDATE_viewStateStatus", '');
return;
} }
async getLibs( SrcUsr, TargetUsr ){ async getLibs( SrcUsr, TargetUsr ){
@ -352,13 +317,13 @@ const viewstate = new class ViewState {
return; return;
} }
if ( JSON.stringify(SrcUsr) === JSON.stringify(TargetUsr) ){ if ( JSON.stringify(SrcUsr) === JSON.stringify(TargetUsr) ){
this.clearStatus(); status.clearStatus();
this.updateStatusMsg(1, i18n.t("Modules.PMS.ViewState.Status.Msg.Idle")); status.updateStatusMsg(status.MsgType.Status, i18n.t("Common.Status.Msg.Global.Idle"));
log.info('[viewstate.js] Same user selected, so aborting'); log.info('[viewstate.js] Same user selected, so aborting');
return; return;
} }
this.clearStatus(); status.clearStatus();
this.updateStatusMsg(1, i18n.t("Modules.PMS.ViewState.Status.Msg.GatheringLibs")); status.updateStatusMsg(1, i18n.t("Modules.PMS.ViewState.Status.Msg.GatheringLibs"));
log.silly(`[viewstate.js] (getLibs) Source usr: ${JSON.stringify(SrcUsr)}`); log.silly(`[viewstate.js] (getLibs) Source usr: ${JSON.stringify(SrcUsr)}`);
log.silly(`[viewstate.js] (getLibs) Target usr: ${JSON.stringify(TargetUsr)}`); log.silly(`[viewstate.js] (getLibs) Target usr: ${JSON.stringify(TargetUsr)}`);
this.libs = {}; this.libs = {};
@ -401,8 +366,8 @@ const viewstate = new class ViewState {
for (let lib in this.libs){ for (let lib in this.libs){
libstatus.push(this.libs[lib]['title']) libstatus.push(this.libs[lib]['title'])
} }
this.updateStatusMsg(1, i18n.t("Modules.PMS.ViewState.Status.Msg.Idle")); status.updateStatusMsg(status.RevMsgType.Status, i18n.t("Common.Status.Msg.Global.Idle"));
this.updateStatusMsg(2, libstatus.join(', ')) status.updateStatusMsg(2, libstatus.join(', '))
} }
// Here we get the server token for the selected server // Here we get the server token for the selected server

View file

@ -19,7 +19,6 @@ import Store from '../store/index.js';
Vue.use(VueRouter) Vue.use(VueRouter)
const router = new VueRouter({ const router = new VueRouter({
mode: process.env.IS_ELECTRON ? 'hash' : 'history', mode: process.env.IS_ELECTRON ? 'hash' : 'history',
base: process.env.BASE_URL, base: process.env.BASE_URL,
routes: [ routes: [

View file

@ -6,7 +6,7 @@ import poeditor from './modules/poeditor';
import et from './modules/et'; import et from './modules/et';
import language from './modules/language'; import language from './modules/language';
import pms from './modules/pms'; import pms from './modules/pms';
import viewstate from './modules/viewstate'; import status from './modules/status';
Vue.use(Vuex); Vue.use(Vuex);
@ -14,7 +14,6 @@ const vuexLocal = new VuexPersistence({
storage: window.sessionStorage, storage: window.sessionStorage,
}); });
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
}, },
@ -28,7 +27,7 @@ export default new Vuex.Store({
et, et,
language, language,
pms, pms,
viewstate status
}, },
plugins: [vuexLocal.plugin] plugins: [vuexLocal.plugin]
}) })

View file

@ -4,24 +4,24 @@ const log = require('electron-log');
console.log = log.log; console.log = log.log;
const state = { const state = {
viewStateStatus: '' Status: ''
}; };
const mutations = { const mutations = {
UPDATE_viewStateStatus(state, payload) { UPDATE_Status(state, payload) {
state.viewStateStatus = payload state.Status = payload
} }
}; };
const getters = { const getters = {
getViewStateStatus: state => state.viewStateStatus getStatus: state => state.Status
}; };
const viewstateModule = { const statusModule = {
state, state,
mutations, mutations,
getters getters
} }
export default viewstateModule; export default statusModule;