mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	
		
			
	
	
		
			39 lines
		
	
	
		
			907 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			39 lines
		
	
	
		
			907 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								package db
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
							 | 
						||
| 
								 | 
							
									"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
							 | 
						||
| 
								 | 
							
									"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
							 | 
						||
| 
								 | 
							
									"github.com/iwind/TeaGo/maps"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								type StatusAction struct {
							 | 
						||
| 
								 | 
							
									actionutils.ParentAction
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func (this *StatusAction) RunPost(params struct {
							 | 
						||
| 
								 | 
							
									NodeId int64
							 | 
						||
| 
								 | 
							
								}) {
							 | 
						||
| 
								 | 
							
									statusResp, err := this.RPC().DBNodeRPC().CheckDBNodeStatus(this.AdminContext(), &pb.CheckDBNodeStatusRequest{DbNodeId: params.NodeId})
							 | 
						||
| 
								 | 
							
									if err != nil {
							 | 
						||
| 
								 | 
							
										this.ErrorPage(err)
							 | 
						||
| 
								 | 
							
										return
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									var status = statusResp.DbNodeStatus
							 | 
						||
| 
								 | 
							
									if status != nil {
							 | 
						||
| 
								 | 
							
										this.Data["status"] = maps.Map{
							 | 
						||
| 
								 | 
							
											"isOk":    status.IsOk,
							 | 
						||
| 
								 | 
							
											"error":   status.Error,
							 | 
						||
| 
								 | 
							
											"size":    numberutils.FormatBytes(status.Size),
							 | 
						||
| 
								 | 
							
											"version": status.Version,
							 | 
						||
| 
								 | 
							
										}
							 | 
						||
| 
								 | 
							
									} else {
							 | 
						||
| 
								 | 
							
										this.Data["status"] = nil
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									this.Success()
							 | 
						||
| 
								 | 
							
								}
							 |