mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	节点运行日志可以按照节点ID设置为已读
This commit is contained in:
		@@ -120,6 +120,8 @@ func (this *IndexAction) RunGet(params struct {
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var firstUnreadNodeMap maps.Map = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var logs = []maps.Map{}
 | 
						var logs = []maps.Map{}
 | 
				
			||||||
	for _, log := range logsResp.NodeLogs {
 | 
						for _, log := range logsResp.NodeLogs {
 | 
				
			||||||
		// 节点信息
 | 
							// 节点信息
 | 
				
			||||||
@@ -132,6 +134,13 @@ func (this *IndexAction) RunGet(params struct {
 | 
				
			|||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if params.Type == "unread" && firstUnreadNodeMap == nil {
 | 
				
			||||||
 | 
								firstUnreadNodeMap = maps.Map{
 | 
				
			||||||
 | 
									"id":   node.Id,
 | 
				
			||||||
 | 
									"name": node.Name,
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// 服务信息
 | 
							// 服务信息
 | 
				
			||||||
		var serverMap = maps.Map{"id": 0}
 | 
							var serverMap = maps.Map{"id": 0}
 | 
				
			||||||
		if log.ServerId > 0 {
 | 
							if log.ServerId > 0 {
 | 
				
			||||||
@@ -174,5 +183,7 @@ func (this *IndexAction) RunGet(params struct {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	this.Data["logs"] = logs
 | 
						this.Data["logs"] = logs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["firstUnreadNode"] = firstUnreadNodeMap
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Show()
 | 
						this.Show()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ package logs
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -14,9 +15,13 @@ type ReadLogsAction struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (this *ReadLogsAction) RunPost(params struct {
 | 
					func (this *ReadLogsAction) RunPost(params struct {
 | 
				
			||||||
	LogIds []int64
 | 
						LogIds []int64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						NodeId int64
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
	_, err := this.RPC().NodeLogRPC().UpdateNodeLogsRead(this.AdminContext(), &pb.UpdateNodeLogsReadRequest{
 | 
						_, err := this.RPC().NodeLogRPC().UpdateNodeLogsRead(this.AdminContext(), &pb.UpdateNodeLogsReadRequest{
 | 
				
			||||||
		NodeLogIds: params.LogIds,
 | 
							NodeLogIds: params.LogIds,
 | 
				
			||||||
 | 
							NodeId:     params.NodeId,
 | 
				
			||||||
 | 
							Role:       nodeconfigs.NodeRoleNode,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		this.ErrorPage(err)
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,6 +52,7 @@
 | 
				
			|||||||
    <second-menu v-if="logs.length > 0">
 | 
					    <second-menu v-if="logs.length > 0">
 | 
				
			||||||
        <a href="" class="item" @click.prevent="updatePageRead()">[本页已读]</a>
 | 
					        <a href="" class="item" @click.prevent="updatePageRead()">[本页已读]</a>
 | 
				
			||||||
        <a href="" class="item" @click.prevent="updateAllRead()">[全部已读]</a>
 | 
					        <a href="" class="item" @click.prevent="updateAllRead()">[全部已读]</a>
 | 
				
			||||||
 | 
					        <a href="" class="item" @click.prevent="updateNodeRead(firstUnreadNode.id)" v-if="firstUnreadNode != null">["{{firstUnreadNode.name}}"已读]</a>
 | 
				
			||||||
    </second-menu>
 | 
					    </second-menu>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,6 +27,16 @@ Tea.context(function () {
 | 
				
			|||||||
			})
 | 
								})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.updateNodeRead = function (nodeId) {
 | 
				
			||||||
 | 
							this.$post(".readLogs")
 | 
				
			||||||
 | 
								.params({
 | 
				
			||||||
 | 
									nodeId: nodeId
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								.success(function () {
 | 
				
			||||||
 | 
									teaweb.reload()
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.updateAllRead = function () {
 | 
						this.updateAllRead = function () {
 | 
				
			||||||
		this.$post(".readAllLogs")
 | 
							this.$post(".readAllLogs")
 | 
				
			||||||
			.params({})
 | 
								.params({})
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user