diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-23 14:10:17 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-23 16:00:49 +0200 |
commit | 67ed6552b831df66713bac9e672738796128d33f (patch) | |
tree | 59c97d41e0b49d75a90aa3de987968ab9b1ff447 /client/src/app/modal | |
parent | 0c4bacbff53bc732f5a2677d62a6ead7752e2405 (diff) | |
download | PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.gz PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.zst PeerTube-67ed6552b831df66713bac9e672738796128d33f.zip |
Reorganize client shared modules
Diffstat (limited to 'client/src/app/modal')
-rw-r--r-- | client/src/app/modal/confirm.component.html | 30 | ||||
-rw-r--r-- | client/src/app/modal/confirm.component.scss | 21 | ||||
-rw-r--r-- | client/src/app/modal/confirm.component.ts | 73 | ||||
-rw-r--r-- | client/src/app/modal/instance-config-warning-modal.component.ts | 3 | ||||
-rw-r--r-- | client/src/app/modal/quick-settings-modal.component.html | 8 | ||||
-rw-r--r-- | client/src/app/modal/quick-settings-modal.component.ts | 11 | ||||
-rw-r--r-- | client/src/app/modal/welcome-modal.component.ts | 3 |
7 files changed, 135 insertions, 14 deletions
diff --git a/client/src/app/modal/confirm.component.html b/client/src/app/modal/confirm.component.html new file mode 100644 index 000000000..dbc8c23e3 --- /dev/null +++ b/client/src/app/modal/confirm.component.html | |||
@@ -0,0 +1,30 @@ | |||
1 | <ng-template #confirmModal let-close="close" let-dismiss="dismiss"> | ||
2 | |||
3 | <div class="modal-header"> | ||
4 | <h4 class="modal-title">{{ title }}</h4> | ||
5 | |||
6 | <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="dismiss()"></my-global-icon> | ||
7 | </div> | ||
8 | |||
9 | <div class="modal-body" > | ||
10 | <div [innerHtml]="message"></div> | ||
11 | |||
12 | <div *ngIf="inputLabel && expectedInputValue" class="form-group"> | ||
13 | <label for="confirmInput">{{ inputLabel }}</label> | ||
14 | <input type="text" id="confirmInput" name="confirmInput" [(ngModel)]="inputValue" /> | ||
15 | </div> | ||
16 | </div> | ||
17 | |||
18 | <div class="modal-footer inputs"> | ||
19 | <input | ||
20 | type="button" role="button" i18n-value value="Cancel" class="action-button action-button-cancel" | ||
21 | (click)="dismiss()" (key.enter)="dismiss()" | ||
22 | > | ||
23 | |||
24 | <input | ||
25 | ngbAutofocus | ||
26 | type="submit" [value]="confirmButtonText" class="action-button-submit" [disabled]="isConfirmationDisabled()" | ||
27 | (click)="close()" (key.enter)="confirm()" | ||
28 | > | ||
29 | </div> | ||
30 | </ng-template> | ||
diff --git a/client/src/app/modal/confirm.component.scss b/client/src/app/modal/confirm.component.scss new file mode 100644 index 000000000..ed226bc09 --- /dev/null +++ b/client/src/app/modal/confirm.component.scss | |||
@@ -0,0 +1,21 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .modal-body { | ||
5 | font-size: 15px; | ||
6 | } | ||
7 | |||
8 | .button { | ||
9 | padding: 0 13px; | ||
10 | } | ||
11 | |||
12 | input[type=text] { | ||
13 | @include peertube-input-text(100%); | ||
14 | display: block; | ||
15 | } | ||
16 | |||
17 | .form-group { | ||
18 | margin: 20px 0; | ||
19 | } | ||
20 | |||
21 | |||
diff --git a/client/src/app/modal/confirm.component.ts b/client/src/app/modal/confirm.component.ts new file mode 100644 index 000000000..2c7ef46c4 --- /dev/null +++ b/client/src/app/modal/confirm.component.ts | |||
@@ -0,0 +1,73 @@ | |||
1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' | ||
2 | import { ConfirmService } from '@app/core/confirm/confirm.service' | ||
3 | import { POP_STATE_MODAL_DISMISS } from '@app/helpers' | ||
4 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | ||
5 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | ||
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-confirm', | ||
10 | templateUrl: './confirm.component.html', | ||
11 | styleUrls: [ './confirm.component.scss' ] | ||
12 | }) | ||
13 | export class ConfirmComponent implements OnInit { | ||
14 | @ViewChild('confirmModal', { static: true }) confirmModal: ElementRef | ||
15 | |||
16 | title = '' | ||
17 | message = '' | ||
18 | expectedInputValue = '' | ||
19 | inputLabel = '' | ||
20 | |||
21 | inputValue = '' | ||
22 | confirmButtonText = '' | ||
23 | |||
24 | private openedModal: NgbModalRef | ||
25 | |||
26 | constructor ( | ||
27 | private modalService: NgbModal, | ||
28 | private confirmService: ConfirmService, | ||
29 | private i18n: I18n | ||
30 | ) { } | ||
31 | |||
32 | ngOnInit () { | ||
33 | this.confirmService.showConfirm.subscribe( | ||
34 | ({ title, message, expectedInputValue, inputLabel, confirmButtonText }) => { | ||
35 | this.title = title | ||
36 | this.message = message | ||
37 | |||
38 | this.inputLabel = inputLabel | ||
39 | this.expectedInputValue = expectedInputValue | ||
40 | |||
41 | this.confirmButtonText = confirmButtonText || this.i18n('Confirm') | ||
42 | |||
43 | this.showModal() | ||
44 | } | ||
45 | ) | ||
46 | } | ||
47 | |||
48 | confirm () { | ||
49 | if (this.openedModal) this.openedModal.close() | ||
50 | } | ||
51 | |||
52 | isConfirmationDisabled () { | ||
53 | // No input validation | ||
54 | if (!this.inputLabel || !this.expectedInputValue) return false | ||
55 | |||
56 | return this.expectedInputValue !== this.inputValue | ||
57 | } | ||
58 | |||
59 | showModal () { | ||
60 | this.inputValue = '' | ||
61 | |||
62 | this.openedModal = this.modalService.open(this.confirmModal, { centered: true }) | ||
63 | |||
64 | this.openedModal.result | ||
65 | .then(() => this.confirmService.confirmResponse.next(true)) | ||
66 | .catch((reason: string) => { | ||
67 | // If the reason was that the user used the back button, we don't care about the confirm dialog result | ||
68 | if (!reason || reason !== POP_STATE_MODAL_DISMISS) { | ||
69 | this.confirmService.confirmResponse.next(false) | ||
70 | } | ||
71 | }) | ||
72 | } | ||
73 | } | ||
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 5e1433548..1c90f190a 100644 --- a/client/src/app/modal/instance-config-warning-modal.component.ts +++ b/client/src/app/modal/instance-config-warning-modal.component.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { Component, ElementRef, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, ViewChild } from '@angular/core' |
2 | import { Notifier } from '@app/core' | 2 | import { Notifier, UserService } from '@app/core' |
3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
4 | import { About } from '@shared/models/server' | 4 | import { About } from '@shared/models/server' |
5 | import { UserService } from '@app/shared' | ||
6 | 5 | ||
7 | @Component({ | 6 | @Component({ |
8 | selector: 'my-instance-config-warning-modal', | 7 | selector: 'my-instance-config-warning-modal', |
diff --git a/client/src/app/modal/quick-settings-modal.component.html b/client/src/app/modal/quick-settings-modal.component.html index 188a51173..b95c14309 100644 --- a/client/src/app/modal/quick-settings-modal.component.html +++ b/client/src/app/modal/quick-settings-modal.component.html | |||
@@ -7,7 +7,7 @@ | |||
7 | <div class="modal-body"> | 7 | <div class="modal-body"> |
8 | <div i18n class="mb-4 quick-settings-title">Display settings</div> | 8 | <div i18n class="mb-4 quick-settings-title">Display settings</div> |
9 | 9 | ||
10 | <my-account-video-settings | 10 | <my-user-video-settings |
11 | *ngIf="!isUserLoggedIn()" | 11 | *ngIf="!isUserLoggedIn()" |
12 | [user]="user" [userInformationLoaded]="userInformationLoaded" [reactiveUpdate]="true" [notifyOnUpdate]="true" | 12 | [user]="user" [userInformationLoaded]="userInformationLoaded" [reactiveUpdate]="true" [notifyOnUpdate]="true" |
13 | > | 13 | > |
@@ -15,13 +15,13 @@ | |||
15 | <ng-container ngProjectAs="inner-title"> | 15 | <ng-container ngProjectAs="inner-title"> |
16 | <div i18n class="mb-4 mt-4 quick-settings-title">Video settings</div> | 16 | <div i18n class="mb-4 mt-4 quick-settings-title">Video settings</div> |
17 | </ng-container> | 17 | </ng-container> |
18 | </my-account-video-settings> | 18 | </my-user-video-settings> |
19 | 19 | ||
20 | <div i18n class="mb-4 mt-4 quick-settings-title">Interface settings</div> | 20 | <div i18n class="mb-4 mt-4 quick-settings-title">Interface settings</div> |
21 | 21 | ||
22 | <my-account-interface-settings | 22 | <my-user-interface-settings |
23 | *ngIf="!isUserLoggedIn()" | 23 | *ngIf="!isUserLoggedIn()" |
24 | [user]="user" [userInformationLoaded]="userInformationLoaded" [reactiveUpdate]="true" [notifyOnUpdate]="true" | 24 | [user]="user" [userInformationLoaded]="userInformationLoaded" [reactiveUpdate]="true" [notifyOnUpdate]="true" |
25 | ></my-account-interface-settings> | 25 | ></my-user-interface-settings> |
26 | </div> | 26 | </div> |
27 | </ng-template> | 27 | </ng-template> |
diff --git a/client/src/app/modal/quick-settings-modal.component.ts b/client/src/app/modal/quick-settings-modal.component.ts index 155794d1b..95726ab63 100644 --- a/client/src/app/modal/quick-settings-modal.component.ts +++ b/client/src/app/modal/quick-settings-modal.component.ts | |||
@@ -1,11 +1,10 @@ | |||
1 | import { Component, ViewChild, OnInit } from '@angular/core' | ||
2 | import { AuthService, AuthStatus } from '@app/core' | ||
3 | import { FormReactive, FormValidatorService, UserService, User } from '@app/shared' | ||
4 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | ||
5 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | ||
6 | import { ReplaySubject } from 'rxjs' | 1 | import { ReplaySubject } from 'rxjs' |
7 | import { LocalStorageService } from '@app/shared/misc/storage.service' | ||
8 | import { filter } from 'rxjs/operators' | 2 | import { filter } from 'rxjs/operators' |
3 | import { Component, OnInit, ViewChild } from '@angular/core' | ||
4 | import { AuthService, AuthStatus, LocalStorageService, User, UserService } from '@app/core' | ||
5 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | ||
6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | ||
7 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | ||
9 | 8 | ||
10 | @Component({ | 9 | @Component({ |
11 | selector: 'my-quick-settings', | 10 | selector: 'my-quick-settings', |
diff --git a/client/src/app/modal/welcome-modal.component.ts b/client/src/app/modal/welcome-modal.component.ts index e022776e3..c2f289600 100644 --- a/client/src/app/modal/welcome-modal.component.ts +++ b/client/src/app/modal/welcome-modal.component.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { Component, ElementRef, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, ViewChild } from '@angular/core' |
2 | import { Notifier } from '@app/core' | 2 | import { Notifier, UserService } from '@app/core' |
3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
4 | import { UserService } from '@app/shared' | ||
5 | 4 | ||
6 | @Component({ | 5 | @Component({ |
7 | selector: 'my-welcome-modal', | 6 | selector: 'my-welcome-modal', |