Skip to content

Commit b112ee0

Browse files
committed
bug fix #29
1 parent 7155821 commit b112ee0

File tree

5 files changed

+61
-12
lines changed

5 files changed

+61
-12
lines changed

frontend/src/views/domain/DomainAdd.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {useRouter} from 'vue-router'
1212
const {$gettext, interpolate} = useGettext()
1313
1414
const config = reactive({name: ''})
15-
let ngx_config = reactive({
15+
const ngx_config = reactive({
1616
servers: [{
1717
directives: [],
1818
locations: []

frontend/src/views/domain/ngx_conf/LocationEditor.vue

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import CodeEditor from '@/components/CodeEditor'
33
import {useGettext} from 'vue3-gettext'
44
import {reactive, ref} from 'vue'
5+
import {DeleteOutlined} from '@ant-design/icons-vue'
56
67
const {$gettext} = useGettext()
78
@@ -24,7 +25,9 @@ function add() {
2425
2526
function save() {
2627
adding.value = false
27-
props.locations?.push(location)
28+
props.locations?.push({
29+
...location
30+
})
2831
}
2932
3033
function remove(index: number) {
@@ -45,7 +48,19 @@ function remove(index: number) {
4548
<a-input addon-before="location" v-model:value="v.path"/>
4649
</a-form-item>
4750
<a-form-item :label="$gettext('Content')">
48-
<code-editor v-model:content="v.content" default-height="200px"/>
51+
<div class="input-wrapper">
52+
<code-editor v-model:content="v.content" default-height="200px" style="width: 100%;"/>
53+
<a-popconfirm @confirm="remove(k)"
54+
:title="$gettext('Are you sure you want to remove this location?')"
55+
:ok-text="$gettext('Yes')"
56+
:cancel-text="$gettext('No')">
57+
<a-button>
58+
<template #icon>
59+
<DeleteOutlined style="font-size: 14px;"/>
60+
</template>
61+
</a-button>
62+
</a-popconfirm>
63+
</div>
4964
</a-form-item>
5065
</a-form>
5166
</a-card>
@@ -73,5 +88,12 @@ function remove(index: number) {
7388
.ant-card {
7489
margin: 10px 0;
7590
box-shadow: unset;
91+
92+
.input-wrapper {
93+
display: flex;
94+
gap: 10px;
95+
align-items: center;
96+
width: 100%;
97+
}
7698
}
7799
</style>

frontend/src/views/domain/ngx_conf/NgxConfigEditor.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const name = ref(route.params.name)
2020
function change_tls(r: any) {
2121
if (r) {
2222
// deep copy servers[0] to servers[1]
23+
console.log(props.ngx_config)
2324
const server = JSON.parse(JSON.stringify(props.ngx_config.servers[0]))
2425
2526
props.ngx_config.servers.push(server)
@@ -143,7 +144,7 @@ const autoCertRef = computed({
143144
<template v-if="current_support_ssl&&enabled">
144145
<cert
145146
v-if="current_support_ssl"
146-
:cert_info="props.cert_info[k]"
147+
:cert_info="props.cert_info?.[k]"
147148
:current_server_directives="current_server_directives"
148149
:directives-map="directivesMap"
149150
v-model:enabled="autoCertRef"

frontend/src/views/domain/ngx_conf/directive/DirectiveEditor.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function onSave(idx: number) {
5050

5151
<a-input v-else
5252
:addon-before="directive.directive"
53-
v-model:value="directive.params" @click="current_idx=index"/>
53+
v-model:value="directive.params" @click="current_idx=index" @blur="current_idx=-1"/>
5454

5555
<a-popconfirm @confirm="remove(index)"
5656
:title="$gettext('Are you sure you want to remove this directive?')"
@@ -88,7 +88,8 @@ function onSave(idx: number) {
8888
}
8989
9090
.slide-enter-active, .slide-leave-active {
91-
transition: max-height .3s ease;
91+
transition: max-height .2s ease;
92+
overflow: hidden;
9293
}
9394
9495
.slide-enter-from, .slide-leave-to {

server/api/config.go

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,38 @@ func GetConfigs(c *gin.Context) {
3333
file := configFiles[i]
3434
fileInfo, _ := file.Info()
3535

36-
if !file.IsDir() && "." != file.Name()[0:1] {
37-
configs = append(configs, gin.H{
38-
"name": file.Name(),
39-
"size": fileInfo.Size(),
40-
"modify": fileInfo.ModTime(),
41-
})
36+
switch mode := fileInfo.Mode(); {
37+
case mode.IsRegular(): // regular file, not a hidden file
38+
if "." == file.Name()[0:1] {
39+
continue
40+
}
41+
case mode&os.ModeSymlink != 0: // is a symbol
42+
var targetPath string
43+
targetPath, err = os.Readlink(nginx.GetNginxConfPath(file.Name()))
44+
if err != nil {
45+
log.Println("GetConfigs Read Symlink Error", targetPath, err)
46+
continue
47+
}
48+
49+
var targetInfo os.FileInfo
50+
targetInfo, err = os.Stat(targetPath)
51+
if err != nil {
52+
log.Println("GetConfigs Stat Error", targetPath, err)
53+
continue
54+
}
55+
// but target file is not a dir
56+
if targetInfo.IsDir() {
57+
continue
58+
}
59+
default:
60+
continue
4261
}
62+
63+
configs = append(configs, gin.H{
64+
"name": file.Name(),
65+
"size": fileInfo.Size(),
66+
"modify": fileInfo.ModTime(),
67+
})
4368
}
4469

4570
configs = config_list.Sort(orderBy, sort, mySort[orderBy], configs)

0 commit comments

Comments
 (0)