feat: 后端添加获取空闲实验板,继续修改前端界面使其更加合理

This commit is contained in:
2025-07-12 14:59:28 +08:00
parent 44e357b887
commit 0fb0c4e395
11 changed files with 222 additions and 117 deletions

View File

@@ -649,6 +649,54 @@ export class DataClient {
return Promise.resolve<boolean>(null as any);
}
/**
* 获取一个空闲的实验板(普通用户权限)
*/
getAvailableBoard(): Promise<Board> {
let url_ = this.baseUrl + "/api/Data/GetAvailableBoard";
url_ = url_.replace(/[?&]$/, "");
let options_: RequestInit = {
method: "GET",
headers: {
"Accept": "application/json"
}
};
return this.http.fetch(url_, options_).then((_response: Response) => {
return this.processGetAvailableBoard(_response);
});
}
protected processGetAvailableBoard(response: Response): Promise<Board> {
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;
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result200 = Board.fromJS(resultData200);
return result200;
});
} else if (status === 404) {
return response.text().then((_responseText) => {
let result404: any = null;
let resultData404 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result404 = ProblemDetails.fromJS(resultData404);
return throwException("A server side error occurred.", status, _responseText, _headers, result404);
});
} else if (status === 500) {
return response.text().then((_responseText) => {
return throwException("A server side error occurred.", status, _responseText, _headers);
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<Board>(null as any);
}
/**
* 新增板子(管理员权限)
* @param name (optional)
@@ -2721,13 +2769,13 @@ export class Board implements IBoard {
id!: string;
/** FPGA 板子的名称 */
boardName!: string;
/** [TODO:description] */
/** FPGA 板子的IP地址 */
ipAddr!: string;
/** [TODO:description] */
/** FPGA 板子的通信端口 */
port!: number;
/** [TODO:description] */
/** FPGA 板子的当前状态 */
status!: BoardStatus;
/** [TODO:description] */
/** FPGA 板子的固件版本号 */
firmVersion!: string;
constructor(data?: IBoard) {
@@ -2775,17 +2823,17 @@ export interface IBoard {
id: string;
/** FPGA 板子的名称 */
boardName: string;
/** [TODO:description] */
/** FPGA 板子的IP地址 */
ipAddr: string;
/** [TODO:description] */
/** FPGA 板子的通信端口 */
port: number;
/** [TODO:description] */
/** FPGA 板子的当前状态 */
status: BoardStatus;
/** [TODO:description] */
/** FPGA 板子的固件版本号 */
firmVersion: string;
}
/** [TODO:description] */
/** FPGA 板子状态枚举 */
export enum BoardStatus {
Busy = 0,
Available = 1,