mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
fix: 容器日志接口文档修改 (#1372)
This commit is contained in:
parent
8808e1b0c3
commit
20dbd6c181
@ -307,6 +307,15 @@ func (b *BaseApi) Inspect(c *gin.Context) {
|
|||||||
helper.SuccessWithData(c, result)
|
helper.SuccessWithData(c, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Tags Container
|
||||||
|
// @Summary Container logs
|
||||||
|
// @Description 容器日志
|
||||||
|
// @Param container query string false "容器名称"
|
||||||
|
// @Param since query string false "时间筛选"
|
||||||
|
// @Param follow query string false "是否追踪"
|
||||||
|
// @Param tail query string false "显示行号"
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Router /containers/search/log [post]
|
||||||
func (b *BaseApi) ContainerLogs(c *gin.Context) {
|
func (b *BaseApi) ContainerLogs(c *gin.Context) {
|
||||||
wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
|
wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -354,9 +353,9 @@ func (u *ContainerService) ContainerLogs(wsConn *websocket.Conn, container, sinc
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
reader := bufio.NewReader(stdout)
|
buffer := make([]byte, 1024)
|
||||||
for {
|
for {
|
||||||
bytes, err := reader.ReadBytes('\n')
|
n, err := stdout.Read(buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
break
|
break
|
||||||
@ -364,7 +363,7 @@ func (u *ContainerService) ContainerLogs(wsConn *websocket.Conn, container, sinc
|
|||||||
global.LOG.Errorf("read bytes from container log failed, err: %v", err)
|
global.LOG.Errorf("read bytes from container log failed, err: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err = wsConn.WriteMessage(websocket.TextMessage, bytes); err != nil {
|
if err = wsConn.WriteMessage(websocket.TextMessage, buffer[:n]); err != nil {
|
||||||
global.LOG.Errorf("send message with container log to ws failed, err: %v", err)
|
global.LOG.Errorf("send message with container log to ws failed, err: %v", err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -490,8 +490,8 @@ var doc = `{
|
|||||||
"installId",
|
"installId",
|
||||||
"operate"
|
"operate"
|
||||||
],
|
],
|
||||||
"formatEN": "[appKey] App [appName] [operate]",
|
"formatEN": "[operate] App [appKey][appName]",
|
||||||
"formatZH": "[appKey] 应用 [appName] [operate]",
|
"formatZH": "[operate] 应用 [appKey][appName]",
|
||||||
"paramKeys": []
|
"paramKeys": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2327,32 +2327,37 @@ var doc = `{
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "容器日志",
|
"description": "容器日志",
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"Container"
|
"Container"
|
||||||
],
|
],
|
||||||
"summary": "Container logs",
|
"summary": "Container logs",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "request",
|
"type": "string",
|
||||||
"name": "request",
|
"description": "容器名称",
|
||||||
"in": "body",
|
"name": "container",
|
||||||
"required": true,
|
"in": "query"
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/definitions/dto.ContainerLog"
|
{
|
||||||
}
|
"type": "string",
|
||||||
|
"description": "时间筛选",
|
||||||
|
"name": "since",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "是否追踪",
|
||||||
|
"name": "follow",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "显示行号",
|
||||||
|
"name": "tail",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {}
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/containers/stats/:id": {
|
"/containers/stats/:id": {
|
||||||
@ -10635,21 +10640,6 @@ var doc = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dto.ContainerLog": {
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"containerID",
|
|
||||||
"mode"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"containerID": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"mode": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dto.ContainerOperation": {
|
"dto.ContainerOperation": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@ -10825,8 +10815,8 @@ var doc = `{
|
|||||||
},
|
},
|
||||||
"week": {
|
"week": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"maximum": 7,
|
"maximum": 6,
|
||||||
"minimum": 1
|
"minimum": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -10904,8 +10894,8 @@ var doc = `{
|
|||||||
},
|
},
|
||||||
"week": {
|
"week": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"maximum": 7,
|
"maximum": 6,
|
||||||
"minimum": 1
|
"minimum": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -12347,10 +12337,10 @@ var doc = `{
|
|||||||
"dto.SSHHistory": {
|
"dto.SSHHistory": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"Area": {
|
"address": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"address": {
|
"area": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"authMode": {
|
"authMode": {
|
||||||
|
@ -476,8 +476,8 @@
|
|||||||
"installId",
|
"installId",
|
||||||
"operate"
|
"operate"
|
||||||
],
|
],
|
||||||
"formatEN": "[appKey] App [appName] [operate]",
|
"formatEN": "[operate] App [appKey][appName]",
|
||||||
"formatZH": "[appKey] 应用 [appName] [operate]",
|
"formatZH": "[operate] 应用 [appKey][appName]",
|
||||||
"paramKeys": []
|
"paramKeys": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2313,32 +2313,37 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "容器日志",
|
"description": "容器日志",
|
||||||
"consumes": [
|
|
||||||
"application/json"
|
|
||||||
],
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"Container"
|
"Container"
|
||||||
],
|
],
|
||||||
"summary": "Container logs",
|
"summary": "Container logs",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "request",
|
"type": "string",
|
||||||
"name": "request",
|
"description": "容器名称",
|
||||||
"in": "body",
|
"name": "container",
|
||||||
"required": true,
|
"in": "query"
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/definitions/dto.ContainerLog"
|
{
|
||||||
}
|
"type": "string",
|
||||||
|
"description": "时间筛选",
|
||||||
|
"name": "since",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "是否追踪",
|
||||||
|
"name": "follow",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "显示行号",
|
||||||
|
"name": "tail",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {}
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/containers/stats/:id": {
|
"/containers/stats/:id": {
|
||||||
@ -10621,21 +10626,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dto.ContainerLog": {
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"containerID",
|
|
||||||
"mode"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"containerID": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"mode": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dto.ContainerOperation": {
|
"dto.ContainerOperation": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@ -10811,8 +10801,8 @@
|
|||||||
},
|
},
|
||||||
"week": {
|
"week": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"maximum": 7,
|
"maximum": 6,
|
||||||
"minimum": 1
|
"minimum": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -10890,8 +10880,8 @@
|
|||||||
},
|
},
|
||||||
"week": {
|
"week": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"maximum": 7,
|
"maximum": 6,
|
||||||
"minimum": 1
|
"minimum": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -12333,10 +12323,10 @@
|
|||||||
"dto.SSHHistory": {
|
"dto.SSHHistory": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"Area": {
|
"address": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"address": {
|
"area": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"authMode": {
|
"authMode": {
|
||||||
|
@ -290,16 +290,6 @@ definitions:
|
|||||||
$ref: '#/definitions/dto.VolumeHelper'
|
$ref: '#/definitions/dto.VolumeHelper'
|
||||||
type: array
|
type: array
|
||||||
type: object
|
type: object
|
||||||
dto.ContainerLog:
|
|
||||||
properties:
|
|
||||||
containerID:
|
|
||||||
type: string
|
|
||||||
mode:
|
|
||||||
type: string
|
|
||||||
required:
|
|
||||||
- containerID
|
|
||||||
- mode
|
|
||||||
type: object
|
|
||||||
dto.ContainerOperation:
|
dto.ContainerOperation:
|
||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
@ -415,8 +405,8 @@ definitions:
|
|||||||
website:
|
website:
|
||||||
type: string
|
type: string
|
||||||
week:
|
week:
|
||||||
maximum: 7
|
maximum: 6
|
||||||
minimum: 1
|
minimum: 0
|
||||||
type: integer
|
type: integer
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
@ -469,8 +459,8 @@ definitions:
|
|||||||
website:
|
website:
|
||||||
type: string
|
type: string
|
||||||
week:
|
week:
|
||||||
maximum: 7
|
maximum: 6
|
||||||
minimum: 1
|
minimum: 0
|
||||||
type: integer
|
type: integer
|
||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
@ -1437,10 +1427,10 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
dto.SSHHistory:
|
dto.SSHHistory:
|
||||||
properties:
|
properties:
|
||||||
Area:
|
|
||||||
type: string
|
|
||||||
address:
|
address:
|
||||||
type: string
|
type: string
|
||||||
|
area:
|
||||||
|
type: string
|
||||||
authMode:
|
authMode:
|
||||||
type: string
|
type: string
|
||||||
date:
|
date:
|
||||||
@ -3670,8 +3660,8 @@ paths:
|
|||||||
bodyKeys:
|
bodyKeys:
|
||||||
- installId
|
- installId
|
||||||
- operate
|
- operate
|
||||||
formatEN: '[appKey] App [appName] [operate]'
|
formatEN: '[operate] App [appKey][appName]'
|
||||||
formatZH: '[appKey] 应用 [appName] [operate]'
|
formatZH: '[operate] 应用 [appKey][appName]'
|
||||||
paramKeys: []
|
paramKeys: []
|
||||||
/apps/installed/params/:appInstallId:
|
/apps/installed/params/:appInstallId:
|
||||||
get:
|
get:
|
||||||
@ -4836,21 +4826,25 @@ paths:
|
|||||||
- Container
|
- Container
|
||||||
/containers/search/log:
|
/containers/search/log:
|
||||||
post:
|
post:
|
||||||
consumes:
|
|
||||||
- application/json
|
|
||||||
description: 容器日志
|
description: 容器日志
|
||||||
parameters:
|
parameters:
|
||||||
- description: request
|
- description: 容器名称
|
||||||
in: body
|
in: query
|
||||||
name: request
|
name: container
|
||||||
required: true
|
type: string
|
||||||
schema:
|
- description: 时间筛选
|
||||||
$ref: '#/definitions/dto.ContainerLog'
|
in: query
|
||||||
responses:
|
name: since
|
||||||
"200":
|
type: string
|
||||||
description: OK
|
- description: 是否追踪
|
||||||
schema:
|
in: query
|
||||||
type: string
|
name: follow
|
||||||
|
type: string
|
||||||
|
- description: 显示行号
|
||||||
|
in: query
|
||||||
|
name: tail
|
||||||
|
type: string
|
||||||
|
responses: {}
|
||||||
security:
|
security:
|
||||||
- ApiKeyAuth: []
|
- ApiKeyAuth: []
|
||||||
summary: Container logs
|
summary: Container logs
|
||||||
|
@ -61,10 +61,6 @@ export namespace Container {
|
|||||||
networkTX: number;
|
networkTX: number;
|
||||||
shotTime: Date;
|
shotTime: Date;
|
||||||
}
|
}
|
||||||
export interface ContainerLogSearch {
|
|
||||||
containerID: string;
|
|
||||||
mode: string;
|
|
||||||
}
|
|
||||||
export interface ContainerInspect {
|
export interface ContainerInspect {
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
@ -8,9 +8,6 @@ export const searchContainer = (params: Container.ContainerSearch) => {
|
|||||||
export const createContainer = (params: Container.ContainerCreate) => {
|
export const createContainer = (params: Container.ContainerCreate) => {
|
||||||
return http.post(`/containers`, params, 3000000);
|
return http.post(`/containers`, params, 3000000);
|
||||||
};
|
};
|
||||||
export const logContainer = (params: Container.ContainerLogSearch) => {
|
|
||||||
return http.post<string>(`/containers/search/log`, params, 400000);
|
|
||||||
};
|
|
||||||
export const cleanContainerLog = (containerName: string) => {
|
export const cleanContainerLog = (containerName: string) => {
|
||||||
return http.post(`/containers/clean/log`, { name: containerName });
|
return http.post(`/containers/clean/log`, { name: containerName });
|
||||||
};
|
};
|
||||||
|
@ -2,8 +2,19 @@
|
|||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<el-select @change="searchLogs" style="width: 10%; float: left" v-model="logSearch.mode">
|
<el-select @change="searchLogs" style="width: 10%; float: left" v-model="logSearch.mode">
|
||||||
|
<template #prefix>{{ $t('container.fetch') }}</template>
|
||||||
<el-option v-for="item in timeOptions" :key="item.label" :value="item.value" :label="item.label" />
|
<el-option v-for="item in timeOptions" :key="item.label" :value="item.value" :label="item.label" />
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<el-input
|
||||||
|
@change="searchLogs"
|
||||||
|
class="margin-button"
|
||||||
|
style="width: 10%; float: left"
|
||||||
|
v-model.number="logSearch.tail"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<div style="margin-left: 2px">{{ $t('container.lines') }}</div>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
<div class="margin-button" style="float: left">
|
<div class="margin-button" style="float: left">
|
||||||
<el-checkbox border v-model="logSearch.isWatch">{{ $t('commons.button.watch') }}</el-checkbox>
|
<el-checkbox border v-model="logSearch.isWatch">{{ $t('commons.button.watch') }}</el-checkbox>
|
||||||
</div>
|
</div>
|
||||||
@ -34,14 +45,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { cleanContainerLog, logContainer } from '@/api/modules/container';
|
import { cleanContainerLog } from '@/api/modules/container';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { dateFormatForName } from '@/utils/util';
|
import { dateFormatForName } from '@/utils/util';
|
||||||
import { nextTick, onBeforeUnmount, reactive, ref, shallowRef } from 'vue';
|
import { onBeforeUnmount, reactive, ref, shallowRef } from 'vue';
|
||||||
import { Codemirror } from 'vue-codemirror';
|
import { Codemirror } from 'vue-codemirror';
|
||||||
import { javascript } from '@codemirror/lang-javascript';
|
import { javascript } from '@codemirror/lang-javascript';
|
||||||
import { oneDark } from '@codemirror/theme-one-dark';
|
import { oneDark } from '@codemirror/theme-one-dark';
|
||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||||
|
|
||||||
const extensions = [javascript(), oneDark];
|
const extensions = [javascript(), oneDark];
|
||||||
|
|
||||||
@ -50,14 +61,15 @@ const view = shallowRef();
|
|||||||
const handleReady = (payload) => {
|
const handleReady = (payload) => {
|
||||||
view.value = payload.view;
|
view.value = payload.view;
|
||||||
};
|
};
|
||||||
|
const terminalSocket = ref<WebSocket>();
|
||||||
|
|
||||||
const logSearch = reactive({
|
const logSearch = reactive({
|
||||||
isWatch: false,
|
isWatch: false,
|
||||||
container: '',
|
container: '',
|
||||||
containerID: '',
|
containerID: '',
|
||||||
mode: 'all',
|
mode: 'all',
|
||||||
|
tail: 100,
|
||||||
});
|
});
|
||||||
let timer: NodeJS.Timer | null = null;
|
|
||||||
|
|
||||||
const timeOptions = ref([
|
const timeOptions = ref([
|
||||||
{ label: i18n.global.t('container.all'), value: 'all' },
|
{ label: i18n.global.t('container.all'), value: 'all' },
|
||||||
@ -80,15 +92,26 @@ const timeOptions = ref([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const searchLogs = async () => {
|
const searchLogs = async () => {
|
||||||
const res = await logContainer(logSearch);
|
if (!Number(logSearch.tail) || Number(logSearch.tail) <= 0) {
|
||||||
logInfo.value = res.data || '';
|
MsgError(i18n.global.t('container.linesHelper'));
|
||||||
nextTick(() => {
|
return;
|
||||||
|
}
|
||||||
|
terminalSocket.value?.close();
|
||||||
|
logInfo.value = '';
|
||||||
|
const href = window.location.href;
|
||||||
|
const protocol = href.split('//')[0] === 'http:' ? 'ws' : 'wss';
|
||||||
|
const host = href.split('//')[1].split('/')[0];
|
||||||
|
terminalSocket.value = new WebSocket(
|
||||||
|
`${protocol}://${host}/api/v1/containers/search/log?container=${logSearch.containerID}&since=${logSearch.mode}&tail=${logSearch.tail}&follow=${logSearch.isWatch}`,
|
||||||
|
);
|
||||||
|
terminalSocket.value.onmessage = (event) => {
|
||||||
|
logInfo.value += event.data;
|
||||||
const state = view.value.state;
|
const state = view.value.state;
|
||||||
view.value.dispatch({
|
view.value.dispatch({
|
||||||
selection: { anchor: state.doc.length, head: state.doc.length },
|
selection: { anchor: state.doc.length, head: state.doc.length },
|
||||||
scrollIntoView: true,
|
scrollIntoView: true,
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDownload = async () => {
|
const onDownload = async () => {
|
||||||
@ -108,15 +131,11 @@ interface DialogProps {
|
|||||||
|
|
||||||
const acceptParams = (props: DialogProps): void => {
|
const acceptParams = (props: DialogProps): void => {
|
||||||
logSearch.containerID = props.containerID;
|
logSearch.containerID = props.containerID;
|
||||||
|
logSearch.tail = 100;
|
||||||
logSearch.mode = 'all';
|
logSearch.mode = 'all';
|
||||||
logSearch.isWatch = false;
|
logSearch.isWatch = false;
|
||||||
logSearch.container = props.container;
|
logSearch.container = props.container;
|
||||||
searchLogs();
|
searchLogs();
|
||||||
timer = setInterval(() => {
|
|
||||||
if (logSearch.isWatch) {
|
|
||||||
searchLogs();
|
|
||||||
}
|
|
||||||
}, 1000 * 5);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClean = async () => {
|
const onClean = async () => {
|
||||||
@ -132,8 +151,7 @@ const onClean = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
clearInterval(Number(timer));
|
terminalSocket.value?.close();
|
||||||
timer = null;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
@ -136,7 +136,7 @@ watch(logVisiable, (val) => {
|
|||||||
});
|
});
|
||||||
const searchLogs = async () => {
|
const searchLogs = async () => {
|
||||||
if (!Number(logSearch.tail) || Number(logSearch.tail) <= 0) {
|
if (!Number(logSearch.tail) || Number(logSearch.tail) <= 0) {
|
||||||
MsgError(global.i18n.$t('container.linesHelper'));
|
MsgError(i18n.global.t('container.linesHelper'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
terminalSocket.value?.close();
|
terminalSocket.value?.close();
|
||||||
@ -145,7 +145,7 @@ const searchLogs = async () => {
|
|||||||
const protocol = href.split('//')[0] === 'http:' ? 'ws' : 'wss';
|
const protocol = href.split('//')[0] === 'http:' ? 'ws' : 'wss';
|
||||||
const host = href.split('//')[1].split('/')[0];
|
const host = href.split('//')[1].split('/')[0];
|
||||||
terminalSocket.value = new WebSocket(
|
terminalSocket.value = new WebSocket(
|
||||||
`${protocol}://${host}/containers/search/log?container=${logSearch.containerID}&since=${logSearch.mode}&tail=${logSearch.tail}&follow=${logSearch.isWatch}`,
|
`${protocol}://${host}/api/v1/containers/search/log?container=${logSearch.containerID}&since=${logSearch.mode}&tail=${logSearch.tail}&follow=${logSearch.isWatch}`,
|
||||||
);
|
);
|
||||||
terminalSocket.value.onmessage = (event) => {
|
terminalSocket.value.onmessage = (event) => {
|
||||||
logInfo.value += event.data;
|
logInfo.value += event.data;
|
||||||
@ -188,7 +188,7 @@ const acceptParams = (props: DialogProps): void => {
|
|||||||
logVisiable.value = true;
|
logVisiable.value = true;
|
||||||
logSearch.containerID = props.containerID;
|
logSearch.containerID = props.containerID;
|
||||||
logSearch.tail = 100;
|
logSearch.tail = 100;
|
||||||
logSearch.mode = '10m';
|
logSearch.mode = 'all';
|
||||||
logSearch.isWatch = false;
|
logSearch.isWatch = false;
|
||||||
logSearch.container = props.container;
|
logSearch.container = props.container;
|
||||||
searchLogs();
|
searchLogs();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user