修复全局封锁名单不能创建IP的Bug/创建和修改IP可以直接选择过期时间

This commit is contained in:
GoEdgeLab
2022-07-14 10:19:45 +08:00
parent 35d8c2a6f3
commit c87c3ef5b6
15 changed files with 55 additions and 40 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
"github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types" "github.com/iwind/TeaGo/types"
@@ -63,6 +64,7 @@ func (this *CreateIPPopupAction) RunPost(params struct {
CSRF *actionutils.CSRF CSRF *actionutils.CSRF
}) { }) {
// 校验IPList // 校验IPList
if params.ListId != firewallconfigs.GlobalListId {
existsResp, err := this.RPC().IPListRPC().ExistsEnabledIPList(this.AdminContext(), &pb.ExistsEnabledIPListRequest{IpListId: params.ListId}) existsResp, err := this.RPC().IPListRPC().ExistsEnabledIPList(this.AdminContext(), &pb.ExistsEnabledIPListRequest{IpListId: params.ListId})
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
@@ -71,6 +73,7 @@ func (this *CreateIPPopupAction) RunPost(params struct {
if !existsResp.Exists { if !existsResp.Exists {
this.Fail("IP名单不存在") this.Fail("IP名单不存在")
} }
}
type ipData struct { type ipData struct {
ipFrom string ipFrom string

View File

@@ -155,6 +155,15 @@ Vue.component("datetime-input", {
this.minute = this.leadingZero(date.getMinutes(), 2) this.minute = this.leadingZero(date.getMinutes(), 2)
this.second = this.leadingZero(date.getSeconds(), 2) this.second = this.leadingZero(date.getSeconds(), 2)
this.change() this.change()
},
nextHours: function (hours) {
let date = new Date()
date.setTime(date.getTime() + hours * 3600 * 1000)
this.day = date.getFullYear() + "-" + this.leadingZero(date.getMonth() + 1, 2) + "-" + this.leadingZero(date.getDate(), 2)
this.hour = this.leadingZero(date.getHours(), 2)
this.minute = this.leadingZero(date.getMinutes(), 2)
this.second = this.leadingZero(date.getSeconds(), 2)
this.change()
} }
}, },
template: `<div> template: `<div>
@@ -169,6 +178,6 @@ Vue.component("datetime-input", {
<div class="ui field">:</div> <div class="ui field">:</div>
<div class="ui field" :class="{error: hasSecondError}"><input type="text" v-model="second" maxlength="2" style="width:4em" placeholder="秒" @input="change"/></div> <div class="ui field" :class="{error: hasSecondError}"><input type="text" v-model="second" maxlength="2" style="width:4em" placeholder="秒" @input="change"/></div>
</div> </div>
<p class="comment">常用时间:<a href="" @click.prevent="nextDays(1)"> &nbsp;1天&nbsp; </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(3)"> &nbsp;3天&nbsp; </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(7)"> &nbsp;周&nbsp; </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(30)"> &nbsp;30天&nbsp; </a> </p> <p class="comment">常用时间:<a href="" @click.prevent="nextHours(1)"> &nbsp;1小时&nbsp; </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(1)"> &nbsp;1天&nbsp; </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(3)"> &nbsp;3天&nbsp; </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(7)"> &nbsp;1周&nbsp; </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(30)"> &nbsp;30天&nbsp; </a> </p>
</div>` </div>`
}) })

View File

@@ -1,7 +1,7 @@
Tea.context(function () { Tea.context(function () {
this.updateItem = function (itemId) { this.updateItem = function (itemId) {
teaweb.popup(Tea.url(".updateIPPopup?firewallPolicyId=" + this.firewallPolicyId, {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup?firewallPolicyId=" + this.firewallPolicyId, {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()
@@ -28,7 +28,7 @@ Tea.context(function () {
this.createIP = function (type) { this.createIP = function (type) {
let that = this let that = this
teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, { teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()

View File

@@ -24,7 +24,7 @@ Tea.context(function () {
this.updateItem = function (itemId) { this.updateItem = function (itemId) {
teaweb.popup(Tea.url(".updateIPPopup?firewallPolicyId=" + this.firewallPolicyId, {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup?firewallPolicyId=" + this.firewallPolicyId, {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()
@@ -39,7 +39,7 @@ Tea.context(function () {
this.createIP = function (type) { this.createIP = function (type) {
let that = this let that = this
teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, { teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
window.location = "/servers/components/waf/ipadmin/lists?firewallPolicyId=" + that.firewallPolicyId + "&type=" + type window.location = "/servers/components/waf/ipadmin/lists?firewallPolicyId=" + that.firewallPolicyId + "&type=" + type

View File

@@ -1,7 +1,7 @@
Tea.context(function () { Tea.context(function () {
this.updateItem = function (itemId) { this.updateItem = function (itemId) {
teaweb.popup(Tea.url(".updateIPPopup?listId=" + this.listId, {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup?listId=" + this.listId, {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()
@@ -27,7 +27,7 @@ Tea.context(function () {
*/ */
this.createIP = function (type) { this.createIP = function (type) {
teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, { teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()

View File

@@ -1,7 +1,7 @@
Tea.context(function () { Tea.context(function () {
this.updateItem = function (itemId) { this.updateItem = function (itemId) {
teaweb.popup(Tea.url(".updateIPPopup?listId=" + this.listId, {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup?listId=" + this.listId, {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()
@@ -27,7 +27,7 @@ Tea.context(function () {
*/ */
this.createIP = function (type) { this.createIP = function (type) {
teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, { teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()

View File

@@ -24,7 +24,7 @@ Tea.context(function () {
this.updateItem = function (listId, itemId) { this.updateItem = function (listId, itemId) {
teaweb.popup(Tea.url(".updateIPPopup?listId=" + listId, {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup?listId=" + listId, {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {

View File

@@ -81,6 +81,14 @@
</tr> </tr>
</tbody> </tbody>
<tr>
<td>过期时间</td>
<td>
<datetime-input :v-name="'expiredAt'"></datetime-input>
<p class="comment">在加入名单某一段时间后会失效,留空表示永久有效。</p>
</td>
</tr>
<tr> <tr>
<td>级别</td> <td>级别</td>
<td> <td>
@@ -92,13 +100,6 @@
<td colspan="2"><more-options-indicator></more-options-indicator></td> <td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr> </tr>
<tbody v-show="moreOptionsVisible"> <tbody v-show="moreOptionsVisible">
<tr>
<td>过期时间</td>
<td>
<datetime-input :v-name="'expiredAt'"></datetime-input>
<p class="comment">在加入名单某一段时间后会失效,留空表示永久有效。</p>
</td>
</tr>
<tr> <tr>
<td>备注</td> <td>备注</td>
<td><input type="text" name="reason" maxlength="100"/></td> <td><input type="text" name="reason" maxlength="100"/></td>

View File

@@ -1,7 +1,7 @@
Tea.context(function () { Tea.context(function () {
this.updateItem = function (itemId) { this.updateItem = function (itemId) {
teaweb.popup(Tea.url(".updateIPPopup", {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup", {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()

View File

@@ -1,7 +1,7 @@
Tea.context(function () { Tea.context(function () {
this.updateItem = function (itemId) { this.updateItem = function (itemId) {
teaweb.popup(Tea.url(".updateIPPopup", {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup", {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()
@@ -26,7 +26,7 @@ Tea.context(function () {
*/ */
this.createIP = function () { this.createIP = function () {
teaweb.popup(Tea.url(".createIPPopup", {listId: this.list.id}), { teaweb.popup(Tea.url(".createIPPopup", {listId: this.list.id}), {
height: "23em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()

View File

@@ -22,7 +22,7 @@ Tea.context(function () {
this.updateItem = function (itemId) { this.updateItem = function (itemId) {
teaweb.popup(Tea.url(".updateIPPopup", {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup", {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()

View File

@@ -55,10 +55,7 @@
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr> <tr>
<td>过期时间</td> <td>过期时间</td>
<td> <td>
@@ -66,6 +63,11 @@
<p class="comment">在加入名单某一段时间后会失效,留空表示永久有效。</p> <p class="comment">在加入名单某一段时间后会失效,留空表示永久有效。</p>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr> <tr>
<td>备注</td> <td>备注</td>
<td><input type="text" name="reason" maxlength="100" v-model="item.reason"/></td> <td><input type="text" name="reason" maxlength="100" v-model="item.reason"/></td>

View File

@@ -1,7 +1,7 @@
Tea.context(function () { Tea.context(function () {
this.updateItem = function (itemId) { this.updateItem = function (itemId) {
teaweb.popup(Tea.url(".updateIPPopup?listId=" + this.listId, {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup?listId=" + this.listId, {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()
@@ -27,7 +27,7 @@ Tea.context(function () {
*/ */
this.createIP = function (type) { this.createIP = function (type) {
teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, { teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()

View File

@@ -1,7 +1,7 @@
Tea.context(function () { Tea.context(function () {
this.updateItem = function (itemId) { this.updateItem = function (itemId) {
teaweb.popup(Tea.url(".updateIPPopup?listId=" + this.listId, {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup?listId=" + this.listId, {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()
@@ -27,7 +27,7 @@ Tea.context(function () {
*/ */
this.createIP = function (type) { this.createIP = function (type) {
teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, { teaweb.popup("/servers/iplists/createIPPopup?listId=" + this.listId + '&type=' + type, {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
teaweb.reload() teaweb.reload()

View File

@@ -24,7 +24,7 @@ Tea.context(function () {
this.updateItem = function (listId, itemId) { this.updateItem = function (listId, itemId) {
teaweb.popup(Tea.url(".updateIPPopup?listId=" + listId, {itemId: itemId}), { teaweb.popup(Tea.url(".updateIPPopup?listId=" + listId, {itemId: itemId}), {
height: "26em", height: "30em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {