pinokiod 3.18.4 → 3.18.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.18.4",
3
+ "version": "3.18.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -2480,6 +2480,8 @@ class Server {
2480
2480
  if (options) {
2481
2481
  this.debug = options.debug
2482
2482
  this.browser = options.browser
2483
+ this.onrestart = options.onrestart
2484
+ this.onquit = options.onquit
2483
2485
  }
2484
2486
 
2485
2487
  if (this.listening) {
@@ -4983,6 +4985,16 @@ class Server {
4983
4985
  this.app.get("/check", ex((req, res) => {
4984
4986
  res.json({ success: true })
4985
4987
  }))
4988
+ this.app.post("/onrestart", ex(async (req, res) => {
4989
+ console.log("post /onrestart")
4990
+ if (this.onrestart) {
4991
+ console.log("onrestart exists")
4992
+ this.onrestart()
4993
+ } else {
4994
+ await this.start({ debug: this.debug, browser: this.browser })
4995
+ res.json({ success: true })
4996
+ }
4997
+ }))
4986
4998
  this.app.post("/restart", ex(async (req, res) => {
4987
4999
  console.log("post /restart")
4988
5000
  this.start({ debug: this.debug, browser: this.browser })
@@ -642,11 +642,38 @@ console.log("body", body)
642
642
  allowOutsideClick: false,
643
643
  allowEscapeKey: false,
644
644
  allowEnterKey: false,
645
- showConfirmButton: false,
646
- didOpen: () => {
647
- Swal.showLoading();
645
+ confirmButtonText: "Restart",
646
+ // showConfirmButton: false,
647
+ // didOpen: () => {
648
+ // Swal.showLoading();
649
+ // }
650
+ }).then((result) => {
651
+ if (result.isConfirmed) {
652
+ fetch("/onrestart", {
653
+ method: "POST",
654
+ headers: { "Content-Type": "application/json" },
655
+ body: JSON.stringify({})
656
+ }).then((res) => {
657
+ return res.json()
658
+ })
659
+ setInterval(async () => {
660
+ try {
661
+ let res = await fetch("/check").then((res) => {
662
+ return res.json()
663
+ })
664
+ if (res.success) {
665
+ document.querySelector(".loading").classList.add("hidden")
666
+ setTimeout(() => {
667
+ location.href = "/"
668
+ }, 1000)
669
+ }
670
+ } catch (e) {
671
+ console.log(e)
672
+ }
673
+ }, 1000)
648
674
  }
649
- });
675
+ })
676
+
650
677
  } else {
651
678
  //alert("Successfully updated the pinokio home to " + val)
652
679
  fetch("/restart", {