pinokiod 2.1.5 → 2.1.7

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.
@@ -38,7 +38,6 @@ class Api {
38
38
  }
39
39
  }
40
40
  async startProxy(scriptPath, uri, name, options) {
41
- console.log("startProxy", { scriptPath, uri, name, options })
42
41
  this.checkProxy({ uri, name })
43
42
  // if the name exists, throw error
44
43
  // if the uri exists, throw error
@@ -58,13 +57,10 @@ class Api {
58
57
  // stop all proxies for the script
59
58
  if (this.proxies[config.script]) {
60
59
  for(let p of this.proxies[config.script]) {
61
- console.log("stopProxy", p.target)
62
60
  this.stopProxy({ uri: p.target })
63
61
  }
64
62
  }
65
63
  } else if (config.uri) {
66
- console.log("stopProxy uri", config)
67
- console.log("this.proxies = ", this.proxies)
68
64
 
69
65
  // stop the proxy
70
66
  this.lproxy.stop(config.uri)
@@ -109,7 +105,6 @@ class Api {
109
105
  // 2. stream a message closing the socket
110
106
 
111
107
 
112
- console.log("stop params", req.params)
113
108
 
114
109
  let requestPath = this.filePath(req.params.uri)
115
110
 
@@ -353,7 +348,6 @@ class Api {
353
348
  return modpath
354
349
  }
355
350
  filePath(uri, cwd) {
356
- console.log({ uri, cwd })
357
351
  let modpath
358
352
  if (uri.startsWith("http")) {
359
353
  // git url
@@ -1115,7 +1109,7 @@ class Api {
1115
1109
  rawrpc: request
1116
1110
  })
1117
1111
  } catch (e) {
1118
- console.log("ERROR", e)
1112
+ console.log("E1112", e)
1119
1113
  this.ondata({
1120
1114
  kernel: true,
1121
1115
  id: request.method,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -259,7 +259,6 @@ class Server {
259
259
  }
260
260
 
261
261
  const env = await this.kernel.env("api/" + name)
262
- console.log(">> ENV", env)
263
262
 
264
263
  //res.render("browser", {
265
264
  res.render("browser-experimental", {
@@ -2204,7 +2203,6 @@ class Server {
2204
2203
  this.app.post("/env", async (req, res) => {
2205
2204
  let fullpath = path.resolve(this.kernel.homedir, req.body.filepath, "ENVIRONMENT")
2206
2205
  let updated = req.body.vals
2207
- console.log("updated", updated)
2208
2206
  await Util.update_env(fullpath, updated)
2209
2207
  res.json({})
2210
2208
  })
@@ -2219,6 +2217,7 @@ class Server {
2219
2217
 
2220
2218
 
2221
2219
  res.render("env_editor", {
2220
+ home: true,
2222
2221
  config: null,
2223
2222
  name: null,
2224
2223
  init: null,
@@ -2250,6 +2249,7 @@ class Server {
2250
2249
  }
2251
2250
 
2252
2251
  res.render("env_editor", {
2252
+ home: null,
2253
2253
  config,
2254
2254
  name,
2255
2255
  init: req.query ? req.query.init : null,
@@ -91,7 +91,13 @@ td.key {
91
91
  }
92
92
  <% } %>
93
93
 
94
- header .runner {
94
+ header .btn {
95
+ font-family: Sans-serif;
96
+ display: block;
97
+ margin-left: 10px;
98
+ font-style: normal;
99
+ font-size: 14px;
100
+ font-weight: normal;
95
101
  }
96
102
  .disabled {
97
103
  opacity: 0.7;
@@ -179,11 +185,27 @@ footer {
179
185
  background: none;
180
186
  padding: 0;
181
187
  text-align: right;
182
- display: block;
183
- margin-bottom: 20px;
188
+ display: flex;
189
+ margin: 10px 0 20px 0;
184
190
  }
185
191
  footer .btn {
186
192
  margin-left: 10px;
193
+ display: inline-block;
194
+ -webkit-appearance: button;
195
+ -moz-appearance: button;
196
+ appearance: button;
197
+
198
+ }
199
+ footer .btn.go-home {
200
+ margin-left: 0px;
201
+ }
202
+ .btn.home-button {
203
+ background: none !important;
204
+ margin: 0 !important;
205
+ font-size: 16px !important;
206
+ }
207
+ #editor {
208
+ height: auto;
187
209
  }
188
210
  </style>
189
211
  <script>
@@ -246,6 +268,8 @@ document.addEventListener("DOMContentLoaded", async () => {
246
268
  </div>
247
269
  <% } %>
248
270
  <footer>
271
+ <a href="/" class='btn go-home'><i class='fa-solid fa-home'></i> home</a>
272
+ <div class='flexible'></div>
249
273
  <button id='customize' class='btn'><i class="fa-solid fa-gear"></i> Customize</button>
250
274
  <div id='save' class='btn'>
251
275
  <span class='save'><i class="fa-solid fa-check"></i> Install</span>
@@ -254,17 +278,25 @@ document.addEventListener("DOMContentLoaded", async () => {
254
278
  </div>
255
279
  <% } else { %>
256
280
  <header class='navheader grabbable'>
257
- <div class='runner'>
258
- <div id='save' class='btn'>
259
- <span class='save'><i class="fa-solid fa-check"></i> Save</span>
260
- </div>
261
- <a class='btn' href="<%=editorpath%>"><i class="fa-solid fa-pen-to-square"></i> Edit file</a>
262
- <button class='btn' id='open-fs' data-filepath="<%=filepath%>"><i class="fa-solid fa-eye"></i> Open in File Explorer</button>
263
- </div>
281
+ <h1>
282
+ <% if (home) { %>
283
+ <a class='home-button btn' href="/"><i class='fa-solid fa-home'></i></a>
284
+ <% } %>
285
+ <div class='flexible'></div>
286
+ <div class='nav-btns'>
287
+ <a class='btn' href="<%=editorpath%>"><i class="fa-solid fa-pen-to-square"></i> Edit file</a>
288
+ <button class='btn' id='open-fs' data-filepath="<%=filepath%>"><i class="fa-solid fa-eye"></i> Open in File Explorer</button>
289
+ <div id='save' class='btn'>
290
+ <span class='save'><i class="fa-solid fa-check"></i> Save</span>
291
+ </div>
292
+ </div>
293
+ </h1>
264
294
  </header>
265
295
  <% } %>
266
296
  <div id='editor' class='<%=init ? "hidden" : ''%>'>
297
+ <!--
267
298
  <h1>Configure</h1>
299
+ -->
268
300
  <% items.forEach((item) => { %>
269
301
  <% if (item.type === "comment") { %>
270
302
  <div class='comment'><%=item.val.replaceAll(/^[ #]+/g, "")%></div>
@@ -290,6 +290,9 @@ body.dark .browser-options-row {
290
290
  <button class='btn browse' data-src="<%=item.browser_url%>/browse">
291
291
  <i class='fa-regular fa-folder-open'></i>
292
292
  </button>
293
+ <button class='btn del' data-src="<%=item.url%>">
294
+ <i class="fa-solid fa-trash-can"></i>
295
+ </button>
293
296
  <% if (item.running_scripts) { %>
294
297
  <% item.running_scripts.forEach((s) => { %>
295
298
  <button class='btn shutdown' data-src="<%=s.path%>">
@@ -340,6 +343,9 @@ body.dark .browser-options-row {
340
343
  <button class='btn browse' data-src="<%=item.browser_url%>/browse">
341
344
  <i class='fa-regular fa-folder-open'></i>
342
345
  </button>
346
+ <button class='btn del' data-src="<%=item.url%>">
347
+ <i class="fa-solid fa-trash-can"></i>
348
+ </button>
343
349
  <% if (item.shortcuts && item.shortcuts.length > 0) { %>
344
350
  <div class='btns'>
345
351
  <% item.shortcuts.forEach((btn) => { %>
@@ -722,7 +728,7 @@ document.addEventListener("keydown", (e) => {
722
728
  }
723
729
  }
724
730
  });
725
- document.addEventListener("click", (e) => {
731
+ document.addEventListener("click", async (e) => {
726
732
 
727
733
  let target
728
734
 
@@ -776,6 +782,56 @@ document.addEventListener("click", (e) => {
776
782
  }
777
783
 
778
784
 
785
+ // delete
786
+ if (e.target.classList.contains("del")) {
787
+ target = e.target
788
+ } else {
789
+ target = e.target.closest(".del")
790
+ }
791
+ if (target) {
792
+ e.preventDefault()
793
+ e.stopPropagation()
794
+ let confirmed = confirm("Are you sure you want to delete the folder? All files in the folder will be gone.")
795
+ if (confirmed) {
796
+ let itemEl = target.closest(".line[data-uri]")
797
+ let name = itemEl.getAttribute("data-uri")
798
+ console.log("delete", name)
799
+ Swal.fire({
800
+ html: '<i class="fa-solid fa-circle-notch fa-spin"></i> Deleting',
801
+ customClass: {
802
+ container: "loader-container",
803
+ popup: "loader-popup",
804
+ htmlContainer: "loader-dialog",
805
+ footer: "hidden",
806
+ actions: "hidden"
807
+ }
808
+ });
809
+ debugger
810
+ let res = await fetch("/pinokio/delete", {
811
+ method: "post",
812
+ headers: {
813
+ "Content-Type": "application/json"
814
+ },
815
+ body: JSON.stringify({ name })
816
+ }).then((res) => {
817
+ return res.json()
818
+ })
819
+ console.log("res", res)
820
+ Swal.close()
821
+ if (res) {
822
+ if (res.success) {
823
+ location.href = "/"
824
+ } else if (res.error) {
825
+ alert(res.error)
826
+ }
827
+ }
828
+ } else {
829
+ }
830
+ return
831
+ }
832
+
833
+
834
+
779
835
  if (document.querySelector(".container")) {
780
836
  document.querySelector(".container").addEventListener("click", async (e) => {
781
837
  let el = e.target.closest(".menu-btn")