plane/web/services/dashboard.service.ts
Bavisetti Narayan c9337d4a41 feat: dashboard widgets (#3362)
* fix: created dashboard, widgets and dashboard widget model

* fix: new user home dashboard

* chore: recent projects list

* chore: recent collaborators

* chore: priority order change

* chore: payload changes

* chore: collaborator's active issue count

* chore: all dashboard widgets added with services and typs

* chore: centered metric for pie chart

* chore: widget filters

* chore: created issue filter

* fix: created and assigned issues payload change

* chore: created issue payload change

* fix: date filter change

* chore: implement filters

* fix: added expansion fields

* fix: changed issue structure with relation

* chore: new issues response

* fix: project member fix

* chore: updated issue_relation structure

* chore: code cleanup

* chore: update issues response and added empty states

* fix: button text wrap

* chore: update empty state messages

* fix: filters

* chore: update dark mode empty states

* build-error: Type check in the issue relation service

* fix: issues redirection

* fix: project empty state

* chore: project member active check

* chore: project member check in state and priority

* chore: remove console logs and replace harcoded values with constants

* fix: code refactoring

* fix: key name changed

* refactor: mapping through similar components using an array

* fix: build errors

---------

Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
Co-authored-by: gurusainath <gurusainath007@gmail.com>
2024-01-22 13:22:09 +05:30

54 lines
1.6 KiB
TypeScript

import { APIService } from "services/api.service";
// helpers
import { API_BASE_URL } from "helpers/common.helper";
// types
import { THomeDashboardResponse, TWidget, TWidgetStatsResponse, TWidgetStatsRequestParams } from "@plane/types";
export class DashboardService extends APIService {
constructor() {
super(API_BASE_URL);
}
async getHomeDashboardWidgets(workspaceSlug: string): Promise<THomeDashboardResponse> {
return this.get(`/api/workspaces/${workspaceSlug}/dashboard/`, {
params: {
dashboard_type: "home",
},
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async getWidgetStats(
workspaceSlug: string,
dashboardId: string,
params: TWidgetStatsRequestParams
): Promise<TWidgetStatsResponse> {
return this.get(`/api/workspaces/${workspaceSlug}/dashboard/${dashboardId}/`, {
params,
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async getDashboardDetails(dashboardId: string): Promise<TWidgetStatsResponse> {
return this.get(`/api/dashboard/${dashboardId}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async updateDashboardWidget(dashboardId: string, widgetId: string, data: Partial<TWidget>): Promise<TWidget> {
return this.patch(`/api/dashboard/${dashboardId}/widgets/${widgetId}/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}