work on logger popup
This commit is contained in:
parent
87e65a99d4
commit
bd2fa787e1
@ -1,8 +1,24 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="showLoggerUi" class="root-window flex flex-column overflow-hidden">
|
<div v-if="showLoggerUi" class="root-window flex flex-column overflow-hidden">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1>{{header.header}}</h1>
|
<div class="header-top flex flex-row">
|
||||||
<div>{{header.subheader}}</div>
|
<div class="flex-grow">
|
||||||
|
<h1>{{header.header}}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="button flex-noshrink button-header"
|
||||||
|
@click="hidePopup()"
|
||||||
|
>
|
||||||
|
Close
|
||||||
|
</div>
|
||||||
|
<!-- <div class="button flex-noshrink button-header"
|
||||||
|
@click="stopLogging()"
|
||||||
|
>
|
||||||
|
Stop logging
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
<div class="header-bottom">
|
||||||
|
<div>{{header.subheader}}</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content flex flex-row flex-grow overflow-hidden">
|
<div class="content flex flex-row flex-grow overflow-hidden">
|
||||||
|
|
||||||
@ -17,7 +33,7 @@
|
|||||||
<div ref="settingsEditArea"
|
<div ref="settingsEditArea"
|
||||||
style="white-space: pre-wrap; border: 1px solid orange; padding: 10px;"
|
style="white-space: pre-wrap; border: 1px solid orange; padding: 10px;"
|
||||||
class="monospace"
|
class="monospace"
|
||||||
:class="{'jsonbg': !hasError, 'jsonbg-error': hasError}"
|
:class="{'jsonbg': !confHasError, 'jsonbg-error': confHasError}"
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
@input="updateSettings"
|
@input="updateSettings"
|
||||||
>{{parsedSettings}}</div>
|
>{{parsedSettings}}</div>
|
||||||
@ -29,15 +45,41 @@
|
|||||||
<div class="panel-top">
|
<div class="panel-top">
|
||||||
<h2>Logger results</h2>
|
<h2>Logger results</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-middle scrollable flex-grow">
|
<template v-if="logStringified">
|
||||||
<pre>
|
<div class="panel-middle scrollable flex-grow">
|
||||||
{{logStringified}}
|
<pre>
|
||||||
</pre>
|
{{logStringified}}
|
||||||
</div>
|
</pre>
|
||||||
|
</div>
|
||||||
|
<div class="flex-noshrink flex flex-row flex-end">
|
||||||
|
<div class="button">New log</div>
|
||||||
|
<div class="button">Export log</div>
|
||||||
|
<div class="button">Export & quit</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<div class="panel-middle scrollable flex-grow">
|
||||||
|
<div v-if="!parsedSettings" class="text-center w100">
|
||||||
|
Please paste logger config into the text box to the left.
|
||||||
|
←←←
|
||||||
|
</div>
|
||||||
|
<div v-else-if="confHasError" class="warn">
|
||||||
|
Logger configuration contains an error. Cannot start logging.
|
||||||
|
</div>
|
||||||
|
<div v-else-if="lastSettings && lastSettings.allowLogging && lastSettings.consoleOptions && lastSettings.consoleOptions.enabled">
|
||||||
|
Logging in progress ...
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div class="button">
|
||||||
|
Start logging
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
button row is here
|
button row is heres
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -49,14 +91,14 @@ import Logger from '../ext/lib/Logger';
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showLoggerUi: true,
|
showLoggerUi: false,
|
||||||
header: {
|
header: {
|
||||||
header: 'whoopsie daisy',
|
header: 'whoopsie daisy',
|
||||||
subheader: 'you broke the header choosing script'
|
subheader: 'you broke the header choosing script'
|
||||||
},
|
},
|
||||||
parsedSettings: '',
|
parsedSettings: '',
|
||||||
lastSettings: {},
|
lastSettings: {},
|
||||||
hasError: false,
|
confHasError: false,
|
||||||
logStringified: '',
|
logStringified: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -76,43 +118,50 @@ export default {
|
|||||||
|
|
||||||
this.lastSettings = await Logger.getConfig() || {};
|
this.lastSettings = await Logger.getConfig() || {};
|
||||||
this.parsedSettings = JSON.stringify(this.lastSettings, null, 2) || '';
|
this.parsedSettings = JSON.stringify(this.lastSettings, null, 2) || '';
|
||||||
|
|
||||||
// this.$store.watch(
|
|
||||||
// (state, getters) => {},
|
|
||||||
// (newValue, oldValue) => {
|
|
||||||
// console.log("$store.watch — updating from", oldValue, "to", newValue);
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState([
|
...mapState([
|
||||||
'uwLog',
|
'uwLog',
|
||||||
|
'showLogger'
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
uwLog(newValue, oldValue) {
|
uwLog(newValue, oldValue) {
|
||||||
console.log("updating status from", oldValue, "to", newValue);
|
|
||||||
if (oldValue !== newValue) {
|
if (oldValue !== newValue) {
|
||||||
this.logStringified = JSON.stringify(newValue, null, 2);
|
this.logStringified = JSON.stringify(newValue, null, 2);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
showLogger(newValue) {
|
||||||
|
this.showLoggerUi = newValue;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateSettings(val) {
|
updateSettings(val) {
|
||||||
try {
|
try {
|
||||||
// this.settings.active = JSON.parse(val.target.textContent);
|
// this.settings.active = JSON.parse(val.target.textContent);
|
||||||
this.hasError = false;
|
this.confHasError = false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.hasError = true;
|
this.confHasError = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
hidePopup() {
|
||||||
|
// this function only works as 'close' if logging has finished
|
||||||
|
if (this.logStringified) {
|
||||||
|
Logger.saveConfig({...this.lastSettings, allowLogging: false});
|
||||||
|
}
|
||||||
|
this.$store.dispatch('uw-hide-logger');
|
||||||
|
},
|
||||||
|
stopLogging() {
|
||||||
|
Logger.saveConfig({...this.lastSettings, allowLogging: false});
|
||||||
|
this.$store.dispatch('uw-hide-logger');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import url('/res/css/colors.scss');
|
@import '../res/css/colors.scss';
|
||||||
@import url('/res/css/font/overpass.css');
|
@import '../res/css/font/overpass.css';
|
||||||
@import url('/res/css/font/overpass-mono.css');
|
@import url('/res/css/font/overpass-mono.css');
|
||||||
@import url('/res/css/common.scss');
|
@import url('/res/css/common.scss');
|
||||||
@import url('/res/css/flex.css');
|
@import url('/res/css/flex.css');
|
||||||
@ -124,13 +173,17 @@ export default {
|
|||||||
width: 90vw !important;
|
width: 90vw !important;
|
||||||
height: 90vh !important;
|
height: 90vh !important;
|
||||||
z-index: 999999 !important;
|
z-index: 999999 !important;
|
||||||
background-color: rgba(18,17,15,0.9) !important;
|
background-color: rgba( $page-background, 0.9) !important;
|
||||||
color: #f1f1f1 !important;
|
color: #f1f1f1 !important;
|
||||||
font-size: 14px !important;
|
font-size: 14px !important;
|
||||||
|
|
||||||
box-sizing: border-box !important;
|
box-sizing: border-box !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
font-family: 'Overpass';
|
||||||
|
}
|
||||||
|
|
||||||
h1, h2 {
|
h1, h2 {
|
||||||
font-family: 'Overpass Thin';
|
font-family: 'Overpass Thin';
|
||||||
}
|
}
|
||||||
@ -142,9 +195,19 @@ h2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
|
h1 {
|
||||||
* {
|
margin-bottom: -0.20em;
|
||||||
padding-left: 32px;
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
.header-top, .header-bottom {
|
||||||
|
padding-left: 16px;
|
||||||
|
padding-right: 16px;
|
||||||
|
}
|
||||||
|
.header-top {
|
||||||
|
background-color: $popup-header-background !important;
|
||||||
|
}
|
||||||
|
.header-bottom {
|
||||||
|
font-size: 1.75em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.content {
|
.content {
|
||||||
@ -177,18 +240,23 @@ h2 {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
font-family: 'Overpass Mono';
|
||||||
|
}
|
||||||
|
|
||||||
.flex {
|
.button {
|
||||||
display: flex !important;
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-items: center;
|
||||||
|
padding-left: 2em;
|
||||||
|
padding-right: 2em;
|
||||||
}
|
}
|
||||||
.flex-column {
|
|
||||||
flex-flow: column !important;
|
.button-header {
|
||||||
|
font-size: 2em;
|
||||||
|
padding-top: 0.1em;
|
||||||
|
padding-left: 1em;
|
||||||
|
padding-right: 1em;
|
||||||
}
|
}
|
||||||
.flex-row {
|
|
||||||
flex-flow: row !important;
|
|
||||||
}
|
|
||||||
.flex-noshrink {
|
|
||||||
flex-shrink: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
@ -287,6 +287,10 @@ class Logger {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isLoggingToFile() {
|
||||||
|
return this.conf.allowLogging && this.conf.fileOptions?.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: THIS FUNCTION IS NEVER USED INTERNALLY!
|
// NOTE: THIS FUNCTION IS NEVER USED INTERNALLY!
|
||||||
canLog(component) {
|
canLog(component) {
|
||||||
const stackInfo = this.parseStack();
|
const stackInfo = this.parseStack();
|
||||||
|
@ -41,11 +41,10 @@ class UW {
|
|||||||
this.settings = undefined;
|
this.settings = undefined;
|
||||||
this.actionHandler = undefined;
|
this.actionHandler = undefined;
|
||||||
this.logger = undefined;
|
this.logger = undefined;
|
||||||
this.store = {};
|
this.vuexStore = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(){
|
async init(){
|
||||||
this.createUi();
|
|
||||||
if (Debug.debug) {
|
if (Debug.debug) {
|
||||||
console.log("[uw::main] loading configuration ...");
|
console.log("[uw::main] loading configuration ...");
|
||||||
}
|
}
|
||||||
@ -84,9 +83,18 @@ class UW {
|
|||||||
'handleMouseMove': false
|
'handleMouseMove': false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.logger = new Logger({vuexStore: this.store});
|
this.logger = new Logger({vuexStore: this.vuexStore});
|
||||||
await this.logger.init(loggingOptions);
|
await this.logger.init(loggingOptions);
|
||||||
// await this.logger.init(); // not needed if logging options are provided at creation
|
|
||||||
|
// show popup if logging to file is enabled
|
||||||
|
if (this.logger.isLoggingToFile()) {
|
||||||
|
console.info('[uw::init] Logging to file is enabled. Will show popup!');
|
||||||
|
try {
|
||||||
|
this.vuexStore.dispatch('uw-show-logger');
|
||||||
|
} catch (e) {
|
||||||
|
console.error('[uw::init] Failed to open popup!', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("logger init failed!", e)
|
console.error("logger init failed!", e)
|
||||||
@ -109,6 +117,10 @@ class UW {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.comms = new CommsClient('content-client-port', this.settings, this.logger);
|
this.comms = new CommsClient('content-client-port', this.settings, this.logger);
|
||||||
|
|
||||||
|
// add showPopup, hidePopup listener to comms
|
||||||
|
this.comms.subscribe('show-logger', () => this.showLogger());
|
||||||
|
this.comms.subscribe('hide-logger', () => this.hideLogger());
|
||||||
|
|
||||||
// če smo razširitev onemogočili v nastavitvah, ne naredimo ničesar
|
// če smo razširitev onemogočili v nastavitvah, ne naredimo ničesar
|
||||||
// If extension is soft-disabled, don't do shit
|
// If extension is soft-disabled, don't do shit
|
||||||
@ -144,38 +156,48 @@ class UW {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.log('error', 'debug', "[uw::init] FAILED TO START EXTENSION. Error:", e);
|
this.logger.log('error', 'debug', "[uw::init] FAILED TO START EXTENSION. Error:", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initVue() {
|
initVue() {
|
||||||
Vue.prototype.$browser = global.browser;
|
Vue.prototype.$browser = global.browser;
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
this.store = new Vuex.Store({
|
this.vuexStore = new Vuex.Store({
|
||||||
plugins: [VuexWebExtensions({
|
plugins: [VuexWebExtensions({
|
||||||
persistentStates: [
|
persistentStates: [
|
||||||
'uwLog'
|
'uwLog',
|
||||||
|
'showLogger',
|
||||||
],
|
],
|
||||||
})],
|
})],
|
||||||
state: {
|
state: {
|
||||||
uwLog: '',
|
uwLog: '',
|
||||||
|
showLogger: false,
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
'uw-set-log'(state, payload) {
|
'uw-set-log'(state, payload) {
|
||||||
console.info('setting state')
|
|
||||||
state['uwLog'] = payload;
|
state['uwLog'] = payload;
|
||||||
|
},
|
||||||
|
'uw-show-logger'(state) {
|
||||||
|
state['showLogger'] = true;
|
||||||
|
},
|
||||||
|
'uw-hide-logger'(state) {
|
||||||
|
state['showLogger'] = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
'uw-set-log' ({commit}, payload) {
|
'uw-set-log' ({commit}, payload) {
|
||||||
console.info("comitting uw-set-log with payload", payload);
|
|
||||||
commit('uw-set-log', payload);
|
commit('uw-set-log', payload);
|
||||||
|
},
|
||||||
|
'uw-show-logger'({commit}) {
|
||||||
|
commit('uw-show-logger');
|
||||||
|
},
|
||||||
|
'uw-hide-logger'({commit}) {
|
||||||
|
commit('uw-hide-logger');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
createUi() {
|
initUi() {
|
||||||
console.log("CREATING UI");
|
console.log("CREATING UI");
|
||||||
const random = Math.round(Math.random() * 69420);
|
const random = Math.round(Math.random() * 69420);
|
||||||
const uwid = `uw-ui-root-${random}`;
|
const uwid = `uw-ui-root-${random}`;
|
||||||
@ -192,14 +214,22 @@ class UW {
|
|||||||
components: {
|
components: {
|
||||||
LoggerUi
|
LoggerUi
|
||||||
},
|
},
|
||||||
store: this.store,
|
store: this.vuexStore,
|
||||||
render(h) {
|
render(h) {
|
||||||
return h('logger-ui');
|
return h('logger-ui');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showLogger() {
|
||||||
|
this.vuexStore.dispatch('uw-show-logger');
|
||||||
|
}
|
||||||
|
hideLogger() {
|
||||||
|
this.vuexStore.dispatch('uw-hide-logger');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var main = new UW();
|
var main = new UW();
|
||||||
main.initVue();
|
main.initVue();
|
||||||
|
main.initUi();
|
||||||
main.init();
|
main.init();
|
||||||
|
@ -7,6 +7,7 @@ $secondary-color: #e70c0c;
|
|||||||
$input-background: #141414;
|
$input-background: #141414;
|
||||||
$input-border: #4e3527;
|
$input-border: #4e3527;
|
||||||
$page-background: #101010;
|
$page-background: #101010;
|
||||||
|
$popup-header-background: #7f1416;
|
||||||
|
|
||||||
$background-primary: #101010;
|
$background-primary: #101010;
|
||||||
$selected-color: #f5cbaf;
|
$selected-color: #f5cbaf;
|
||||||
|
@ -215,7 +215,9 @@ small {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.text-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.invalid-input {
|
.invalid-input {
|
||||||
|
Loading…
Reference in New Issue
Block a user