mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 13:10:26 +08:00 
			
		
		
		
	增加置顶集群功能
This commit is contained in:
		@@ -145,6 +145,7 @@ func (this *IndexAction) RunGet(params struct {
 | 
				
			|||||||
				"dnsDomainName":     dnsDomainName,
 | 
									"dnsDomainName":     dnsDomainName,
 | 
				
			||||||
				"countServers":      countServersResp.Count,
 | 
									"countServers":      countServersResp.Count,
 | 
				
			||||||
				"timeZone":          cluster.TimeZone,
 | 
									"timeZone":          cluster.TimeZone,
 | 
				
			||||||
 | 
									"isPinned":          cluster.IsPinned,
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,7 @@ func init() {
 | 
				
			|||||||
			Prefix("/clusters").
 | 
								Prefix("/clusters").
 | 
				
			||||||
			Get("", new(IndexAction)).
 | 
								Get("", new(IndexAction)).
 | 
				
			||||||
			GetPost("/create", new(CreateAction)).
 | 
								GetPost("/create", new(CreateAction)).
 | 
				
			||||||
 | 
								Post("/pin", new(PinAction)).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// 只要登录即可访问的Action
 | 
								// 只要登录即可访问的Action
 | 
				
			||||||
			EndHelpers().
 | 
								EndHelpers().
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										34
									
								
								internal/web/actions/default/clusters/pin.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								internal/web/actions/default/clusters/pin.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package clusters
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type PinAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *PinAction) RunPost(params struct {
 | 
				
			||||||
 | 
						ClusterId int64
 | 
				
			||||||
 | 
						IsPinned  bool
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						if params.IsPinned {
 | 
				
			||||||
 | 
							defer this.CreateLogInfo("置顶集群 %d", params.ClusterId)
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							defer this.CreateLogInfo("取消置顶集群 %d", params.ClusterId)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().NodeClusterRPC().UpdateNodeClusterPinned(this.AdminContext(), &pb.UpdateNodeClusterPinnedRequest{
 | 
				
			||||||
 | 
							NodeClusterId: params.ClusterId,
 | 
				
			||||||
 | 
							IsPinned:      params.IsPinned,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					.cluster-name-td {
 | 
				
			||||||
 | 
					  position: relative;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					.cluster-name-td .icon.pin {
 | 
				
			||||||
 | 
					  display: none;
 | 
				
			||||||
 | 
					  position: absolute;
 | 
				
			||||||
 | 
					  right: 1em;
 | 
				
			||||||
 | 
					  top: 50%;
 | 
				
			||||||
 | 
					  margin-top: -0.7em;
 | 
				
			||||||
 | 
					  opacity: 0.6;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					.cluster-name-td .icon.visible {
 | 
				
			||||||
 | 
					  display: inline;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					.cluster-name-td .icon.opacity {
 | 
				
			||||||
 | 
					  opacity: 0.3;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					.cluster-name-td:hover .icon.pin {
 | 
				
			||||||
 | 
					  display: inline;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					/*# sourceMappingURL=index.css.map */
 | 
				
			||||||
@@ -1 +1 @@
 | 
				
			|||||||
undefined
 | 
					{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA;EACC,kBAAA;;AADD,gBAGC,MAAK;EACJ,aAAA;EACA,kBAAA;EACA,UAAA;EACA,QAAA;EACA,kBAAA;EACA,YAAA;;AATF,gBAYC,MAAK;EACJ,eAAA;;AAbF,gBAgBC,MAAK;EACJ,YAAA;;AAIF,gBAAgB,MACf,MAAK;EACJ,eAAA","file":"index.css"}
 | 
				
			||||||
@@ -41,11 +41,14 @@
 | 
				
			|||||||
            </tr>
 | 
					            </tr>
 | 
				
			||||||
        </thead>
 | 
					        </thead>
 | 
				
			||||||
        <tr v-for="cluster in clusters">
 | 
					        <tr v-for="cluster in clusters">
 | 
				
			||||||
            <td>
 | 
					            <td class="cluster-name-td">
 | 
				
			||||||
                <a :href="'/clusters/cluster?clusterId=' + cluster.id"><keyword :v-word="keyword">{{cluster.name}}</keyword></a>
 | 
					                <a :href="'/clusters/cluster?clusterId=' + cluster.id"><keyword :v-word="keyword">{{cluster.name}}</keyword></a>
 | 
				
			||||||
                <div v-if="cluster.timeZone != null && cluster.timeZone.length > 0">
 | 
					                <div v-if="cluster.timeZone != null && cluster.timeZone.length > 0">
 | 
				
			||||||
                    <grey-label>时区:{{cluster.timeZone}}</grey-label>
 | 
					                    <grey-label>时区:{{cluster.timeZone}}</grey-label>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <a href="" title="取消置顶" v-if="cluster.isPinned" @click.prevent="pin(cluster.id, false)"><i class="icon pin grey visible"></i></a>
 | 
				
			||||||
 | 
					                <a href="" title="置顶" v-else @click.prevent="pin(cluster.id, true)"><i class="icon pin grey opacity"></i></a>
 | 
				
			||||||
            </td>
 | 
					            </td>
 | 
				
			||||||
            <td class="center">
 | 
					            <td class="center">
 | 
				
			||||||
                <a :href="'/clusters/cluster/nodes?clusterId=' + cluster.id" v-if="cluster.countAllNodes > 0"><span :class="{red:cluster.countAllNodes > cluster.countActiveNodes}">{{cluster.countAllNodes}}</span></a>
 | 
					                <a :href="'/clusters/cluster/nodes?clusterId=' + cluster.id" v-if="cluster.countAllNodes > 0"><span :class="{red:cluster.countAllNodes > cluster.countActiveNodes}">{{cluster.countAllNodes}}</span></a>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,4 +4,15 @@ Tea.context(function () {
 | 
				
			|||||||
	this.showLatest = function () {
 | 
						this.showLatest = function () {
 | 
				
			||||||
		this.latestVisible = !this.latestVisible
 | 
							this.latestVisible = !this.latestVisible
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.pin = function (clusterId, isPinned) {
 | 
				
			||||||
 | 
							this.$post(".pin")
 | 
				
			||||||
 | 
								.params({
 | 
				
			||||||
 | 
									clusterId: clusterId,
 | 
				
			||||||
 | 
									isPinned: isPinned
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								.success(function () {
 | 
				
			||||||
 | 
									teaweb.reload()
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@@ -1,2 +1,26 @@
 | 
				
			|||||||
table a span {
 | 
					.cluster-name-td {
 | 
				
			||||||
 | 
						position: relative;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						.icon.pin {
 | 
				
			||||||
 | 
							display: none;
 | 
				
			||||||
 | 
							position: absolute;
 | 
				
			||||||
 | 
							right: 1em;
 | 
				
			||||||
 | 
							top: 50%;
 | 
				
			||||||
 | 
							margin-top: -0.7em;
 | 
				
			||||||
 | 
							opacity: 0.6;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						.icon.visible {
 | 
				
			||||||
 | 
							display: inline;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						.icon.opacity {
 | 
				
			||||||
 | 
							opacity: 0.3;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.cluster-name-td:hover {
 | 
				
			||||||
 | 
						.icon.pin {
 | 
				
			||||||
 | 
							display: inline;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user