mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
通知媒介可以设置发送频率
This commit is contained in:
@@ -3,6 +3,7 @@ package instances
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/monitorconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
@@ -65,6 +66,9 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
|
||||
TelegramToken string
|
||||
|
||||
RateMinutes int32
|
||||
RateCount int32
|
||||
|
||||
Description string
|
||||
|
||||
Must *actions.Must
|
||||
@@ -231,11 +235,22 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
var rateConfig = &monitorconfigs.RateConfig{
|
||||
Minutes: params.RateMinutes,
|
||||
Count: params.RateCount,
|
||||
}
|
||||
rateJSON, err := json.Marshal(rateConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := this.RPC().MessageMediaInstanceRPC().CreateMessageMediaInstance(this.AdminContext(), &pb.CreateMessageMediaInstanceRequest{
|
||||
Name: params.Name,
|
||||
MediaType: params.MediaType,
|
||||
ParamsJSON: optionsJSON,
|
||||
Description: params.Description,
|
||||
RateJSON: rateJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -3,6 +3,7 @@ package instances
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/monitorconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
@@ -38,6 +39,16 @@ func (this *InstanceAction) RunGet(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
// 频率
|
||||
var rateConfig = &monitorconfigs.RateConfig{}
|
||||
if len(instance.RateJSON) > 0 {
|
||||
err = json.Unmarshal(instance.RateJSON, rateConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.Data["instance"] = maps.Map{
|
||||
"id": instance.Id,
|
||||
"name": instance.Name,
|
||||
@@ -48,6 +59,7 @@ func (this *InstanceAction) RunGet(params struct {
|
||||
},
|
||||
"description": instance.Description,
|
||||
"params": mediaParams,
|
||||
"rate": rateConfig,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
|
||||
@@ -3,6 +3,7 @@ package instances
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/monitorconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
@@ -39,6 +40,15 @@ func (this *UpdateAction) RunGet(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
var rateConfig = &monitorconfigs.RateConfig{}
|
||||
if len(instance.RateJSON) > 0 {
|
||||
err = json.Unmarshal(instance.RateJSON, rateConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.Data["instance"] = maps.Map{
|
||||
"id": instance.Id,
|
||||
"name": instance.Name,
|
||||
@@ -49,6 +59,7 @@ func (this *UpdateAction) RunGet(params struct {
|
||||
},
|
||||
"description": instance.Description,
|
||||
"params": mediaParams,
|
||||
"rate": rateConfig,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
@@ -104,6 +115,9 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
Description string
|
||||
IsOn bool
|
||||
|
||||
RateMinutes int32
|
||||
RateCount int32
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
@@ -270,12 +284,23 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
var rateConfig = &monitorconfigs.RateConfig{
|
||||
Minutes: params.RateMinutes,
|
||||
Count: params.RateCount,
|
||||
}
|
||||
rateJSON, err := json.Marshal(rateConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().MessageMediaInstanceRPC().UpdateMessageMediaInstance(this.AdminContext(), &pb.UpdateMessageMediaInstanceRequest{
|
||||
MessageMediaInstanceId: params.InstanceId,
|
||||
Name: params.Name,
|
||||
MediaType: params.MediaType,
|
||||
ParamsJSON: optionsJSON,
|
||||
Description: params.Description,
|
||||
RateJSON: rateJSON,
|
||||
IsOn: params.IsOn,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -342,6 +342,28 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tr>
|
||||
<td>发送频率<em>(次/分钟)</em></td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="rateCount" size="4"/>
|
||||
<span class="ui label">次</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui field">/</div>
|
||||
<div class="ui field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="rateMinutes" size="4"/>
|
||||
<span class="ui label">分钟</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">用来限制此媒介的发送频率。</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>备注</td>
|
||||
<td>
|
||||
|
||||
@@ -227,6 +227,13 @@
|
||||
<td>{{instance.params.accessSecret}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tr>
|
||||
<td>发送频率<em>(次/分钟)</em></td>
|
||||
<td>
|
||||
<span v-if="instance.rate.minutes <= 0 || instance.rate.count <= 0" class="disabled">没有限制</span>
|
||||
<span v-else>{{instance.rate.count}}次/{{instance.rate.minutes}}分钟</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>备注</td>
|
||||
<td>
|
||||
|
||||
@@ -342,6 +342,27 @@
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tr>
|
||||
<td>发送频率<em>(次/分钟)</em></td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="rateCount" size="4" v-model="instance.rate.count"/>
|
||||
<span class="ui label">次</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui field">/</div>
|
||||
<div class="ui field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="rateMinutes" size="4" v-model="instance.rate.minutes"/>
|
||||
<span class="ui label">分钟</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">用来限制此媒介的发送频率。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>备注</td>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user