mirror of
https://github.com/makeplane/plane.git
synced 2025-12-24 15:49:36 +01:00
* [WEB-5134] refactor: update `web` ESLint configuration and refactor imports to use type imports - Enhanced ESLint configuration by adding new rules for import consistency and type imports. - Refactored multiple files to replace regular imports with type imports for better clarity and performance. - Ensured consistent use of type imports across the application to align with TypeScript best practices. * refactor: standardize type imports across components - Updated multiple files to replace regular imports with type imports for improved clarity and consistency. - Ensured adherence to TypeScript best practices in the rich filters and issue layouts components.
107 lines
2.7 KiB
TypeScript
107 lines
2.7 KiB
TypeScript
// plane imports
|
|
import { API_BASE_URL } from "@plane/constants";
|
|
import type {
|
|
IAnalyticsResponse,
|
|
TAnalyticsTabsBase,
|
|
TAnalyticsGraphsBase,
|
|
TAnalyticsFilterParams,
|
|
} from "@plane/types";
|
|
// services
|
|
import { APIService } from "./api.service";
|
|
|
|
export class AnalyticsService extends APIService {
|
|
constructor() {
|
|
super(API_BASE_URL);
|
|
}
|
|
|
|
async getAdvanceAnalytics<T extends IAnalyticsResponse>(
|
|
workspaceSlug: string,
|
|
tab: TAnalyticsTabsBase,
|
|
params?: TAnalyticsFilterParams,
|
|
isPeekView?: boolean
|
|
): Promise<T> {
|
|
return this.get(this.processUrl<TAnalyticsTabsBase>("advance-analytics", workspaceSlug, tab, params, isPeekView), {
|
|
params: {
|
|
tab,
|
|
...params,
|
|
},
|
|
})
|
|
.then((res) => res?.data)
|
|
.catch((err) => {
|
|
throw err?.response?.data;
|
|
});
|
|
}
|
|
|
|
async getAdvanceAnalyticsStats<T>(
|
|
workspaceSlug: string,
|
|
tab: Exclude<TAnalyticsTabsBase, "overview">,
|
|
params?: TAnalyticsFilterParams,
|
|
isPeekView?: boolean
|
|
): Promise<T> {
|
|
const processedUrl = this.processUrl<Exclude<TAnalyticsTabsBase, "overview">>(
|
|
"advance-analytics-stats",
|
|
workspaceSlug,
|
|
tab,
|
|
params,
|
|
isPeekView
|
|
);
|
|
return this.get(processedUrl, {
|
|
params: {
|
|
type: tab,
|
|
...params,
|
|
},
|
|
})
|
|
.then((res) => res?.data)
|
|
.catch((err) => {
|
|
throw err?.response?.data;
|
|
});
|
|
}
|
|
|
|
async getAdvanceAnalyticsCharts<T>(
|
|
workspaceSlug: string,
|
|
tab: TAnalyticsGraphsBase,
|
|
params?: TAnalyticsFilterParams,
|
|
isPeekView?: boolean
|
|
): Promise<T> {
|
|
const processedUrl = this.processUrl<TAnalyticsGraphsBase>(
|
|
"advance-analytics-charts",
|
|
workspaceSlug,
|
|
tab,
|
|
params,
|
|
isPeekView
|
|
);
|
|
return this.get(processedUrl, {
|
|
params: {
|
|
type: tab,
|
|
...params,
|
|
},
|
|
})
|
|
.then((res) => res?.data)
|
|
.catch((err) => {
|
|
throw err?.response?.data;
|
|
});
|
|
}
|
|
|
|
processUrl<T extends string>(
|
|
endpoint: string,
|
|
workspaceSlug: string,
|
|
tab: TAnalyticsGraphsBase | TAnalyticsTabsBase,
|
|
params?: TAnalyticsFilterParams,
|
|
isPeekView?: boolean
|
|
) {
|
|
let processedUrl = `/api/workspaces/${workspaceSlug}`;
|
|
if (isPeekView && (tab === "work-items" || tab === "custom-work-items")) {
|
|
const projectIds = params?.project_ids;
|
|
if (typeof projectIds !== "string" || !projectIds.trim()) {
|
|
throw new Error("project_ids parameter is required for peek view of work items");
|
|
}
|
|
const projectId = projectIds.split(",")[0];
|
|
if (!projectId) {
|
|
throw new Error("Invalid project_ids format - no project ID found");
|
|
}
|
|
processedUrl += `/projects/${projectId}`;
|
|
}
|
|
return `${processedUrl}/${endpoint}`;
|
|
}
|
|
}
|