mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
refactor(kubernetes): move react codebase [EE-3349] (#7953)
This commit is contained in:
parent
2868da296a
commit
77c29ff87e
33 changed files with 18 additions and 21 deletions
23
app/react/kubernetes/services/kubeconfig.service.ts
Normal file
23
app/react/kubernetes/services/kubeconfig.service.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { saveAs } from 'file-saver';
|
||||
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
const baseUrl = 'kubernetes';
|
||||
|
||||
export async function downloadKubeconfigFile(environmentIds: EnvironmentId[]) {
|
||||
try {
|
||||
const { headers, data } = await axios.get<Blob>(`${baseUrl}/config`, {
|
||||
params: { ids: JSON.stringify(environmentIds) },
|
||||
responseType: 'blob',
|
||||
headers: {
|
||||
Accept: 'text/yaml',
|
||||
},
|
||||
});
|
||||
const contentDispositionHeader = headers['content-disposition'];
|
||||
const filename = contentDispositionHeader.replace('attachment;', '').trim();
|
||||
saveAs(data, filename);
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error, '');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue