-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into restart-pm2-on-reboot
- Loading branch information
Showing
31 changed files
with
721 additions
and
334 deletions.
There are no files selected for viewing
44 changes: 22 additions & 22 deletions
44
app/dist/assets/index-d91d7471.js → app/dist/assets/index-f894ec8d.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,37 @@ | ||
import type { Writable } from "svelte/store"; | ||
import { get_image_tags } from "../api/swarm"; | ||
import { get_all_image_actual_version, get_image_tags } from "../api/swarm"; | ||
import type { Stack, Node } from "../nodes"; | ||
import { swarm } from "../api"; | ||
|
||
export async function getVersionFromDigest( | ||
digest: string, | ||
org_image_name: string, | ||
page: string, | ||
page_size: string | ||
) { | ||
try { | ||
const splittedDigest = digest.split("@")[1]; | ||
const response = await get_image_tags(org_image_name, page, page_size); | ||
|
||
const tags = JSON.parse(response); | ||
|
||
for (let i = 0; i < tags.results.length; i++) { | ||
const result = tags.results[i]; | ||
if (result.digest === splittedDigest) { | ||
if (result.name !== "latest") { | ||
return result.name; | ||
} else { | ||
const architectureDigests = []; | ||
for (let j = 0; j < result.images.length; j++) { | ||
architectureDigests.push(result.images[j].digest); | ||
} | ||
return findArchitectureDigest(architectureDigests, tags.results); | ||
} | ||
} | ||
} | ||
|
||
if (tags.next) { | ||
const urlString = tags.next; | ||
const url = new URL(urlString); | ||
const params = new URLSearchParams(url.search); | ||
|
||
const page = params.get("page"); | ||
const page_size = params.get("page_size"); | ||
|
||
return await getVersionFromDigest( | ||
digest, | ||
org_image_name, | ||
page, | ||
page_size | ||
); | ||
} | ||
} catch (error) { | ||
throw error; | ||
} | ||
} | ||
|
||
function findArchitectureDigest(architectureDigests, results) { | ||
for (let i = 0; i < results.length; i++) { | ||
const result = results[i]; | ||
if (result.name !== "latest") { | ||
for (let j = 0; j < result.images.length; j++) { | ||
const image = result.images[j]; | ||
if (architectureDigests.includes(image.digest)) { | ||
return result.name; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
export async function getImageVersion( | ||
node_name: string, | ||
stack: Writable<Stack>, | ||
selectedNode: Writable<Node> | ||
) { | ||
let image_name = `sphinx-${node_name}`; | ||
if (node_name === "relay") { | ||
image_name = `sphinx-relay-swarm`; | ||
} else if (node_name === "cln") { | ||
image_name = `cln-sphinx`; | ||
} else if (node_name === "navfiber") { | ||
image_name = `sphinx-nav-fiber`; | ||
} else if (node_name === "cache") { | ||
image_name = ``; | ||
} else if (node_name === "jarvis") { | ||
image_name = `sphinx-jarvis-backend`; | ||
} | ||
const image_digest_response = await swarm.get_image_digest( | ||
`sphinxlightning/${image_name}` | ||
); | ||
if (image_digest_response.success) { | ||
const version = await getVersionFromDigest( | ||
image_digest_response.digest, | ||
`sphinxlightning/${image_name}`, | ||
"1", | ||
"100" | ||
); | ||
const image_versions = await get_all_image_actual_version(); | ||
console.log(image_versions); | ||
if (image_versions.success) { | ||
let version_object = {}; | ||
|
||
for (let i = 0; i < image_versions.data.length; i++) { | ||
const image_version = image_versions.data[i]; | ||
version_object[image_version.name] = image_version.version; | ||
} | ||
|
||
if (version) { | ||
stack.update((stack) => { | ||
for (let i = 0; i < stack.nodes.length; i++) { | ||
const oldNode = { ...stack.nodes[i] }; | ||
if (oldNode.name === node_name) { | ||
const newNode = { | ||
...oldNode, | ||
version, | ||
}; | ||
stack.update((stack) => { | ||
for (let i = 0; i < stack.nodes.length; i++) { | ||
const newNode = { | ||
...stack.nodes[i], | ||
version: version_object[stack.nodes[i].name], | ||
}; | ||
|
||
selectedNode.update((node) => | ||
node && node.name === newNode.name ? { ...newNode } : node | ||
); | ||
selectedNode.update((node) => | ||
node && node.name === newNode.name ? { ...newNode } : node | ||
); | ||
|
||
stack.nodes[i] = { ...newNode }; | ||
break; | ||
} | ||
} | ||
return stack; | ||
}); | ||
} | ||
stack.nodes[i] = { ...newNode }; | ||
} | ||
|
||
return stack; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.