put admin controls in its own accordion with position: fixed
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAmRhu64ACgkQO3+8IhRO Y5jB1hAAl/YKwWJO4RaMcU6ezu4fwe1VUO0lD0wu0o645qwGMKd/yuEHsdnyZZku 06e1pmjbfjdAU/5uVB9cRxfE45RnCTlFYFNDCHXr94pTbovDNGuy3D5BjI3x0P5r Nt0UdC5xWqlQW0Hkjo9HDwCnmmRDiuujd5ClIDD5W1tTWphvVg+5XKSAXlyw40pZ 5tZqBUskylltrYoxyCl0Ja2qPUHbDi1uWmtcJMD3um8y+YExUDWbVvheXAgYPADw lV2vl5E5+WRNbDZHnzkxWYKmmePUfnNq6bqLb7iFwpnj2vYWVJLt5XirJK7aILqb dnEqUDN9xYnNSInOsMRIRlKySFAtdo1cxBK40hlhuLYvrLN4tfTYqM4zL7e4cmVl WcsNeEEf3N8YSUJKCM/3KQixFnRVUF2gHYm4hbmW+M1/+4iAo7pDmf7jU1bOlmA2 NV+svlabwq+DiUMLehy9cExYTZ26fFFh0rSRqpYHKlUOSc3ESRP8EtTZhdAlS/Cb nXg4NROPB7x+O5kwIIzhfn6MQdeH1JzTVM37vtAdjQD6eJDNFcvazC+GWzxQOIy4 3bHMxvSfiqRv2DKEv3dm9OGIDDtaAHhw7nHVTlY688lsF4GWHQvuugMRu8J3syqb fxhgK5mUUlanXn0YDUzUCX0m5Ya99jT0KS9aKaCpqVGUPENXlXI= =YZkt -----END PGP SIGNATURE-----
3 files changed,
29 insertions(+),
12 deletions(-)
M
admin/admin.go
→
admin/admin.go
@@ -150,7 +150,7 @@
return http.HandlerFunc(handlerFunc) } -func apiUploadImg(next http.Handler, udb auth.UserStore, dbAdapter mongodb.DbAdapter, uploads, uploadType string, uploadMax int) http.Handler { +func apiUploadImg(next http.Handler, dbAdapter mongodb.DbAdapter, uploads, uploadType string, uploadMax int) http.Handler { handlerFunc := func(w http.ResponseWriter, req *http.Request) { // get table from request body r, err := req.MultipartReader()@@ -218,12 +218,6 @@ }
dest.Write(fileData) dest.Close() - err = dbAdapter.SetMapImageUrl(tableKey, "/uploads/"+tableKey.Name+"/"+uploadType+"/"+header.Filename) - if err != nil { - w.WriteHeader(500) - next.ServeHTTP(w, req) - return - } // respond with URL so UI can update AddContextValue(req, "location", "/uploads/"+tableKey.Name+"/"+uploadType+"/"+header.Filename) next.ServeHTTP(w, req)@@ -259,6 +253,16 @@
return http.HandlerFunc(handlerFunc) } +func apiDeleteImage(next http.Handler, uploads string, uploadType string) http.Handler { + handlerFunc := func(w http.ResponseWriter, req *http.Request) { + // put the path together + // if the file exists, delete it and return the deleted path + // otherwise, return an error + } + + return http.HandlerFunc(handlerFunc) +} + func CreateAdminInterface(udb auth.UserStore, dbAdapter mongodb.DbAdapter, uploads string, uploadMaxMB int) http.Handler { // create quartzgun router rtr := &router.Router{Fallback: *template.Must(template.ParseFiles("static/error.html"))}@@ -274,11 +278,12 @@ rtr.Post("/api/table/", Validate(apiCreateTable(renderer.JSON("result"), udb, dbAdapter), udb, scopes))
rtr.Delete(`/api/table/(?P<Slug>\S+)`, Validate(apiDestroyTable(renderer.JSON("result"), udb, dbAdapter), udb, scopes)) // asset management - rtr.Post(`/api/upload/(?P<Slug>\S+)/map/`, Validate(apiUploadImg(renderer.JSON("location"), udb, dbAdapter, uploads, "map", uploadMaxMB), udb, scopes)) + rtr.Post(`/api/upload/(?P<Slug>\S+)/map/`, Validate(apiUploadImg(renderer.JSON("location"), dbAdapter, uploads, "map", uploadMaxMB), udb, scopes)) // GET /api/upload/<table>/map/ rtr.Get(`/api/upload/(?P<Slug>\S+)/map/`, Validate(apiListImages(renderer.JSON("files"), uploads, "map"), udb, scopes)) // DELETE /api/upload/<table>/map/<map> - rtr.Post(`/api/upload/(?P<Slug>\S+)/token/`, Validate(apiUploadImg(renderer.JSON("location"), udb, dbAdapter, uploads, "token", uploadMaxMB), udb, scopes)) + rtr.Post(`/api/upload/(?P<Slug>\S+)/token/`, Validate(apiUploadImg(renderer.JSON("location"), dbAdapter, uploads, "token", uploadMaxMB), udb, scopes)) + rtr.Get(`/api/upload/(?P<Slug>\S+)/token/`, Validate(apiListImages(renderer.JSON("files"), uploads, "token"), udb, scopes)) // DELETE /api/upload/<table>/token/<token> return http.HandlerFunc(rtr.ServeHTTP)
M
static/index.html
→
static/index.html
@@ -60,8 +60,7 @@ <div id="dice_log"></div>
<div id="aux"></div> <div id="map"></div> </main> - <div id="adminWrapper" style="display:none;"> - <div id="adminCtrl"> + <details id="adminWrapper" style="display:none;"><summary>admin</summary> <button onclick="setTableCreateFormVisible(true)">New Table</button> <form onsubmit="return false" id="createTableForm" style="display:none;"> <input id="newTableName"/>@@ -71,7 +70,7 @@ <button onclick="setTableCreateFormVisible(false)">Cancel</button>
</form> </div> <div id="adminZone"></div> - </div> + </details> </body> <script src="./util.js" type="text/javascript"></script> <script src="./socket.js" type="text/javascript"></script>
M
static/style.css
→
static/style.css
@@ -86,4 +86,17 @@ color: #000;
height: auto; width: auto; border: solid 1px dimgray; +} + +#adminWrapper { + position: fixed; + top: 2em; + right: 0; + padding: 1em; + border: solid 1px #fff; + background: rgba(0,0,0,0.8); + color: #fff; + box-sizing: border-box; + max-height: calc(100vh - 4em); + overflow-y: auto; }