feat: add max upload size setting to UI & UI improvements (#1646)

* Add preliminar Windows support for both
development and production environments.

Default profile.Data will be set to "C:\ProgramData\memos" on Windows.
Folder will be created if it does not exist, as this behavior is
expected for Windows applications.

System service installation can be achieved with third-party tools,
explained in docs/windows-service.md.

Not sure if it's worth using https://github.com/kardianos/service
to make service support built-in.

This could be a nice addition alongside #1583 (add Windows artifacts)

* feat: improve Windows support

- Fix local file storage path handling on Windows

- Improve Windows dev script

* feat: add max upload size setting to UI & more

- feat: add max upload size setting to UI

- feat: max upload size setting is checked on UI during upload,
but also enforced by the server

- fix: overflowing mobile layout for Create SSO, Create Storage
and other Settings dialogs

- feat: add HelpButton component with some links to docs were appropriate

- remove LearnMore component in favor of HelpButton

- refactor: change some if/else to switch statements

- refactor: inline some err == nil checks

! Existing databases without the new setting 'max-upload-size-mib'
will show an upload error, but this can be user-fixed by simply
setting the value on system settings UI.

* improvements requested by @boojack
This commit is contained in:
Lincoln Nogueira
2023-05-13 11:27:28 -03:00
committed by GitHub
parent 5c5199920e
commit 96021e518a
20 changed files with 591 additions and 204 deletions

View File

@ -44,6 +44,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
AllowSignUp: false,
IgnoreUpgrade: false,
DisablePublicMemos: false,
MaxUploadSizeMiB: 32,
AdditionalStyle: "",
AdditionalScript: "",
CustomizedProfile: api.CustomizedProfile{
@ -74,27 +75,40 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
continue
}
if systemSetting.Name == api.SystemSettingAllowSignUpName {
switch systemSetting.Name {
case api.SystemSettingAllowSignUpName:
systemStatus.AllowSignUp = baseValue.(bool)
} else if systemSetting.Name == api.SystemSettingIgnoreUpgradeName {
case api.SystemSettingIgnoreUpgradeName:
systemStatus.IgnoreUpgrade = baseValue.(bool)
} else if systemSetting.Name == api.SystemSettingDisablePublicMemosName {
case api.SystemSettingDisablePublicMemosName:
systemStatus.DisablePublicMemos = baseValue.(bool)
} else if systemSetting.Name == api.SystemSettingAdditionalStyleName {
case api.SystemSettingMaxUploadSizeMiBName:
systemStatus.MaxUploadSizeMiB = int(baseValue.(float64))
case api.SystemSettingAdditionalStyleName:
systemStatus.AdditionalStyle = baseValue.(string)
} else if systemSetting.Name == api.SystemSettingAdditionalScriptName {
case api.SystemSettingAdditionalScriptName:
systemStatus.AdditionalScript = baseValue.(string)
} else if systemSetting.Name == api.SystemSettingCustomizedProfileName {
case api.SystemSettingCustomizedProfileName:
customizedProfile := api.CustomizedProfile{}
err := json.Unmarshal([]byte(systemSetting.Value), &customizedProfile)
if err != nil {
if err := json.Unmarshal([]byte(systemSetting.Value), &customizedProfile); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting customized profile value").SetInternal(err)
}
systemStatus.CustomizedProfile = customizedProfile
} else if systemSetting.Name == api.SystemSettingStorageServiceIDName {
case api.SystemSettingStorageServiceIDName:
systemStatus.StorageServiceID = int(baseValue.(float64))
} else if systemSetting.Name == api.SystemSettingLocalStoragePathName {
case api.SystemSettingLocalStoragePathName:
systemStatus.LocalStoragePath = baseValue.(string)
default:
log.Warn("Unknown system setting name", zap.String("setting name", systemSetting.Name.String()))
}
}