110 lines
2.8 KiB
TypeScript
Raw Normal View History

2019-10-15 11:07:26 +09:00
import {
Component,
OnInit,
Input,
OnDestroy,
Output,
EventEmitter
} 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';
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';
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { StatusCode } from '@ucap-webmessenger/core';
2019-10-02 17:12:51 +09:00
2019-10-15 13:54:58 +09:00
import { PresenceType } from '../types/presence-type.type';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
2019-10-15 13:54:58 +09:00
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']
})
export class UserListItemComponent implements OnInit, OnDestroy {
2019-10-02 17:12:51 +09:00
@Input()
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN;
@Input()
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;
@Input()
sessionVerinfo: VersionInfo2Response;
2019-10-02 17:12:51 +09:00
2019-10-11 18:24:57 +09:00
userPresence: StatusBulkInfo | StatusInfo;
2019-10-14 13:53:44 +09:00
PresenceType = PresenceType;
// private profileImageRootSubscription: Subscription;
constructor(
private store: Store<any>,
private logger: NGXLogger,
private sessionStorageService: SessionStorageService
) {}
ngOnInit() {
// this.profileImageRootSubscription = this.store
// .pipe(
// select(AppStore.SettingSelector.VersionInfoSelector.profileImageRoot),
// tap(profileImageRoot => {
// this.profileImageRoot = this.profileImageRoot || profileImageRoot;
// })
// )
// .subscribe();
this.profileImageRoot =
this.profileImageRoot || this.sessionVerinfo.profileRoot;
}
2019-10-02 17:12:51 +09:00
ngOnDestroy(): void {
// if (!!this.profileImageRootSubscription) {
// this.profileImageRootSubscription.unsubscribe();
// }
}
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;
}
}