1 import {Injectable} from '@angular/core';
13 success: Boolean = false;
16 let s = `Event: ${this.code}:${this.textcode} -> ${this.desc}`;
18 s += ` ${this.ilsperm}@${this.ilspermloc}`;
21 s += `\n${this.note}`;
27 @Injectable({providedIn: 'root'})
28 export class EventService {
31 * Returns an Event if 'thing' is an event, null otherwise.
33 parse(thing: any): EgEvent {
35 // All events have a textcode
36 if (thing && typeof thing === 'object' && 'textcode' in thing) {
38 const evt = new EgEvent();
40 ['textcode', 'payload', 'desc', 'note', 'servertime', 'ilsperm']
41 .forEach(field => { evt[field] = thing[field]; });
43 evt.debug = thing.stacktrace;
44 evt.code = +(thing.ilsevent || -1);
45 evt.ilspermloc = +(thing.ilspermloc || -1);
46 evt.success = thing.textcode === 'SUCCESS';