aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-04 15:58:55 +0100
committerRigel Kent <sendmemail@rigelk.eu>2020-12-04 16:01:53 +0100
commitf8b530e0a523a0d9ff469ef716838374c395a360 (patch)
treea55d49365e539582dd5000a2c73b9351df93a52d /client/src/app/shared
parentaa5ee5017a83b280352f8dbcfed2d4741709a4fd (diff)
downloadPeerTube-f8b530e0a523a0d9ff469ef716838374c395a360.tar.gz
PeerTube-f8b530e0a523a0d9ff469ef716838374c395a360.tar.zst
PeerTube-f8b530e0a523a0d9ff469ef716838374c395a360.zip
unify inputs requiring buttons like password inputs
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/form-validators/user-validators.ts9
-rw-r--r--client/src/app/shared/shared-forms/dynamic-form-field.component.html2
-rw-r--r--client/src/app/shared/shared-forms/index.ts2
-rw-r--r--client/src/app/shared/shared-forms/input-readonly-copy.component.html9
-rw-r--r--client/src/app/shared/shared-forms/input-readonly-copy.component.scss3
-rw-r--r--client/src/app/shared/shared-forms/input-readonly-copy.component.ts18
-rw-r--r--client/src/app/shared/shared-forms/input-toggle-hidden.component.html13
-rw-r--r--client/src/app/shared/shared-forms/input-toggle-hidden.component.scss11
-rw-r--r--client/src/app/shared/shared-forms/input-toggle-hidden.component.ts66
-rw-r--r--client/src/app/shared/shared-forms/shared-form.module.ts6
-rw-r--r--client/src/app/shared/shared-share-modal/video-share.component.html8
-rw-r--r--client/src/app/shared/shared-share-modal/video-share.component.scss2
-rw-r--r--client/src/app/shared/shared-video-live/live-stream-information.component.html4
13 files changed, 111 insertions, 42 deletions
diff --git a/client/src/app/shared/form-validators/user-validators.ts b/client/src/app/shared/form-validators/user-validators.ts
index 9efc5180d..115930146 100644
--- a/client/src/app/shared/form-validators/user-validators.ts
+++ b/client/src/app/shared/form-validators/user-validators.ts
@@ -39,6 +39,15 @@ export const USER_EMAIL_VALIDATOR: BuildFormValidator = {
39 } 39 }
40} 40}
41 41
42export const USER_EXISTING_PASSWORD_VALIDATOR: BuildFormValidator = {
43 VALIDATORS: [
44 Validators.required
45 ],
46 MESSAGES: {
47 'required': $localize`Password is required.`
48 }
49}
50
42export const USER_PASSWORD_VALIDATOR: BuildFormValidator = { 51export const USER_PASSWORD_VALIDATOR: BuildFormValidator = {
43 VALIDATORS: [ 52 VALIDATORS: [
44 Validators.required, 53 Validators.required,
diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.html b/client/src/app/shared/shared-forms/dynamic-form-field.component.html
index 6a3c31637..658d8ce5b 100644
--- a/client/src/app/shared/shared-forms/dynamic-form-field.component.html
+++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.html
@@ -5,7 +5,7 @@
5 5
6 <input *ngIf="setting.type === 'input'" type="text" [id]="setting.name" [formControlName]="setting.name" /> 6 <input *ngIf="setting.type === 'input'" type="text" [id]="setting.name" [formControlName]="setting.name" />
7 7
8 <input *ngIf="setting.type === 'input-password'" type="password" [id]="setting.name" [formControlName]="setting.name" /> 8 <my-input-toggle-hidden *ngIf="setting.type === 'input-password'" [formControlName]="setting.name" [id]="setting.name"></my-input-toggle-hidden>
9 9
10 <textarea *ngIf="setting.type === 'input-textarea'" type="text" [id]="setting.name" [formControlName]="setting.name"></textarea> 10 <textarea *ngIf="setting.type === 'input-textarea'" type="text" [id]="setting.name" [formControlName]="setting.name"></textarea>
11 11
diff --git a/client/src/app/shared/shared-forms/index.ts b/client/src/app/shared/shared-forms/index.ts
index 66b426191..1d859b991 100644
--- a/client/src/app/shared/shared-forms/index.ts
+++ b/client/src/app/shared/shared-forms/index.ts
@@ -1,7 +1,7 @@
1export * from './form-validator.service' 1export * from './form-validator.service'
2export * from './form-reactive' 2export * from './form-reactive'
3export * from './select' 3export * from './select'
4export * from './input-readonly-copy.component' 4export * from './input-toggle-hidden.component'
5export * from './input-switch.component' 5export * from './input-switch.component'
6export * from './markdown-textarea.component' 6export * from './markdown-textarea.component'
7export * from './peertube-checkbox.component' 7export * from './peertube-checkbox.component'
diff --git a/client/src/app/shared/shared-forms/input-readonly-copy.component.html b/client/src/app/shared/shared-forms/input-readonly-copy.component.html
deleted file mode 100644
index 7a75bd70b..000000000
--- a/client/src/app/shared/shared-forms/input-readonly-copy.component.html
+++ /dev/null
@@ -1,9 +0,0 @@
1<div class="input-group input-group-sm">
2 <input [id]="id" #urlInput (click)="urlInput.select()" type="text" class="form-control readonly" readonly [value]="value" />
3
4 <div class="input-group-append">
5 <button [cdkCopyToClipboard]="urlInput.value" (click)="activateCopiedMessage()" type="button" class="btn btn-outline-secondary">
6 <span class="glyphicon glyphicon-copy"></span>
7 </button>
8 </div>
9</div>
diff --git a/client/src/app/shared/shared-forms/input-readonly-copy.component.scss b/client/src/app/shared/shared-forms/input-readonly-copy.component.scss
deleted file mode 100644
index 8dc4f113c..000000000
--- a/client/src/app/shared/shared-forms/input-readonly-copy.component.scss
+++ /dev/null
@@ -1,3 +0,0 @@
1input.readonly {
2 font-size: 15px;
3}
diff --git a/client/src/app/shared/shared-forms/input-readonly-copy.component.ts b/client/src/app/shared/shared-forms/input-readonly-copy.component.ts
deleted file mode 100644
index b04d69d05..000000000
--- a/client/src/app/shared/shared-forms/input-readonly-copy.component.ts
+++ /dev/null
@@ -1,18 +0,0 @@
1import { Component, Input } from '@angular/core'
2import { Notifier } from '@app/core'
3
4@Component({
5 selector: 'my-input-readonly-copy',
6 templateUrl: './input-readonly-copy.component.html',
7 styleUrls: [ './input-readonly-copy.component.scss' ]
8})
9export class InputReadonlyCopyComponent {
10 @Input() id: string
11 @Input() value = ''
12
13 constructor (private notifier: Notifier) { }
14
15 activateCopiedMessage () {
16 this.notifier.success($localize`Copied`)
17 }
18}
diff --git a/client/src/app/shared/shared-forms/input-toggle-hidden.component.html b/client/src/app/shared/shared-forms/input-toggle-hidden.component.html
new file mode 100644
index 000000000..f59dc6215
--- /dev/null
+++ b/client/src/app/shared/shared-forms/input-toggle-hidden.component.html
@@ -0,0 +1,13 @@
1<div class="input-group input-group-sm">
2 <input [id]="id" [autocomplete]="autocomplete" [value]="value" [placeholder]="placeholder" [(ngModel)]="value" (ngModelChange)="update()" [ngClass]="{ 'readonly': readonly }" [readonly]="readonly"
3 #input (click)="input.select()" (input)="update()" (change)="update()" [type]="inputType" class="form-control" />
4
5 <div *ngIf="withToggle || withCopy" class="input-group-append">
6 <button *ngIf="withToggle" (click)="toggle()" type="button" class="btn btn-outline-secondary" [title]="toggleTitle">
7 <span class="glyphicon glyphicon-eye-{{ show ? 'open' : 'close' }}"></span>
8 </button>
9 <button *ngIf="withCopy" [cdkCopyToClipboard]="input.value" (click)="activateCopiedMessage()" type="button" class="btn btn-outline-secondary" i18n-title title="Copy">
10 <span class="glyphicon glyphicon-copy"></span>
11 </button>
12 </div>
13</div>
diff --git a/client/src/app/shared/shared-forms/input-toggle-hidden.component.scss b/client/src/app/shared/shared-forms/input-toggle-hidden.component.scss
new file mode 100644
index 000000000..e20f69b86
--- /dev/null
+++ b/client/src/app/shared/shared-forms/input-toggle-hidden.component.scss
@@ -0,0 +1,11 @@
1@import '_variables';
2@import '_mixins';
3
4input {
5 @include peertube-input-text(auto);
6
7 // set again properties of peertube-input-text that are overriden by .input-group
8 font-size: 15px !important;
9 padding-left: 15px !important;
10 padding-right: 15px !important;
11}
diff --git a/client/src/app/shared/shared-forms/input-toggle-hidden.component.ts b/client/src/app/shared/shared-forms/input-toggle-hidden.component.ts
new file mode 100644
index 000000000..0e974426b
--- /dev/null
+++ b/client/src/app/shared/shared-forms/input-toggle-hidden.component.ts
@@ -0,0 +1,66 @@
1import { Component, forwardRef, Input } from '@angular/core'
2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3import { Notifier } from '@app/core'
4
5@Component({
6 selector: 'my-input-toggle-hidden',
7 templateUrl: './input-toggle-hidden.component.html',
8 styleUrls: [ './input-toggle-hidden.component.scss' ],
9 providers: [
10 {
11 provide: NG_VALUE_ACCESSOR,
12 useExisting: forwardRef(() => InputToggleHiddenComponent),
13 multi: true
14 }
15 ]
16})
17export class InputToggleHiddenComponent implements ControlValueAccessor {
18 @Input() id = Math.random().toString(11).slice(2, 8) // id cannot be left empty or undefined
19 @Input() value = ''
20 @Input() autocomplete = 'off'
21 @Input() placeholder = ''
22 @Input() withToggle = true
23 @Input() withCopy = false
24 @Input() readonly = false
25 @Input() show = false
26
27 constructor (private notifier: Notifier) { }
28
29 get inputType () {
30 return this.show
31 ? 'text'
32 : 'password'
33 }
34
35 get toggleTitle () {
36 return this.show
37 ? $localize`Hide`
38 : $localize`Show`
39 }
40
41 toggle () {
42 this.show = !this.show
43 }
44
45 activateCopiedMessage () {
46 this.notifier.success($localize`Copied`)
47 }
48
49 propagateChange = (_: any) => { /* empty */ }
50
51 writeValue (value: string) {
52 this.value = value
53 }
54
55 registerOnChange (fn: (_: any) => void) {
56 this.propagateChange = fn
57 }
58
59 registerOnTouched () {
60 // Unused
61 }
62
63 update () {
64 this.propagateChange(this.value)
65 }
66}
diff --git a/client/src/app/shared/shared-forms/shared-form.module.ts b/client/src/app/shared/shared-forms/shared-form.module.ts
index 060abc995..22e8dd05a 100644
--- a/client/src/app/shared/shared-forms/shared-form.module.ts
+++ b/client/src/app/shared/shared-forms/shared-form.module.ts
@@ -7,7 +7,7 @@ import { SharedGlobalIconModule } from '../shared-icons'
7import { SharedMainModule } from '../shared-main/shared-main.module' 7import { SharedMainModule } from '../shared-main/shared-main.module'
8import { DynamicFormFieldComponent } from './dynamic-form-field.component' 8import { DynamicFormFieldComponent } from './dynamic-form-field.component'
9import { FormValidatorService } from './form-validator.service' 9import { FormValidatorService } from './form-validator.service'
10import { InputReadonlyCopyComponent } from './input-readonly-copy.component' 10import { InputToggleHiddenComponent } from './input-toggle-hidden.component'
11import { InputSwitchComponent } from './input-switch.component' 11import { InputSwitchComponent } from './input-switch.component'
12import { MarkdownTextareaComponent } from './markdown-textarea.component' 12import { MarkdownTextareaComponent } from './markdown-textarea.component'
13import { PeertubeCheckboxComponent } from './peertube-checkbox.component' 13import { PeertubeCheckboxComponent } from './peertube-checkbox.component'
@@ -30,7 +30,7 @@ import { TimestampInputComponent } from './timestamp-input.component'
30 ], 30 ],
31 31
32 declarations: [ 32 declarations: [
33 InputReadonlyCopyComponent, 33 InputToggleHiddenComponent,
34 MarkdownTextareaComponent, 34 MarkdownTextareaComponent,
35 PeertubeCheckboxComponent, 35 PeertubeCheckboxComponent,
36 PreviewUploadComponent, 36 PreviewUploadComponent,
@@ -55,7 +55,7 @@ import { TimestampInputComponent } from './timestamp-input.component'
55 InputMaskModule, 55 InputMaskModule,
56 NgSelectModule, 56 NgSelectModule,
57 57
58 InputReadonlyCopyComponent, 58 InputToggleHiddenComponent,
59 MarkdownTextareaComponent, 59 MarkdownTextareaComponent,
60 PeertubeCheckboxComponent, 60 PeertubeCheckboxComponent,
61 PreviewUploadComponent, 61 PreviewUploadComponent,
diff --git a/client/src/app/shared/shared-share-modal/video-share.component.html b/client/src/app/shared/shared-share-modal/video-share.component.html
index 80b4e446a..bcb1db4c4 100644
--- a/client/src/app/shared/shared-share-modal/video-share.component.html
+++ b/client/src/app/shared/shared-share-modal/video-share.component.html
@@ -18,7 +18,7 @@
18 <ng-template ngbNavContent> 18 <ng-template ngbNavContent>
19 <div class="nav-content"> 19 <div class="nav-content">
20 20
21 <my-input-readonly-copy [value]="getPlaylistUrl()"></my-input-readonly-copy> 21 <my-input-toggle-hidden [value]="getPlaylistUrl()" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>
22 </div> 22 </div>
23 </ng-template> 23 </ng-template>
24 </ng-container> 24 </ng-container>
@@ -38,7 +38,7 @@
38 38
39 <ng-template ngbNavContent> 39 <ng-template ngbNavContent>
40 <div class="nav-content"> 40 <div class="nav-content">
41 <my-input-readonly-copy [value]="getPlaylistIframeCode()"></my-input-readonly-copy> 41 <my-input-toggle-hidden [value]="getPlaylistIframeCode()" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>
42 42
43 <div i18n *ngIf="notSecure()" class="alert alert-warning"> 43 <div i18n *ngIf="notSecure()" class="alert alert-warning">
44 The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites). 44 The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites).
@@ -72,7 +72,7 @@
72 72
73 <ng-template ngbNavContent> 73 <ng-template ngbNavContent>
74 <div class="nav-content"> 74 <div class="nav-content">
75 <my-input-readonly-copy [value]="getVideoUrl()"></my-input-readonly-copy> 75 <my-input-toggle-hidden [value]="getVideoUrl()" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>
76 </div> 76 </div>
77 </ng-template> 77 </ng-template>
78 </ng-container> 78 </ng-container>
@@ -92,7 +92,7 @@
92 92
93 <ng-template ngbNavContent> 93 <ng-template ngbNavContent>
94 <div class="nav-content"> 94 <div class="nav-content">
95 <my-input-readonly-copy [value]="getVideoIframeCode()"></my-input-readonly-copy> 95 <my-input-toggle-hidden [value]="getVideoIframeCode()" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>
96 96
97 <div i18n *ngIf="notSecure()" class="alert alert-warning"> 97 <div i18n *ngIf="notSecure()" class="alert alert-warning">
98 The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites). 98 The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites).
diff --git a/client/src/app/shared/shared-share-modal/video-share.component.scss b/client/src/app/shared/shared-share-modal/video-share.component.scss
index 091d4dc3b..e4d3aacff 100644
--- a/client/src/app/shared/shared-share-modal/video-share.component.scss
+++ b/client/src/app/shared/shared-share-modal/video-share.component.scss
@@ -1,7 +1,7 @@
1@import '_mixins'; 1@import '_mixins';
2@import '_variables'; 2@import '_variables';
3 3
4my-input-readonly-copy { 4my-input-toggle-hidden {
5 width: 100%; 5 width: 100%;
6} 6}
7 7
diff --git a/client/src/app/shared/shared-video-live/live-stream-information.component.html b/client/src/app/shared/shared-video-live/live-stream-information.component.html
index 6693c1af2..8d9467fe5 100644
--- a/client/src/app/shared/shared-video-live/live-stream-information.component.html
+++ b/client/src/app/shared/shared-video-live/live-stream-information.component.html
@@ -13,12 +13,12 @@
13 13
14 <div class="form-group"> 14 <div class="form-group">
15 <label for="liveVideoRTMPUrl" i18n>Live RTMP Url</label> 15 <label for="liveVideoRTMPUrl" i18n>Live RTMP Url</label>
16 <my-input-readonly-copy id="liveVideoRTMPUrl" [value]="live.rtmpUrl"></my-input-readonly-copy> 16 <my-input-toggle-hidden id="liveVideoRTMPUrl" [value]="live.rtmpUrl" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>
17 </div> 17 </div>
18 18
19 <div class="form-group"> 19 <div class="form-group">
20 <label for="liveVideoStreamKey" i18n>Live stream key</label> 20 <label for="liveVideoStreamKey" i18n>Live stream key</label>
21 <my-input-readonly-copy id="liveVideoStreamKey" [value]="live.streamKey"></my-input-readonly-copy> 21 <my-input-toggle-hidden id="liveVideoStreamKey" [value]="live.streamKey" [withCopy]="true" [readonly]="true"></my-input-toggle-hidden>
22 22
23 <div class="form-group-description" i18n>⚠️ Never share your stream key with anyone.</div> 23 <div class="form-group-description" i18n>⚠️ Never share your stream key with anyone.</div>
24 </div> 24 </div>