mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 05:45:22 +02:00
feat(cache): introduce cache option [EE-6293] (#10641)
This commit is contained in:
parent
fffc7b364e
commit
2c032f1739
70 changed files with 418 additions and 45 deletions
|
@ -23,3 +23,21 @@ func (migrator *Migrator) updateAppTemplatesVersionForDB110() error {
|
|||
|
||||
return migrator.settingsService.UpdateSettings(settings)
|
||||
}
|
||||
|
||||
// setUseCacheForDB110 sets the user cache to true for all users
|
||||
func (migrator *Migrator) setUserCacheForDB110() error {
|
||||
users, err := migrator.userService.ReadAll()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := range users {
|
||||
user := &users[i]
|
||||
user.UseCache = true
|
||||
if err := migrator.userService.Update(user.ID, user); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -231,6 +231,7 @@ func (m *Migrator) initMigrations() {
|
|||
|
||||
m.addMigrations("2.20",
|
||||
m.updateAppTemplatesVersionForDB110,
|
||||
m.setUserCacheForDB110,
|
||||
)
|
||||
|
||||
// Add new migrations below...
|
||||
|
|
|
@ -903,6 +903,7 @@
|
|||
"color": ""
|
||||
},
|
||||
"TokenIssueAt": 0,
|
||||
"UseCache": true,
|
||||
"Username": "admin"
|
||||
},
|
||||
{
|
||||
|
@ -932,10 +933,11 @@
|
|||
"color": ""
|
||||
},
|
||||
"TokenIssueAt": 0,
|
||||
"UseCache": true,
|
||||
"Username": "prabhat"
|
||||
}
|
||||
],
|
||||
"version": {
|
||||
"VERSION": "{\"SchemaVersion\":\"2.20.0\",\"MigratorCount\":1,\"Edition\":1,\"InstanceID\":\"463d5c47-0ea5-4aca-85b1-405ceefee254\"}"
|
||||
"VERSION": "{\"SchemaVersion\":\"2.20.0\",\"MigratorCount\":2,\"Edition\":1,\"InstanceID\":\"463d5c47-0ea5-4aca-85b1-405ceefee254\"}"
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ type userUpdatePayload struct {
|
|||
Username string `validate:"required" example:"bob"`
|
||||
Password string `validate:"required" example:"cg9Wgky3"`
|
||||
NewPassword string `validate:"required" example:"asfj2emv"`
|
||||
UseCache *bool `validate:"required" example:"true"`
|
||||
Theme *themePayload
|
||||
|
||||
// User role (1 for administrator account and 2 for regular account)
|
||||
|
@ -147,6 +148,10 @@ func (handler *Handler) userUpdate(w http.ResponseWriter, r *http.Request) *http
|
|||
}
|
||||
}
|
||||
|
||||
if payload.UseCache != nil {
|
||||
user.UseCache = *payload.UseCache
|
||||
}
|
||||
|
||||
if payload.Role != 0 {
|
||||
user.Role = portainer.UserRole(payload.Role)
|
||||
user.TokenIssueAt = time.Now().Unix()
|
||||
|
|
|
@ -1314,9 +1314,10 @@ type (
|
|||
Username string `json:"Username" example:"bob"`
|
||||
Password string `json:"Password,omitempty" swaggerignore:"true"`
|
||||
// User role (1 for administrator account and 2 for regular account)
|
||||
Role UserRole `json:"Role" example:"1"`
|
||||
TokenIssueAt int64 `json:"TokenIssueAt" example:"1"`
|
||||
ThemeSettings UserThemeSettings
|
||||
Role UserRole `json:"Role" example:"1"`
|
||||
TokenIssueAt int64 `json:"TokenIssueAt" example:"1"`
|
||||
ThemeSettings UserThemeSettings `json:"ThemeSettings"`
|
||||
UseCache bool `json:"UseCache" example:"true"`
|
||||
|
||||
// Deprecated fields
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue