2020-01-31 01:03:06 +01:00
|
|
|
<template>
|
2020-02-03 22:14:07 +01:00
|
|
|
<div v-if="showLoggerUi" class="root-window flex flex-column overflow-hidden">
|
2020-02-02 00:57:54 +01:00
|
|
|
<div class="header">
|
2020-02-04 00:56:48 +01:00
|
|
|
<div class="header-top flex flex-row">
|
|
|
|
<div class="flex-grow">
|
|
|
|
<h1>{{header.header}}</h1>
|
|
|
|
</div>
|
|
|
|
<div class="button flex-noshrink button-header"
|
|
|
|
@click="hidePopup()"
|
|
|
|
>
|
2020-02-06 22:29:59 +01:00
|
|
|
<template v-if="logStringified">Finish logging</template>
|
|
|
|
<template v-else>Hide popup</template>
|
2020-02-04 00:56:48 +01:00
|
|
|
</div>
|
|
|
|
<!-- <div class="button flex-noshrink button-header"
|
|
|
|
@click="stopLogging()"
|
|
|
|
>
|
|
|
|
Stop logging
|
|
|
|
</div> -->
|
|
|
|
</div>
|
|
|
|
<div class="header-bottom">
|
|
|
|
<div>{{header.subheader}}</div>
|
|
|
|
</div>
|
2020-01-31 01:03:06 +01:00
|
|
|
</div>
|
2020-02-03 22:14:07 +01:00
|
|
|
<div class="content flex flex-row flex-grow overflow-hidden">
|
2020-02-02 00:57:54 +01:00
|
|
|
|
|
|
|
<!-- LOGGER SETTINGS PANEL -->
|
2020-02-03 22:14:07 +01:00
|
|
|
<div class="settings-panel flex flex-noshrink flex-column">
|
2020-02-05 00:39:16 +01:00
|
|
|
<div class="panel-top flex-nogrow">
|
2020-02-02 00:57:54 +01:00
|
|
|
<h2>Logger configuration</h2>
|
|
|
|
<p>Paste logger configuration in this box</p>
|
|
|
|
</div>
|
|
|
|
|
2020-02-05 00:39:16 +01:00
|
|
|
<div class="panel-middle scrollable flex-grow p-t-025em">
|
2020-02-02 00:57:54 +01:00
|
|
|
<div ref="settingsEditArea"
|
|
|
|
style="white-space: pre-wrap; border: 1px solid orange; padding: 10px;"
|
2020-02-05 00:39:16 +01:00
|
|
|
class="monospace h100"
|
2020-02-04 00:56:48 +01:00
|
|
|
:class="{'jsonbg': !confHasError, 'jsonbg-error': confHasError}"
|
2020-02-02 00:57:54 +01:00
|
|
|
contenteditable="true"
|
|
|
|
@input="updateSettings"
|
2020-02-05 00:39:16 +01:00
|
|
|
>
|
|
|
|
{{parsedSettings}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex-noshrink flex flex-row flex-cross-center p-t-025em">
|
|
|
|
<div class="button button-bar"
|
|
|
|
@click="restoreLoggerSettings()"
|
|
|
|
>
|
|
|
|
Revert logger config
|
|
|
|
</div>
|
2020-02-02 00:57:54 +01:00
|
|
|
</div>
|
2020-01-31 01:03:06 +01:00
|
|
|
</div>
|
2020-02-02 00:57:54 +01:00
|
|
|
|
|
|
|
<!-- LOGGER OUTPUT/START LOGGING -->
|
2020-02-03 22:14:07 +01:00
|
|
|
<div class="results-panel flex flex-shrink flex-column overflow-hidden">
|
2020-02-05 00:39:16 +01:00
|
|
|
<div class="panel-top flex-nogrow">
|
2020-02-02 00:57:54 +01:00
|
|
|
<h2>Logger results</h2>
|
|
|
|
</div>
|
2020-02-04 00:56:48 +01:00
|
|
|
<template v-if="logStringified">
|
2020-02-05 00:39:16 +01:00
|
|
|
<div v-if="confHasError" class="warn">
|
|
|
|
Logger configuration contains an error. You can export current log, but you will be unable to record a new log.
|
|
|
|
</div>
|
|
|
|
<div class="panel-middle scrollable flex-grow p-t-025em">
|
2020-02-04 00:56:48 +01:00
|
|
|
<pre>
|
|
|
|
{{logStringified}}
|
|
|
|
</pre>
|
|
|
|
</div>
|
2020-02-04 23:31:50 +01:00
|
|
|
<div class="flex-noshrink flex flex-row flex-end p-t-025em">
|
|
|
|
<div class="button button-bar"
|
|
|
|
@click="startLogging()"
|
|
|
|
>
|
|
|
|
New log
|
|
|
|
</div>
|
|
|
|
<div class="button button-bar"
|
|
|
|
@click="exportLog()"
|
|
|
|
>
|
|
|
|
Export log
|
|
|
|
</div>
|
|
|
|
<div class="button button-bar button-primary"
|
|
|
|
@click="exportAndQuit()"
|
|
|
|
>
|
2020-02-06 22:29:59 +01:00
|
|
|
Export & finish
|
2020-02-04 23:31:50 +01:00
|
|
|
</div>
|
2020-02-04 00:56:48 +01:00
|
|
|
</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>
|
2020-02-04 23:31:50 +01:00
|
|
|
<div v-else-if="lastSettings && lastSettings.allowLogging && lastSettings.consoleOptions && lastSettings.consoleOptions.enabled"
|
|
|
|
class="flex flex-column flex-center flex-cross-center w100 h100"
|
|
|
|
>
|
|
|
|
<p class="m-025em">
|
|
|
|
Logging in progress ...
|
|
|
|
</p>
|
|
|
|
<div class="button button-big button-primary"
|
|
|
|
@click="stopLogging()"
|
|
|
|
>
|
|
|
|
Stop logging
|
|
|
|
</div>
|
|
|
|
<p v-if="lastSettings && lastSettings.timeout"
|
|
|
|
class="m-025em"
|
|
|
|
>
|
|
|
|
... or wait until logging ends.
|
|
|
|
</p>
|
2020-02-04 00:56:48 +01:00
|
|
|
</div>
|
2020-02-04 23:31:50 +01:00
|
|
|
<div v-else class="flex flex-column flex-center flex-cross-center w100 h100">
|
|
|
|
<div class="button button-big button-primary"
|
|
|
|
@click="startLogging()"
|
|
|
|
>
|
2020-02-04 00:56:48 +01:00
|
|
|
Start logging
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2020-01-31 01:03:06 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-02-04 23:31:50 +01:00
|
|
|
<!-- <div>
|
2020-02-04 00:56:48 +01:00
|
|
|
button row is heres
|
2020-02-04 23:31:50 +01:00
|
|
|
</div> -->
|
2020-01-31 01:03:06 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-02-02 00:57:54 +01:00
|
|
|
import { mapState } from 'vuex';
|
|
|
|
import Logger from '../ext/lib/Logger';
|
2020-02-04 23:31:50 +01:00
|
|
|
import Comms from '../ext/lib/comms/Comms';
|
|
|
|
import IO from '../common/js/IO';
|
2020-02-02 00:57:54 +01:00
|
|
|
|
2020-01-31 01:03:06 +01:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2020-02-04 00:56:48 +01:00
|
|
|
showLoggerUi: false,
|
2020-02-02 00:57:54 +01:00
|
|
|
header: {
|
|
|
|
header: 'whoopsie daisy',
|
|
|
|
subheader: 'you broke the header choosing script'
|
|
|
|
},
|
|
|
|
parsedSettings: '',
|
|
|
|
lastSettings: {},
|
2020-02-04 00:56:48 +01:00
|
|
|
confHasError: false,
|
2020-02-02 00:57:54 +01:00
|
|
|
logStringified: '',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async created() {
|
|
|
|
const headerRotation = [{
|
|
|
|
header: "DEFORESTATOR 5000",
|
|
|
|
subheader: "Iron Legion's finest logging tool"
|
|
|
|
}, {
|
|
|
|
header: "Astinus",
|
|
|
|
subheader: "Ultrawidify logging tool"
|
|
|
|
}, {
|
|
|
|
header: "Tracer",
|
|
|
|
subheader: "I'm already printing stack traces"
|
|
|
|
}];
|
|
|
|
|
|
|
|
this.header = headerRotation[Math.floor(+Date.now() / (3600000*24)) % headerRotation.length] || this.header;
|
|
|
|
|
2020-02-05 00:39:16 +01:00
|
|
|
this.getLoggerSettings();
|
2020-02-02 00:57:54 +01:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState([
|
|
|
|
'uwLog',
|
2020-02-04 00:56:48 +01:00
|
|
|
'showLogger'
|
2020-02-02 00:57:54 +01:00
|
|
|
]),
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
uwLog(newValue, oldValue) {
|
|
|
|
if (oldValue !== newValue) {
|
2020-02-04 23:31:50 +01:00
|
|
|
this.$store.dispatch('uw-show-logger');
|
2020-02-02 00:57:54 +01:00
|
|
|
this.logStringified = JSON.stringify(newValue, null, 2);
|
2020-01-31 01:03:06 +01:00
|
|
|
}
|
2020-02-04 00:56:48 +01:00
|
|
|
},
|
2020-02-04 23:31:50 +01:00
|
|
|
async showLogger(newValue) {
|
2020-02-04 00:56:48 +01:00
|
|
|
this.showLoggerUi = newValue;
|
2020-02-04 23:31:50 +01:00
|
|
|
|
2020-02-05 00:39:16 +01:00
|
|
|
// update logger settings (they could have changed while the popup was closed)
|
2020-02-04 23:31:50 +01:00
|
|
|
if (newValue) {
|
2020-02-05 00:39:16 +01:00
|
|
|
this.getLoggerSettings();
|
2020-02-04 23:31:50 +01:00
|
|
|
}
|
2020-01-31 01:03:06 +01:00
|
|
|
}
|
2020-02-02 00:57:54 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2020-02-05 00:39:16 +01:00
|
|
|
async getLoggerSettings() {
|
|
|
|
this.lastSettings = await Logger.getConfig() || {};
|
|
|
|
this.parsedSettings = JSON.stringify(this.lastSettings, null, 2) || '';
|
|
|
|
},
|
2020-02-02 00:57:54 +01:00
|
|
|
updateSettings(val) {
|
|
|
|
try {
|
2020-02-05 00:39:16 +01:00
|
|
|
this.parsedSettings = JSON.stringify(JSON.parse(val.target.textContent.trim()), null, 2);
|
|
|
|
// this.lastSettings = JSON.parse(val.target.textContent.trim());
|
2020-02-04 00:56:48 +01:00
|
|
|
this.confHasError = false;
|
2020-02-02 00:57:54 +01:00
|
|
|
} catch (e) {
|
2020-02-04 00:56:48 +01:00
|
|
|
this.confHasError = true;
|
|
|
|
}
|
|
|
|
},
|
2020-02-05 00:39:16 +01:00
|
|
|
restoreLoggerSettings() {
|
|
|
|
this.parsedSettings = JSON.stringify(this.lastSettings, null, 2);
|
|
|
|
this.confHasError = false;
|
|
|
|
},
|
2020-02-04 23:31:50 +01:00
|
|
|
async startLogging(){
|
|
|
|
this.logStringified = undefined;
|
|
|
|
await Logger.saveConfig({...this.lastSettings, allowLogging: true});
|
|
|
|
window.location.reload();
|
|
|
|
},
|
2020-02-04 00:56:48 +01:00
|
|
|
hidePopup() {
|
|
|
|
// this function only works as 'close' if logging has finished
|
|
|
|
if (this.logStringified) {
|
|
|
|
Logger.saveConfig({...this.lastSettings, allowLogging: false});
|
2020-02-04 23:31:50 +01:00
|
|
|
this.logStringified = undefined;
|
2020-02-02 00:57:54 +01:00
|
|
|
}
|
2020-02-04 00:56:48 +01:00
|
|
|
this.$store.dispatch('uw-hide-logger');
|
2020-02-02 00:57:54 +01:00
|
|
|
},
|
2020-02-04 23:31:50 +01:00
|
|
|
closePopupAndStopLogging() {
|
2020-02-04 00:56:48 +01:00
|
|
|
Logger.saveConfig({...this.lastSettings, allowLogging: false});
|
2020-02-04 23:31:50 +01:00
|
|
|
this.logStringified = undefined;
|
2020-02-04 00:56:48 +01:00
|
|
|
this.$store.dispatch('uw-hide-logger');
|
2020-02-04 23:31:50 +01:00
|
|
|
},
|
|
|
|
stopLogging() {
|
|
|
|
Logger.saveConfig({...this.lastSettings, allowLogging: false});
|
2020-02-05 00:39:16 +01:00
|
|
|
this.lastSettings.allowLogging = false;
|
2020-02-04 23:31:50 +01:00
|
|
|
},
|
|
|
|
exportLog() {
|
|
|
|
IO.csStringToFile(this.logStringified);
|
|
|
|
},
|
|
|
|
exportAndQuit() {
|
|
|
|
this.exportLog();
|
|
|
|
this.logStringified = undefined;
|
|
|
|
this.closePopupAndStopLogging();
|
2020-02-04 00:56:48 +01:00
|
|
|
}
|
2020-01-31 01:03:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-02-04 00:56:48 +01:00
|
|
|
@import '../res/css/colors.scss';
|
|
|
|
@import '../res/css/font/overpass.css';
|
2020-02-02 00:57:54 +01:00
|
|
|
@import url('/res/css/font/overpass-mono.css');
|
|
|
|
@import url('/res/css/common.scss');
|
|
|
|
@import url('/res/css/flex.css');
|
2020-02-01 17:48:31 +01:00
|
|
|
|
2020-02-02 00:57:54 +01:00
|
|
|
.root-window {
|
2020-02-01 17:48:31 +01:00
|
|
|
position: fixed !important;
|
|
|
|
top: 5vh !important;
|
|
|
|
left: 5vw !important;
|
|
|
|
width: 90vw !important;
|
|
|
|
height: 90vh !important;
|
|
|
|
z-index: 999999 !important;
|
2020-02-04 00:56:48 +01:00
|
|
|
background-color: rgba( $page-background, 0.9) !important;
|
2020-02-01 17:48:31 +01:00
|
|
|
color: #f1f1f1 !important;
|
|
|
|
font-size: 14px !important;
|
2020-02-03 22:14:07 +01:00
|
|
|
|
|
|
|
box-sizing: border-box !important;
|
2020-02-01 17:48:31 +01:00
|
|
|
}
|
2020-01-31 01:03:06 +01:00
|
|
|
|
2020-02-04 00:56:48 +01:00
|
|
|
div {
|
|
|
|
font-family: 'Overpass';
|
|
|
|
}
|
|
|
|
|
2020-02-02 00:57:54 +01:00
|
|
|
h1, h2 {
|
|
|
|
font-family: 'Overpass Thin';
|
|
|
|
}
|
|
|
|
h1 {
|
|
|
|
font-size: 4em;
|
|
|
|
}
|
|
|
|
h2 {
|
|
|
|
font-size: 2em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header {
|
2020-02-04 00:56:48 +01:00
|
|
|
h1 {
|
|
|
|
margin-bottom: -0.20em;
|
|
|
|
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;
|
2020-02-02 00:57:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.content {
|
2020-02-03 22:14:07 +01:00
|
|
|
box-sizing: border-box;
|
2020-02-02 00:57:54 +01:00
|
|
|
padding: 8px 32px;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
.settings-panel {
|
2020-02-03 22:14:07 +01:00
|
|
|
box-sizing: border-box;
|
|
|
|
padding-right: 8px;
|
|
|
|
flex-grow: 2 !important;
|
|
|
|
min-width: 30% !important;
|
|
|
|
flex-shrink: 0 !important;
|
|
|
|
height: inherit !important;
|
2020-02-02 00:57:54 +01:00
|
|
|
}
|
|
|
|
.results-panel {
|
2020-02-03 22:14:07 +01:00
|
|
|
box-sizing: border-box;
|
|
|
|
padding-left: 8px;
|
|
|
|
max-width: 70% !important;
|
|
|
|
flex-grow: 5 !important;
|
|
|
|
flex-shrink: 0 !important;
|
|
|
|
height: inherit !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.scrollable {
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.overflow-hidden {
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
2020-02-04 00:56:48 +01:00
|
|
|
pre {
|
|
|
|
font-family: 'Overpass Mono';
|
2020-02-03 22:14:07 +01:00
|
|
|
}
|
2020-02-04 00:56:48 +01:00
|
|
|
|
2020-02-04 23:31:50 +01:00
|
|
|
.m-025em {
|
|
|
|
margin: 0.25em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-t-025em {
|
|
|
|
padding-top: 0.25em;
|
|
|
|
}
|
|
|
|
|
2020-02-04 00:56:48 +01:00
|
|
|
.button {
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-items: center;
|
|
|
|
padding-left: 2em;
|
|
|
|
padding-right: 2em;
|
2020-02-03 22:14:07 +01:00
|
|
|
}
|
2020-02-04 00:56:48 +01:00
|
|
|
|
2020-02-04 23:31:50 +01:00
|
|
|
.button-primary {
|
|
|
|
background-color: $primary;
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
.button-big {
|
|
|
|
font-size: 1.5em;
|
|
|
|
padding: 1.75em 3.25em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.button-bar {
|
|
|
|
font-size: 1.25em;
|
|
|
|
padding: 0.25em 1.25em;
|
|
|
|
margin-left: 0.25em;
|
|
|
|
}
|
|
|
|
|
2020-02-04 00:56:48 +01:00
|
|
|
.button-header {
|
|
|
|
font-size: 2em;
|
|
|
|
padding-top: 0.1em;
|
|
|
|
padding-left: 1em;
|
|
|
|
padding-right: 1em;
|
2020-02-02 00:57:54 +01:00
|
|
|
}
|
|
|
|
|
2020-02-05 00:39:16 +01:00
|
|
|
.jsonbg {
|
|
|
|
background-color: #131313;
|
|
|
|
}
|
|
|
|
.jsonbg-error {
|
|
|
|
background-color: #884420;
|
|
|
|
}
|
|
|
|
|
2020-01-31 01:03:06 +01:00
|
|
|
</style>
|