Adapt to recent change of session-interface in surflet-handler
This commit is contained in:
parent
5b2e2ddd6a
commit
20821bdfb5
|
@ -72,28 +72,31 @@
|
||||||
(show-outdated (make-callback show-surflets))
|
(show-outdated (make-callback show-surflets))
|
||||||
(for-each unload-surflet surflet-names)))
|
(for-each unload-surflet surflet-names)))
|
||||||
|
|
||||||
(define (no-surflets)
|
(define (no-surflets callback)
|
||||||
`(p "Currently, there are no SUrflets loaded "
|
`(p "Currently, there are no SUrflets loaded "
|
||||||
(url ,(make-callback show-surflets) "(reload)")
|
(url ,(callback show-surflets) "(reload)")
|
||||||
", but there may be "
|
", but there may be "
|
||||||
(url ,(make-callback show-sessions) "sessions")
|
(url ,(callback show-sessions) "sessions")
|
||||||
" you want to administer."))
|
" you want to administer."))
|
||||||
|
|
||||||
(define (show-surflets req . maybe-update-text)
|
(define (show-surflets req . maybe-update-text)
|
||||||
(let* ((update-text (:optional maybe-update-text ""))
|
(let* ((update-text (:optional maybe-update-text ""))
|
||||||
(loaded-surflets (sort-list! (get-loaded-surflets) string<?))
|
(loaded-surflets (sort-list! (get-loaded-surflets) string<?))
|
||||||
(outdated? (make-outdater))
|
(outdated? (make-outdater))
|
||||||
|
(callback (make-annotated-callback callback-functor))
|
||||||
(title "SUrflet-Administration -- SUrflets")
|
(title "SUrflet-Administration -- SUrflets")
|
||||||
(header `((h1 "SUrflet Administration")
|
(header `((h1 "SUrflet Administration")
|
||||||
(h2 "SUrflets")
|
(h2 "SUrflets")
|
||||||
(p (font (@ (color "red")) ,update-text))))
|
(p (font (@ (color "red")) ,update-text))))
|
||||||
(footer `((hr)
|
(footer `((hr)
|
||||||
(url ,(make-callback return-to-main-page) "Return to administration menu.")
|
(url ,(callback return-to-main-page)
|
||||||
|
"Return to administration menu.")
|
||||||
(br)
|
(br)
|
||||||
(url "/" "Return to main menu.")))
|
(url "/" "Return to main menu.")))
|
||||||
(actions '("unload" "unload all")))
|
(actions '("unload" "unload all")))
|
||||||
(if (null? loaded-surflets)
|
(if (null? loaded-surflets)
|
||||||
(send-html `(html (title ,title) (body ,header ,(no-surflets) ,footer)))
|
(send-html `(html (title ,title)
|
||||||
|
(body ,header ,(no-surflets callback) ,footer)))
|
||||||
(receive (action selected-surflets req)
|
(receive (action selected-surflets req)
|
||||||
(select-table title ; title
|
(select-table title ; title
|
||||||
header ; header
|
header ; header
|
||||||
|
@ -107,7 +110,7 @@
|
||||||
`(p "Note that unloading the SUrflets does not imply "
|
`(p "Note that unloading the SUrflets does not imply "
|
||||||
"the unloading of sessions of this SUrflet. " (br)
|
"the unloading of sessions of this SUrflet. " (br)
|
||||||
"This can be done on the "
|
"This can be done on the "
|
||||||
(url ,(make-callback show-sessions)
|
(url ,(callback show-sessions)
|
||||||
"sessions adminstration page."))
|
"sessions adminstration page."))
|
||||||
footer))
|
footer))
|
||||||
(if (not action)
|
(if (not action)
|
||||||
|
@ -125,20 +128,21 @@
|
||||||
(else
|
(else
|
||||||
(error "unknown action" action)))))))))
|
(error "unknown action" action)))))))))
|
||||||
|
|
||||||
(define (session-surflet-name<? entry1 entry2)
|
(define (session-surflet-name<? session1 session2)
|
||||||
(let ((name1 (session-surflet-name (cdr entry1)))
|
(let ((name1 (session-surflet-name session1))
|
||||||
(name2 (session-surflet-name (cdr entry2))))
|
(name2 (session-surflet-name session2)))
|
||||||
;; handle multiple session names
|
;; handle multiple session names
|
||||||
(if (string=? name1 name2)
|
(if (string=? name1 name2)
|
||||||
(session-id<? entry1 entry2)
|
(session-id<? session1 session2)
|
||||||
(string<? name1 name2))))
|
(string<? name1 name2))))
|
||||||
(define (session-id<? entry1 entry2)
|
(define (session-id<? session1 session2)
|
||||||
;; there are no multiple session-ids
|
;; there are no multiple session-ids
|
||||||
(< (car entry1) (car entry2)))
|
(< (session-session-id session1)
|
||||||
(define (session-id>? entry1 entry2)
|
(session-session-id session2)))
|
||||||
(session-id<? entry2 entry1))
|
(define (session-surflet-name>? session1 session2)
|
||||||
(define (session-surflet-name>? entry1 entry2)
|
(session-surflet-name<? session2 session1))
|
||||||
(session-surflet-name<? entry2 entry1))
|
(define (session-id>? session1 session2)
|
||||||
|
(session-id<? session2 session1))
|
||||||
|
|
||||||
(define (no-current-sessions)
|
(define (no-current-sessions)
|
||||||
;; Avoid using send/suspend in this context as there
|
;; Avoid using send/suspend in this context as there
|
||||||
|
@ -155,7 +159,8 @@
|
||||||
(my-session-id req))))
|
(my-session-id req))))
|
||||||
|
|
||||||
(define (real-sessions current-sessions update-text this-session-id)
|
(define (real-sessions current-sessions update-text this-session-id)
|
||||||
(let ((outdated? (make-outdater))
|
(let* ((outdated? (make-outdater))
|
||||||
|
(callback (make-annotated-callback callback-functor))
|
||||||
(title "SUrflet Adminstration - Sessions")
|
(title "SUrflet Adminstration - Sessions")
|
||||||
(header `((h1 "SUrflet Administration")
|
(header `((h1 "SUrflet Administration")
|
||||||
(h2 "Sessions")
|
(h2 "Sessions")
|
||||||
|
@ -165,14 +170,15 @@
|
||||||
"session (id: " ,this-session-id ").")
|
"session (id: " ,this-session-id ").")
|
||||||
#f)
|
#f)
|
||||||
(hr)
|
(hr)
|
||||||
(url ,(make-callback show-surflets) "Return to SUrflets menu.") (br)
|
(url ,(callback show-surflets)
|
||||||
(url ,(make-callback return-to-main-page) "Return to administration menu.")
|
"Return to SUrflets menu.")
|
||||||
(br)
|
(br) (url ,(callback return-to-main-page)
|
||||||
(url "/" "Return to main menu.")))
|
"Return to administration menu.")
|
||||||
|
(br) (url "/" "Return to main menu.")))
|
||||||
(actions '("kill"
|
(actions '("kill"
|
||||||
"adjust timeout"
|
"adjust timeout"
|
||||||
"view continuations"))
|
"view continuations"))
|
||||||
(sessions-callback (make-callback show-sessions)))
|
(sessions-callback (callback show-sessions)))
|
||||||
(if (null? current-sessions)
|
(if (null? current-sessions)
|
||||||
(send-html `(html (title ,title)
|
(send-html `(html (title ,title)
|
||||||
(body ,@header ,(no-current-sessions) ,footer)))
|
(body ,@header ,(no-current-sessions) ,footer)))
|
||||||
|
@ -181,11 +187,10 @@
|
||||||
header
|
header
|
||||||
`((th "SUrflet Name") (th "Session-Id"))
|
`((th "SUrflet Name") (th "Session-Id"))
|
||||||
current-sessions
|
current-sessions
|
||||||
(lambda (session-pair)
|
(lambda (session)
|
||||||
(let ((session-id (car session-pair))
|
`((td ,(session-surflet-name session))
|
||||||
(session-entry (cdr session-pair)))
|
(td (@ (align "right"))
|
||||||
`((td ,(session-surflet-name session-entry))
|
,(session-session-id session))))
|
||||||
(td (@ (align "right")) ,session-id))))
|
|
||||||
actions
|
actions
|
||||||
footer)
|
footer)
|
||||||
(if (not action)
|
(if (not action)
|
||||||
|
@ -196,13 +201,13 @@
|
||||||
(if-outdated outdated?
|
(if-outdated outdated?
|
||||||
(show-outdated sessions-callback)
|
(show-outdated sessions-callback)
|
||||||
(for-each delete-session!
|
(for-each delete-session!
|
||||||
(map car selected-sessions)))
|
selected-sessions))
|
||||||
"Sessions killed.")
|
"Sessions killed.")
|
||||||
((string=? action "adjust timeout")
|
((string=? action "adjust timeout")
|
||||||
(if-outdated outdated?
|
(if-outdated outdated?
|
||||||
(show-outdated sessions-callback)
|
(show-outdated sessions-callback)
|
||||||
(for-each session-adjust-timeout!
|
(for-each session-adjust-timeout!
|
||||||
(map car selected-sessions)))
|
selected-sessions))
|
||||||
"Timeout adjusted.")
|
"Timeout adjusted.")
|
||||||
((string=? action "view continuations")
|
((string=? action "view continuations")
|
||||||
(if-outdated outdated?
|
(if-outdated outdated?
|
||||||
|
@ -210,20 +215,19 @@
|
||||||
(if (zero? (length selected-sessions))
|
(if (zero? (length selected-sessions))
|
||||||
"You must choose at least one session."
|
"You must choose at least one session."
|
||||||
;; this does not return
|
;; this does not return
|
||||||
(show-continuations selected-sessions req))))
|
(show-continuations req selected-sessions))))
|
||||||
(else
|
(else
|
||||||
(error "unknown action" action)))))
|
(error "unknown action" action)))))
|
||||||
(show-sessions req new-update-text)))))))
|
(show-sessions req new-update-text)))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define (no-current-continuations session req)
|
(define (no-current-continuations callback session req)
|
||||||
`((p "Currently, there are no continuations for this session. ")
|
`((p "Currently, there are no continuations for this session. ")
|
||||||
(p "You may " (url ,(make-callback
|
(p "You may " (url ,(callback show-continuations (list session))
|
||||||
(lambda (req) (show-continuations (list session) req)))
|
|
||||||
"reload")
|
"reload")
|
||||||
" this page or go back to the "
|
" this page or go back to the "
|
||||||
(url ,(make-callback show-sessions) "session table overview."))))
|
(url ,(callback show-sessions) "session table overview."))))
|
||||||
|
|
||||||
(define (no-more-than-one-session title header1 sessions req)
|
(define (no-more-than-one-session title header1 sessions req)
|
||||||
(let* ((address (make-annotated-address))
|
(let* ((address (make-annotated-address))
|
||||||
|
@ -242,37 +246,38 @@
|
||||||
" where you can select one session"
|
" where you can select one session"
|
||||||
" or select one session from your chosen sessions:" (br)
|
" or select one session from your chosen sessions:" (br)
|
||||||
(ul
|
(ul
|
||||||
,@(map (lambda (session)
|
,@(map
|
||||||
|
(lambda (session)
|
||||||
`(li (url ,(address k-url session)
|
`(li (url ,(address k-url session)
|
||||||
,(session-surflet-name (cdr session))
|
,(session-surflet-name session)
|
||||||
" (" ,(car session) ")")))
|
" (" ,(session-session-id session) ")")))
|
||||||
sessions))))))))
|
sessions))))))))
|
||||||
(bindings (get-bindings req))
|
(bindings (get-bindings req))
|
||||||
(chosen-session (returned-via address bindings)))
|
(chosen-session (returned-via address bindings)))
|
||||||
(show-continuations (list chosen-session) req)))
|
(show-continuations req (list chosen-session))))
|
||||||
|
|
||||||
(define (continuation-id<? entry1 entry2)
|
(define (continuation-id<? cont1 cont2)
|
||||||
(< (car entry1) (car entry2)))
|
(< (continuation-id cont1)
|
||||||
|
(continuation-id cont2)))
|
||||||
|
|
||||||
(define (show-continuations sessions req . maybe-update-text)
|
(define (show-continuations req sessions . maybe-update-text)
|
||||||
(let ((title "SUrflet Adminstration - Continuations")
|
(let ((title "SUrflet Adminstration - Continuations")
|
||||||
(header1 '(h1 "SUrflet Administration")))
|
(header1 '(h1 "SUrflet Administration")))
|
||||||
(if (not (= 1 (length sessions)))
|
(if (not (= 1 (length sessions)))
|
||||||
(no-more-than-one-session title header1 sessions req)
|
(no-more-than-one-session title header1 sessions req)
|
||||||
(let* ((session-pair (car sessions))
|
(let* ((session (car sessions))
|
||||||
(session-id (car session-pair))
|
(session-id (session-session-id session))
|
||||||
(session-entry (cdr session-pair))
|
|
||||||
(this-continuation-id (my-continuation-id req))
|
(this-continuation-id (my-continuation-id req))
|
||||||
(update-text (:optional maybe-update-text "")))
|
(update-text (:optional maybe-update-text ""))
|
||||||
(let* ((current-continuations
|
(current-continuations
|
||||||
(sort-list! (get-continuations session-id)
|
(sort-list! (get-continuations session-id)
|
||||||
continuation-id<?))
|
continuation-id<?))
|
||||||
(outdated? (make-outdater))
|
(outdated? (make-outdater))
|
||||||
|
(callback (make-annotated-callback callback-functor))
|
||||||
(header (cons header1
|
(header (cons header1
|
||||||
`((h2 "Continuations of " ,session-id)
|
`((h2 "Continuations of " ,session-id)
|
||||||
(p "(belongs to the SUrflet '"
|
(p "(belongs to the SUrflet '"
|
||||||
,(session-surflet-name session-entry) "')")
|
,(session-surflet-name session) "')")
|
||||||
(p (font (@ (color "red")) ,update-text)))))
|
(p (font (@ (color "red")) ,update-text)))))
|
||||||
(footer
|
(footer
|
||||||
`(,(if (not (null? current-continuations))
|
`(,(if (not (null? current-continuations))
|
||||||
|
@ -280,32 +285,33 @@
|
||||||
"continuation (id: " ,this-continuation-id ").")
|
"continuation (id: " ,this-continuation-id ").")
|
||||||
#f)
|
#f)
|
||||||
(hr)
|
(hr)
|
||||||
(url ,(make-callback show-surflets) "Return to SUrflets menu.") (br)
|
(url ,(callback show-surflets)
|
||||||
(url ,(make-callback show-sessions) "Return to sessions menu.") (br)
|
"Return to SUrflets menu.")
|
||||||
(url ,(make-callback return-to-main-page) "Return to administration menu.")
|
(br) (url ,(callback show-sessions)
|
||||||
(br)
|
"Return to sessions menu.")
|
||||||
(url "/" "Return to main menu.")))
|
(br) (url ,(callback return-to-main-page)
|
||||||
|
"Return to administration menu.")
|
||||||
|
(br) (url "/" "Return to main menu.")))
|
||||||
(actions '("delete" "delete all"))
|
(actions '("delete" "delete all"))
|
||||||
(continuations-callback
|
(continuations-callback (callback show-continuations sessions)))
|
||||||
(make-callback (lambda (req)
|
|
||||||
(show-continuations sessions req)))))
|
|
||||||
(if (null? current-continuations)
|
(if (null? current-continuations)
|
||||||
(send-html `(html (title ,title)
|
(send-html
|
||||||
|
`(html (title ,title)
|
||||||
(body ,header
|
(body ,header
|
||||||
,(no-current-continuations session-pair req)
|
,(no-current-continuations callback session req)
|
||||||
,footer)))
|
,footer)))
|
||||||
(receive (action selected-continuations req)
|
(receive (action selected-continuations req)
|
||||||
(select-table title
|
(select-table title
|
||||||
header
|
header
|
||||||
'((th "Continuation-Id"))
|
'((th "Continuation-Id"))
|
||||||
current-continuations
|
current-continuations
|
||||||
(lambda (continuation-pair)
|
(lambda (continuation)
|
||||||
(let ((continuation-id (car continuation-pair)))
|
`((td (@ (align "right"))
|
||||||
`((td (@ (align "right")) ,continuation-id))))
|
,(continuation-id continuation))))
|
||||||
actions
|
actions
|
||||||
footer)
|
footer)
|
||||||
(if (not action)
|
(if (not action)
|
||||||
(show-continuations sessions req
|
(show-continuations req sessions
|
||||||
"Choose an action.")
|
"Choose an action.")
|
||||||
(begin
|
(begin
|
||||||
(cond
|
(cond
|
||||||
|
@ -317,8 +323,8 @@
|
||||||
session-id current-continuations))
|
session-id current-continuations))
|
||||||
(else
|
(else
|
||||||
(error "unknown action" action)))
|
(error "unknown action" action)))
|
||||||
(show-continuations sessions req
|
(show-continuations req sessions
|
||||||
"Deleted."))))))))))
|
"Deleted.")))))))))
|
||||||
|
|
||||||
(define (delete-continuations outdated? continuations-callback
|
(define (delete-continuations outdated? continuations-callback
|
||||||
session-id continuations)
|
session-id continuations)
|
||||||
|
@ -326,10 +332,7 @@
|
||||||
(show-outdated continuations-callback)
|
(show-outdated continuations-callback)
|
||||||
;; Do it this way to easily expand to more sessions in the
|
;; Do it this way to easily expand to more sessions in the
|
||||||
;; future.
|
;; future.
|
||||||
(for-each delete-continuation!
|
(for-each delete-continuation! continuations)))
|
||||||
(make-list (length continuations)
|
|
||||||
session-id)
|
|
||||||
(map car continuations))))
|
|
||||||
|
|
||||||
(define (return-to-main-page req)
|
(define (return-to-main-page req)
|
||||||
(send-error (status-code moved-perm) req
|
(send-error (status-code moved-perm) req
|
||||||
|
|
Loading…
Reference in New Issue