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/videos/+video-edit/shared | |
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/videos/+video-edit/shared')
4 files changed, 117 insertions, 27 deletions
diff --git a/client/src/app/videos/+video-edit/shared/i18n-primeng-calendar.service.ts b/client/src/app/videos/+video-edit/shared/i18n-primeng-calendar.service.ts new file mode 100644 index 000000000..b05852ff8 --- /dev/null +++ b/client/src/app/videos/+video-edit/shared/i18n-primeng-calendar.service.ts | |||
@@ -0,0 +1,94 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Injectable } from '@angular/core' | ||
3 | |||
4 | @Injectable() | ||
5 | export class I18nPrimengCalendarService { | ||
6 | private readonly calendarLocale: any = {} | ||
7 | |||
8 | constructor (private i18n: I18n) { | ||
9 | this.calendarLocale = { | ||
10 | firstDayOfWeek: 0, | ||
11 | dayNames: [ | ||
12 | this.i18n('Sunday'), | ||
13 | this.i18n('Monday'), | ||
14 | this.i18n('Tuesday'), | ||
15 | this.i18n('Wednesday'), | ||
16 | this.i18n('Thursday'), | ||
17 | this.i18n('Friday'), | ||
18 | this.i18n('Saturday') | ||
19 | ], | ||
20 | |||
21 | dayNamesShort: [ | ||
22 | this.i18n({ value: 'Sun', description: 'Day name short' }), | ||
23 | this.i18n({ value: 'Mon', description: 'Day name short' }), | ||
24 | this.i18n({ value: 'Tue', description: 'Day name short' }), | ||
25 | this.i18n({ value: 'Wed', description: 'Day name short' }), | ||
26 | this.i18n({ value: 'Thu', description: 'Day name short' }), | ||
27 | this.i18n({ value: 'Fri', description: 'Day name short' }), | ||
28 | this.i18n({ value: 'Sat', description: 'Day name short' }) | ||
29 | ], | ||
30 | |||
31 | dayNamesMin: [ | ||
32 | this.i18n({ value: 'Su', description: 'Day name min' }), | ||
33 | this.i18n({ value: 'Mo', description: 'Day name min' }), | ||
34 | this.i18n({ value: 'Tu', description: 'Day name min' }), | ||
35 | this.i18n({ value: 'We', description: 'Day name min' }), | ||
36 | this.i18n({ value: 'Th', description: 'Day name min' }), | ||
37 | this.i18n({ value: 'Fr', description: 'Day name min' }), | ||
38 | this.i18n({ value: 'Sa', description: 'Day name min' }) | ||
39 | ], | ||
40 | |||
41 | monthNames: [ | ||
42 | this.i18n('January'), | ||
43 | this.i18n('February'), | ||
44 | this.i18n('March'), | ||
45 | this.i18n('April'), | ||
46 | this.i18n('May'), | ||
47 | this.i18n('June'), | ||
48 | this.i18n('July'), | ||
49 | this.i18n('August'), | ||
50 | this.i18n('September'), | ||
51 | this.i18n('October'), | ||
52 | this.i18n('November'), | ||
53 | this.i18n('December') | ||
54 | ], | ||
55 | |||
56 | monthNamesShort: [ | ||
57 | this.i18n({ value: 'Jan', description: 'Month name short' }), | ||
58 | this.i18n({ value: 'Feb', description: 'Month name short' }), | ||
59 | this.i18n({ value: 'Mar', description: 'Month name short' }), | ||
60 | this.i18n({ value: 'Apr', description: 'Month name short' }), | ||
61 | this.i18n({ value: 'May', description: 'Month name short' }), | ||
62 | this.i18n({ value: 'Jun', description: 'Month name short' }), | ||
63 | this.i18n({ value: 'Jul', description: 'Month name short' }), | ||
64 | this.i18n({ value: 'Aug', description: 'Month name short' }), | ||
65 | this.i18n({ value: 'Sep', description: 'Month name short' }), | ||
66 | this.i18n({ value: 'Oct', description: 'Month name short' }), | ||
67 | this.i18n({ value: 'Nov', description: 'Month name short' }), | ||
68 | this.i18n({ value: 'Dec', description: 'Month name short' }) | ||
69 | ], | ||
70 | |||
71 | today: this.i18n('Today'), | ||
72 | |||
73 | clear: this.i18n('Clear') | ||
74 | } | ||
75 | } | ||
76 | |||
77 | getCalendarLocale () { | ||
78 | return this.calendarLocale | ||
79 | } | ||
80 | |||
81 | getTimezone () { | ||
82 | const gmt = new Date().toString().match(/([A-Z]+[\+-][0-9]+)/)[1] | ||
83 | const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone | ||
84 | |||
85 | return `${timezone} - ${gmt}` | ||
86 | } | ||
87 | |||
88 | getDateFormat () { | ||
89 | return this.i18n({ | ||
90 | value: 'yy-mm-dd ', | ||
91 | description: 'Date format in this locale.' | ||
92 | }) | ||
93 | } | ||
94 | } | ||
diff --git a/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts b/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts index 9856aac9e..a90d04ce8 100644 --- a/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts | |||
@@ -1,11 +1,9 @@ | |||
1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' |
2 | import { FormReactive } from '@app/shared' | ||
3 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | ||
4 | import { VideoCaptionsValidatorsService } from '@app/shared/forms/form-validators/video-captions-validators.service' | ||
5 | import { ServerService } from '@app/core' | 2 | import { ServerService } from '@app/core' |
6 | import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model' | 3 | import { FormReactive, FormValidatorService, VideoCaptionsValidatorsService } from '@app/shared/shared-forms' |
4 | import { VideoCaptionEdit } from '@app/shared/shared-main' | ||
7 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' | 5 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' |
8 | import { ServerConfig, VideoConstant } from '../../../../../../shared' | 6 | import { ServerConfig, VideoConstant } from '@shared/models' |
9 | 7 | ||
10 | @Component({ | 8 | @Component({ |
11 | selector: 'my-video-caption-add-modal', | 9 | selector: 'my-video-caption-add-modal', |
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts index 15073fc44..239e453ad 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts | |||
@@ -1,19 +1,13 @@ | |||
1 | import { map } from 'rxjs/operators' | ||
1 | import { Component, Input, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' | 2 | import { Component, Input, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' |
2 | import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms' | 3 | import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 4 | import { ServerService } from '@app/core' |
4 | import { FormReactiveValidationMessages, VideoValidatorsService } from '@app/shared' | 5 | import { removeElementFromArray } from '@app/helpers' |
5 | import { Notifier } from '@app/core' | 6 | import { FormReactiveValidationMessages, FormValidatorService, VideoValidatorsService } from '@app/shared/shared-forms' |
6 | import { ServerService } from '../../../core/server' | 7 | import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' |
7 | import { VideoEdit } from '../../../shared/video/video-edit.model' | 8 | import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' |
8 | import { map } from 'rxjs/operators' | 9 | import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' |
9 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | 10 | import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' |
10 | import { I18nPrimengCalendarService } from '@app/shared/i18n/i18n-primeng-calendar' | ||
11 | import { VideoCaptionService } from '@app/shared/video-caption' | ||
12 | import { VideoCaptionAddModalComponent } from '@app/videos/+video-edit/shared/video-caption-add-modal.component' | ||
13 | import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model' | ||
14 | import { removeElementFromArray } from '@app/shared/misc/utils' | ||
15 | import { ServerConfig, VideoConstant, VideoPrivacy } from '../../../../../../shared' | ||
16 | import { VideoService } from '@app/shared/video/video.service' | ||
17 | 11 | ||
18 | @Component({ | 12 | @Component({ |
19 | selector: 'my-video-edit', | 13 | selector: 'my-video-edit', |
@@ -60,11 +54,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
60 | constructor ( | 54 | constructor ( |
61 | private formValidatorService: FormValidatorService, | 55 | private formValidatorService: FormValidatorService, |
62 | private videoValidatorsService: VideoValidatorsService, | 56 | private videoValidatorsService: VideoValidatorsService, |
63 | private videoCaptionService: VideoCaptionService, | ||
64 | private videoService: VideoService, | 57 | private videoService: VideoService, |
65 | private route: ActivatedRoute, | ||
66 | private router: Router, | ||
67 | private notifier: Notifier, | ||
68 | private serverService: ServerService, | 58 | private serverService: ServerService, |
69 | private i18nPrimengCalendarService: I18nPrimengCalendarService, | 59 | private i18nPrimengCalendarService: I18nPrimengCalendarService, |
70 | private ngZone: NgZone | 60 | private ngZone: NgZone |
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.module.ts b/client/src/app/videos/+video-edit/shared/video-edit.module.ts index 1357d607c..96061a300 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.module.ts +++ b/client/src/app/videos/+video-edit/shared/video-edit.module.ts | |||
@@ -1,16 +1,20 @@ | |||
1 | import { NgModule } from '@angular/core' | ||
2 | import { TagInputModule } from 'ngx-chips' | 1 | import { TagInputModule } from 'ngx-chips' |
3 | import { SharedModule } from '../../../shared/' | ||
4 | import { VideoEditComponent } from './video-edit.component' | ||
5 | import { CalendarModule } from 'primeng/calendar' | 2 | import { CalendarModule } from 'primeng/calendar' |
3 | import { NgModule } from '@angular/core' | ||
4 | import { SharedFormModule } from '@app/shared/shared-forms' | ||
5 | import { SharedGlobalIconModule } from '@app/shared/shared-icons' | ||
6 | import { SharedMainModule } from '@app/shared/shared-main' | ||
6 | import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' | 7 | import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' |
8 | import { VideoEditComponent } from './video-edit.component' | ||
7 | 9 | ||
8 | @NgModule({ | 10 | @NgModule({ |
9 | imports: [ | 11 | imports: [ |
10 | TagInputModule, | 12 | TagInputModule, |
11 | CalendarModule, | 13 | CalendarModule, |
12 | 14 | ||
13 | SharedModule | 15 | SharedMainModule, |
16 | SharedFormModule, | ||
17 | SharedGlobalIconModule | ||
14 | ], | 18 | ], |
15 | 19 | ||
16 | declarations: [ | 20 | declarations: [ |
@@ -22,6 +26,10 @@ import { VideoCaptionAddModalComponent } from './video-caption-add-modal.compone | |||
22 | TagInputModule, | 26 | TagInputModule, |
23 | CalendarModule, | 27 | CalendarModule, |
24 | 28 | ||
29 | SharedMainModule, | ||
30 | SharedFormModule, | ||
31 | SharedGlobalIconModule, | ||
32 | |||
25 | VideoEditComponent | 33 | VideoEditComponent |
26 | ], | 34 | ], |
27 | 35 | ||