Skip to content

Commit

Permalink
fix(monitor): clone alert dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
zexi committed Dec 2, 2024
1 parent e84e532 commit cd56cea
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/monitor/models/alertdashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,15 @@ func (dash *SAlertDashBoard) PerformCloneDashboard(ctx context.Context, userCred
return nil, errors.Wrapf(err, "dashboard:%s getAttachPanels err", dash.Id)
}
for _, panel := range alertPanels {
err := panel.attachDashboard(ctx, iModel.(*SAlertDashBoard).Id)
newDashId := iModel.(*SAlertDashBoard).GetId()
_, err := panel.ClonePanel(ctx, newDashId, monitor.AlertClonePanelInput{})
if err != nil {
err := iModel.Delete(ctx, userCred)
if err != nil {
log.Errorf("delete cloneDashboard:%s err when panel attachDashboard err:%v", input.CloneName, err)
}
return nil, errors.Wrapf(err, "panel:%s attachCloneDashboard:%s err", panel.Name, input.CloneName)
return nil, errors.Wrapf(err, "ClonePanel %s for dashboard %s", panel.GetId(), newDashId)
}
}
boardDetails, err := iModel.(*SAlertDashBoard).GetMoreDetails(monitor.AlertDashBoardDetails{})
if err != nil {
return nil, errors.Wrap(err, "cloneDashboard getDetails err")
return nil, errors.Wrap(err, "GetMoreDetails of dashboard")
}
output := jsonutils.Marshal(iModel)
output.(*jsonutils.JSONDict).Update((jsonutils.Marshal(&boardDetails)))
Expand Down

0 comments on commit cd56cea

Please sign in to comment.