فهرست منبع

fix(apps): app dashboards can now be updated, fixes #4817

Torkel Ödegaard 9 سال پیش
والد
کامیت
bce5c447b3

+ 1 - 1
pkg/api/dtos/plugins.go

@@ -48,6 +48,6 @@ func (slice PluginList) Swap(i, j int) {
 type ImportDashboardCommand struct {
 type ImportDashboardCommand struct {
 	PluginId  string                         `json:"pluginId"`
 	PluginId  string                         `json:"pluginId"`
 	Path      string                         `json:"path"`
 	Path      string                         `json:"path"`
-	Reinstall bool                           `json:"reinstall"`
+	Overwrite bool                           `json:"overwrite"`
 	Inputs    []plugins.ImportDashboardInput `json:"inputs"`
 	Inputs    []plugins.ImportDashboardInput `json:"inputs"`
 }
 }

+ 6 - 5
pkg/api/plugins.go

@@ -156,11 +156,12 @@ func GetPluginReadme(c *middleware.Context) Response {
 func ImportDashboard(c *middleware.Context, apiCmd dtos.ImportDashboardCommand) Response {
 func ImportDashboard(c *middleware.Context, apiCmd dtos.ImportDashboardCommand) Response {
 
 
 	cmd := plugins.ImportDashboardCommand{
 	cmd := plugins.ImportDashboardCommand{
-		OrgId:    c.OrgId,
-		UserId:   c.UserId,
-		PluginId: apiCmd.PluginId,
-		Path:     apiCmd.Path,
-		Inputs:   apiCmd.Inputs,
+		OrgId:     c.OrgId,
+		UserId:    c.UserId,
+		PluginId:  apiCmd.PluginId,
+		Path:      apiCmd.Path,
+		Inputs:    apiCmd.Inputs,
+		Overwrite: apiCmd.Overwrite,
 	}
 	}
 
 
 	if err := bus.Dispatch(&cmd); err != nil {
 	if err := bus.Dispatch(&cmd); err != nil {

+ 7 - 5
pkg/plugins/dashboard_importer.go

@@ -11,12 +11,13 @@ import (
 )
 )
 
 
 type ImportDashboardCommand struct {
 type ImportDashboardCommand struct {
-	Path   string                 `json:"string"`
-	Inputs []ImportDashboardInput `json:"inputs"`
+	Path      string
+	Inputs    []ImportDashboardInput
+	Overwrite bool
 
 
-	OrgId    int64  `json:"-"`
-	UserId   int64  `json:"-"`
-	PluginId string `json:"-"`
+	OrgId    int64
+	UserId   int64
+	PluginId string
 	Result   *PluginDashboardInfoDTO
 	Result   *PluginDashboardInfoDTO
 }
 }
 
 
@@ -67,6 +68,7 @@ func ImportDashboard(cmd *ImportDashboardCommand) error {
 		Dashboard: generatedDash,
 		Dashboard: generatedDash,
 		OrgId:     cmd.OrgId,
 		OrgId:     cmd.OrgId,
 		UserId:    cmd.UserId,
 		UserId:    cmd.UserId,
+		Overwrite: cmd.Overwrite,
 	}
 	}
 
 
 	if err := bus.Dispatch(&saveCmd); err != nil {
 	if err := bus.Dispatch(&saveCmd); err != nil {

+ 4 - 4
public/app/features/plugins/import_list/import_list.html

@@ -15,16 +15,16 @@
 				</td>
 				</td>
 				<td>
 				<td>
 					v{{dash.revision}}
 					v{{dash.revision}}
-				</td>
-				<td ng-if="dash.installed">
-					Imported v{{dash.installedRevision}}
+					<span ng-if="dash.installed">
+						&nbsp;(Imported v{{dash.installedRevision}})
+					<span>
 				</td>
 				</td>
 				<td style="text-align: right">
 				<td style="text-align: right">
 					<button class="btn btn-secondary" ng-click="ctrl.import(dash, false)" ng-show="!dash.installed">
 					<button class="btn btn-secondary" ng-click="ctrl.import(dash, false)" ng-show="!dash.installed">
 						Import
 						Import
 					</button>
 					</button>
 					<button class="btn btn-secondary" ng-click="ctrl.import(dash, true)" ng-show="dash.installed">
 					<button class="btn btn-secondary" ng-click="ctrl.import(dash, true)" ng-show="dash.installed">
-						Re-Import
+						Update
 					</button>
 					</button>
 					<button class="btn btn-danger" ng-click="ctrl.remove(dash)" ng-show="dash.installed">
 					<button class="btn btn-danger" ng-click="ctrl.remove(dash)" ng-show="dash.installed">
 						Delete
 						Delete

+ 2 - 2
public/app/features/plugins/import_list/import_list.ts

@@ -43,11 +43,11 @@ export class DashImportListCtrl {
     });
     });
   }
   }
 
 
-  import(dash, reinstall) {
+  import(dash, overwrite) {
     var installCmd = {
     var installCmd = {
       pluginId: this.plugin.id,
       pluginId: this.plugin.id,
       path: dash.path,
       path: dash.path,
-      reinstall: reinstall,
+      overwrite: overwrite,
       inputs: []
       inputs: []
     };
     };