aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-16 16:05:40 +0100
committerChocobozzz <me@florianbigard.com>2019-01-17 10:38:18 +0100
commit457bb213b273a9b206cc5654eb085cede4e916ad (patch)
tree6b1a317872a4ca27b5d0dbe543452320b26aacff /client/src/app/core
parent848f499def54db2dd36437ef0dfb74dd5041c23b (diff)
downloadPeerTube-457bb213b273a9b206cc5654eb085cede4e916ad.tar.gz
PeerTube-457bb213b273a9b206cc5654eb085cede4e916ad.tar.zst
PeerTube-457bb213b273a9b206cc5654eb085cede4e916ad.zip
Refactor how we use icons
Inject them in an angular component so we can easily change their color
Diffstat (limited to 'client/src/app/core')
-rw-r--r--client/src/app/core/confirm/confirm.component.html25
-rw-r--r--client/src/app/core/confirm/confirm.component.scss17
-rw-r--r--client/src/app/core/confirm/confirm.component.ts68
-rw-r--r--client/src/app/core/confirm/index.ts1
-rw-r--r--client/src/app/core/core.module.ts4
5 files changed, 1 insertions, 114 deletions
diff --git a/client/src/app/core/confirm/confirm.component.html b/client/src/app/core/confirm/confirm.component.html
deleted file mode 100644
index 43f0c6190..000000000
--- a/client/src/app/core/confirm/confirm.component.html
+++ /dev/null
@@ -1,25 +0,0 @@
1<ng-template #confirmModal let-close="close" let-dismiss="dismiss">
2
3 <div class="modal-header">
4 <h4 class="modal-title">{{ title }}</h4>
5 <span class="close" aria-label="Close" role="button" (click)="dismiss()"></span>
6 </div>
7
8 <div class="modal-body" >
9 <div [innerHtml]="message"></div>
10
11 <div *ngIf="inputLabel && expectedInputValue" class="form-group">
12 <label for="confirmInput">{{ inputLabel }}</label>
13 <input type="text" id="confirmInput" name="confirmInput" [(ngModel)]="inputValue" />
14 </div>
15 </div>
16
17 <div class="modal-footer inputs">
18 <span i18n class="action-button action-button-cancel" (click)="dismiss()" role="button">Cancel</span>
19
20 <input
21 type="submit" [value]="confirmButtonText" class="action-button-submit" [disabled]="isConfirmationDisabled()"
22 (click)="close()"
23 >
24 </div>
25</ng-template>
diff --git a/client/src/app/core/confirm/confirm.component.scss b/client/src/app/core/confirm/confirm.component.scss
deleted file mode 100644
index 93dd7926b..000000000
--- a/client/src/app/core/confirm/confirm.component.scss
+++ /dev/null
@@ -1,17 +0,0 @@
1@import '_variables';
2@import '_mixins';
3
4.button {
5 padding: 0 13px;
6}
7
8input[type=text] {
9 @include peertube-input-text(100%);
10 display: block;
11}
12
13.form-group {
14 margin: 20px 0;
15}
16
17
diff --git a/client/src/app/core/confirm/confirm.component.ts b/client/src/app/core/confirm/confirm.component.ts
deleted file mode 100644
index 5138b7848..000000000
--- a/client/src/app/core/confirm/confirm.component.ts
+++ /dev/null
@@ -1,68 +0,0 @@
1import { Component, ElementRef, HostListener, OnInit, ViewChild } from '@angular/core'
2import { ConfirmService } from './confirm.service'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
5import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
6
7@Component({
8 selector: 'my-confirm',
9 templateUrl: './confirm.component.html',
10 styleUrls: [ './confirm.component.scss' ]
11})
12export class ConfirmComponent implements OnInit {
13 @ViewChild('confirmModal') confirmModal: ElementRef
14
15 title = ''
16 message = ''
17 expectedInputValue = ''
18 inputLabel = ''
19
20 inputValue = ''
21 confirmButtonText = ''
22
23 private openedModal: NgbModalRef
24
25 constructor (
26 private modalService: NgbModal,
27 private confirmService: ConfirmService,
28 private i18n: I18n
29 ) { }
30
31 ngOnInit () {
32 this.confirmService.showConfirm.subscribe(
33 ({ title, message, expectedInputValue, inputLabel, confirmButtonText }) => {
34 this.title = title
35 this.message = message
36
37 this.inputLabel = inputLabel
38 this.expectedInputValue = expectedInputValue
39
40 this.confirmButtonText = confirmButtonText || this.i18n('Confirm')
41
42 this.showModal()
43 }
44 )
45 }
46
47 @HostListener('document:keydown.enter')
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)
63
64 this.openedModal.result
65 .then(() => this.confirmService.confirmResponse.next(true))
66 .catch(() => this.confirmService.confirmResponse.next(false))
67 }
68}
diff --git a/client/src/app/core/confirm/index.ts b/client/src/app/core/confirm/index.ts
index 44aabfc13..aca591e1a 100644
--- a/client/src/app/core/confirm/index.ts
+++ b/client/src/app/core/confirm/index.ts
@@ -1,2 +1 @@
1export * from './confirm.component'
2export * from './confirm.service' export * from './confirm.service'
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts
index 3bc0e2885..4ef3b1e73 100644
--- a/client/src/app/core/core.module.ts
+++ b/client/src/app/core/core.module.ts
@@ -8,7 +8,7 @@ import { LoadingBarHttpClientModule } from '@ngx-loading-bar/http-client'
8import { LoadingBarRouterModule } from '@ngx-loading-bar/router' 8import { LoadingBarRouterModule } from '@ngx-loading-bar/router'
9 9
10import { AuthService } from './auth' 10import { AuthService } from './auth'
11import { ConfirmComponent, ConfirmService } from './confirm' 11import { ConfirmService } from './confirm'
12import { throwIfAlreadyLoaded } from './module-import-guard' 12import { throwIfAlreadyLoaded } from './module-import-guard'
13import { LoginGuard, RedirectService, UserRightGuard } from './routing' 13import { LoginGuard, RedirectService, UserRightGuard } from './routing'
14import { ServerService } from './server' 14import { ServerService } from './server'
@@ -38,7 +38,6 @@ import { UserNotificationSocket } from '@app/core/notification/user-notification
38 ], 38 ],
39 39
40 declarations: [ 40 declarations: [
41 ConfirmComponent,
42 CheatSheetComponent 41 CheatSheetComponent
43 ], 42 ],
44 43
@@ -48,7 +47,6 @@ import { UserNotificationSocket } from '@app/core/notification/user-notification
48 47
49 ToastModule, 48 ToastModule,
50 49
51 ConfirmComponent,
52 CheatSheetComponent 50 CheatSheetComponent
53 ], 51 ],
54 52