diff options
author | Chocobozzz <me@florianbigard.com> | 2019-05-21 10:05:12 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-05-21 10:05:12 +0200 |
commit | 73b3aa6429dfb2e31628fa09a479dce318289d7d (patch) | |
tree | 88cf5c7c49ba89c18633a4a64a4acfc8d40b4a50 /client/src/app/shared | |
parent | fd822c1c699fb89bb1c3218e047e1d842bc1ba1a (diff) | |
parent | 618750486ee2732e0ad3525349e4d42f29e1803e (diff) | |
download | PeerTube-73b3aa6429dfb2e31628fa09a479dce318289d7d.tar.gz PeerTube-73b3aa6429dfb2e31628fa09a479dce318289d7d.tar.zst PeerTube-73b3aa6429dfb2e31628fa09a479dce318289d7d.zip |
Merge branch 'feature/audio-upload' into develop
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/buttons/button.component.scss | 13 | ||||
-rw-r--r-- | client/src/app/shared/buttons/button.component.ts | 2 | ||||
-rw-r--r-- | client/src/app/shared/buttons/delete-button.component.html | 2 | ||||
-rw-r--r-- | client/src/app/shared/buttons/edit-button.component.html | 2 | ||||
-rw-r--r-- | client/src/app/shared/forms/reactive-file.component.html | 7 | ||||
-rw-r--r-- | client/src/app/shared/forms/reactive-file.component.scss | 10 | ||||
-rw-r--r-- | client/src/app/shared/forms/reactive-file.component.ts | 2 | ||||
-rw-r--r-- | client/src/app/shared/images/image-upload.component.html | 9 | ||||
-rw-r--r-- | client/src/app/shared/images/image-upload.component.scss | 18 | ||||
-rw-r--r-- | client/src/app/shared/images/preview-upload.component.html | 13 | ||||
-rw-r--r-- | client/src/app/shared/images/preview-upload.component.scss | 27 | ||||
-rw-r--r-- | client/src/app/shared/images/preview-upload.component.ts (renamed from client/src/app/shared/images/image-upload.component.ts) | 17 | ||||
-rw-r--r-- | client/src/app/shared/shared.module.ts | 6 | ||||
-rw-r--r-- | client/src/app/shared/video/video-edit.model.ts | 5 |
14 files changed, 75 insertions, 58 deletions
diff --git a/client/src/app/shared/buttons/button.component.scss b/client/src/app/shared/buttons/button.component.scss index 04199a2a9..99d7f51c1 100644 --- a/client/src/app/shared/buttons/button.component.scss +++ b/client/src/app/shared/buttons/button.component.scss | |||
@@ -5,16 +5,9 @@ | |||
5 | @include peertube-button-link; | 5 | @include peertube-button-link; |
6 | @include button-with-icon(21px, 0, -2px); | 6 | @include button-with-icon(21px, 0, -2px); |
7 | 7 | ||
8 | font-weight: $font-semibold; | 8 | // FIXME: Firefox does not apply global .orange-button icon color |
9 | color: $grey-foreground-color; | 9 | &.orange-button { |
10 | background-color: $grey-background-color; | 10 | @include apply-svg-color(#fff) |
11 | |||
12 | &:hover { | ||
13 | background-color: $grey-background-hover-color; | ||
14 | } | ||
15 | |||
16 | my-global-icon { | ||
17 | @include apply-svg-color($grey-foreground-color); | ||
18 | } | 11 | } |
19 | } | 12 | } |
20 | 13 | ||
diff --git a/client/src/app/shared/buttons/button.component.ts b/client/src/app/shared/buttons/button.component.ts index c2b69d31a..cf334e8d5 100644 --- a/client/src/app/shared/buttons/button.component.ts +++ b/client/src/app/shared/buttons/button.component.ts | |||
@@ -9,7 +9,7 @@ import { GlobalIconName } from '@app/shared/images/global-icon.component' | |||
9 | 9 | ||
10 | export class ButtonComponent { | 10 | export class ButtonComponent { |
11 | @Input() label = '' | 11 | @Input() label = '' |
12 | @Input() className: string = undefined | 12 | @Input() className = 'grey-button' |
13 | @Input() icon: GlobalIconName = undefined | 13 | @Input() icon: GlobalIconName = undefined |
14 | @Input() title: string = undefined | 14 | @Input() title: string = undefined |
15 | 15 | ||
diff --git a/client/src/app/shared/buttons/delete-button.component.html b/client/src/app/shared/buttons/delete-button.component.html index 4d12a84c0..d278e7015 100644 --- a/client/src/app/shared/buttons/delete-button.component.html +++ b/client/src/app/shared/buttons/delete-button.component.html | |||
@@ -1,4 +1,4 @@ | |||
1 | <span class="action-button action-button-delete" [title]="getTitle()" role="button"> | 1 | <span class="action-button action-button-delete grey-button" [title]="getTitle()" role="button"> |
2 | <my-global-icon iconName="delete"></my-global-icon> | 2 | <my-global-icon iconName="delete"></my-global-icon> |
3 | 3 | ||
4 | <span class="button-label" *ngIf="label">{{ label }}</span> | 4 | <span class="button-label" *ngIf="label">{{ label }}</span> |
diff --git a/client/src/app/shared/buttons/edit-button.component.html b/client/src/app/shared/buttons/edit-button.component.html index da3addbae..3d7cd4780 100644 --- a/client/src/app/shared/buttons/edit-button.component.html +++ b/client/src/app/shared/buttons/edit-button.component.html | |||
@@ -1,4 +1,4 @@ | |||
1 | <a class="action-button action-button-edit" [routerLink]="routerLink" i18n-title title="Edit"> | 1 | <a class="action-button action-button-edit grey-button" [routerLink]="routerLink" i18n-title title="Edit"> |
2 | <my-global-icon iconName="edit"></my-global-icon> | 2 | <my-global-icon iconName="edit"></my-global-icon> |
3 | 3 | ||
4 | <span class="button-label" *ngIf="label">{{ label }}</span> | 4 | <span class="button-label" *ngIf="label">{{ label }}</span> |
diff --git a/client/src/app/shared/forms/reactive-file.component.html b/client/src/app/shared/forms/reactive-file.component.html index 7d691059d..f6bf5f9ae 100644 --- a/client/src/app/shared/forms/reactive-file.component.html +++ b/client/src/app/shared/forms/reactive-file.component.html | |||
@@ -1,6 +1,9 @@ | |||
1 | <div class="root"> | 1 | <div class="root"> |
2 | <div class="button-file"> | 2 | <div class="button-file" [ngClass]="{ 'with-icon': !!icon }"> |
3 | <my-global-icon *ngIf="icon" [iconName]="icon"></my-global-icon> | ||
4 | |||
3 | <span>{{ inputLabel }}</span> | 5 | <span>{{ inputLabel }}</span> |
6 | |||
4 | <input | 7 | <input |
5 | type="file" | 8 | type="file" |
6 | [name]="inputName" [id]="inputName" [accept]="extensions" | 9 | [name]="inputName" [id]="inputName" [accept]="extensions" |
@@ -8,7 +11,5 @@ | |||
8 | /> | 11 | /> |
9 | </div> | 12 | </div> |
10 | 13 | ||
11 | <div i18n class="file-constraints">(extensions: {{ allowedExtensionsMessage }}, max size: {{ maxFileSize | bytes }})</div> | ||
12 | |||
13 | <div class="filename" *ngIf="displayFilename === true && filename">{{ filename }}</div> | 14 | <div class="filename" *ngIf="displayFilename === true && filename">{{ filename }}</div> |
14 | </div> | 15 | </div> |
diff --git a/client/src/app/shared/forms/reactive-file.component.scss b/client/src/app/shared/forms/reactive-file.component.scss index d89844264..84c23c1d6 100644 --- a/client/src/app/shared/forms/reactive-file.component.scss +++ b/client/src/app/shared/forms/reactive-file.component.scss | |||
@@ -8,13 +8,11 @@ | |||
8 | 8 | ||
9 | .button-file { | 9 | .button-file { |
10 | @include peertube-button-file(auto); | 10 | @include peertube-button-file(auto); |
11 | @include grey-button; | ||
11 | 12 | ||
12 | min-width: 190px; | 13 | &.with-icon { |
13 | } | 14 | @include button-with-icon; |
14 | 15 | } | |
15 | .file-constraints { | ||
16 | margin-left: 5px; | ||
17 | font-size: 13px; | ||
18 | } | 16 | } |
19 | 17 | ||
20 | .filename { | 18 | .filename { |
diff --git a/client/src/app/shared/forms/reactive-file.component.ts b/client/src/app/shared/forms/reactive-file.component.ts index f60c38e8d..b7a821d4f 100644 --- a/client/src/app/shared/forms/reactive-file.component.ts +++ b/client/src/app/shared/forms/reactive-file.component.ts | |||
@@ -2,6 +2,7 @@ import { Component, EventEmitter, forwardRef, Input, OnInit, Output } from '@ang | |||
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { Notifier } from '@app/core' | 3 | import { Notifier } from '@app/core' |
4 | import { I18n } from '@ngx-translate/i18n-polyfill' | 4 | import { I18n } from '@ngx-translate/i18n-polyfill' |
5 | import { GlobalIconName } from '@app/shared/images/global-icon.component' | ||
5 | 6 | ||
6 | @Component({ | 7 | @Component({ |
7 | selector: 'my-reactive-file', | 8 | selector: 'my-reactive-file', |
@@ -21,6 +22,7 @@ export class ReactiveFileComponent implements OnInit, ControlValueAccessor { | |||
21 | @Input() extensions: string[] = [] | 22 | @Input() extensions: string[] = [] |
22 | @Input() maxFileSize: number | 23 | @Input() maxFileSize: number |
23 | @Input() displayFilename = false | 24 | @Input() displayFilename = false |
25 | @Input() icon: GlobalIconName | ||
24 | 26 | ||
25 | @Output() fileChanged = new EventEmitter<Blob>() | 27 | @Output() fileChanged = new EventEmitter<Blob>() |
26 | 28 | ||
diff --git a/client/src/app/shared/images/image-upload.component.html b/client/src/app/shared/images/image-upload.component.html deleted file mode 100644 index c09c862c4..000000000 --- a/client/src/app/shared/images/image-upload.component.html +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | <div class="root"> | ||
2 | <my-reactive-file | ||
3 | [inputName]="inputName" [inputLabel]="inputLabel" [extensions]="videoImageExtensions" [maxFileSize]="maxVideoImageSize" | ||
4 | (fileChanged)="onFileChanged($event)" | ||
5 | ></my-reactive-file> | ||
6 | |||
7 | <img *ngIf="imageSrc" [ngStyle]="{ width: previewWidth, height: previewHeight }" [src]="imageSrc" class="preview" /> | ||
8 | <div *ngIf="!imageSrc" [ngStyle]="{ width: previewWidth, height: previewHeight }" class="preview no-image"></div> | ||
9 | </div> | ||
diff --git a/client/src/app/shared/images/image-upload.component.scss b/client/src/app/shared/images/image-upload.component.scss deleted file mode 100644 index b63963bca..000000000 --- a/client/src/app/shared/images/image-upload.component.scss +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .root { | ||
5 | height: auto; | ||
6 | display: flex; | ||
7 | align-items: center; | ||
8 | |||
9 | .preview { | ||
10 | border: 2px solid grey; | ||
11 | border-radius: 4px; | ||
12 | margin-left: 50px; | ||
13 | |||
14 | &.no-image { | ||
15 | background-color: #ececec; | ||
16 | } | ||
17 | } | ||
18 | } | ||
diff --git a/client/src/app/shared/images/preview-upload.component.html b/client/src/app/shared/images/preview-upload.component.html new file mode 100644 index 000000000..5e1d5211b --- /dev/null +++ b/client/src/app/shared/images/preview-upload.component.html | |||
@@ -0,0 +1,13 @@ | |||
1 | <div class="root"> | ||
2 | <div class="preview-container"> | ||
3 | <my-reactive-file | ||
4 | [inputName]="inputName" [inputLabel]="inputLabel" [extensions]="videoImageExtensions" [maxFileSize]="maxVideoImageSize" | ||
5 | icon="edit" (fileChanged)="onFileChanged($event)" | ||
6 | ></my-reactive-file> | ||
7 | |||
8 | <img *ngIf="imageSrc" [ngStyle]="{ width: previewWidth, height: previewHeight }" [src]="imageSrc" class="preview" /> | ||
9 | <div *ngIf="!imageSrc" [ngStyle]="{ width: previewWidth, height: previewHeight }" class="preview no-image"></div> | ||
10 | </div> | ||
11 | |||
12 | <div i18n class="file-constraints">(extensions: {{ allowedExtensionsMessage }}, max size: {{ maxVideoImageSize | bytes }})</div> | ||
13 | </div> | ||
diff --git a/client/src/app/shared/images/preview-upload.component.scss b/client/src/app/shared/images/preview-upload.component.scss new file mode 100644 index 000000000..257060239 --- /dev/null +++ b/client/src/app/shared/images/preview-upload.component.scss | |||
@@ -0,0 +1,27 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .root { | ||
5 | height: auto; | ||
6 | display: flex; | ||
7 | flex-direction: column; | ||
8 | |||
9 | .preview-container { | ||
10 | position: relative; | ||
11 | |||
12 | my-reactive-file { | ||
13 | position: absolute; | ||
14 | bottom: 10px; | ||
15 | left: 10px; | ||
16 | } | ||
17 | |||
18 | .preview { | ||
19 | border: 2px solid grey; | ||
20 | border-radius: 4px; | ||
21 | |||
22 | &.no-image { | ||
23 | background-color: #ececec; | ||
24 | } | ||
25 | } | ||
26 | } | ||
27 | } | ||
diff --git a/client/src/app/shared/images/image-upload.component.ts b/client/src/app/shared/images/preview-upload.component.ts index 2da1592ff..44b78866e 100644 --- a/client/src/app/shared/images/image-upload.component.ts +++ b/client/src/app/shared/images/preview-upload.component.ts | |||
@@ -1,27 +1,28 @@ | |||
1 | import { Component, forwardRef, Input } from '@angular/core' | 1 | import { Component, forwardRef, Input, OnInit } from '@angular/core' |
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' | 3 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' |
4 | import { ServerService } from '@app/core' | 4 | import { ServerService } from '@app/core' |
5 | 5 | ||
6 | @Component({ | 6 | @Component({ |
7 | selector: 'my-image-upload', | 7 | selector: 'my-preview-upload', |
8 | styleUrls: [ './image-upload.component.scss' ], | 8 | styleUrls: [ './preview-upload.component.scss' ], |
9 | templateUrl: './image-upload.component.html', | 9 | templateUrl: './preview-upload.component.html', |
10 | providers: [ | 10 | providers: [ |
11 | { | 11 | { |
12 | provide: NG_VALUE_ACCESSOR, | 12 | provide: NG_VALUE_ACCESSOR, |
13 | useExisting: forwardRef(() => ImageUploadComponent), | 13 | useExisting: forwardRef(() => PreviewUploadComponent), |
14 | multi: true | 14 | multi: true |
15 | } | 15 | } |
16 | ] | 16 | ] |
17 | }) | 17 | }) |
18 | export class ImageUploadComponent implements ControlValueAccessor { | 18 | export class PreviewUploadComponent implements OnInit, ControlValueAccessor { |
19 | @Input() inputLabel: string | 19 | @Input() inputLabel: string |
20 | @Input() inputName: string | 20 | @Input() inputName: string |
21 | @Input() previewWidth: string | 21 | @Input() previewWidth: string |
22 | @Input() previewHeight: string | 22 | @Input() previewHeight: string |
23 | 23 | ||
24 | imageSrc: SafeResourceUrl | 24 | imageSrc: SafeResourceUrl |
25 | allowedExtensionsMessage = '' | ||
25 | 26 | ||
26 | private file: File | 27 | private file: File |
27 | 28 | ||
@@ -38,6 +39,10 @@ export class ImageUploadComponent implements ControlValueAccessor { | |||
38 | return this.serverService.getConfig().video.image.size.max | 39 | return this.serverService.getConfig().video.image.size.max |
39 | } | 40 | } |
40 | 41 | ||
42 | ngOnInit () { | ||
43 | this.allowedExtensionsMessage = this.videoImageExtensions.join(', ') | ||
44 | } | ||
45 | |||
41 | onFileChanged (file: File) { | 46 | onFileChanged (file: File) { |
42 | this.file = file | 47 | this.file = file |
43 | 48 | ||
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index ded65653f..39f1a69e2 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts | |||
@@ -69,7 +69,7 @@ import { HtmlRendererService, LinkifierService, MarkdownService } from '@app/sha | |||
69 | import { ConfirmComponent } from '@app/shared/confirm/confirm.component' | 69 | import { ConfirmComponent } from '@app/shared/confirm/confirm.component' |
70 | import { SmallLoaderComponent } from '@app/shared/misc/small-loader.component' | 70 | import { SmallLoaderComponent } from '@app/shared/misc/small-loader.component' |
71 | import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' | 71 | import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' |
72 | import { ImageUploadComponent } from '@app/shared/images/image-upload.component' | 72 | import { PreviewUploadComponent } from '@app/shared/images/preview-upload.component' |
73 | import { GlobalIconComponent } from '@app/shared/images/global-icon.component' | 73 | import { GlobalIconComponent } from '@app/shared/images/global-icon.component' |
74 | import { VideoPlaylistMiniatureComponent } from '@app/shared/video-playlist/video-playlist-miniature.component' | 74 | import { VideoPlaylistMiniatureComponent } from '@app/shared/video-playlist/video-playlist-miniature.component' |
75 | import { VideoAddToPlaylistComponent } from '@app/shared/video-playlist/video-add-to-playlist.component' | 75 | import { VideoAddToPlaylistComponent } from '@app/shared/video-playlist/video-add-to-playlist.component' |
@@ -154,7 +154,7 @@ import { ClipboardModule } from 'ngx-clipboard' | |||
154 | ConfirmComponent, | 154 | ConfirmComponent, |
155 | 155 | ||
156 | GlobalIconComponent, | 156 | GlobalIconComponent, |
157 | ImageUploadComponent | 157 | PreviewUploadComponent |
158 | ], | 158 | ], |
159 | 159 | ||
160 | exports: [ | 160 | exports: [ |
@@ -218,7 +218,7 @@ import { ClipboardModule } from 'ngx-clipboard' | |||
218 | ConfirmComponent, | 218 | ConfirmComponent, |
219 | 219 | ||
220 | GlobalIconComponent, | 220 | GlobalIconComponent, |
221 | ImageUploadComponent, | 221 | PreviewUploadComponent, |
222 | 222 | ||
223 | NumberFormatterPipe, | 223 | NumberFormatterPipe, |
224 | ObjectLengthPipe, | 224 | ObjectLengthPipe, |
diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts index 1f633d427..67d8e7711 100644 --- a/client/src/app/shared/video/video-edit.model.ts +++ b/client/src/app/shared/video/video-edit.model.ts | |||
@@ -85,6 +85,11 @@ export class VideoEdit implements VideoUpdate { | |||
85 | const originallyPublishedAt = new Date(values['originallyPublishedAt']) | 85 | const originallyPublishedAt = new Date(values['originallyPublishedAt']) |
86 | this.originallyPublishedAt = originallyPublishedAt.toISOString() | 86 | this.originallyPublishedAt = originallyPublishedAt.toISOString() |
87 | } | 87 | } |
88 | |||
89 | // Use the same file than the preview for the thumbnail | ||
90 | if (this.previewfile) { | ||
91 | this.thumbnailfile = this.previewfile | ||
92 | } | ||
88 | } | 93 | } |
89 | 94 | ||
90 | toFormPatch () { | 95 | toFormPatch () { |