Working snapshot create webflow.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
(chicken file)
|
||||
(chicken condition)
|
||||
(chicken sort)
|
||||
(chicken random)
|
||||
|
||||
(rename srfi-1 (delete srfi1:delete))
|
||||
srfi-13
|
||||
@@ -1935,18 +1936,65 @@ chmod -R 777 /opt/keys")))
|
||||
(Form-Nav (@ (back-to ,(conc "/backups/" instance-id)) (submit-button "Create"))))))))))
|
||||
|
||||
(post "/backups/:instance_id/create-submit"
|
||||
(let ((instance-id (alist-ref "instance_id" (current-params) equal?))
|
||||
(app-config (with-db/transaction
|
||||
(lambda (db)
|
||||
(get-user-app-config db (session-user-id) instance-id)))))
|
||||
;; TODO make requests to instance control
|
||||
;; get the root domain and subdomain for instance control
|
||||
;; then call subdomain.rootdomain/hooks/queue-restic-snapshot
|
||||
;; content-type application/json
|
||||
;; data: 'path "/" 'tag tag 'request_id (generate-one?) 'version 0
|
||||
;; then run through hmac ((hmac "instance-control-secret-key" sha256-primitive) data)
|
||||
;; then make a new page to redirect the user to that polls for status page using the request id
|
||||
(redirect (conc "/config/wizard/review/" instance-id))))
|
||||
(let* ((instance-id (alist-ref "instance_id" (current-params) equal?))
|
||||
(app-config (with-db/transaction
|
||||
(lambda (db)
|
||||
(get-user-app-config db (session-user-id) instance-id))))
|
||||
(request-id (conc (truncate (time->seconds (current-time))) "-" (pseudo-random-integer 10000))))
|
||||
(send-instance-control-command
|
||||
(alist-ref 'root-domain app-config)
|
||||
(alist-ref 'subdomain (alist-ref 'instance-control (alist-ref 'config app-config)))
|
||||
"queue-restic-snapshot"
|
||||
(alist-ref 'webhooks-secret (alist-ref 'instance-control (alist-ref 'config app-config)))
|
||||
`((path . "/") ;; unused for now but we do want root until we support backing up individual apps
|
||||
(tag . ,(alist-ref 'tag (current-params)))
|
||||
;; effectively a guid, we just want something unique
|
||||
(request_id . ,request-id)
|
||||
(version . 0)))
|
||||
(redirect (conc "/backups/" instance-id "/create-success/" request-id))))
|
||||
|
||||
(get/widgets
|
||||
("/backups/:instance_id/create-success/:request_id"
|
||||
(let* ((instance-id (alist-ref "instance_id" (current-params) equal?))
|
||||
(request-id (alist-ref "request_id" (current-params) equal?))
|
||||
(app-config (with-db/transaction
|
||||
(lambda (db)
|
||||
(get-user-app-config db (session-user-id) instance-id))))
|
||||
(status-result
|
||||
(send-instance-control-command
|
||||
(alist-ref 'root-domain app-config)
|
||||
(alist-ref 'subdomain (alist-ref 'instance-control (alist-ref 'config app-config)))
|
||||
"restic-snapshot-status"
|
||||
(alist-ref 'webhooks-secret (alist-ref 'instance-control (alist-ref 'config app-config)))
|
||||
`((request_id . ,request-id)
|
||||
(version . 0))))
|
||||
(complete (string=? (alist-ref 'status status-result) "complete")))
|
||||
(if complete
|
||||
'()
|
||||
'((meta (@ (http-equiv "refresh") (content "5")))))))
|
||||
(let* ((instance-id (alist-ref "instance_id" (current-params) equal?))
|
||||
(request-id (alist-ref "request_id" (current-params) equal?))
|
||||
(app-config (with-db/transaction
|
||||
(lambda (db)
|
||||
(get-user-app-config db (session-user-id) instance-id))))
|
||||
(status-result
|
||||
(send-instance-control-command
|
||||
(alist-ref 'root-domain app-config)
|
||||
(alist-ref 'subdomain (alist-ref 'instance-control (alist-ref 'config app-config)))
|
||||
"restic-snapshot-status"
|
||||
(alist-ref 'webhooks-secret (alist-ref 'instance-control (alist-ref 'config app-config)))
|
||||
`((request_id . ,request-id)
|
||||
(version . 0))))
|
||||
(complete (string=? (alist-ref 'status status-result) "complete")))
|
||||
`(App
|
||||
(Main-Container
|
||||
(VStack
|
||||
(h1 ,(if complete "Snapshot Complete" "Snapshot In Progress..."))
|
||||
(div
|
||||
(a (@ (href "/dashboard")) "Dashboard")
|
||||
,@(if complete
|
||||
'()
|
||||
" (snapshot will continue in the background if you leave this page)")))))))
|
||||
|
||||
(schematra-install)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user