mirror of
https://github.com/tnb-labs/panel.git
synced 2026-08-31 01:12:17 +08:00
fix: 修复问题
This commit is contained in:
@@ -266,7 +266,14 @@ func (s *App) UpdateDataSource(w http.ResponseWriter, r *http.Request) {
|
||||
for i, item := range list {
|
||||
if ds, ok := item.(map[string]any); ok && ds["name"] == oldName {
|
||||
found = true
|
||||
list[i] = s.buildDatasourceMap(req)
|
||||
newDs := s.buildDatasourceMap(req)
|
||||
// 密码为空时保留原有 secureJsonData
|
||||
if req.Password == "" {
|
||||
if sec, exists := ds["secureJsonData"]; exists {
|
||||
newDs["secureJsonData"] = sec
|
||||
}
|
||||
}
|
||||
list[i] = newDs
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ type ConfigTune struct {
|
||||
// DataSource 数据源
|
||||
type DataSource struct {
|
||||
Name string `form:"name" json:"name" validate:"required"`
|
||||
Type string `form:"type" json:"type" validate:"required"`
|
||||
Type string `form:"type" json:"type" validate:"required|in:prometheus,mysql,postgres,influxdb,loki,elasticsearch"`
|
||||
URL string `form:"url" json:"url" validate:"required"`
|
||||
Access string `form:"access" json:"access"`
|
||||
IsDefault bool `form:"is_default" json:"is_default"`
|
||||
|
||||
@@ -15,6 +15,7 @@ export default {
|
||||
datasources: (): any => http.Get('/apps/grafana/datasources'),
|
||||
createDatasource: (data: any): any => http.Post('/apps/grafana/datasources', data),
|
||||
updateDatasource: (name: string, data: any): any =>
|
||||
http.Post(`/apps/grafana/datasources/${name}`, data),
|
||||
deleteDatasource: (name: string): any => http.Delete(`/apps/grafana/datasources/${name}`)
|
||||
http.Post(`/apps/grafana/datasources/${encodeURIComponent(name)}`, data),
|
||||
deleteDatasource: (name: string): any =>
|
||||
http.Delete(`/apps/grafana/datasources/${encodeURIComponent(name)}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user