-
Notifications
You must be signed in to change notification settings - Fork 3k
feat: Add node service detection #7545
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 |
|---|---|---|
|
|
@@ -187,7 +187,7 @@ func (u *SettingService) UpdatePort(port uint) error { | |
| if common.ScanPort(int(port)) { | ||
| return buserr.WithDetail(constant.ErrPortInUsed, port, nil) | ||
| } | ||
| oldPort, err := settingRepo.Get(repo.WithByKey("Port")) | ||
| oldPort, err := settingRepo.Get(repo.WithByKey("ServerPort")) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -197,6 +197,20 @@ func (u *SettingService) UpdatePort(port uint) error { | |
| if err := firewall.UpdatePort(oldPort.Value, fmt.Sprintf("%v", port)); err != nil { | ||
| return err | ||
| } | ||
| masterAddr, err := settingRepo.Get(repo.WithByKey("MasterAddr")) | ||
| if err != nil { | ||
| global.LOG.Errorf("load master addr from db failed, err: %v", err) | ||
| return err | ||
| } | ||
| if len(masterAddr.Value) != 0 { | ||
| oldMasterPort := loadPort(masterAddr.Value) | ||
| if len(oldMasterPort) != 0 { | ||
| if err := xpack.UpdateMasterAddr(strings.ReplaceAll(masterAddr.Value, oldMasterPort, fmt.Sprintf("%v", port))); err != nil { | ||
| global.LOG.Errorf("update master addr from db failed, err: %v", err) | ||
| return err | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if err := settingRepo.Update("ServerPort", strconv.Itoa(int(port))); err != nil { | ||
| return err | ||
|
|
@@ -208,20 +222,6 @@ func (u *SettingService) UpdatePort(port uint) error { | |
| global.LOG.Errorf("restart system port failed, err: %v", err) | ||
| } | ||
| }() | ||
| masterAddr, err := settingRepo.Get(repo.WithByKey("MasterAddr")) | ||
| if err != nil { | ||
| global.LOG.Errorf("load master addr from db failed, err: %v", err) | ||
| return | ||
| } | ||
| if len(masterAddr.Value) != 0 { | ||
| oldMasterPort := loadPort(masterAddr.Value) | ||
| if len(oldMasterPort) != 0 { | ||
| if err := xpack.UpdateMasterAddr(strings.ReplaceAll(masterAddr.Value, oldMasterPort, fmt.Sprintf("%v", port))); err != nil { | ||
| global.LOG.Errorf("update master addr from db failed, err: %v", err) | ||
| return | ||
| } | ||
| } | ||
| } | ||
| }() | ||
| return nil | ||
| } | ||
|
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. There does not appear to be any obvious issues with this code snippet from an English perspective. It appears it checks if a provided port number is valid using a scan function and updates settings accordingly through |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| <template> | ||
| <el-dialog | ||
| :title="title" | ||
| v-model="dialogVisible" | ||
| :destroy-on-close="true" | ||
| :close-on-click-modal="false" | ||
| :width="size" | ||
| > | ||
| <div v-if="slots.content"> | ||
| <slot name="content"></slot> | ||
| </div> | ||
| <el-row v-else> | ||
| <el-col :span="22" :offset="1"> | ||
| <slot></slot> | ||
| </el-col> | ||
| </el-row> | ||
|
|
||
| <template #footer v-if="slots.footer"> | ||
| <slot name="footer"></slot> | ||
| </template> | ||
| </el-dialog> | ||
| </template> | ||
|
|
||
| <script lang="ts" setup> | ||
| import { computed, useSlots } from 'vue'; | ||
| defineOptions({ name: 'DrawerPro' }); | ||
|
|
||
| const props = defineProps({ | ||
| title: String, | ||
| size: { | ||
| type: String, | ||
| default: 'normal', | ||
| }, | ||
| modelValue: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| }); | ||
|
|
||
| const slots = useSlots(); | ||
|
|
||
| const emit = defineEmits(['update:modelValue', 'close']); | ||
|
|
||
| const size = computed(() => { | ||
| switch (props.size) { | ||
| case 'small': | ||
| return '30%'; | ||
| case 'normal': | ||
| return '40%'; | ||
| case 'large': | ||
| return '50%'; | ||
| case 'full': | ||
| return '100%'; | ||
| case '60%': | ||
| return '60%'; | ||
| default: | ||
| return '50%'; | ||
| } | ||
| }); | ||
|
|
||
| const dialogVisible = computed({ | ||
| get() { | ||
| return props.modelValue; | ||
| }, | ||
| set(value: boolean) { | ||
| emit('update:modelValue', value); | ||
| }, | ||
| }); | ||
| </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. Based on the provided snippet, here are some observations and suggested improvements:
Here's the refined code based on these points: <div class="drawer-pro" @click="$emit('close')">
<div :class="'drawer-' ~ $attrs.width || "normal"' ref="drawer"> <!-- Adjusted line -->
<!-- Content goes here -->
</div>
</div>This version addresses most concerns listed above while maintaining a consistent syntax across all components within this package if it were included laterally, like in |
||
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.
It seems that there are several issues with this code snippet.
Issues
Type mismatches
SettingService) does not correctly extend from the interfaceISettingService.Interface methods and implementation of update method missing
Suggestions
I would make these changes:
These implementations should fix the aforementioned bugs and improve readability and maintainability.
Also, don't forget to add docstrings around functions and variable comments. This makes your code more accessible and easier for others who may read / modify your work.