2023-09-25 10:36:05 +02:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {HttpClient} from "@angular/common/http";
|
|
|
|
import {CustomOptions} from "./servicesUtils/customOptions.class";
|
|
|
|
import {PluginTemplate} from "../utils/entities/adminTool/pluginTemplate";
|
2023-09-26 16:32:27 +02:00
|
|
|
import {Plugin} from "../utils/entities/adminTool/plugin";
|
|
|
|
import {properties} from "../../../environments/environment";
|
2023-09-25 10:36:05 +02:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class PluginsService {
|
|
|
|
|
2024-03-15 14:56:54 +01:00
|
|
|
constructor(private http: HttpClient) {
|
2023-09-25 10:36:05 +02:00
|
|
|
}
|
2024-09-12 09:49:03 +02:00
|
|
|
getPluginTemplates(pageId) {
|
|
|
|
return this.http.get<Array<PluginTemplate>>(properties.adminToolsAPIURL + 'pluginTemplates' + (pageId ? '/page/' + pageId : ''))
|
2023-09-25 10:36:05 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
savePluginTemplate(pluginTemplate: PluginTemplate) {
|
|
|
|
return this.http.post<PluginTemplate>(properties.adminToolsAPIURL + 'pluginTemplate/save', pluginTemplate, CustomOptions.getAuthOptionsWithBody());
|
2023-09-25 10:36:05 +02:00
|
|
|
}
|
2024-03-15 14:56:54 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
updatePluginTemplateOrder(pluginTemplate: PluginTemplate, position) {
|
|
|
|
return this.http.post<PluginTemplate>(properties.adminToolsAPIURL + 'pluginTemplate/save/order/' + position, pluginTemplate, CustomOptions.getAuthOptionsWithBody());
|
2024-02-02 08:33:01 +01:00
|
|
|
}
|
2024-03-15 14:56:54 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
updatePluginOrder(plugin: Plugin, position, community) {
|
|
|
|
return this.http.post<Plugin>(properties.adminToolsAPIURL + 'community/'+community+'/plugin/save/order/' + position, plugin, CustomOptions.getAuthOptionsWithBody());
|
2024-02-02 08:33:01 +01:00
|
|
|
}
|
2024-03-15 14:56:54 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
savePlugin(plugin, community) {
|
|
|
|
return this.http.post<Plugin>(properties.adminToolsAPIURL + 'community/' + community + '/plugin/save', JSON.stringify(plugin), CustomOptions.getAuthOptionsWithBody());
|
2023-09-25 10:36:05 +02:00
|
|
|
}
|
2024-03-15 14:56:54 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
deletePluginTemplate(id) {
|
|
|
|
return this.http.delete<PluginTemplate>(properties.adminToolsAPIURL + 'pluginTemplate/' + id, CustomOptions.getAuthOptionsWithBody());
|
2024-02-02 08:33:01 +01:00
|
|
|
}
|
2024-09-12 09:49:03 +02:00
|
|
|
deletePlugin(id) {
|
|
|
|
return this.http.delete<PluginTemplate>(properties.adminToolsAPIURL + 'plugin/' + id, CustomOptions.getAuthOptionsWithBody());
|
2024-05-22 10:09:18 +02:00
|
|
|
}
|
2024-03-15 14:56:54 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
countPluginTemplatePerPage(pid: string) {
|
|
|
|
return this.http.get(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/pluginTemplate/page/count');
|
2023-10-17 08:20:16 +02:00
|
|
|
}
|
2024-03-15 14:56:54 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
countPluginTemplatePerPageForAllPortals() {
|
|
|
|
return this.http.get(properties.adminToolsAPIURL + 'pluginTemplate/page/count');
|
2023-09-26 16:32:27 +02:00
|
|
|
}
|
2024-03-15 14:56:54 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getPluginsByPage(pid: string, pageId: string) {
|
|
|
|
return this.http.get<Array<Plugin>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/plugins/page/' + pageId);
|
2023-09-26 16:32:27 +02:00
|
|
|
}
|
2024-03-15 14:56:54 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getPluginTemplatesByPage(pid: string, pageId: string) {
|
|
|
|
return this.http.get<Array<PluginTemplate>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/pluginTemplates/page/' + pageId);
|
2023-10-17 08:20:16 +02:00
|
|
|
}
|
2024-09-13 08:59:24 +02:00
|
|
|
getPluginsByPageRoute(pid:string, route:string){
|
|
|
|
let url = properties.adminToolsAPIURL + 'community/' +pid+'/plugins/page/route?route=' + route;
|
2024-05-09 09:18:20 +02:00
|
|
|
return this.http.get<Array<Plugin>>(/*(properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url) + (properties.forceCacheReload?'&forceReload=true':'')) : */url);
|
2024-03-15 19:19:31 +01:00
|
|
|
}
|
2024-09-13 08:59:24 +02:00
|
|
|
getPluginTemplatesByPageRoute(pid:string, route:string){
|
|
|
|
let url = properties.adminToolsAPIURL + 'community/' + pid + '/pluginTemplates/page/route?route=' + route;
|
2024-05-09 09:18:20 +02:00
|
|
|
return this.http.get<Array<PluginTemplate>>(/*(properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url) + (properties.forceCacheReload?'&forceReload=true':'')) :*/ url);
|
2023-10-02 09:20:36 +02:00
|
|
|
}
|
2024-03-27 12:08:52 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
togglePlugin(id: string, status: boolean, community) {
|
|
|
|
return this.http.post(properties.adminToolsAPIURL + 'community/' + community + '/plugin/status/' + id, status, CustomOptions.getAuthOptionsWithBody());
|
2024-03-27 12:08:52 +01:00
|
|
|
}
|
2024-09-12 09:49:03 +02:00
|
|
|
getPluginById(id: string) {
|
|
|
|
return this.http.get<Plugin>(properties.adminToolsAPIURL + 'plugin/' + id);
|
2024-05-22 10:09:18 +02:00
|
|
|
}
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getPluginTemplateById(id: string) {
|
|
|
|
return this.http.get<PluginTemplate>(properties.adminToolsAPIURL + 'pluginTemplates/' + id);
|
2024-05-22 10:09:18 +02:00
|
|
|
}
|
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
}
|