64 lines
2.6 KiB
TypeScript
64 lines
2.6 KiB
TypeScript
import {Injectable} from '@angular/core';
|
|
import {HttpClient} from "@angular/common/http";
|
|
import {CustomOptions} from "./servicesUtils/customOptions.class";
|
|
import {PluginTemplate} from "../utils/entities/adminTool/pluginTemplate";
|
|
import {Plugin} from "../utils/entities/adminTool/plugin";
|
|
import {properties} from "../../../environments/environment";
|
|
import {catchError} from "rxjs/operators";
|
|
|
|
@Injectable()
|
|
export class PluginsService {
|
|
|
|
constructor(private http:HttpClient) {
|
|
}
|
|
|
|
getPluginTemplate(api:string, code:string) {
|
|
return this.http.get<PluginTemplate>(api + 'pluginTemplates/' + code)
|
|
|
|
}
|
|
getAllPluginTemplates(api:string) {
|
|
return this.http.get<Array<PluginTemplate>>(api + 'pluginTemplates')
|
|
|
|
}
|
|
getAllPlugins(api:string) {
|
|
return this.http.get<Array<Plugin>>(api + 'plugins')
|
|
|
|
}
|
|
|
|
savePluginTemplate(pluginTemplate:PluginTemplate, api:string) {
|
|
// console.log(pluginTemplate, pluginTemplate.toJsonObj())
|
|
return this.http.post<PluginTemplate>(api + 'pluginTemplate/save', pluginTemplate, CustomOptions.getAuthOptionsWithBody());
|
|
}
|
|
savePlugin(plugin, api:string) {
|
|
return this.http.post<Plugin>(api + 'plugin/save', JSON.stringify(plugin), CustomOptions.getAuthOptionsWithBody());
|
|
}
|
|
deletePlugin(id, api:string) {
|
|
return this.http.delete<Plugin>(api + 'plugin/'+id, CustomOptions.getAuthOptionsWithBody());
|
|
}
|
|
deletePluginTemplate(id, api:string) {
|
|
return this.http.delete<PluginTemplate>(api + 'pluginTemplate/'+id, CustomOptions.getAuthOptionsWithBody());
|
|
}
|
|
countPluginPerPage( api:string, pid:string){
|
|
return this.http.get(api + properties.adminToolsPortalType + '/' +pid+'/plugin/page/count');
|
|
}
|
|
countPluginTemplatePerPage( api:string, pid:string){
|
|
return this.http.get(api + properties.adminToolsPortalType + '/' +pid+'/pluginTemplate/page/count');
|
|
}
|
|
countPluginPerTemplate( api:string){
|
|
return this.http.get(api + '/plugin/template/count');
|
|
}
|
|
getPluginsByPage(api:string, pid:string, pageId:string){
|
|
return this.http.get<Array<Plugin>>(api + properties.adminToolsPortalType + '/' +pid+'/plugins/page/' + pageId);
|
|
}
|
|
getPluginTemplatesByPage(api:string, pid:string, pageId:string){
|
|
return this.http.get<Array<PluginTemplate>>(api + properties.adminToolsPortalType + '/' +pid+'/pluginTemplates/page/' + pageId);
|
|
}
|
|
getPluginsByTemplatesCode(api:string, pid:string, code:string){
|
|
return this.http.get<Array<Plugin>>(api +'/plugins/template/' + code);
|
|
}
|
|
|
|
togglePages(id : string,status : boolean, api:string) {
|
|
return this.http.post(api + 'plugin/status/' + id, status, CustomOptions.getAuthOptionsWithBody());
|
|
}
|
|
}
|