Add profile 3D preferences and adapt DICOM preview resolution to memory budget
This commit is contained in:
1 parent
705762d57c
commit
7fd7ae6733
22 files changed
+500
-68
No files matched your search
+17
-16
@@ -6,22 +6,23 @@ import (
|
||||
)
|
||||
|
||||
type userInfo struct {
|
||||
ID uint `json:"id"`
|
||||
Locale string `json:"locale"`
|
||||
ViewMode users.ViewMode `json:"viewMode"`
|
||||
SingleClick bool `json:"singleClick"`
|
||||
RedirectAfterCopyMove bool `json:"redirectAfterCopyMove"`
|
||||
Perm users.Permissions `json:"perm"`
|
||||
Commands []string `json:"commands"`
|
||||
LockPassword bool `json:"lockPassword"`
|
||||
HideDotfiles bool `json:"hideDotfiles"`
|
||||
HidePreviews bool `json:"hidePreviews"`
|
||||
DateFormat bool `json:"dateFormat"`
|
||||
Username string `json:"username"`
|
||||
ProfileName string `json:"profileName,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Picture string `json:"picture,omitempty"`
|
||||
AceEditorTheme string `json:"aceEditorTheme"`
|
||||
ID uint `json:"id"`
|
||||
Locale string `json:"locale"`
|
||||
ViewMode users.ViewMode `json:"viewMode"`
|
||||
SingleClick bool `json:"singleClick"`
|
||||
RedirectAfterCopyMove bool `json:"redirectAfterCopyMove"`
|
||||
Perm users.Permissions `json:"perm"`
|
||||
Commands []string `json:"commands"`
|
||||
LockPassword bool `json:"lockPassword"`
|
||||
HideDotfiles bool `json:"hideDotfiles"`
|
||||
HidePreviews bool `json:"hidePreviews"`
|
||||
Dicom3D users.Dicom3DSettings `json:"dicom3D"`
|
||||
DateFormat bool `json:"dateFormat"`
|
||||
Username string `json:"username"`
|
||||
ProfileName string `json:"profileName,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Picture string `json:"picture,omitempty"`
|
||||
AceEditorTheme string `json:"aceEditorTheme"`
|
||||
}
|
||||
|
||||
func withUser(fn handleFunc) handleFunc {
|
||||
|
||||
+1
-1
@@ -462,5 +462,5 @@ func applySSOIdentity(u *users.User, i sessionIdentity) {
|
||||
u.DisplayName = i.Name
|
||||
}
|
||||
func ssoUserInfo(u *users.User) userInfo {
|
||||
return userInfo{ID: u.ID, Username: u.DisplayName, ProfileName: u.ProfileName, Email: u.Email, Locale: u.Locale, ViewMode: u.ViewMode, SingleClick: u.SingleClick, RedirectAfterCopyMove: u.RedirectAfterCopyMove, Perm: u.Perm, Commands: []string{}, LockPassword: true, HideDotfiles: u.HideDotfiles, HidePreviews: u.HidePreviews, DateFormat: u.DateFormat, AceEditorTheme: u.AceEditorTheme}
|
||||
return userInfo{ID: u.ID, Username: u.DisplayName, ProfileName: u.ProfileName, Email: u.Email, Locale: u.Locale, ViewMode: u.ViewMode, SingleClick: u.SingleClick, RedirectAfterCopyMove: u.RedirectAfterCopyMove, Perm: u.Perm, Commands: []string{}, LockPassword: true, HideDotfiles: u.HideDotfiles, HidePreviews: u.HidePreviews, Dicom3D: u.Dicom3D.Normalized(), DateFormat: u.DateFormat, AceEditorTheme: u.AceEditorTheme}
|
||||
}
|
||||
@@ -12,6 +12,40 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func TestDicom3DPreferencesAreSelfEditableAndValidated(t *testing.T) {
|
||||
st := scopedUserStorage(t, t.TempDir(), users.Permissions{}, []byte("key"))
|
||||
for _, test := range []struct {
|
||||
body string
|
||||
status int
|
||||
}{
|
||||
{`{"what":"user","which":["dicom3D"],"data":{"id":1,"dicom3D":{"memoryMiB":512,"quality":"auto","opacity":50}}}`, 200},
|
||||
{`{"what":"user","which":["dicom3D"],"data":{"id":1,"dicom3D":{"memoryMiB":2048,"quality":"auto","opacity":50}}}`, 400},
|
||||
{`{"what":"user","which":["dicom3D"],"data":{"id":1,"dicom3D":{"quality":"invalid"}}}`, 400},
|
||||
} {
|
||||
r := mux.SetURLVars(httptest.NewRequest("PUT", "/users/1", strings.NewReader(test.body)), map[string]string{"id": "1"})
|
||||
r = authorizeTestRequest(r, testSession(1, "u", false))
|
||||
w := httptest.NewRecorder()
|
||||
handle(userPutHandler, "", st, &settings.Server{}).ServeHTTP(w, r)
|
||||
if w.Code != test.status {
|
||||
t.Fatalf("status %d, want %d: %s", w.Code, test.status, w.Body.String())
|
||||
}
|
||||
}
|
||||
u, err := st.Users.Get("", false, uint(1))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if u.Dicom3D.MemoryMiB != 512 || u.Dicom3D.Opacity != 50 || u.Dicom3D.Quality != "auto" {
|
||||
t.Fatalf("settings not persisted: %+v", u.Dicom3D)
|
||||
}
|
||||
if u.Perm.Admin {
|
||||
t.Fatal("preferences changed permissions")
|
||||
}
|
||||
// Check the same profile representation returned on subsequent SSO sessions.
|
||||
if ssoUserInfo(u).Dicom3D != u.Dicom3D {
|
||||
t.Fatal("session profile lost preferences")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalAdminCannotOverrideSSORole(t *testing.T) {
|
||||
st := scopedUserStorage(t, t.TempDir(), users.Permissions{Admin: true}, []byte("key"))
|
||||
r := authorizeTestRequest(httptest.NewRequest("GET", "/", nil), testSession(1, "u", false))
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ var userPutHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request
|
||||
if req.Data == nil || req.Data.ID != d.raw.(uint) || len(req.Which) == 0 || req.Data.Password != "" {
|
||||
return http.StatusBadRequest, nil
|
||||
}
|
||||
allowed := map[string]string{"scope": "Scope", "perm": "Perm", "rules": "Rules", "locale": "Locale", "viewmode": "ViewMode", "singleclick": "SingleClick", "redirectaftercopymove": "RedirectAfterCopyMove", "hidedotfiles": "HideDotfiles", "hidepreviews": "HidePreviews", "dateformat": "DateFormat", "aceeditortheme": "AceEditorTheme", "sorting": "Sorting"}
|
||||
allowed := map[string]string{"scope": "Scope", "perm": "Perm", "rules": "Rules", "locale": "Locale", "viewmode": "ViewMode", "singleclick": "SingleClick", "redirectaftercopymove": "RedirectAfterCopyMove", "hidedotfiles": "HideDotfiles", "hidepreviews": "HidePreviews", "dicom3d": "Dicom3D", "dateformat": "DateFormat", "aceeditortheme": "AceEditorTheme", "sorting": "Sorting"}
|
||||
for i, field := range req.Which {
|
||||
canonical, ok := allowed[strings.ToLower(field)]
|
||||
if !ok {
|
||||
|
||||
Reference in new issue
Block a user