mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-25 10:16:12 +08:00
1.panel和dashboard继承scoperesource。通过joint进行关联 2.dashboade 通过details 参数控制是否返回所关联的panel信息。penel新建时需要此逻辑 3.依据scoperesource属性实现查询,创建的逻辑
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package models
|
|
|
|
import (
|
|
"context"
|
|
|
|
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
|
"yunion.io/x/onecloud/pkg/mcclient"
|
|
)
|
|
|
|
var (
|
|
AlertDashBoardPanelManager *SAlertDashboardPanelManager
|
|
)
|
|
|
|
type SAlertDashboardPanelManager struct {
|
|
db.SJointResourceBaseManager
|
|
}
|
|
|
|
func init() {
|
|
db.InitManager(func() {
|
|
AlertDashBoardPanelManager = &SAlertDashboardPanelManager{
|
|
SJointResourceBaseManager: db.NewJointResourceBaseManager(
|
|
SAlertDashboardPanel{},
|
|
"alertdashboardpanel_tbl",
|
|
"alertdashboardpanel",
|
|
"alertdashboardpanels",
|
|
AlertDashBoardManager,
|
|
AlertPanelManager,
|
|
),
|
|
}
|
|
AlertDashBoardPanelManager.SetVirtualObject(AlertDashBoardPanelManager)
|
|
AlertDashBoardPanelManager.TableSpec().AddIndex(true, AlertDashBoardPanelManager.GetMasterFieldName(), AlertDashBoardPanelManager.GetSlaveFieldName())
|
|
})
|
|
}
|
|
|
|
type SAlertDashboardPanel struct {
|
|
db.SVirtualJointResourceBase
|
|
|
|
DashboardId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"`
|
|
PanelId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"`
|
|
}
|
|
|
|
func (man *SAlertDashboardPanelManager) GetMasterFieldName() string {
|
|
return "dashboard_Id"
|
|
}
|
|
|
|
func (man *SAlertDashboardPanelManager) GetSlaveFieldName() string {
|
|
return "panel_id"
|
|
}
|
|
|
|
func (joint *SAlertDashboardPanel) Detach(ctx context.Context, userCred mcclient.TokenCredential) error {
|
|
return db.DetachJoint(ctx, userCred, joint)
|
|
}
|