import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service'
import { ComponentPagination, ConfirmService, hasMoreItems, Notifier } from '@app/core'
import { PluginService } from '@app/core/plugins/plugin.service'
-import { compareSemVer } from '@shared/core-utils/miscs/miscs'
+import { compareSemVer } from '@shared/core-utils'
import { PeerTubePlugin, PluginType } from '@shared/models'
@Component({
selector: 'my-plugin-list-installed',
templateUrl: './plugin-list-installed.component.html',
- styleUrls: [
- '../shared/toggle-plugin-type.scss',
- '../shared/plugin-list.component.scss',
- './plugin-list-installed.component.scss'
- ]
+ styleUrls: [ './plugin-list-installed.component.scss' ]
})
export class PluginListInstalledComponent implements OnInit {
- pluginTypeOptions: { label: string, value: PluginType }[] = []
- pluginType: PluginType = PluginType.PLUGIN
+ pluginType: PluginType
pagination: ComponentPagination = {
currentPage: 1,
private router: Router,
private route: ActivatedRoute
) {
- this.pluginTypeOptions = this.pluginApiService.getPluginTypeOptions()
}
ngOnInit () {
- const query = this.route.snapshot.queryParams
- if (query['pluginType']) this.pluginType = parseInt(query['pluginType'], 10)
+ if (!this.route.snapshot.queryParams['pluginType']) {
+ const queryParams = { pluginType: PluginType.PLUGIN }
- this.reloadPlugins()
+ this.router.navigate([], { queryParams })
+ }
+
+ this.route.queryParams.subscribe(query => {
+ if (!query['pluginType']) return
+
+ this.pluginType = parseInt(query['pluginType'], 10)
+
+ this.reloadPlugins()
+ })
}
reloadPlugins () {
this.pagination.currentPage = 1
this.plugins = []
- this.router.navigate([], { queryParams: { pluginType: this.pluginType } })
-
this.loadMorePlugins()
}
loadMorePlugins () {
this.pluginApiService.getPlugins(this.pluginType, this.pagination, this.sort)
- .subscribe(
- res => {
+ .subscribe({
+ next: res => {
this.plugins = this.plugins.concat(res.data)
this.pagination.totalItems = res.total
this.onDataSubject.next(res.data)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
onNearOfBottom () {
if (res === false) return
this.pluginApiService.uninstall(plugin.name, plugin.type)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.notifier.success($localize`${plugin.name} uninstalled.`)
this.plugins = this.plugins.filter(p => p.name !== plugin.name)
this.pagination.totalItems--
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
async update (plugin: PeerTubePlugin) {
this.pluginApiService.update(plugin.name, plugin.type)
.pipe()
- .subscribe(
- res => {
+ .subscribe({
+ next: res => {
this.updating[updatingKey] = false
this.notifier.success($localize`${plugin.name} updated.`)
Object.assign(plugin, res)
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
getShowRouterLink (plugin: PeerTubePlugin) {