mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 12:20:28 +08:00
源站增加快速停用/启用功能
This commit is contained in:
@@ -14,6 +14,7 @@ func init() {
|
||||
GetPost("/addPopup", new(AddPopupAction)).
|
||||
Post("/delete", new(DeleteAction)).
|
||||
GetPost("/updatePopup", new(UpdatePopupAction)).
|
||||
Post("/updateIsOn", new(UpdateIsOnAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package origins
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type UpdateIsOnAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdateIsOnAction) RunPost(params struct {
|
||||
OriginId int64
|
||||
IsOn bool
|
||||
}) {
|
||||
defer this.CreateLogInfo(codes.ServerOrigin_LogUpdateOriginIsOn, params.OriginId)
|
||||
|
||||
_, err := this.RPC().OriginRPC().UpdateOriginIsOn(this.AdminContext(), &pb.UpdateOriginIsOnRequest{
|
||||
OriginId: params.OriginId,
|
||||
IsOn: params.IsOn,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -40,9 +40,9 @@ Vue.component("origin-list-box", {
|
||||
}
|
||||
})
|
||||
},
|
||||
deleteOrigin: function (originId, originType) {
|
||||
deleteOrigin: function (originId, originAddr, originType) {
|
||||
let that = this
|
||||
teaweb.confirm("确定要删除此源站吗?", function () {
|
||||
teaweb.confirm("确定要删除此源站(" + originAddr + ")吗?", function () {
|
||||
Tea.action("/servers/server/settings/origins/delete?" + that.vParams + "&originId=" + originId + "&originType=" + originType)
|
||||
.post()
|
||||
.success(function () {
|
||||
@@ -51,16 +51,37 @@ Vue.component("origin-list-box", {
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
updateOriginIsOn: function (originId, originAddr, isOn) {
|
||||
let message
|
||||
let resultMessage
|
||||
if (isOn) {
|
||||
message = "确定要启用此源站(" + originAddr + ")吗?"
|
||||
resultMessage = "启用成功"
|
||||
} else {
|
||||
message = "确定要停用此源站(" + originAddr + ")吗?"
|
||||
resultMessage = "停用成功"
|
||||
}
|
||||
let that = this
|
||||
teaweb.confirm(message, function () {
|
||||
Tea.action("/servers/server/settings/origins/updateIsOn?" + that.vParams + "&originId=" + originId + "&isOn=" + (isOn ? 1 : 0))
|
||||
.post()
|
||||
.success(function () {
|
||||
teaweb.success(resultMessage, function () {
|
||||
window.location.reload()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<h3>主要源站 <a href="" @click.prevent="createPrimaryOrigin()">[添加主要源站]</a> </h3>
|
||||
<p class="comment" v-if="primaryOrigins.length == 0">暂时还没有主要源站。</p>
|
||||
<origin-list-table v-if="primaryOrigins.length > 0" :v-origins="vPrimaryOrigins" :v-origin-type="'primary'" @deleteOrigin="deleteOrigin" @updateOrigin="updateOrigin"></origin-list-table>
|
||||
<origin-list-table v-if="primaryOrigins.length > 0" :v-origins="vPrimaryOrigins" :v-origin-type="'primary'" @deleteOrigin="deleteOrigin" @updateOrigin="updateOrigin" @updateOriginIsOn="updateOriginIsOn"></origin-list-table>
|
||||
|
||||
<h3>备用源站 <a href="" @click.prevent="createBackupOrigin()">[添加备用源站]</a></h3>
|
||||
<p class="comment" v-if="backupOrigins.length == 0" :v-origins="primaryOrigins">暂时还没有备用源站。</p>
|
||||
<origin-list-table v-if="backupOrigins.length > 0" :v-origins="backupOrigins" :v-origin-type="'backup'" @deleteOrigin="deleteOrigin" @updateOrigin="updateOrigin"></origin-list-table>
|
||||
<p class="comment" v-if="backupOrigins.length == 0">暂时还没有备用源站。</p>
|
||||
<origin-list-table v-if="backupOrigins.length > 0" :v-origins="backupOrigins" :v-origin-type="'backup'" @deleteOrigin="deleteOrigin" @updateOrigin="updateOrigin" @updateOriginIsOn="updateOriginIsOn"></origin-list-table>
|
||||
</div>`
|
||||
})
|
||||
|
||||
@@ -82,11 +103,14 @@ Vue.component("origin-list-table", {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deleteOrigin: function (originId) {
|
||||
this.$emit("deleteOrigin", originId, this.vOriginType)
|
||||
deleteOrigin: function (originId, originAddr) {
|
||||
this.$emit("deleteOrigin", originId, originAddr, this.vOriginType)
|
||||
},
|
||||
updateOrigin: function (originId) {
|
||||
this.$emit("updateOrigin", originId, this.vOriginType)
|
||||
},
|
||||
updateOriginIsOn: function (originId, originAddr, isOn) {
|
||||
this.$emit("updateOriginIsOn", originId, originAddr, isOn)
|
||||
}
|
||||
},
|
||||
template: `
|
||||
@@ -94,9 +118,9 @@ Vue.component("origin-list-table", {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>源站地址</th>
|
||||
<th>权重</th>
|
||||
<th class="width10">状态</th>
|
||||
<th class="two op">操作</th>
|
||||
<th class="width5">权重</th>
|
||||
<th class="width6">状态</th>
|
||||
<th class="three op">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -121,7 +145,8 @@ Vue.component("origin-list-table", {
|
||||
</td>
|
||||
<td>
|
||||
<a href="" @click.prevent="updateOrigin(origin.id)">修改</a>
|
||||
<a href="" @click.prevent="deleteOrigin(origin.id)">删除</a>
|
||||
<a href="" v-if="origin.isOn" @click.prevent="updateOriginIsOn(origin.id, origin.addr, false)">停用</a><a href="" v-if="!origin.isOn" @click.prevent="updateOriginIsOn(origin.id, origin.addr, true)"><span class="red">启用</span></a>
|
||||
<a href="" @click.prevent="deleteOrigin(origin.id, origin.addr)">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user