-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Operation logs Add node information #8212
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,15 +7,19 @@ | |
| @mouseenter="collapseButtonShow = true" | ||
| @mouseleave="collapseButtonShow = false" | ||
| > | ||
| <el-affix v-if="collapseButtonShow" :offset="124" class="affix"> | ||
| <el-button | ||
| size="small" | ||
| circle | ||
| :style="{ 'margin-left': menuStore.isCollapse ? '60px' : '165px', position: 'absolute' }" | ||
| :icon="menuStore.isCollapse ? 'ArrowRight' : 'ArrowLeft'" | ||
| plain | ||
| @click="handleCollapse()" | ||
| ></el-button> | ||
| <el-affix v-if="collapseButtonShow" :offset="18" class="affix"> | ||
| <el-tooltip | ||
| :content="menuStore.isCollapse ? $t('commons.button.expand') : $t('commons.button.collapse')" | ||
| > | ||
| <el-button | ||
| size="small" | ||
| circle | ||
| :style="{ 'margin-left': menuStore.isCollapse ? '60px' : '165px', position: 'absolute' }" | ||
| :icon="menuStore.isCollapse ? 'ArrowRight' : 'ArrowLeft'" | ||
| plain | ||
| @click="handleCollapse()" | ||
| ></el-button> | ||
| </el-tooltip> | ||
| </el-affix> | ||
| <Sidebar @menu-click="handleMenuClick" :menu-router="!classObj.openMenuTabs" @open-task="openTask" /> | ||
| </div> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided patch contains several changes and optimizations:
Here is the updated snippet: @@ -7,15 +7,19 @@
@mouseenter="collapseButtonShow = true"
@mouseleave="collapseButtonShow = false"
>
- <el-affix v-if="collapseButtonShow" :offset="124" class="affix">
- <el-button
- size="small"
- circle
- :style="{ 'margin-left': menuStore.isCollapse ? '60px' : '165px', position: 'absolute' }"
- :icon="menuStore.isCollapse ? 'ArrowRight' : 'ArrowLeft'"
- plain
- @click="handleCollapse()"
- ></el-button>
+ <el-affix v-if="collapseButtonShow" :offset="18" class="affix">
+ <el-tooltip
+ :content="$t('commons.button.' + (menuStore.isCollapse ? 'expand' : 'collapse'))"
+ >
+ <el-button
+ size="small"
+ circle
+ :style="{ 'margin-left': menuStore.isCollapse ? '60px' : '165px', position: 'absolute' }"
+ :icon="menuStore.isCollapse ? 'ArrowRight' : 'ArrowLeft'"
+ plain
+ @click="handleCollapse()"
+ ></el-button>
+ </el-tooltip>
</el-affix>
<Sidebar @menu-click="handleMenuClick" :menu-router="!classObj.openMenuTabs" @open-task="openTask" />Potential Issues:
Optimization Suggestions:
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| </el-button> | ||
| </template> | ||
| <template #rightToolBar> | ||
| <el-select v-model="searchGroup" @change="search()" clearable class="p-w-200 mr-2.5"> | ||
| <el-select v-model="searchGroup" @change="search()" clearable class="p-w-200"> | ||
| <template #prefix>{{ $t('logs.resource') }}</template> | ||
| <el-option :label="$t('commons.table.all')" value=""></el-option> | ||
| <el-option :label="$t('logs.detail.apps')" value="apps"></el-option> | ||
|
|
@@ -25,12 +25,18 @@ | |
| <el-option :label="$t('logs.detail.logs')" value="logs"></el-option> | ||
| <el-option :label="$t('logs.detail.settings')" value="settings"></el-option> | ||
| </el-select> | ||
| <el-select v-model="searchStatus" @change="search()" clearable class="p-w-200 mr-2.5"> | ||
| <template #prefix>{{ $t('commons.table.status') }}</template> | ||
| <el-select v-model="searchStatus" @change="search()" clearable class="p-w-200"> | ||
| <template #prefix>{{ $t('xpack.node.node') }}</template> | ||
| <el-option :label="$t('commons.table.all')" value=""></el-option> | ||
| <el-option :label="$t('commons.status.success')" value="Success"></el-option> | ||
| <el-option :label="$t('commons.status.failed')" value="Failed"></el-option> | ||
| </el-select> | ||
| <el-select v-model="searchNode" @change="search()" clearable class="p-w-200"> | ||
| <template #prefix>{{ $t('xpack.node.node') }}</template> | ||
| <el-option :label="$t('commons.table.all')" value=""></el-option> | ||
| <el-option :label="$t('xpack.node.master')" value="local" /> | ||
| <el-option v-for="(node, index) in nodes" :key="index" :label="node.name" :value="node.name" /> | ||
| </el-select> | ||
| <TableSearch @search="search()" v-model:searchName="searchName" /> | ||
| <TableRefresh @search="search()" /> | ||
| <TableSetting title="operation-log-refresh" @search="search()" /> | ||
|
|
@@ -52,7 +58,11 @@ | |
| <span v-if="globalStore.language === 'en'">{{ row.detailEN }}</span> | ||
| </template> | ||
| </el-table-column> | ||
|
|
||
| <el-table-column v-if="globalStore.isMasterProductPro" :label="$t('xpack.node.node')" prop="node"> | ||
| <template #default="{ row }"> | ||
| <span>{{ row.node === 'local' ? $t('xpack.node.master') : row.node }}</span> | ||
| </template> | ||
| </el-table-column> | ||
| <el-table-column :label="$t('commons.table.status')" prop="status"> | ||
| <template #default="{ row }"> | ||
| <Status :status="row.status" :msg="row.message" /> | ||
|
|
@@ -81,6 +91,7 @@ import { onMounted, reactive, ref } from '@vue/runtime-core'; | |
| import i18n from '@/lang'; | ||
| import { MsgSuccess } from '@/utils/message'; | ||
| import { GlobalStore } from '@/store'; | ||
| import { listNodeOptions } from '@/api/modules/setting'; | ||
|
|
||
| const loading = ref(); | ||
| const data = ref(); | ||
|
|
@@ -94,6 +105,8 @@ const paginationConfig = reactive({ | |
| const searchName = ref<string>(''); | ||
| const searchGroup = ref<string>(''); | ||
| const searchStatus = ref<string>(''); | ||
| const searchNode = ref<string>(''); | ||
| const nodes = ref(); | ||
|
|
||
| const globalStore = GlobalStore(); | ||
|
|
||
|
|
@@ -104,6 +117,7 @@ const search = async () => { | |
| pageSize: paginationConfig.pageSize, | ||
| status: searchStatus.value, | ||
| source: searchGroup.value, | ||
| node: searchNode.value, | ||
| }; | ||
| loading.value = true; | ||
| await getOperationLogs(params) | ||
|
|
@@ -140,6 +154,23 @@ const loadDetail = (log: string) => { | |
| return log; | ||
| }; | ||
|
|
||
| const loadNodes = async () => { | ||
| await listNodeOptions() | ||
| .then((res) => { | ||
| if (!res) { | ||
| nodes.value = []; | ||
| return; | ||
| } | ||
| nodes.value = res.data || []; | ||
| if (nodes.value.length === 0) { | ||
| globalStore.currentNode = 'local'; | ||
| } | ||
| }) | ||
| .catch(() => { | ||
| nodes.value = []; | ||
| }); | ||
| }; | ||
|
|
||
| const replacements = { | ||
| '[enable]': 'commons.button.enable', | ||
| '[Enable]': 'commons.button.enable', | ||
|
|
@@ -172,6 +203,9 @@ const onSubmitClean = async () => { | |
| }; | ||
|
|
||
| onMounted(() => { | ||
| if (globalStore.isMasterProductPro) { | ||
| loadNodes(); | ||
| } | ||
| search(); | ||
| }); | ||
| </script> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes made to the code appear to be improving its functionality and localization support. Some key improvements include:
These modifications help make the component more modular, maintainable, and user-friendly by enhancing the user experience with localized strings and additional informative columns. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code seems to be correct with minor changes. The primary difference is that
Updatemethod now takes areq dto.CommandOperateinstead ofid uint, upMap map[string]interface{}. This change allows easier validation before updating the record usingGet. However, it's important to ensure that this does not introduce security vulnerabilities by directly manipulating user input in query conditions without proper sanitization.Additionally, there are redundant fields added while performing updates ("group_id", "command"), which might not always be needed depending on how your application handles these data. It would be cleaner if these were conditionally added based on whether the fields exist within the request.
Lastly, the use of
_ = commandRepo.Get(...)ignores an optional error (fromrepo.WithByNameor others), but this could potentially indicate a failure in retrieving records under certain scenarios. Depending on your needs, you might want to handle these errors.Overall, despite these optimizations, the existing implementation appears to work correctly and maintainable with appropriate checks in place to reduce risk and improve robustness.