Skip to content

Commit d61956f

Browse files
authored
Enable download for endpoint logs (#975)
* feat(EndpointLogs): update styles and add placeholder - Change select width to utility class - Add placeholder paragraph in logs section * fix(EndpointLogs): update class binding for select - Add ! to width class - Ensure proper styling behavior * feat(endpoint-logs): add log download feature - Added download button for logs - Implemented log download functionality - Updated English and Chinese translations
1 parent 7dfd607 commit d61956f

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

frontend/src/components/endpoints/EndpointLogs.vue

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
<template>
22
<div class="my-[16px]">
3-
<el-select
4-
v-model="currentInstance"
5-
placeholder="Select"
6-
style="width: 240px"
7-
@change="refreshInstanceLogs"
8-
>
9-
<el-option
10-
v-for="instance in instances"
11-
:key="instance.name"
12-
:label="instance.name"
13-
:value="instance.name"
14-
/>
15-
</el-select>
3+
<div class="flex justify-between items-center">
4+
<el-select
5+
v-model="currentInstance"
6+
placeholder="Select"
7+
class="!w-[240px] mb-1"
8+
@change="refreshInstanceLogs"
9+
>
10+
<el-option
11+
v-for="instance in instances"
12+
:key="instance.name"
13+
:label="instance.name"
14+
:value="instance.name"
15+
/>
16+
</el-select>
17+
<div class="cursor-pointer text-xs px-4 text-brand-700 font-normal" @click="downloadLog">
18+
{{ $t('endpoints.logDownload') }}
19+
</div>
20+
</div>
1621
<div
1722
class="h-[80vh] border bg-gray-800 p-6 rounded-xl text-white overflow-scroll"
1823
ref="instanceLogDiv"
1924
>
25+
<p>...</p>
2026
</div>
2127
</div>
2228
</template>
@@ -126,6 +132,24 @@
126132
}
127133
}
128134
135+
const downloadLog = () => {
136+
const targetDiv = instanceLogDiv;
137+
if (!targetDiv.value) return;
138+
139+
const logElements = targetDiv.value.querySelectorAll('p');
140+
let logContent = '';
141+
logElements.forEach((element) => {
142+
logContent += element.textContent + '\n';
143+
});
144+
145+
const blob = new Blob([logContent], { type: 'text/plain' });
146+
const link = document.createElement('a');
147+
link.href = URL.createObjectURL(blob);
148+
link.download = 'inference_deploy_log.txt'
149+
link.click();
150+
URL.revokeObjectURL(link.href);
151+
};
152+
129153
const refreshInstanceLogs = (value) => {
130154
syncInstanceLogs(value)
131155
}

frontend/src/locales/en_js/endpoints.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export const endpoints = {
33
resourceType: 'Resource Type',
44
replica: "Replica",
55
summary: 'Overview',
6+
logDownload: 'Download Logs',
67
detail: {
78
endpointUrl: 'Inference Endpoint URL',
89
modelId: 'Model ID',

frontend/src/locales/zh_js/endpoints.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export const endpoints = {
33
resourceType: '资源类型',
44
replica: "弹性副本",
55
summary: '概览',
6+
logDownload: '下载日志',
67
detail: {
78
endpointUrl: '专属实例 URL',
89
modelId: '模型 ID',

0 commit comments

Comments
 (0)