50 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-10-11 18:03:01 +09:00
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Info } from '@ucap-webmessenger/protocol-event';
2019-10-11 18:03:01 +09:00
import { NGXLogger } from 'ngx-logger';
import { StatusCode } from '@ucap-webmessenger/api';
import { MassTextInfo } from '../../models/mass-talk-info.json';
2019-10-07 13:49:12 +09:00
@Component({
selector: 'ucap-chat-message-box-mass',
templateUrl: './mass.component.html',
styleUrls: ['./mass.component.scss']
})
export class MassComponent implements OnInit {
@Input()
message: Info;
2019-10-11 18:03:01 +09:00
@Output()
massDetail = new EventEmitter<number>();
2019-10-07 13:49:12 +09:00
2019-10-11 18:03:01 +09:00
content: string;
eventMassSeq: number;
detailButteonShow = true;
constructor(private logger: NGXLogger) {}
ngOnInit() {
try {
const contentJson: MassTextInfo = JSON.parse(this.message.sentMessage);
if (contentJson.StatusCode === StatusCode.Success) {
this.content = contentJson.Content;
} else {
this.content = contentJson.ErrorMessage || '[Error] System Error!!';
this.detailButteonShow = false;
}
if (!!contentJson.EventMassSeq) {
this.eventMassSeq = contentJson.EventMassSeq;
} else {
this.detailButteonShow = false;
}
} catch (e) {
this.logger.error(e);
this.detailButteonShow = false;
}
}
onClickDetailView() {
this.massDetail.emit(this.eventMassSeq);
}
}