2019-10-10 15:50:50 +09:00
|
|
|
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
|
2019-10-02 17:12:51 +09:00
|
|
|
import { UserInfo } from '@ucap-webmessenger/protocol-sync';
|
|
|
|
import {
|
|
|
|
UserInfoSS,
|
|
|
|
UserInfoF,
|
|
|
|
UserInfoDN
|
|
|
|
} from '@ucap-webmessenger/protocol-query';
|
|
|
|
import { StatusBulkInfo, StatusInfo } from '@ucap-webmessenger/protocol-status';
|
2019-10-10 15:50:50 +09:00
|
|
|
import { Store, select } from '@ngrx/store';
|
|
|
|
import * as AppStore from '@app/store';
|
|
|
|
import { Subscription } from 'rxjs';
|
|
|
|
import { NGXLogger } from 'ngx-logger';
|
|
|
|
import { tap } from 'rxjs/operators';
|
2019-10-11 11:39:19 +09:00
|
|
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
|
|
|
import { KEY_VER_INFO, VerInfo2 } from '@app/types/ver-info.type';
|
2019-10-14 10:31:28 +09:00
|
|
|
import { StatusCode } from '@ucap-webmessenger/core';
|
2019-10-02 17:12:51 +09:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'ucap-profile-user-list-item',
|
|
|
|
templateUrl: './user-list-item.component.html',
|
|
|
|
styleUrls: ['./user-list-item.component.scss']
|
|
|
|
})
|
2019-10-10 15:50:50 +09:00
|
|
|
export class UserListItemComponent implements OnInit, OnDestroy {
|
2019-10-02 17:12:51 +09:00
|
|
|
@Input()
|
|
|
|
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN;
|
|
|
|
@Input()
|
2019-10-10 15:50:50 +09:00
|
|
|
profileImageRoot?: string;
|
2019-10-02 17:12:51 +09:00
|
|
|
@Input()
|
2019-10-11 18:24:57 +09:00
|
|
|
set presence(value: StatusBulkInfo | StatusInfo) {
|
|
|
|
this.logger.debug('presence', value);
|
|
|
|
this.userPresence = value;
|
|
|
|
}
|
2019-10-02 17:12:51 +09:00
|
|
|
@Input()
|
|
|
|
checkable = false;
|
|
|
|
@Input()
|
|
|
|
compactable = false;
|
|
|
|
|
2019-10-11 18:24:57 +09:00
|
|
|
userPresence: StatusBulkInfo | StatusInfo;
|
|
|
|
|
2019-10-14 10:31:28 +09:00
|
|
|
get PresenceType() {
|
|
|
|
return PresenceType;
|
|
|
|
}
|
|
|
|
|
2019-10-11 11:39:19 +09:00
|
|
|
// private profileImageRootSubscription: Subscription;
|
2019-10-10 15:50:50 +09:00
|
|
|
|
2019-10-11 11:39:19 +09:00
|
|
|
constructor(
|
|
|
|
private store: Store<any>,
|
|
|
|
private logger: NGXLogger,
|
|
|
|
private sessionStorageService: SessionStorageService
|
|
|
|
) {}
|
2019-10-10 15:50:50 +09:00
|
|
|
|
|
|
|
ngOnInit() {
|
2019-10-11 11:39:19 +09:00
|
|
|
// this.profileImageRootSubscription = this.store
|
|
|
|
// .pipe(
|
|
|
|
// select(AppStore.SettingSelector.VersionInfoSelector.profileImageRoot),
|
|
|
|
// tap(profileImageRoot => {
|
|
|
|
// this.profileImageRoot = this.profileImageRoot || profileImageRoot;
|
|
|
|
// })
|
|
|
|
// )
|
|
|
|
// .subscribe();
|
|
|
|
|
|
|
|
const verInfo = this.sessionStorageService.get<VerInfo2>(KEY_VER_INFO);
|
|
|
|
this.profileImageRoot = this.profileImageRoot || verInfo.profileRoot;
|
2019-10-10 15:50:50 +09:00
|
|
|
}
|
2019-10-02 17:12:51 +09:00
|
|
|
|
2019-10-10 15:50:50 +09:00
|
|
|
ngOnDestroy(): void {
|
2019-10-11 11:39:19 +09:00
|
|
|
// if (!!this.profileImageRootSubscription) {
|
|
|
|
// this.profileImageRootSubscription.unsubscribe();
|
|
|
|
// }
|
2019-10-10 15:50:50 +09:00
|
|
|
}
|
2019-10-14 10:31:28 +09:00
|
|
|
|
|
|
|
getPresence(type: string): string {
|
|
|
|
let status: string;
|
|
|
|
let rtnClass = '';
|
|
|
|
switch (type) {
|
|
|
|
case 'pc':
|
|
|
|
status = this.userPresence.pcStatus;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!!status) {
|
|
|
|
switch (status) {
|
|
|
|
case StatusCode.OnLine:
|
|
|
|
rtnClass = type + 'On';
|
|
|
|
break;
|
|
|
|
case StatusCode.Away:
|
|
|
|
rtnClass = type + 'Out';
|
|
|
|
break;
|
|
|
|
case StatusCode.Busy:
|
|
|
|
rtnClass = type + 'Other';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rtnClass = type + 'Off';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rtnClass;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum PresenceType {
|
|
|
|
PC = 'pc',
|
|
|
|
MOBILE = 'mobile',
|
|
|
|
CONFERENCE = 'conference',
|
|
|
|
MOBILE_CONFERENCE = 'mobileConference',
|
|
|
|
PHONE = 'phone',
|
|
|
|
IMESSENER = 'imessenger'
|
2019-10-02 17:12:51 +09:00
|
|
|
}
|