feat: cloud options
This commit is contained in:
@@ -1,14 +1,29 @@
|
||||
import { downloadFile } from '@/utils/download-stream';
|
||||
import { request } from '@umijs/max';
|
||||
import { message } from 'antd';
|
||||
import { GPUDeviceItem, ListItem, ModelFile } from '../config/types';
|
||||
|
||||
export const WORKERS_API = '/workers';
|
||||
export const GPU_DEVICES_API = '/gpu-devices';
|
||||
export const MODEL_FILES_API = '/model-files';
|
||||
|
||||
export async function downloadWorkerPrivateKey(id: string | number) {
|
||||
return request(`${WORKERS_API}/${id}/privatekey`, {
|
||||
method: 'GET'
|
||||
});
|
||||
// download stream data and save as a csv file
|
||||
export async function downloadWorkerPrivateKey({
|
||||
id,
|
||||
name
|
||||
}: {
|
||||
id: string | number;
|
||||
name?: string;
|
||||
}) {
|
||||
try {
|
||||
const res = await fetch(`/v1${WORKERS_API}/${id}/privatekey`);
|
||||
if (res.ok) {
|
||||
const blob = await res.blob();
|
||||
downloadFile(blob, `${name}-privatekey.csv`);
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('Download failed');
|
||||
}
|
||||
}
|
||||
|
||||
export async function queryWorkersList<T extends Record<string, any>>(
|
||||
|
||||
@@ -102,7 +102,7 @@ const UpdateLabels: React.FC<ViewModalProps> = (props) => {
|
||||
id: 'resources.table.labels'
|
||||
})}
|
||||
labels={labels}
|
||||
btnText="common.button.addLabel"
|
||||
btnText={intl.formatMessage({ id: 'common.button.addLabel' })}
|
||||
onChange={handleLabelsChange}
|
||||
></LabelSelector>
|
||||
</Form.Item>
|
||||
|
||||
@@ -146,7 +146,10 @@ const Workers: React.FC = () => {
|
||||
handleViewDetail(record);
|
||||
}
|
||||
if (val === 'download_ssh_key') {
|
||||
downloadWorkerPrivateKey(record.id);
|
||||
downloadWorkerPrivateKey({
|
||||
id: record.id,
|
||||
name: record.name
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export const status: any = {
|
||||
[WorkerStatusMap.not_ready]: StatusMaps.error,
|
||||
[WorkerStatusMap.unreachable]: StatusMaps.error,
|
||||
[WorkerStatusMap.provisioning]: StatusMaps.transitioning,
|
||||
[WorkerStatusMap.deleting]: StatusMaps.warning,
|
||||
[WorkerStatusMap.deleting]: StatusMaps.transitioning,
|
||||
[WorkerStatusMap.error]: StatusMaps.error
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user