Files
orion-visor/orion-visor-ui/src/api/asset/host-sftp.ts

98 lines
2.3 KiB
TypeScript
Raw Normal View History

2024-03-05 18:07:26 +08:00
import type { DataGrid, Pagination } from '@/types/global';
import type { TableData } from '@arco-design/web-vue/es/table/interface';
2024-06-04 20:01:05 +08:00
import { httpBaseUrl } from '@/utils/env';
2024-03-05 18:07:26 +08:00
import axios from 'axios';
import qs from 'query-string';
/**
* SFTP
*/
export interface HostSftpLogQueryRequest extends Pagination {
userId?: number;
hostId?: number;
type?: string;
result?: number;
startTimeRange?: string[];
}
/**
* SFTP
*/
export interface HostSftpLogQueryResponse extends TableData {
id: number;
userId: number;
username: number;
hostId: number;
hostName: string;
hostAddress: string;
address: string;
location: string;
userAgent: string;
paths: string[];
type: string;
result: string;
startTime: number;
extra: HostSftpLogExtra;
}
/**
* SFTP
*/
export interface HostSftpLogExtra {
mod: number;
target: string;
maxCount: number;
2024-03-05 18:07:26 +08:00
}
/**
* SFTP
*/
export function getHostSftpLogPage(request: HostSftpLogQueryRequest) {
2024-06-04 20:01:05 +08:00
return axios.post<DataGrid<HostSftpLogQueryResponse>>('/asset/host-sftp/query-log', request);
2024-03-05 18:07:26 +08:00
}
/**
* SFTP
*/
export function deleteHostSftpLog(idList: Array<number>) {
2024-06-04 20:01:05 +08:00
return axios.delete('/asset/host-sftp/delete-log', {
2024-03-05 18:07:26 +08:00
params: { idList },
paramsSerializer: params => {
return qs.stringify(params, { arrayFormat: 'comma' });
}
});
}
2024-06-04 20:01:05 +08:00
2024-10-10 23:18:53 +08:00
/**
* SFTP
*/
export function getSftpFileContent(token: string) {
return axios.get<string>('/asset/host-sftp/get-content', {
unwrap: true,
params: { token },
timeout: 60000
});
}
/**
* SFTP
*/
export function setSftpFileContent(token: string, content: string) {
const formData = new FormData();
formData.append('token', token);
formData.append('file', new File([content], Date.now() + '', { type: 'text/plain' }));
return axios.post<boolean>('/asset/host-sftp/set-content', formData, {
timeout: 60000,
headers: {
'Content-Type': 'multipart/form-data'
}
});
}
2024-06-04 20:01:05 +08:00
/**
*
*/
2024-06-11 12:31:16 +08:00
export function getDownloadTransferUrl(channelId: string, transferToken: string) {
return `${httpBaseUrl}/asset/host-sftp/download?channelId=${channelId}&transferToken=${transferToken}`;
2024-06-04 20:01:05 +08:00
}