#77 start, and cleanup of PMS fetch

This commit is contained in:
UKDTOM 2020-08-08 13:10:39 +02:00
parent 798d162bb2
commit a3cced6289
8 changed files with 67 additions and 108 deletions

View file

@ -21,8 +21,6 @@ import Menu from './components/layout/Menu';
import Header from './components/layout/Header';
import store from './store'
export default {
name: "app",
data(){

View file

@ -2,14 +2,13 @@
<section class="section">
<h1 class="title is-2">{{ $t("Common.Language.Name") }}</h1>
<h2 class="subtitle">{{ $t("Common.Language.Description") }}</h2>
<br>
<br>
<div class="control has-icons-left">
<div class="locale-changer select is-dark is-medium" >
<b-form-select id="langselect" @change.native="onChange($event)" v-model="selectedLang" :options="olLangs"></b-form-select>
<b-form-select id="langselect" @change.native="onChange($event)" v-model="$i18n.locale" :options="olLangs"></b-form-select>
</div>
<span class="icon is-medium is-left">
<i class="fas fa-globe"></i>
<i class="fas fa-globe"></i>
</span>
<button id="btnDownload" v-on:click="forcedownload">{{ $t("Common.Language.btnForce") }}</button>
</div>

View file

@ -12,13 +12,8 @@
</div>
</div>
</div>
<div class="level-item">
<div class="select is-dark">
<div class="select is-dark">
<b-select v-bind:placeholder="$t('Common.SelServer')"
v-model="selectedOption"
@input="selected">
@ -29,11 +24,9 @@
{{ option.name }}
</option>
</b-select>
</div>
<b-button id="sync-button" @click="fetchServers" type="is-warning"
icon-left="fas fa-sync" icon-pack="fas" class="is-pulled-right" >
<b-button id="sync-button" @click="fetchServers" type="is-warning"
icon-left="fas fa-sync" icon-pack="fas" class="is-pulled-right" >
</b-button>
</div>
<div class="level-left">
@ -55,8 +48,6 @@ import store from '../../store';
import { ptv } from '../modules/General/plextv';
const log = require('electron-log');
export default {
data(){
return {
@ -70,23 +61,22 @@ export default {
},
active2(e) {
log.info("active2 called")
this.active = e;
},
this.active = e;
},
selected: function () {
log.info('HEADER: selected server: ' + this.selectedOption.name)
ptv.checkServerConnect(this.selectedOption)
this.$store.commit("UPDATE_SELECTED_SERVER", this.selectedOption);
},
onChange(event) {
log.info(event.target.selected);
},
getAvatar(){
return this.$store.getters.getAvatar
},
getPlexName(){
return this.$store.getters.getPlexName
}
getAvatar(){
return this.$store.getters.getAvatar
},
getPlexName(){
return this.$store.getters.getPlexName
}
},
created(){
log.info("menu created")

View file

@ -10,8 +10,6 @@
const log = require('electron-log');
import '@fortawesome/fontawesome-free/css/all.css'
import i18n from '../../i18n'
export default {
data() {
return {

View file

@ -61,82 +61,12 @@ const menu = require('electron').remote.Menu.buildFromTemplate(menuTemplate.defa
require('electron').remote.Menu.setApplicationMenu(menu)
log.info('App Menu builded')
// ET-EXCEL STUFF
// We export library named "Ged" of the type movie with a level of "Level 3"
const libName = 'Movies'
//const level = 'Tommy'
const level = 'Level 3'
const libType = 'movie'
/*
Some hidden stuff during dev only
I need baseurl of the server, as
well as the accesstoken, so I store
those for devs only in the config file,
in a key named "Developer", and since this
is never pushed to GitHub, it's safe ;)
like:
{
"general": {
"username": "dane22",
"language": "en",
"rememberlastusername": true,
"transfilescopied": "0.0.0"
},
"Log": {
"maxSize": 10485760
},
"ET": {
"OutPath": "/home/tm/Videos",
"ArraySep": " - "
"Default Sort title to title, if empty": true
},
"Developer": {
"baseURI": "http://192.168.1.14:32400",
"accessToken": "MyAccessToken",
"password": "MyPassword"
}
}
*/
const baseURI = wtconfig.get('Developer.baseURI', 'NO SERVER URI');
const accessToken = wtconfig.get('Developer.accessToken', 'NO SERVER TOKEN');
// Real stuff to use
// ET Stuff
import {excel2} from './components/modules/ExportTools/et'
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
// Temp json files to export, until linked called by webpage
const testimp4 = require('./components/modules/ExportTools/Samples/testimp4.json')
const testimp3 = require('./components/modules/ExportTools/Samples/testimp3.json')
const testimp = require('./components/modules/ExportTools/Samples/testimp.json')
const testimp1 = require('./components/modules/ExportTools/Samples/testimp1.json')
const AllMovies = require('./components/modules/ExportTools/Samples/AllMovies.json')
const Fast = require('./components/modules/ExportTools/Samples/2Fast.json')
// EXCEL Stuff
// To avoid errors if not exporting, remove below when frontend is calling
libName, level, libType, baseURI, accessToken, excel2, testimp4, testimp3, testimp, testimp1, AllMovies, Fast
// Add a couple of Rows
//excel2.createOutFile( libName, level, libType, 'xlsx', testimp1, baseURI, accessToken );
//excel2.createOutFile( libName, level, libType, 'xlsx', testimp3, baseURI, accessToken );
//excel2.createOutFile( libName, level, libType, 'xlsx', Fast, baseURI, accessToken );
//excel2.createOutFile( libName, level, libType, 'xlsx', AllMovies, baseURI, accessToken );
new Vue({
render: h => h(App),
router: router,

View file

@ -4,6 +4,7 @@ import VuexPersistence from 'vuex-persist';
import plextv from './modules/plextv'
import poeditor from './modules/poeditor'
import et from './modules/et'
import language from './modules/language'
Vue.use(Vuex)
@ -22,7 +23,8 @@ export default new Vuex.Store({
modules: {
plextv,
poeditor,
et
et,
language
},
plugins: [vuexLocal.plugin]
})

View file

@ -0,0 +1,26 @@
// mutation.js
//import {App} from '../../main'
import i18n from '../../i18n'
const log = require('electron-log');
export const mutations = {
SET_LANG (state, payload) {
//App.$i18n.locale = payload
i18n.locale = payload
}
}
export const actions = {
setLang({commit}, payload) {
log.info(`Set lang to: ${JSON.stringify(payload)}`)
commit('SET_LANG', payload)
}
}
const serverModule = {
//state,
mutations,
actions,
//getters
}
export default serverModule;

View file

@ -1,5 +1,6 @@
import axios from 'axios';
import router from '../../router'
import {wtconfig} from '../../wtutils'
const log = require('electron-log');
@ -61,14 +62,29 @@ const actions = {
.then((response) => {
let result=[];
log.info('Response from fetchPlexServers recieved')
response.data.forEach((req) => {
// if (req.owned == true && req.product == "Plex Media Server") {
if (req.product == "Plex Media Server") {
log.warn('GED&NUGGA : fetchPlexServers : ser ikke owned')
log.debug(req)
result.push(req);
}
})
const showNotOwned = wtconfig.get('Developer.showNotOwned', false)
response.data.forEach((req) => {
if (showNotOwned){
if (req.product == "Plex Media Server") {
let pmsServer = {};
pmsServer['name'] = req.name;
pmsServer['accessToken'] = req.accessToken;
pmsServer['connections'] = req.connections;
pmsServer['clientIdentifier'] = req.clientIdentifier
log.warn('fetchPlexServers : ser ikke owned')
result.push(pmsServer);
}
} else {
if (req.owned == true && req.product == "Plex Media Server") {
let pmsServer = {};
pmsServer['name'] = req.name;
pmsServer['accessToken'] = req.accessToken;
pmsServer['connections'] = req.connections;
pmsServer['clientIdentifier'] = req.clientIdentifier
result.push(pmsServer);
}
}
})
commit('UPDATE_PLEX_SERVERS', result)
})
.catch(function (error) {