bug fixed

This commit is contained in:
Richard Park 2020-01-08 18:06:05 +09:00
parent d6ca5bc7ce
commit 0ad42ef10d
2 changed files with 51 additions and 10 deletions

View File

@ -32,14 +32,11 @@
[value]="setting.method" [value]="setting.method"
(selectionChange)="onSelectionChangeMethod($event)" (selectionChange)="onSelectionChangeMethod($event)"
> >
<mat-option [value]="NotificationMethod.Sound"> <mat-option
{{ 'settings.notification.methodTypeSound' | translate }} *ngFor="let notificationMethod of notificationMethodList"
</mat-option> [value]="notificationMethod.type"
<mat-option [value]="NotificationMethod.Alert"> >
{{ 'settings.notification.methodTypeAlert' | translate }} {{ notificationMethod.name }}
</mat-option>
<mat-option [value]="NotificationMethod.SoundAndAlert">
{{ 'settings.notification.methodTypeSoundAndAlert' | translate }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>

View File

@ -4,7 +4,8 @@ import {
ChangeDetectorRef, ChangeDetectorRef,
Input, Input,
Output, Output,
EventEmitter EventEmitter,
OnDestroy
} from '@angular/core'; } from '@angular/core';
import { NotificationSetting } from '../models/settings'; import { NotificationSetting } from '../models/settings';
import { import {
@ -14,28 +15,48 @@ import {
} from '@angular/material'; } from '@angular/material';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { NotificationMethod } from '@ucap-webmessenger/core'; import { NotificationMethod } from '@ucap-webmessenger/core';
import { TranslateService } from '@ngx-translate/core';
import { Subscription, merge } from 'rxjs';
@Component({ @Component({
selector: 'ucap-settings-notification', selector: 'ucap-settings-notification',
templateUrl: './notification.component.html', templateUrl: './notification.component.html',
styleUrls: ['./notification.component.scss'] styleUrls: ['./notification.component.scss']
}) })
export class NotificationComponent implements OnInit { export class NotificationComponent implements OnInit, OnDestroy {
@Input() @Input()
setting: NotificationSetting; setting: NotificationSetting;
@Output() @Output()
changed = new EventEmitter<NotificationSetting>(); changed = new EventEmitter<NotificationSetting>();
notificationMethodList: { type: NotificationMethod; name: string }[];
langChangeSubscription: Subscription;
NotificationMethod = NotificationMethod; NotificationMethod = NotificationMethod;
constructor( constructor(
private translateService: TranslateService,
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private logger: NGXLogger private logger: NGXLogger
) {} ) {}
ngOnInit() { ngOnInit() {
this.logger.debug('setting', this.setting); this.logger.debug('setting', this.setting);
this.langChangeSubscription = merge(
this.translateService.onLangChange,
this.translateService.onDefaultLangChange,
this.translateService.onTranslationChange
).subscribe(() => {
this.setNotificationMethodList();
});
}
ngOnDestroy(): void {
if (!!this.langChangeSubscription) {
this.langChangeSubscription.unsubscribe();
}
} }
onChangeUse(event: MatRadioChange) { onChangeUse(event: MatRadioChange) {
@ -62,4 +83,27 @@ export class NotificationComponent implements OnInit {
this.setting = setting; this.setting = setting;
this.changed.emit(this.setting); this.changed.emit(this.setting);
} }
private setNotificationMethodList() {
const langs = this.translateService.instant([
'settings.notification.methodTypeSound',
'settings.notification.methodTypeAlert',
'settings.notification.methodTypeSoundAndAlert'
]);
this.notificationMethodList = [
{
type: NotificationMethod.Sound,
name: langs['settings.notification.methodTypeSound']
},
{
type: NotificationMethod.Alert,
name: langs['settings.notification.methodTypeAlert']
},
{
type: NotificationMethod.SoundAndAlert,
name: langs['settings.notification.methodTypeSoundAndAlert']
}
];
}
} }