Fix logging problems
This commit is contained in:
parent
9c7161c8d9
commit
0e66a015e8
4 changed files with 93 additions and 27 deletions
|
|
@ -50,16 +50,32 @@ export class Logger {
|
||||||
public log(ev: LogEvent) {
|
public log(ev: LogEvent) {
|
||||||
console.log('Logging event');
|
console.log('Logging event');
|
||||||
const uid = store.getState().uid;
|
const uid = store.getState().uid;
|
||||||
|
|
||||||
|
if (uid) {
|
||||||
const logEvKey = this.database.ref(uid).child('logs').push().key;
|
const logEvKey = this.database.ref(uid).child('logs').push().key;
|
||||||
|
|
||||||
this.database.ref(uid).update({ [`logs/${logEvKey}`]: ev });
|
this.database.ref(uid).update({ [`logs/${logEvKey}`]: ev });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public logPersonalData() {}
|
public logPersonalData(name: string, age: number, background: string, experience: string) {
|
||||||
|
const uid = store.getState().uid;
|
||||||
|
|
||||||
public logKnowledgeQuestions() {}
|
this.database.ref(uid).set({
|
||||||
|
name,
|
||||||
|
age,
|
||||||
|
background,
|
||||||
|
experience,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public logGeneralQuestions() {}
|
public logQuestions(answers: string[], isKQ: boolean = false) {
|
||||||
|
const uid = store.getState().uid;
|
||||||
|
|
||||||
|
this.database.ref(uid).set({
|
||||||
|
[`${isKQ ? 'knowledge' : 'general'}Questions`]: answers,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const logger = new Logger();
|
export const logger = new Logger();
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,17 @@ export class Revealable {
|
||||||
if (this.isHovered && !this.wasInteractedWith) {
|
if (this.isHovered && !this.wasInteractedWith) {
|
||||||
this.wasInteractedWith = true;
|
this.wasInteractedWith = true;
|
||||||
|
|
||||||
|
logger.log({
|
||||||
|
type:
|
||||||
|
this.type === RevealableTypes.CONTRIBUTOR
|
||||||
|
? 'NS'
|
||||||
|
: this.type === RevealableTypes.LEGACY
|
||||||
|
? 'LS'
|
||||||
|
: 'PS',
|
||||||
|
timestamp: Date.now(),
|
||||||
|
message: `Showing info message for ${this.name}`,
|
||||||
|
});
|
||||||
|
|
||||||
store.getState().addInfoMessage({
|
store.getState().addInfoMessage({
|
||||||
type: this.type,
|
type: this.type,
|
||||||
headline: this.name,
|
headline: this.name,
|
||||||
|
|
|
||||||
|
|
@ -80,22 +80,16 @@ export class InfoMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private show() {
|
private show() {
|
||||||
logger.log({
|
|
||||||
type:
|
|
||||||
this.type === RevealableTypes.CONTRIBUTOR
|
|
||||||
? 'NS'
|
|
||||||
: this.type === RevealableTypes.LEGACY
|
|
||||||
? 'LS'
|
|
||||||
: 'PS',
|
|
||||||
timestamp: Date.now(),
|
|
||||||
message: `Showing info message for ${this.name}`,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.infoMessage.style.display = 'block';
|
this.infoMessage.style.display = 'block';
|
||||||
this.backdrop.style.display = 'block';
|
this.backdrop.style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
private hide() {
|
private hide() {
|
||||||
|
this.infoMessage.style.display = 'none';
|
||||||
|
this.backdrop.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
private onBackdropClick() {
|
||||||
logger.log({
|
logger.log({
|
||||||
type:
|
type:
|
||||||
this.type === RevealableTypes.CONTRIBUTOR
|
this.type === RevealableTypes.CONTRIBUTOR
|
||||||
|
|
@ -106,16 +100,20 @@ export class InfoMessage {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
message: `Closing info message for ${this.name}`,
|
message: `Closing info message for ${this.name}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.infoMessage.style.display = 'none';
|
|
||||||
this.backdrop.style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
private onBackdropClick() {
|
|
||||||
store.setState({ infoMessageShown: false });
|
store.setState({ infoMessageShown: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
private onCloseClick() {
|
private onCloseClick() {
|
||||||
|
logger.log({
|
||||||
|
type:
|
||||||
|
this.type === RevealableTypes.CONTRIBUTOR
|
||||||
|
? 'NC'
|
||||||
|
: this.type === RevealableTypes.LEGACY
|
||||||
|
? 'LC'
|
||||||
|
: 'PC',
|
||||||
|
timestamp: Date.now(),
|
||||||
|
message: `Closing info message for ${this.name}`,
|
||||||
|
});
|
||||||
store.setState({ infoMessageShown: false });
|
store.setState({ infoMessageShown: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,17 @@ export class Intro {
|
||||||
backgroundRef: HTMLInputElement;
|
backgroundRef: HTMLInputElement;
|
||||||
experienceRef: HTMLSelectElement;
|
experienceRef: HTMLSelectElement;
|
||||||
|
|
||||||
|
fb1: HTMLTextAreaElement;
|
||||||
|
fb2: HTMLTextAreaElement;
|
||||||
|
fb3: HTMLTextAreaElement;
|
||||||
|
fb4: HTMLTextAreaElement;
|
||||||
|
fb5: HTMLTextAreaElement;
|
||||||
|
fb6: HTMLTextAreaElement;
|
||||||
|
fb7: HTMLTextAreaElement;
|
||||||
|
fb8: HTMLTextAreaElement;
|
||||||
|
fb9: HTMLTextAreaElement;
|
||||||
|
fb10: HTMLTextAreaElement;
|
||||||
|
|
||||||
errorRef: HTMLElement;
|
errorRef: HTMLElement;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -43,6 +54,17 @@ export class Intro {
|
||||||
this.backgroundRef = document.querySelector('#intro-background');
|
this.backgroundRef = document.querySelector('#intro-background');
|
||||||
this.experienceRef = document.querySelector('#intro-experience');
|
this.experienceRef = document.querySelector('#intro-experience');
|
||||||
|
|
||||||
|
this.fb1 = document.querySelector('#fb1');
|
||||||
|
this.fb2 = document.querySelector('#fb2');
|
||||||
|
this.fb3 = document.querySelector('#fb3');
|
||||||
|
this.fb4 = document.querySelector('#fb4');
|
||||||
|
this.fb5 = document.querySelector('#fb5');
|
||||||
|
this.fb6 = document.querySelector('#fb6');
|
||||||
|
this.fb7 = document.querySelector('#fb7');
|
||||||
|
this.fb8 = document.querySelector('#fb8');
|
||||||
|
this.fb9 = document.querySelector('#fb9');
|
||||||
|
this.fb10 = document.querySelector('#fb10');
|
||||||
|
|
||||||
this.errorRef = document.querySelector('#intro-error');
|
this.errorRef = document.querySelector('#intro-error');
|
||||||
|
|
||||||
this.nextButton.addEventListener('click', () => this.onNextClick());
|
this.nextButton.addEventListener('click', () => this.onNextClick());
|
||||||
|
|
@ -132,17 +154,36 @@ export class Intro {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentStep === 6) {
|
||||||
|
this.sendGeneralQuestionAnswers();
|
||||||
|
}
|
||||||
|
|
||||||
store.setState((state) => ({ currentIntroStep: state.currentIntroStep + 1 }));
|
store.setState((state) => ({ currentIntroStep: state.currentIntroStep + 1 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
private sendConsent() {}
|
|
||||||
|
|
||||||
private sendDemographicData(name: string, age: number, background: string, experience: string) {
|
private sendDemographicData(name: string, age: number, background: string, experience: string) {
|
||||||
console.log(name, age, background, experience);
|
logger.logPersonalData(name, age, background, experience);
|
||||||
|
|
||||||
// TODO: Log
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private sendGeneralQuestionAnswers() {
|
||||||
|
const answers = [
|
||||||
|
this.fb1.value,
|
||||||
|
this.fb2.value,
|
||||||
|
this.fb3.value,
|
||||||
|
this.fb4.value,
|
||||||
|
this.fb5.value,
|
||||||
|
this.fb6.value,
|
||||||
|
this.fb7.value,
|
||||||
|
this.fb8.value,
|
||||||
|
this.fb9.value,
|
||||||
|
this.fb10.value,
|
||||||
|
];
|
||||||
|
|
||||||
|
console.log(answers);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sendKnowledgeQuestionAnswers() {}
|
||||||
|
|
||||||
private hideNameInput() {}
|
private hideNameInput() {}
|
||||||
|
|
||||||
private showStep() {
|
private showStep() {
|
||||||
|
|
|
||||||
Reference in a new issue