ultrawidify/src/csui/LoggerUi.vue

195 lines
4.3 KiB
Vue
Raw Normal View History

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">
<h1>{{header.header}}</h1>
<div>{{header.subheader}}</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-02 00:57:54 +01:00
<div class="panel-top">
<h2>Logger configuration</h2>
<p>Paste logger configuration in this box</p>
</div>
<div class="panel-middle">
<div ref="settingsEditArea"
style="white-space: pre-wrap; border: 1px solid orange; padding: 10px;"
class="monospace"
:class="{'jsonbg': !hasError, 'jsonbg-error': hasError}"
contenteditable="true"
@input="updateSettings"
>{{parsedSettings}}</div>
</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-02 00:57:54 +01:00
<div class="panel-top">
<h2>Logger results</h2>
</div>
2020-02-03 22:14:07 +01:00
<div class="panel-middle scrollable flex-grow">
<pre>
{{logStringified}}
</pre>
2020-02-02 00:57:54 +01:00
</div>
2020-01-31 01:03:06 +01:00
</div>
</div>
2020-02-01 17:48:31 +01:00
<div>
2020-01-31 01:03:06 +01:00
button row is here
</div>
</div>
</template>
<script>
2020-02-02 00:57:54 +01:00
import { mapState } from 'vuex';
import Logger from '../ext/lib/Logger';
2020-01-31 01:03:06 +01:00
export default {
data() {
return {
showLoggerUi: true,
2020-02-02 00:57:54 +01:00
header: {
header: 'whoopsie daisy',
subheader: 'you broke the header choosing script'
},
parsedSettings: '',
lastSettings: {},
hasError: false,
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;
this.lastSettings = await Logger.getConfig() || {};
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: {
...mapState([
'uwLog',
]),
},
watch: {
uwLog(newValue, oldValue) {
console.log("updating status from", oldValue, "to", newValue);
if (oldValue !== newValue) {
this.logStringified = JSON.stringify(newValue, null, 2);
2020-01-31 01:03:06 +01:00
}
}
2020-02-02 00:57:54 +01:00
},
methods: {
updateSettings(val) {
try {
// this.settings.active = JSON.parse(val.target.textContent);
this.hasError = false;
} catch (e) {
this.hasError = true;
}
},
2020-01-31 01:03:06 +01:00
}
}
</script>
<style lang="scss" scoped>
2020-02-02 00:57:54 +01:00
@import url('/res/css/colors.scss');
@import url('/res/css/font/overpass.css');
@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;
background-color: rgba(18,17,15,0.9) !important;
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-02 00:57:54 +01:00
h1, h2 {
font-family: 'Overpass Thin';
}
h1 {
font-size: 4em;
}
h2 {
font-size: 2em;
}
.header {
* {
padding-left: 32px;
}
}
.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;
}
.flex {
display: flex !important;
}
.flex-column {
flex-flow: column !important;
}
.flex-row {
flex-flow: row !important;
2020-02-02 00:57:54 +01:00
}
2020-02-03 22:14:07 +01:00
.flex-noshrink {
flex-shrink: 0 !important;
}
2020-02-02 00:57:54 +01:00
2020-01-31 01:03:06 +01:00
</style>