mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 01:10:29 +08:00
通知媒介可以设置发送频率
This commit is contained in:
@@ -3,6 +3,7 @@ package instances
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/monitorconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
@@ -65,6 +66,9 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
|
|
||||||
TelegramToken string
|
TelegramToken string
|
||||||
|
|
||||||
|
RateMinutes int32
|
||||||
|
RateCount int32
|
||||||
|
|
||||||
Description string
|
Description string
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
@@ -231,11 +235,22 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
return
|
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{
|
resp, err := this.RPC().MessageMediaInstanceRPC().CreateMessageMediaInstance(this.AdminContext(), &pb.CreateMessageMediaInstanceRequest{
|
||||||
Name: params.Name,
|
Name: params.Name,
|
||||||
MediaType: params.MediaType,
|
MediaType: params.MediaType,
|
||||||
ParamsJSON: optionsJSON,
|
ParamsJSON: optionsJSON,
|
||||||
Description: params.Description,
|
Description: params.Description,
|
||||||
|
RateJSON: rateJSON,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package instances
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/monitorconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"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{
|
this.Data["instance"] = maps.Map{
|
||||||
"id": instance.Id,
|
"id": instance.Id,
|
||||||
"name": instance.Name,
|
"name": instance.Name,
|
||||||
@@ -48,6 +59,7 @@ func (this *InstanceAction) RunGet(params struct {
|
|||||||
},
|
},
|
||||||
"description": instance.Description,
|
"description": instance.Description,
|
||||||
"params": mediaParams,
|
"params": mediaParams,
|
||||||
|
"rate": rateConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package instances
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/monitorconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"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{
|
this.Data["instance"] = maps.Map{
|
||||||
"id": instance.Id,
|
"id": instance.Id,
|
||||||
"name": instance.Name,
|
"name": instance.Name,
|
||||||
@@ -49,6 +59,7 @@ func (this *UpdateAction) RunGet(params struct {
|
|||||||
},
|
},
|
||||||
"description": instance.Description,
|
"description": instance.Description,
|
||||||
"params": mediaParams,
|
"params": mediaParams,
|
||||||
|
"rate": rateConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
@@ -104,6 +115,9 @@ func (this *UpdateAction) RunPost(params struct {
|
|||||||
Description string
|
Description string
|
||||||
IsOn bool
|
IsOn bool
|
||||||
|
|
||||||
|
RateMinutes int32
|
||||||
|
RateCount int32
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
CSRF *actionutils.CSRF
|
CSRF *actionutils.CSRF
|
||||||
}) {
|
}) {
|
||||||
@@ -270,12 +284,23 @@ func (this *UpdateAction) RunPost(params struct {
|
|||||||
return
|
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{
|
_, err = this.RPC().MessageMediaInstanceRPC().UpdateMessageMediaInstance(this.AdminContext(), &pb.UpdateMessageMediaInstanceRequest{
|
||||||
MessageMediaInstanceId: params.InstanceId,
|
MessageMediaInstanceId: params.InstanceId,
|
||||||
Name: params.Name,
|
Name: params.Name,
|
||||||
MediaType: params.MediaType,
|
MediaType: params.MediaType,
|
||||||
ParamsJSON: optionsJSON,
|
ParamsJSON: optionsJSON,
|
||||||
Description: params.Description,
|
Description: params.Description,
|
||||||
|
RateJSON: rateJSON,
|
||||||
IsOn: params.IsOn,
|
IsOn: params.IsOn,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -342,6 +342,28 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</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>
|
<tr>
|
||||||
<td>备注</td>
|
<td>备注</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -227,6 +227,13 @@
|
|||||||
<td>{{instance.params.accessSecret}}</td>
|
<td>{{instance.params.accessSecret}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</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>
|
<tr>
|
||||||
<td>备注</td>
|
<td>备注</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -342,6 +342,27 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</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>
|
<tr>
|
||||||
<td>备注</td>
|
<td>备注</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user