From 589d9f55f6f3f0d069d4bbb207d3d20769cc4ded Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Aug 2019 15:46:56 +0200 Subject: Add config instance warning modal --- .../instance-config-warning-modal.component.ts | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'client/src/app/modal/instance-config-warning-modal.component.ts') diff --git a/client/src/app/modal/instance-config-warning-modal.component.ts b/client/src/app/modal/instance-config-warning-modal.component.ts index 5cc9207cd..08d83f383 100644 --- a/client/src/app/modal/instance-config-warning-modal.component.ts +++ b/client/src/app/modal/instance-config-warning-modal.component.ts @@ -1,7 +1,8 @@ import { Component, ElementRef, ViewChild } from '@angular/core' import { Notifier } from '@app/core' -import { I18n } from '@ngx-translate/i18n-polyfill' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' +import { About } from '@shared/models/server' +import { UserService } from '@app/shared' @Component({ selector: 'my-instance-config-warning-modal', @@ -11,13 +12,31 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap' export class InstanceConfigWarningModalComponent { @ViewChild('modal', { static: true }) modal: ElementRef + stopDisplayModal = false + about: About + constructor ( + private userService: UserService, private modalService: NgbModal, - private notifier: Notifier, - private i18n: I18n + private notifier: Notifier ) { } - show () { - this.modalService.open(this.modal) + show (about: About) { + this.about = about + + const ref = this.modalService.open(this.modal) + + ref.result.finally(() => { + if (this.stopDisplayModal === true) this.doNotOpenAgain() + }) + } + + private doNotOpenAgain () { + this.userService.updateMyProfile({ noInstanceConfigWarningModal: true }) + .subscribe( + () => console.log('We will not open the instance config warning modal again.'), + + err => this.notifier.error(err.message) + ) } } -- cgit v1.2.3