diff options
author | Chocobozzz <me@florianbigard.com> | 2021-03-29 15:56:01 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-03-31 09:05:51 +0200 |
commit | 100d9ce23bb7c5186132607e4c444f9cba5002a4 (patch) | |
tree | 2028938d90321c6d2454c4aea2e6f24e53393a4a /client/src/app/shared | |
parent | 900f7820814b95b07ef0bcac04036a95abfbe060 (diff) | |
download | PeerTube-100d9ce23bb7c5186132607e4c444f9cba5002a4.tar.gz PeerTube-100d9ce23bb7c5186132607e4c444f9cba5002a4.tar.zst PeerTube-100d9ce23bb7c5186132607e4c444f9cba5002a4.zip |
Add support button in channel page
Diffstat (limited to 'client/src/app/shared')
6 files changed, 86 insertions, 1 deletions
diff --git a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts index c6a63fe6c..bd187a873 100644 --- a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts +++ b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts | |||
@@ -46,7 +46,7 @@ export class VideoChannel extends Actor implements ServerVideoChannel { | |||
46 | if (hash.ownerAccount) { | 46 | if (hash.ownerAccount) { |
47 | this.ownerAccount = hash.ownerAccount | 47 | this.ownerAccount = hash.ownerAccount |
48 | this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host) | 48 | this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host) |
49 | this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount) | 49 | this.ownerAvatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this.ownerAccount) |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
diff --git a/client/src/app/shared/shared-support-modal/index.ts b/client/src/app/shared/shared-support-modal/index.ts new file mode 100644 index 000000000..f41bb4bc2 --- /dev/null +++ b/client/src/app/shared/shared-support-modal/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './support-modal.component' | ||
2 | |||
3 | export * from './shared-support-modal.module' | ||
diff --git a/client/src/app/shared/shared-support-modal/shared-support-modal.module.ts b/client/src/app/shared/shared-support-modal/shared-support-modal.module.ts new file mode 100644 index 000000000..1101d5535 --- /dev/null +++ b/client/src/app/shared/shared-support-modal/shared-support-modal.module.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { NgModule } from '@angular/core' | ||
2 | import { SharedFormModule } from '../shared-forms' | ||
3 | import { SharedGlobalIconModule } from '../shared-icons' | ||
4 | import { SharedMainModule } from '../shared-main/shared-main.module' | ||
5 | import { SupportModalComponent } from './support-modal.component' | ||
6 | |||
7 | @NgModule({ | ||
8 | imports: [ | ||
9 | SharedMainModule, | ||
10 | SharedFormModule, | ||
11 | SharedGlobalIconModule | ||
12 | ], | ||
13 | |||
14 | declarations: [ | ||
15 | SupportModalComponent | ||
16 | ], | ||
17 | |||
18 | exports: [ | ||
19 | SupportModalComponent | ||
20 | ], | ||
21 | |||
22 | providers: [ ] | ||
23 | }) | ||
24 | export class SharedSupportModal { } | ||
diff --git a/client/src/app/shared/shared-support-modal/support-modal.component.html b/client/src/app/shared/shared-support-modal/support-modal.component.html new file mode 100644 index 000000000..4a967987f --- /dev/null +++ b/client/src/app/shared/shared-support-modal/support-modal.component.html | |||
@@ -0,0 +1,15 @@ | |||
1 | <ng-template #modal let-hide="close"> | ||
2 | <div class="modal-header"> | ||
3 | <h4 i18n class="modal-title">Support {{ displayName }}</h4> | ||
4 | <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon> | ||
5 | </div> | ||
6 | |||
7 | <div class="modal-body" [innerHTML]="htmlSupport"></div> | ||
8 | |||
9 | <div class="modal-footer inputs"> | ||
10 | <input | ||
11 | type="button" role="button" i18n-value value="Maybe later" class="action-button action-button-cancel" | ||
12 | (click)="hide()" (key.enter)="hide()" | ||
13 | > | ||
14 | </div> | ||
15 | </ng-template> | ||
diff --git a/client/src/app/shared/shared-support-modal/support-modal.component.scss b/client/src/app/shared/shared-support-modal/support-modal.component.scss new file mode 100644 index 000000000..184e09027 --- /dev/null +++ b/client/src/app/shared/shared-support-modal/support-modal.component.scss | |||
@@ -0,0 +1,3 @@ | |||
1 | .action-button-cancel { | ||
2 | margin-right: 0 !important; | ||
3 | } | ||
diff --git a/client/src/app/shared/shared-support-modal/support-modal.component.ts b/client/src/app/shared/shared-support-modal/support-modal.component.ts new file mode 100644 index 000000000..ae603c7a8 --- /dev/null +++ b/client/src/app/shared/shared-support-modal/support-modal.component.ts | |||
@@ -0,0 +1,40 @@ | |||
1 | import { Component, Input, ViewChild } from '@angular/core' | ||
2 | import { MarkdownService } from '@app/core' | ||
3 | import { VideoDetails } from '@app/shared/shared-main' | ||
4 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | ||
5 | import { VideoChannel } from '@shared/models' | ||
6 | |||
7 | @Component({ | ||
8 | selector: 'my-support-modal', | ||
9 | templateUrl: './support-modal.component.html', | ||
10 | styleUrls: [ './support-modal.component.scss' ] | ||
11 | }) | ||
12 | export class SupportModalComponent { | ||
13 | @Input() video: VideoDetails = null | ||
14 | @Input() videoChannel: VideoChannel = null | ||
15 | |||
16 | @ViewChild('modal', { static: true }) modal: NgbModal | ||
17 | |||
18 | htmlSupport = '' | ||
19 | displayName = '' | ||
20 | |||
21 | constructor ( | ||
22 | private markdownService: MarkdownService, | ||
23 | private modalService: NgbModal | ||
24 | ) { } | ||
25 | |||
26 | show () { | ||
27 | const modalRef = this.modalService.open(this.modal, { centered: true }) | ||
28 | |||
29 | const support = this.video?.support || this.videoChannel.support | ||
30 | |||
31 | this.markdownService.enhancedMarkdownToHTML(support) | ||
32 | .then(r => this.htmlSupport = r) | ||
33 | |||
34 | this.displayName = this.video | ||
35 | ? this.video.channel.displayName | ||
36 | : this.videoChannel.displayName | ||
37 | |||
38 | return modalRef | ||
39 | } | ||
40 | } | ||