aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/plugins/plugin-list-installed
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-11 14:40:19 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commitdba85a1e9e9f603ba52e1ea42deaf3fdd799b1d8 (patch)
tree7695023d90b78f972abafc718346c50264587ff5 /client/src/app/+admin/plugins/plugin-list-installed
parentd00dc28dd73ad9dd419d5a5ac6ac747cefbc6e8b (diff)
downloadPeerTube-dba85a1e9e9f603ba52e1ea42deaf3fdd799b1d8.tar.gz
PeerTube-dba85a1e9e9f603ba52e1ea42deaf3fdd799b1d8.tar.zst
PeerTube-dba85a1e9e9f603ba52e1ea42deaf3fdd799b1d8.zip
WIP plugins: add plugin settings/uninstall in client
Diffstat (limited to 'client/src/app/+admin/plugins/plugin-list-installed')
-rw-r--r--client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.html28
-rw-r--r--client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.scss35
-rw-r--r--client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts42
3 files changed, 97 insertions, 8 deletions
diff --git a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.html b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.html
index 6bb8bcd75..d4501490f 100644
--- a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.html
+++ b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.html
@@ -7,7 +7,31 @@
7</div> 7</div>
8 8
9<div class="plugins" myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [autoInit]="true"> 9<div class="plugins" myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [autoInit]="true">
10 <div class="section plugin" *ngFor="let plugin of plugins"> 10 <div class="card plugin" *ngFor="let plugin of plugins">
11 {{ plugin.name }} 11 <div class="card-body">
12 <div class="first-row">
13 <a class="plugin-name" [routerLink]="getShowRouterLink(plugin)" title="Show plugin settings">{{ plugin.name }}</a>
14
15 <span class="plugin-version">{{ plugin.version }}</span>
16 </div>
17
18 <div class="second-row">
19 <div class="description">{{ plugin.description }}</div>
20
21 <div class="buttons">
22 <a class="action-button action-button-edit grey-button" target="_blank" rel="noopener noreferrer"
23 [href]="plugin.homepage" i18n-title title="Go to the plugin homepage"
24 >
25 <my-global-icon iconName="go"></my-global-icon>
26 <span i18n class="button-label">Homepage</span>
27 </a>
28
29
30 <my-edit-button [routerLink]="getShowRouterLink(plugin)" label="Settings" i18n-label></my-edit-button>
31
32 <my-delete-button (click)="uninstall(plugin)" label="Uninstall" i18n-label></my-delete-button>
33 </div>
34 </div>
35 </div>
12 </div> 36 </div>
13</div> 37</div>
diff --git a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.scss b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.scss
index 9e98fcd34..f250404ed 100644
--- a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.scss
+++ b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.scss
@@ -1,8 +1,37 @@
1@import '_variables'; 1@import '_variables';
2@import '_mixins'; 2@import '_mixins';
3 3
4.toggle-plugin-type { 4.first-row {
5 margin-bottom: 10px;
6
7 .plugin-name {
8 font-size: 16px;
9 margin-right: 10px;
10 font-weight: $font-semibold;
11 }
12
13 .plugin-version {
14 opacity: 0.6;
15 }
16}
17
18.second-row {
5 display: flex; 19 display: flex;
6 justify-content: center; 20 align-items: center;
7 margin-bottom: 30px; 21 justify-content: space-between;
22
23 .description {
24 opacity: 0.8
25 }
26
27 .buttons {
28 > *:not(:last-child) {
29 margin-right: 10px;
30 }
31 }
32}
33
34.action-button {
35 @include peertube-button-link;
36 @include button-with-icon(21px, 0, -2px);
8} 37}
diff --git a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
index 9745bc36b..26a9a616e 100644
--- a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
+++ b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
@@ -3,13 +3,17 @@ import { PluginType } from '@shared/models/plugins/plugin.type'
3import { I18n } from '@ngx-translate/i18n-polyfill' 3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service' 4import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service'
5import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model' 5import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model'
6import { Notifier } from '@app/core' 6import { ConfirmService, Notifier } from '@app/core'
7import { PeerTubePlugin } from '@shared/models/plugins/peertube-plugin.model' 7import { PeerTubePlugin } from '@shared/models/plugins/peertube-plugin.model'
8import { ActivatedRoute, Router } from '@angular/router'
8 9
9@Component({ 10@Component({
10 selector: 'my-plugin-list-installed', 11 selector: 'my-plugin-list-installed',
11 templateUrl: './plugin-list-installed.component.html', 12 templateUrl: './plugin-list-installed.component.html',
12 styleUrls: [ './plugin-list-installed.component.scss' ] 13 styleUrls: [
14 '../shared/toggle-plugin-type.scss',
15 './plugin-list-installed.component.scss'
16 ]
13}) 17})
14export class PluginListInstalledComponent implements OnInit { 18export class PluginListInstalledComponent implements OnInit {
15 pluginTypeOptions: { label: string, value: PluginType }[] = [] 19 pluginTypeOptions: { label: string, value: PluginType }[] = []
@@ -26,12 +30,18 @@ export class PluginListInstalledComponent implements OnInit {
26 constructor ( 30 constructor (
27 private i18n: I18n, 31 private i18n: I18n,
28 private pluginService: PluginApiService, 32 private pluginService: PluginApiService,
29 private notifier: Notifier 33 private notifier: Notifier,
34 private confirmService: ConfirmService,
35 private router: Router,
36 private route: ActivatedRoute
30 ) { 37 ) {
31 this.pluginTypeOptions = this.pluginService.getPluginTypeOptions() 38 this.pluginTypeOptions = this.pluginService.getPluginTypeOptions()
32 } 39 }
33 40
34 ngOnInit () { 41 ngOnInit () {
42 const query = this.route.snapshot.queryParams
43 if (query['pluginType']) this.pluginType = parseInt(query['pluginType'], 10)
44
35 this.reloadPlugins() 45 this.reloadPlugins()
36 } 46 }
37 47
@@ -39,6 +49,8 @@ export class PluginListInstalledComponent implements OnInit {
39 this.pagination.currentPage = 1 49 this.pagination.currentPage = 1
40 this.plugins = [] 50 this.plugins = []
41 51
52 this.router.navigate([], { queryParams: { pluginType: this.pluginType }})
53
42 this.loadMorePlugins() 54 this.loadMorePlugins()
43 } 55 }
44 56
@@ -69,4 +81,28 @@ export class PluginListInstalledComponent implements OnInit {
69 81
70 return this.i18n('You don\'t have themes installed yet.') 82 return this.i18n('You don\'t have themes installed yet.')
71 } 83 }
84
85 async uninstall (plugin: PeerTubePlugin) {
86 const res = await this.confirmService.confirm(
87 this.i18n('Do you really want to uninstall {{pluginName}}?', { pluginName: plugin.name }),
88 this.i18n('Uninstall')
89 )
90 if (res === false) return
91
92 this.pluginService.uninstall(plugin.name, plugin.type)
93 .subscribe(
94 () => {
95 this.notifier.success(this.i18n('{{pluginName}} uninstalled.', { pluginName: plugin.name }))
96
97 this.plugins = this.plugins.filter(p => p.name !== plugin.name)
98 this.pagination.totalItems--
99 },
100
101 err => this.notifier.error(err.message)
102 )
103 }
104
105 getShowRouterLink (plugin: PeerTubePlugin) {
106 return [ '/admin', 'plugins', 'show', this.pluginService.nameToNpmName(plugin.name, plugin.type) ]
107 }
72} 108}