Add admin page for bundle

This commit is contained in:
2025-11-10 11:50:20 +07:00
parent ecf07a7863
commit 0861e9a8d2
18 changed files with 2071 additions and 49 deletions

View File

@@ -368,6 +368,126 @@ export class AccountClient extends AuthorizedApiBase {
}
}
export class AdminClient extends AuthorizedApiBase {
private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
private baseUrl: string;
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
super(configuration);
this.http = http ? http : window as any;
this.baseUrl = baseUrl ?? "http://localhost:5000";
}
admin_GetBundleBacktestRequestsPaginated(page: number | undefined, pageSize: number | undefined, sortBy: BundleBacktestRequestSortableColumn | undefined, sortOrder: string | null | undefined, nameContains: string | null | undefined, status: BundleBacktestRequestStatus | null | undefined, userId: number | null | undefined, userNameContains: string | null | undefined, totalBacktestsMin: number | null | undefined, totalBacktestsMax: number | null | undefined, completedBacktestsMin: number | null | undefined, completedBacktestsMax: number | null | undefined, progressPercentageMin: number | null | undefined, progressPercentageMax: number | null | undefined, createdAtFrom: Date | null | undefined, createdAtTo: Date | null | undefined): Promise<PaginatedBundleBacktestRequestsResponse> {
let url_ = this.baseUrl + "/Admin/BundleBacktestRequests/Paginated?";
if (page === null)
throw new Error("The parameter 'page' cannot be null.");
else if (page !== undefined)
url_ += "page=" + encodeURIComponent("" + page) + "&";
if (pageSize === null)
throw new Error("The parameter 'pageSize' cannot be null.");
else if (pageSize !== undefined)
url_ += "pageSize=" + encodeURIComponent("" + pageSize) + "&";
if (sortBy === null)
throw new Error("The parameter 'sortBy' cannot be null.");
else if (sortBy !== undefined)
url_ += "sortBy=" + encodeURIComponent("" + sortBy) + "&";
if (sortOrder !== undefined && sortOrder !== null)
url_ += "sortOrder=" + encodeURIComponent("" + sortOrder) + "&";
if (nameContains !== undefined && nameContains !== null)
url_ += "nameContains=" + encodeURIComponent("" + nameContains) + "&";
if (status !== undefined && status !== null)
url_ += "status=" + encodeURIComponent("" + status) + "&";
if (userId !== undefined && userId !== null)
url_ += "userId=" + encodeURIComponent("" + userId) + "&";
if (userNameContains !== undefined && userNameContains !== null)
url_ += "userNameContains=" + encodeURIComponent("" + userNameContains) + "&";
if (totalBacktestsMin !== undefined && totalBacktestsMin !== null)
url_ += "totalBacktestsMin=" + encodeURIComponent("" + totalBacktestsMin) + "&";
if (totalBacktestsMax !== undefined && totalBacktestsMax !== null)
url_ += "totalBacktestsMax=" + encodeURIComponent("" + totalBacktestsMax) + "&";
if (completedBacktestsMin !== undefined && completedBacktestsMin !== null)
url_ += "completedBacktestsMin=" + encodeURIComponent("" + completedBacktestsMin) + "&";
if (completedBacktestsMax !== undefined && completedBacktestsMax !== null)
url_ += "completedBacktestsMax=" + encodeURIComponent("" + completedBacktestsMax) + "&";
if (progressPercentageMin !== undefined && progressPercentageMin !== null)
url_ += "progressPercentageMin=" + encodeURIComponent("" + progressPercentageMin) + "&";
if (progressPercentageMax !== undefined && progressPercentageMax !== null)
url_ += "progressPercentageMax=" + encodeURIComponent("" + progressPercentageMax) + "&";
if (createdAtFrom !== undefined && createdAtFrom !== null)
url_ += "createdAtFrom=" + encodeURIComponent(createdAtFrom ? "" + createdAtFrom.toISOString() : "") + "&";
if (createdAtTo !== undefined && createdAtTo !== null)
url_ += "createdAtTo=" + encodeURIComponent(createdAtTo ? "" + createdAtTo.toISOString() : "") + "&";
url_ = url_.replace(/[?&]$/, "");
let options_: RequestInit = {
method: "GET",
headers: {
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response: Response) => {
return this.processAdmin_GetBundleBacktestRequestsPaginated(_response);
});
}
protected processAdmin_GetBundleBacktestRequestsPaginated(response: Response): Promise<PaginatedBundleBacktestRequestsResponse> {
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
let result200: any = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as PaginatedBundleBacktestRequestsResponse;
return result200;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<PaginatedBundleBacktestRequestsResponse>(null as any);
}
admin_GetBundleBacktestRequestsSummary(): Promise<BundleBacktestRequestSummaryResponse> {
let url_ = this.baseUrl + "/Admin/BundleBacktestRequests/Summary";
url_ = url_.replace(/[?&]$/, "");
let options_: RequestInit = {
method: "GET",
headers: {
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response: Response) => {
return this.processAdmin_GetBundleBacktestRequestsSummary(_response);
});
}
protected processAdmin_GetBundleBacktestRequestsSummary(response: Response): Promise<BundleBacktestRequestSummaryResponse> {
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
let result200: any = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as BundleBacktestRequestSummaryResponse;
return result200;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<BundleBacktestRequestSummaryResponse>(null as any);
}
}
export class BacktestClient extends AuthorizedApiBase {
private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
private baseUrl: string;
@@ -4501,6 +4621,69 @@ export interface ExchangeInitializedStatus {
isInitialized?: boolean;
}
export interface PaginatedBundleBacktestRequestsResponse {
bundleRequests?: BundleBacktestRequestListItemResponse[];
totalCount?: number;
currentPage?: number;
pageSize?: number;
totalPages?: number;
hasNextPage?: boolean;
hasPreviousPage?: boolean;
}
export interface BundleBacktestRequestListItemResponse {
requestId?: string;
name?: string;
version?: number;
status?: string;
createdAt?: Date;
completedAt?: Date | null;
updatedAt?: Date;
totalBacktests?: number;
completedBacktests?: number;
failedBacktests?: number;
progressPercentage?: number;
userId?: number | null;
userName?: string | null;
errorMessage?: string | null;
currentBacktest?: string | null;
estimatedTimeRemainingSeconds?: number | null;
}
export enum BundleBacktestRequestSortableColumn {
RequestId = "RequestId",
Name = "Name",
Status = "Status",
CreatedAt = "CreatedAt",
CompletedAt = "CompletedAt",
TotalBacktests = "TotalBacktests",
CompletedBacktests = "CompletedBacktests",
FailedBacktests = "FailedBacktests",
ProgressPercentage = "ProgressPercentage",
UserId = "UserId",
UserName = "UserName",
UpdatedAt = "UpdatedAt",
}
export enum BundleBacktestRequestStatus {
Pending = "Pending",
Running = "Running",
Completed = "Completed",
Failed = "Failed",
Cancelled = "Cancelled",
Saved = "Saved",
}
export interface BundleBacktestRequestSummaryResponse {
statusSummary?: BundleBacktestRequestStatusSummary[];
totalRequests?: number;
}
export interface BundleBacktestRequestStatusSummary {
status?: string;
count?: number;
}
export interface Backtest {
id: string;
finalPnl: number;
@@ -4937,15 +5120,7 @@ export interface BundleBacktestRequest {
progressInfo?: string | null;
currentBacktest?: string | null;
estimatedTimeRemainingSeconds?: number | null;
}
export enum BundleBacktestRequestStatus {
Pending = "Pending",
Running = "Running",
Completed = "Completed",
Failed = "Failed",
Cancelled = "Cancelled",
Saved = "Saved",
updatedAt: Date;
}
export interface RunBundleBacktestRequest {