feat: frontend add virtual matrix key
This commit is contained in:
@@ -955,7 +955,13 @@ export class MatrixKeyClient {
|
||||
this.baseUrl = baseUrl ?? "http://localhost:5000";
|
||||
}
|
||||
|
||||
enabelMatrixKey(address: string | undefined, port: number | undefined): Promise<number> {
|
||||
/**
|
||||
* 启用矩阵键控制。
|
||||
* @param address (optional) 设备的IP地址
|
||||
* @param port (optional) 设备的端口号
|
||||
* @return 返回操作结果的状态码
|
||||
*/
|
||||
enabelMatrixKey(address: string | undefined, port: number | undefined): Promise<boolean> {
|
||||
let url_ = this.baseUrl + "/api/MatrixKey/EnabelMatrixKey?";
|
||||
if (address === null)
|
||||
throw new Error("The parameter 'address' cannot be null.");
|
||||
@@ -968,7 +974,7 @@ export class MatrixKeyClient {
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: RequestInit = {
|
||||
method: "GET",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
}
|
||||
@@ -979,7 +985,7 @@ export class MatrixKeyClient {
|
||||
});
|
||||
}
|
||||
|
||||
protected processEnabelMatrixKey(response: Response): Promise<number> {
|
||||
protected processEnabelMatrixKey(response: Response): Promise<boolean> {
|
||||
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) {
|
||||
@@ -1002,10 +1008,16 @@ export class MatrixKeyClient {
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
});
|
||||
}
|
||||
return Promise.resolve<number>(null as any);
|
||||
return Promise.resolve<boolean>(null as any);
|
||||
}
|
||||
|
||||
disableMatrixKey(address: string | undefined, port: number | undefined): Promise<number> {
|
||||
/**
|
||||
* 禁用矩阵键控制。
|
||||
* @param address (optional) 设备的IP地址
|
||||
* @param port (optional) 设备的端口号
|
||||
* @return 返回操作结果的状态码
|
||||
*/
|
||||
disableMatrixKey(address: string | undefined, port: number | undefined): Promise<boolean> {
|
||||
let url_ = this.baseUrl + "/api/MatrixKey/DisableMatrixKey?";
|
||||
if (address === null)
|
||||
throw new Error("The parameter 'address' cannot be null.");
|
||||
@@ -1018,7 +1030,7 @@ export class MatrixKeyClient {
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: RequestInit = {
|
||||
method: "GET",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
}
|
||||
@@ -1029,7 +1041,7 @@ export class MatrixKeyClient {
|
||||
});
|
||||
}
|
||||
|
||||
protected processDisableMatrixKey(response: Response): Promise<number> {
|
||||
protected processDisableMatrixKey(response: Response): Promise<boolean> {
|
||||
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) {
|
||||
@@ -1052,10 +1064,17 @@ export class MatrixKeyClient {
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
});
|
||||
}
|
||||
return Promise.resolve<number>(null as any);
|
||||
return Promise.resolve<boolean>(null as any);
|
||||
}
|
||||
|
||||
setMatrixKeyStatus(address: string | undefined, port: number | undefined, keyStates: boolean[]): Promise<number> {
|
||||
/**
|
||||
* 设置矩阵键的状态。
|
||||
* @param address (optional) 设备的IP地址
|
||||
* @param port (optional) 设备的端口号
|
||||
* @param keyStates 矩阵键的状态数组,长度应为16
|
||||
* @return 返回操作结果的状态码
|
||||
*/
|
||||
setMatrixKeyStatus(address: string | undefined, port: number | undefined, keyStates: boolean[]): Promise<boolean> {
|
||||
let url_ = this.baseUrl + "/api/MatrixKey/SetMatrixKeyStatus?";
|
||||
if (address === null)
|
||||
throw new Error("The parameter 'address' cannot be null.");
|
||||
@@ -1071,7 +1090,7 @@ export class MatrixKeyClient {
|
||||
|
||||
let options_: RequestInit = {
|
||||
body: content_,
|
||||
method: "GET",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json"
|
||||
@@ -1083,7 +1102,7 @@ export class MatrixKeyClient {
|
||||
});
|
||||
}
|
||||
|
||||
protected processSetMatrixKeyStatus(response: Response): Promise<number> {
|
||||
protected processSetMatrixKeyStatus(response: Response): Promise<boolean> {
|
||||
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) {
|
||||
@@ -1106,7 +1125,7 @@ export class MatrixKeyClient {
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
});
|
||||
}
|
||||
return Promise.resolve<number>(null as any);
|
||||
return Promise.resolve<boolean>(null as any);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user