Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft 资源新增 enable_websocket 字段 #871

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/dashboard-front/src/components/resource-detail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@
</div>
</bk-col>
</bk-row> -->

<bk-row :class="{ 'ag-diff': checkDiff('localData.enable_websocket') }">
<bk-col :span="4">
<label class="ag-key">{{ $t("启用 WebSocket") }}:</label>
</bk-col>
<bk-col :span="10">
<div class="ag-value">{{ localData.enable_websocket ? $t("是") : $t("否") }}</div>
</bk-col>
</bk-row>
</bk-container>

<template v-if="localData.proxy?.backend_id">
Expand Down
3 changes: 3 additions & 0 deletions src/dashboard-front/src/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
.mt5 {
margin-top: 5px !important;
}
.mt8 {
margin-top: 8px !important;
}
.mt10 {
margin-top: 10px !important;
}
Expand Down
2 changes: 2 additions & 0 deletions src/dashboard-front/src/language/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,8 @@ const lang: ILANG = {
'文件名需要跟资源名称完全一致才能导入,请检查文件名': ['Filename must matches resource name'],
'已匹配到资源': ['Resource matched'],
'未匹配到资源': ['Resource not matched'],
'启用 WebSocket': ['Enable WebSocket'],
'启用 WebSocket:': ['Enable WebSocket: '],

// 变量的使用 $t('test', { vari1: 1, vari2: 2 })
// // 变量的使用 $t('test', { vari1: 1, vari2: 2 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
</bk-checkbox>
</div>
</bk-form-item>
<bk-form-item
:label="t('启用 WebSocket')"
property="enable_websocket"
required>
<bk-switcher v-model="frontConfigData.enable_websocket" theme="primary" size="small"></bk-switcher>
</bk-form-item>
</bk-form>
</template>
<script setup lang="ts">
Expand Down Expand Up @@ -58,6 +64,7 @@ const frontConfigData = ref({
path: '',
method: 'GET',
match_subpath: false,
enable_websocket: false,
});

const cloneData = ref({
Expand Down Expand Up @@ -104,8 +111,8 @@ watch(
() => props.detail,
(val: any) => {
if (Object.keys(val).length) {
const { path, method, match_subpath } = val;
frontConfigData.value = { path, method, match_subpath };
const { path, method, match_subpath, enable_websocket } = val;
frontConfigData.value = { path, method, match_subpath, enable_websocket };
if (props.isClone) {
cloneData.value = { path, method };
setTimeout(() => {
Expand Down
25 changes: 25 additions & 0 deletions src/dashboard-front/src/views/resource/setting/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,29 @@
</bk-popover>
</div>
</bk-form-item>
<!-- 是否启用 websocket -->
<bk-form-item class="form-item-cls">
<template #label>
<span class="label-cls">{{ t('启用 WebSocket:') }}</span>
</template>

<div v-if="!frontWsEdit" class="value-container">
<span>{{ formData?.enable_websocket ? t('是') : t('否') }}</span>
<span class="operate-btn">
<i @click="frontWsEdit = true" class="apigateway-icon icon-ag-edit-line"></i>
</span>
</div>

<div class="edit-name mt8" v-else>
<bk-switcher
v-model="formData.enable_websocket"
theme="primary"
size="small"
@change="handleEditSave"
class="method">
</bk-switcher>
</div>
</bk-form-item>
</bk-form>

<div class="title">{{ t('后端配置') }}</div>
Expand Down Expand Up @@ -579,6 +602,7 @@ const permEdit = ref<boolean>(false);
const publicEdit = ref<boolean>(false);
const frontMethodEdit = ref<boolean>(false);
const frontPathEdit = ref<boolean>(false);
const frontWsEdit = ref(false); // 是否启用websocket的编辑态
const backMethodEdit = ref<boolean>(false);
const backServicesEdit = ref<boolean>(false);
const backPathEdit = ref<boolean>(false);
Expand Down Expand Up @@ -855,6 +879,7 @@ const handleEditSave = async () => {
publicEdit.value = false;
frontMethodEdit.value = false;
frontPathEdit.value = false;
frontWsEdit.value = false;
backMethodEdit.value = false;
backServicesEdit.value = false;
backPathEdit.value = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@
<div class="ag-value">{{ source.path }}</div>
</bk-col>
</bk-row>

<bk-row>
<bk-col :span="4">
<label class="ag-key">{{ $t("启用 WebSocket") }}:</label>
</bk-col>
<bk-col :span="10">
<div class="ag-value">{{ source.enable_websocket ? $t("是") : $t("否") }}</div>
</bk-col>
</bk-row>
</bk-container>

<template v-if="info.schema_version === '2.0'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@
<div class="ag-value">{{ currentSource.path }}</div>
</bk-col>
</bk-row>

<bk-row>
<bk-col :span="4">
<label class="ag-key">{{ $t("启用 Websocket") }}:</label>
</bk-col>
<bk-col :span="10">
<div class="ag-value">{{ currentSource.enable_websocket ? t('是') : t('否') }}</div>
</bk-col>
</bk-row>
</bk-container>

<p
Expand Down
Loading