1 import { Component, OnInit } from '@angular/core'
2 import { PluginType } from '@shared/models/plugins/plugin.type'
3 import { I18n } from '@ngx-translate/i18n-polyfill'
4 import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service'
5 import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model'
6 import { Notifier } from '@app/core'
7 import { PeerTubePlugin } from '@shared/models/plugins/peertube-plugin.model'
10 selector: 'my-plugin-list-installed',
11 templateUrl: './plugin-list-installed.component.html',
12 styleUrls: [ './plugin-list-installed.component.scss' ]
14 export class PluginListInstalledComponent implements OnInit {
15 pluginTypeOptions: { label: string, value: PluginType }[] = []
16 pluginType: PluginType = PluginType.PLUGIN
18 pagination: ComponentPagination = {
24 plugins: PeerTubePlugin[] = []
28 private pluginService: PluginApiService,
29 private notifier: Notifier
31 this.pluginTypeOptions = this.pluginService.getPluginTypeOptions()
39 this.pagination.currentPage = 1
42 this.loadMorePlugins()
46 this.pluginService.getPlugins(this.pluginType, this.pagination, this.sort)
49 this.plugins = this.plugins.concat(res.data)
50 this.pagination.totalItems = res.total
53 err => this.notifier.error(err.message)
58 if (!hasMoreItems(this.pagination)) return
60 this.pagination.currentPage += 1
62 this.loadMorePlugins()
65 getNoResultMessage () {
66 if (this.pluginType === PluginType.PLUGIN) {
67 return this.i18n('You don\'t have plugins installed yet.')
70 return this.i18n('You don\'t have themes installed yet.')