feat(camera): Refactor camera management with new components, update localization keys, and enhance API integration
This commit is contained in:
@@ -145,3 +145,69 @@ export async function apiQueryNodeConfigMessage(
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
export async function apiQueryCamera(
|
||||
dataChanelId: string,
|
||||
authorization: string,
|
||||
params: MasterModel.SearchMessagePaginationBody,
|
||||
) {
|
||||
const resp = await request<MasterModel.CameraV6MessageResponse>(
|
||||
`${API_READER}/${dataChanelId}/messages`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
},
|
||||
params: params,
|
||||
},
|
||||
);
|
||||
|
||||
// Process messages to add string_value_parsed
|
||||
if (resp.messages) {
|
||||
resp.messages = resp.messages.map((message) => {
|
||||
if (message.string_value) {
|
||||
try {
|
||||
message.string_value_parsed = JSON.parse(message.string_value);
|
||||
} catch (error) {
|
||||
console.error('Failed to parse string_value:', error);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
});
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
export async function apiQueryConfigAlarm(
|
||||
dataChanelId: string,
|
||||
authorization: string,
|
||||
params: MasterModel.SearchMessagePaginationBody,
|
||||
) {
|
||||
const resp = await request<MasterModel.AlarmMessageResponse>(
|
||||
`${API_READER}/${dataChanelId}/messages`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
},
|
||||
params: params,
|
||||
},
|
||||
);
|
||||
|
||||
// Process messages to add string_value_parsed
|
||||
if (resp.messages) {
|
||||
resp.messages = resp.messages.map((message) => {
|
||||
if (message.string_value) {
|
||||
try {
|
||||
message.string_value_parsed = JSON.parse(message.string_value);
|
||||
} catch (error) {
|
||||
console.error('Failed to parse string_value:', error);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
});
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
9
src/services/master/typings/log.d.ts
vendored
9
src/services/master/typings/log.d.ts
vendored
@@ -22,6 +22,7 @@ declare namespace MasterModel {
|
||||
// Response types cho từng domain
|
||||
type CameraMessageResponse = MesageReaderResponse<CameraV5>;
|
||||
type CameraV6MessageResponse = MesageReaderResponse<CameraV6>;
|
||||
type AlarmMessageResponse = MesageReaderResponse<Alarm>;
|
||||
type NodeConfigMessageResponse = MesageReaderResponse<NodeConfig[]>;
|
||||
|
||||
type MessageDataType = NodeConfig[] | CameraV5 | CameraV6;
|
||||
@@ -46,7 +47,7 @@ declare namespace MasterModel {
|
||||
cams?: Camera[];
|
||||
}
|
||||
interface CameraV6 extends CameraV5 {
|
||||
record_type?: string;
|
||||
record_type?: 'none' | 'alarm' | 'all';
|
||||
record_alarm_list?: string[];
|
||||
}
|
||||
|
||||
@@ -62,4 +63,10 @@ declare namespace MasterModel {
|
||||
ip?: string;
|
||||
stream?: number;
|
||||
}
|
||||
|
||||
interface Alarm {
|
||||
id: string;
|
||||
type: Type;
|
||||
name: string;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user