Skip to content

Commit

Permalink
enhance(electron): refine app proxy test url
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf authored and tiensonqin committed Dec 19, 2022
1 parent 1b04ea8 commit 6fc5a26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/electron/electron/handler.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,12 @@
(utils/get-ls-dotdir-root))

(defmethod handle :testProxyUrl [win [_ url]]
(p/let [_ (utils/fetch url)]
(utils/send-to-renderer win :notification {:type "success" :payload (str "Successfully: " url)})))
(p/let [resp (utils/fetch url)
code (.-status resp)]
(js/console.debug resp code)
(if (<= 200 code 299)
(utils/send-to-renderer win :notification {:type "success" :payload (str "Success: " url " status " code)})
(utils/send-to-renderer win :notification {:type "error" :payload (str "Failed: " url " status " code)}))))

(defmethod handle :httpFetchJSON [_win [_ url options]]
(p/let [res (utils/fetch url options)
Expand Down
8 changes: 7 additions & 1 deletion src/main/frontend/components/plugins.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,16 @@
[:span.w-60
[:input.form-input.is-small
{:ref *test-input
:list "proxy-test-url-datalist"
:type "url"
:placeholder "http://"
:on-change #(set-opts!
(assoc opts :test (util/trim-safe (util/evalue %))))
:value (:test opts)}]]
:value (:test opts)}]
[:datalist#proxy-test-url-datalist
[:option "https://www.google.com"]
[:option "https://s3.amazonaws.com"]
[:option "https://clients3.google.com/generate_204"]]]

(ui/button (if testing? (ui/loading "Testing") "Test URL")
:intent "logseq" :large? false
Expand Down

0 comments on commit 6fc5a26

Please sign in to comment.