feat(apps): minor progress on app meta data
This commit is contained in:
+17
-22
@@ -15,36 +15,31 @@ func GetAppPlugins(c *middleware.Context) Response {
|
||||
return ApiError(500, "Failed to list Plugin Bundles", err)
|
||||
}
|
||||
|
||||
installedAppsMap := make(map[string]*dtos.AppPlugin)
|
||||
for t, a := range plugins.Apps {
|
||||
installedAppsMap[t] = &dtos.AppPlugin{
|
||||
Type: a.Type,
|
||||
Enabled: a.Enabled,
|
||||
Pinned: a.Pinned,
|
||||
Module: a.Module,
|
||||
JsonData: make(map[string]interface{}),
|
||||
translateToDto := func(app *plugins.AppPlugin) *dtos.AppPlugin {
|
||||
return &dtos.AppPlugin{
|
||||
Name: app.Name,
|
||||
Type: app.Type,
|
||||
Enabled: app.Enabled,
|
||||
Pinned: app.Pinned,
|
||||
Module: app.Module,
|
||||
}
|
||||
}
|
||||
|
||||
seenApps := make(map[string]bool)
|
||||
|
||||
result := make([]*dtos.AppPlugin, 0)
|
||||
for _, b := range query.Result {
|
||||
if def, ok := installedAppsMap[b.Type]; ok {
|
||||
result = append(result, &dtos.AppPlugin{
|
||||
Type: b.Type,
|
||||
Enabled: b.Enabled,
|
||||
Pinned: b.Pinned,
|
||||
Module: def.Module,
|
||||
JsonData: b.JsonData,
|
||||
})
|
||||
seenApps[b.Type] = true
|
||||
for _, orgApp := range query.Result {
|
||||
if def, ok := plugins.Apps[orgApp.Type]; ok {
|
||||
pluginDto := translateToDto(def)
|
||||
pluginDto.Enabled = orgApp.Enabled
|
||||
pluginDto.JsonData = orgApp.JsonData
|
||||
result = append(result, pluginDto)
|
||||
seenApps[orgApp.Type] = true
|
||||
}
|
||||
}
|
||||
|
||||
for t, a := range installedAppsMap {
|
||||
if _, ok := seenApps[t]; !ok {
|
||||
result = append(result, a)
|
||||
for _, app := range plugins.Apps {
|
||||
if _, ok := seenApps[app.Type]; !ok {
|
||||
result = append(result, translateToDto(app))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dtos
|
||||
|
||||
type AppPlugin struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Pinned bool `json:"pinned"`
|
||||
|
||||
Reference in New Issue
Block a user