#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

@ -3,10 +3,9 @@
<h1 class="title is-2">{{ $t("Common.Language.Name") }}</h1>
<h2 class="subtitle">{{ $t("Common.Language.Description") }}</h2>
<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>

View file

@ -12,13 +12,8 @@
</div>
</div>
</div>
<div class="level-item">
<div class="select is-dark">
<b-select v-bind:placeholder="$t('Common.SelServer')"
v-model="selectedOption"
@input="selected">
@ -29,9 +24,7 @@
{{ 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>
@ -55,8 +48,6 @@ import store from '../../store';
import { ptv } from '../modules/General/plextv';
const log = require('electron-log');
export default {
data(){
return {
@ -71,12 +62,11 @@ export default {
active2(e) {
log.info("active2 called")
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);

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,12 +62,27 @@ const actions = {
.then((response) => {
let result=[];
log.info('Response from fetchPlexServers recieved')
const showNotOwned = wtconfig.get('Developer.showNotOwned', false)
response.data.forEach((req) => {
// if (req.owned == true && req.product == "Plex Media Server") {
if (showNotOwned){
if (req.product == "Plex Media Server") {
log.warn('GED&NUGGA : fetchPlexServers : ser ikke owned')
log.debug(req)
result.push(req);
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)