2020-01-31 01:03:06 +01:00
< template >
2020-03-12 00:37:15 +01:00
< div v -if = " showLoggerUi " class = "root-window flex flex-column overflow-hidden"
@ keyup . stop
@ keydown . stop
@ keypress . stop
>
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 >
< / div >
2020-03-12 23:36:06 +01:00
< div class = "flex flex-row flex-end w100" >
2021-09-15 00:54:46 +02:00
< div v-if ="!showTextMode" class="button" @click="loadDefaultConfig()" >
Default config
< / div >
2020-03-12 23:36:06 +01:00
< div v-if ="!showTextMode" class="button" @click="showTextMode = true" >
2020-12-02 22:39:43 +01:00
< Icon icon = "clipboard-plus" style = "font-size: 2em" > < / Icon > & nbsp ; Paste config ...
2020-02-05 00:39:16 +01:00
< / div >
2020-03-12 23:36:06 +01:00
< div v -else class = "button" @ click = "showTextMode = false" >
Back
2020-02-05 00:39:16 +01:00
< / div >
2020-02-02 00:57:54 +01:00
< / div >
2020-03-12 23:36:06 +01:00
< div class = "panel-middle scrollable flex-grow log-config-margin" >
< template v-if ="showTextMode" >
< div ref = "settingsEditArea"
style = "white-space: pre-wrap; border: 1px solid orange; padding: 10px;"
class = "monospace h100"
: class = "{'jsonbg': !confHasError, 'jsonbg-error': confHasError}"
contenteditable = "true"
@ input = "updateSettings"
>
{ { parsedSettings } }
< / div >
< / template >
< template v-else >
< JsonObject label = "logger-settings"
: value = "currentSettings"
2021-09-15 00:54:46 +02:00
: ignoreKeys = "{'allowLogging': false}"
2020-03-12 23:36:06 +01:00
@ change = "updateSettingsUi"
> < / JsonObject >
< / template >
< / div >
< div class = "flex flex-row flex-end" >
< div class = "button" @click ="restoreLoggerSettings()" >
Revert
< / div >
< div class = "button button-primary" @click ="saveLoggerSettings()" >
Save
< / div >
< / div >
2020-03-11 23:12:29 +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" >
2021-09-15 00:54:46 +02:00
< div >
< p > Here ' s express usage tutorial on how to use the logger . < / p >
< p > Quick rundown of all the options you can put into logger configuration can be found < a href = "https://github.com/tamius-han/ultrawidify/wiki/Development&Debugging:-Logger-options" target = "_blank" > here < / a > . < / p >
< p > If you want logging results to appear here , in this window , you need to put appropriate configuration in the fileOptions section of the settings . You can edit the settings by clicking 'paste config' button . < / p >
< p > To start logging to console , it 's enough to click that tiny ' save ' button down there , under logger options ( < code > logger - settings . allowLogging < / code > must be set to true . Then — depending on where you want logging to happen — you also need to enable either < code > logger - settings . fileOptions . enabled < / code > or < code > logger - settings . consoleOptions . enabled < / code > ) < / p >
< p > You can quickly toggle values for various components by clicking on "true" or "false" . < / p >
< p > Click the small 'save' down at the bottom of this window to immediately apply the logger configuration changes . < / p >
< p > Yes , I know this is not a pinnacle of user - friendliness , nor a pinnacle of web design . It was put together very quickly , mostly for my convenience . I have plans to move extension UI from the popup into the player , tho , and these plans will make this window obsolete . Because of that , I plan to do absolutely nothing about the state of this window . Wait for the extension redesign pls . < / p >
2020-02-04 00:56:48 +01:00
< / div >
2021-09-15 00:54:46 +02:00
< div v-if ="confHasError" class="warn" >
2020-02-04 00:56:48 +01:00
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 >
2020-03-12 23:36:06 +01:00
< template v -if = " lastSettings & & lastSettings.timeout "
class = "m-025em"
2020-02-04 23:31:50 +01:00
>
2020-03-12 23:36:06 +01:00
< p >
... or wait until logging ends .
< / p >
< p >
You can < a @click ="hidePopup()" > hide popup < / a > — it will automatically re -appear when logging finishes.
< / p >
< / template >
< template v -else -if = " lastSettings " >
< p >
You can < a @click ="hidePopup()" > hide popup < / a > — the logging will continue until you re -open the popup and stop it.
< / p >
< / template >
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' ;
2021-09-15 00:54:46 +02:00
import Logger , { baseLoggingOptions } 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-03-11 23:12:29 +01:00
import JsonObject from '../common/components/JsonEditor/JsonObject' ;
2020-12-02 22:39:43 +01:00
import Icon from '../common/components/Icon' ;
2020-02-02 00:57:54 +01:00
2020-01-31 01:03:06 +01:00
export default {
2020-03-11 23:12:29 +01:00
components : {
JsonObject ,
2020-12-02 22:39:43 +01:00
Icon ,
2020-03-11 23:12:29 +01:00
} ,
2020-01-31 01:03:06 +01:00
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-03-11 23:12:29 +01:00
currentSettings : { } ,
2020-02-04 00:56:48 +01:00
confHasError : false ,
2020-02-02 00:57:54 +01:00
logStringified : '' ,
2020-03-12 23:36:06 +01:00
showTextMode : false ,
2020-02-02 00:57:54 +01:00
}
} ,
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"
2021-09-15 00:54:46 +02:00
} , {
header : "Grûmsh" ,
subheader : "He who watches"
} , {
header : "Situation Room/The Council" ,
subheader : "We will always be watching"
2020-02-02 00:57:54 +01:00
} ] ;
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-03-15 19:16:27 +01:00
'showLogger' ,
'loggingEnded' ,
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-03-15 19:16:27 +01:00
} ,
loggingEnded ( newValue ) {
2020-03-15 19:47:38 +01:00
// note — the value of loggingEnded never actually matters. Even if this value is 'true'
// internally, vuexStore.dspatch() will still do its job and give us the signal we want
2020-03-15 19:16:27 +01:00
if ( newValue ) {
this . stopLogging ( ) ;
}
2020-01-31 01:03:06 +01:00
}
2020-02-02 00:57:54 +01:00
} ,
methods : {
2021-09-15 00:54:46 +02:00
loadDefaultConfig ( ) {
this . lastSettings = baseLoggingOptions ;
this . parsedSettings = JSON . stringify ( this . lastSettings , null , 2 ) || '' ;
this . currentSettings = JSON . parse ( JSON . stringify ( this . lastSettings ) ) ;
} ,
2020-02-05 00:39:16 +01:00
async getLoggerSettings ( ) {
2021-09-15 00:54:46 +02:00
this . lastSettings = await Logger . getConfig ( ) || baseLoggingOptions ;
2020-02-05 00:39:16 +01:00
this . parsedSettings = JSON . stringify ( this . lastSettings , null , 2 ) || '' ;
2020-03-11 23:12:29 +01:00
this . currentSettings = JSON . parse ( JSON . stringify ( this . lastSettings ) ) ;
2020-02-05 00:39:16 +01:00
} ,
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 ) ;
2020-02-06 22:59:57 +01:00
this . lastSettings = JSON . parse ( val . target . textContent . trim ( ) ) ;
2020-03-11 23:12:29 +01:00
this . currentSettings = JSON . parse ( JSON . stringify ( this . lastSettings ) ) ;
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-03-12 00:49:24 +01:00
updateSettingsUi ( val ) {
try {
this . parsedSettings = JSON . stringify ( val , null , 2 ) ;
this . lastSettings = val ;
this . currentSettings = JSON . parse ( JSON . stringify ( this . lastSettings ) ) ;
} catch ( e ) {
}
} ,
2020-03-12 23:36:06 +01:00
saveLoggerSettings ( ) {
Logger . saveConfig ( { ... this . lastSettings } ) ;
} ,
2020-02-05 00:39:16 +01:00
restoreLoggerSettings ( ) {
2020-02-06 22:59:57 +01:00
this . getLoggerSettings ( ) ;
2020-02-05 00:39:16 +01:00
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' ) ;
2021-08-24 02:13:05 +02:00
this . showLoggerUi = false ;
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 >
2020-04-13 14:35:04 +02:00
< style lang = "scss" src = "../res/css/flex.scss" scoped > < / style >
2020-03-01 20:24:08 +01:00
2020-01-31 01:03:06 +01:00
< 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-07 00:06:12 +01:00
@ import '../res/css/font/overpass-mono.css' ;
@ import '../res/css/common.scss' ;
2020-12-12 00:38:51 +01:00
. uw - ultrawidify - container - root {
. root - window {
position : fixed ! important ;
top : 5 vh ! important ;
left : 5 vw ! important ;
width : 90 vw ! important ;
height : 90 vh ! important ;
z - index : 999999 ! important ;
background - color : rgba ( $page - background , 0.9 ) ! important ;
color : # f1f1f1 ! important ;
font - size : 14 px ! important ;
2020-02-01 17:48:31 +01:00
2020-12-12 00:38:51 +01:00
box - sizing : border - box ! important ;
2021-08-24 00:57:29 +02:00
pointer - events : auto ! important ;
2020-12-12 00:38:51 +01:00
}
2020-02-04 00:56:48 +01:00
2020-12-12 00:38:51 +01:00
div {
font - family : 'Overpass' ;
}
2020-02-02 00:57:54 +01:00
2020-12-12 00:38:51 +01:00
h1 , h2 {
font - family : 'Overpass Thin' ;
}
2020-02-04 00:56:48 +01:00
h1 {
2020-12-12 00:38:51 +01:00
font - size : 4 em ;
}
h2 {
font - size : 2 em ;
}
. header {
h1 {
margin - bottom : - 0.20 em ;
margin - top : 0.0 em ;
}
. header - top , . header - bottom {
padding - left : 16 px ;
padding - right : 16 px ;
}
. header - top {
background - color : $popup - header - background ! important ;
}
. header - bottom {
font - size : 1.75 em ;
}
2020-02-04 00:56:48 +01:00
}
2020-12-12 00:38:51 +01:00
. content {
box - sizing : border - box ;
padding : 8 px 32 px ;
width : 100 % ;
2020-02-04 00:56:48 +01:00
}
2020-12-12 00:38:51 +01:00
. settings - panel {
box - sizing : border - box ;
padding - right : 8 px ;
flex - grow : 2 ! important ;
min - width : 30 % ! important ;
flex - shrink : 0 ! important ;
height : inherit ! important ;
2020-02-04 00:56:48 +01:00
}
2020-12-12 00:38:51 +01:00
. results - panel {
box - sizing : border - box ;
padding - left : 8 px ;
max - width : 70 % ! important ;
flex - grow : 5 ! important ;
flex - shrink : 0 ! important ;
height : inherit ! important ;
2020-02-02 00:57:54 +01:00
}
2020-02-03 22:14:07 +01:00
2020-12-12 00:38:51 +01:00
. scrollable {
overflow : auto ;
}
2020-02-03 22:14:07 +01:00
2020-12-12 00:38:51 +01:00
. overflow - hidden {
overflow : hidden ;
}
2020-02-03 22:14:07 +01:00
2020-12-12 00:38:51 +01:00
pre {
font - family : 'Overpass Mono' ;
}
2020-02-04 00:56:48 +01:00
2020-12-12 00:38:51 +01:00
. m - 025 em {
margin : 0.25 em ;
}
2020-02-04 23:31:50 +01:00
2020-12-12 00:38:51 +01:00
. p - t - 025 em {
padding - top : 0.25 em ;
}
2020-02-04 23:31:50 +01:00
2020-12-12 00:38:51 +01:00
. button {
display : inline - flex ;
align - items : center ;
justify - items : center ;
padding - left : 2 em ;
padding - right : 2 em ;
}
2020-02-04 00:56:48 +01:00
2020-12-12 00:38:51 +01:00
. button - primary {
background - color : $primary ;
color : # fff ;
}
2020-02-04 23:31:50 +01:00
2020-12-12 00:38:51 +01:00
. button - big {
font - size : 1.5 em ;
padding : 1.75 em 3.25 em ;
}
2020-02-04 23:31:50 +01:00
2020-12-12 00:38:51 +01:00
. button - bar {
font - size : 1.25 em ;
padding : 0.25 em 1.25 em ;
margin - left : 0.25 em ;
}
2020-02-04 23:31:50 +01:00
2020-12-12 00:38:51 +01:00
. button - header {
font - size : 2 em ;
padding - top : 0.1 em ;
padding - left : 1 em ;
padding - right : 1 em ;
}
2020-02-02 00:57:54 +01:00
2020-12-12 00:38:51 +01:00
. jsonbg {
background - color : # 131313 ;
}
. jsonbg - error {
background - color : # 884420 ;
}
2020-02-05 00:39:16 +01:00
2020-12-12 00:38:51 +01:00
. log - config - margin {
margin - top : 3 em ;
margin - bottom : 3 em ;
}
2020-03-11 23:12:29 +01:00
}
2020-01-31 01:03:06 +01:00
< / style >