2024-01-30 08:56:59 +00:00
|
|
|
import { APIService } from "services/api.service";
|
|
|
|
// types
|
|
|
|
import { TView } from "@plane/types";
|
|
|
|
import { TViewService } from "./types";
|
|
|
|
// helpers
|
|
|
|
import { API_BASE_URL } from "helpers/common.helper";
|
|
|
|
|
2024-02-08 18:11:30 +00:00
|
|
|
export class WorkspacePublicViewService extends APIService implements TViewService {
|
2024-01-30 08:56:59 +00:00
|
|
|
constructor() {
|
|
|
|
super(API_BASE_URL);
|
|
|
|
}
|
|
|
|
|
|
|
|
async fetch(workspaceSlug: string): Promise<TView[]> {
|
|
|
|
return this.get(`/api/workspaces/${workspaceSlug}/views/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async fetchById(workspaceSlug: string, viewId: string): Promise<TView> {
|
|
|
|
return this.get(`/api/workspaces/${workspaceSlug}/views/${viewId}/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async create(workspaceSlug: string, data: Partial<TView>): Promise<TView> {
|
|
|
|
return this.post(`/api/workspaces/${workspaceSlug}/views/`, data)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async update(workspaceSlug: string, viewId: string, data: Partial<TView>): Promise<TView> {
|
|
|
|
return this.patch(`/api/workspaces/${workspaceSlug}/views/${viewId}/`, data)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async remove(workspaceSlug: string, viewId: string): Promise<void> {
|
|
|
|
return this.delete(`/api/workspaces/${workspaceSlug}/views/${viewId}/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async lock(workspaceSlug: string, viewId: string): Promise<TView> {
|
|
|
|
return this.post(`/api/workspaces/${workspaceSlug}/views/${viewId}/lock/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async unlock(workspaceSlug: string, viewId: string): Promise<TView> {
|
2024-02-02 08:22:38 +00:00
|
|
|
return this.delete(`/api/workspaces/${workspaceSlug}/views/${viewId}/lock/`)
|
2024-01-30 08:56:59 +00:00
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async duplicate(workspaceSlug: string, viewId: string): Promise<TView> {
|
|
|
|
return this.post(`/api/workspaces/${workspaceSlug}/views/${viewId}/duplicate/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
2024-01-30 11:15:14 +00:00
|
|
|
|
|
|
|
async makeFavorite(workspaceSlug: string, viewId: string): Promise<TView> {
|
|
|
|
return this.post(`/api/workspaces/${workspaceSlug}/views/${viewId}/favorite/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async removeFavorite(workspaceSlug: string, viewId: string): Promise<TView> {
|
2024-02-02 08:22:38 +00:00
|
|
|
return this.delete(`/api/workspaces/${workspaceSlug}/views/${viewId}/favorite/`)
|
2024-01-30 11:15:14 +00:00
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
2024-01-30 08:56:59 +00:00
|
|
|
}
|