mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-11-23 03:44:04 +03:00
fix: don't kill runtime modules, also settings stuff
This commit is contained in:
parent
44da3c8025
commit
8cbd2e74cb
@ -5,8 +5,120 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Kinode Settings</title>
|
||||
<link rel="stylesheet" href="/kinode.css">
|
||||
<script src="/our.js"></script>
|
||||
<script>
|
||||
document.title = window.our.node + " - settings";
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
color: #f0f0f0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
main {
|
||||
margin: 0 auto;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
gap: 20px 20px;
|
||||
grid-auto-flow: row;
|
||||
grid-template-areas:
|
||||
"diagnostics diagnostics diagnostics"
|
||||
"node-info pings pings"
|
||||
"eth-rpc-providers eth-rpc-providers eth-rpc-settings"
|
||||
"kernel kernel kernel";
|
||||
padding: 20px;
|
||||
max-width: 1100px;
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
article#net-diagnostics {
|
||||
grid-area: diagnostics;
|
||||
}
|
||||
|
||||
p#diagnostics,
|
||||
p#peer-pki-response,
|
||||
p#peer-ping-response {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
article#node-info {
|
||||
grid-area: node-info;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
#shutdown {
|
||||
background-color: var(--ansi-red)
|
||||
}
|
||||
|
||||
#shutdown:hover {
|
||||
background-color: var(--maroon);
|
||||
}
|
||||
|
||||
article#pings {
|
||||
grid-area: pings;
|
||||
}
|
||||
|
||||
article#eth-rpc-providers {
|
||||
grid-area: eth-rpc-providers;
|
||||
}
|
||||
|
||||
article#eth-rpc-settings {
|
||||
grid-area: eth-rpc-settings;
|
||||
}
|
||||
|
||||
article#kernel {
|
||||
grid-area: kernel;
|
||||
}
|
||||
|
||||
div#provider-edits {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 20px 20px;
|
||||
grid-auto-flow: row;
|
||||
}
|
||||
|
||||
article {
|
||||
border: 1px solid #444;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
max-height: 600px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
padding: 8px;
|
||||
margin-bottom: 6px;
|
||||
border-radius: 4px;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
#process-map li p:first-child {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#process-map li ul {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
#process-map li ul li {
|
||||
margin-bottom: 1px;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -77,8 +189,7 @@
|
||||
|
||||
<article id="kernel">
|
||||
<h2>running processes</h2>
|
||||
<p>(TODO)</p>
|
||||
<ul></ul>
|
||||
<ul id="process-map"></ul>
|
||||
</article>
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@ function populate(data) {
|
||||
populate_net_diagnostics(data.diagnostics);
|
||||
populate_eth_rpc_providers(data.eth_rpc_providers);
|
||||
populate_eth_rpc_settings(data.eth_rpc_access_settings);
|
||||
// populate_kernel()
|
||||
populate_process_map(data.process_map);
|
||||
}
|
||||
|
||||
function populate_node_info(identity) {
|
||||
@ -99,6 +99,58 @@ function populate_eth_rpc_settings(settings) {
|
||||
}
|
||||
}
|
||||
|
||||
function populate_process_map(process_map) {
|
||||
const ul = document.getElementById('process-map');
|
||||
ul.innerHTML = '';
|
||||
Object.entries(process_map).forEach(([id, process]) => {
|
||||
const li = document.createElement('li');
|
||||
|
||||
const name = document.createElement('p');
|
||||
name.innerHTML = `${id}`;
|
||||
name.innerHTML += `<button class="kill-process" data-id="${id}">kill</button>`;
|
||||
li.appendChild(name);
|
||||
|
||||
const public = document.createElement('p');
|
||||
public.innerHTML = `public: ${process.public}`;
|
||||
li.appendChild(public);
|
||||
|
||||
const on_exit = document.createElement('p');
|
||||
on_exit.innerHTML = `on_exit: ${process.on_exit}`;
|
||||
li.appendChild(on_exit);
|
||||
|
||||
const wit_version = document.createElement('p');
|
||||
if (process.wit_version) {
|
||||
wit_version.innerHTML = `wit_version: ${process.wit_version}`;
|
||||
li.appendChild(wit_version);
|
||||
}
|
||||
|
||||
const wasm_bytes_handle = document.createElement('p');
|
||||
if (process.wasm_bytes_handle) {
|
||||
wasm_bytes_handle.innerHTML = `wasm_bytes_handle: ${process.wasm_bytes_handle}`;
|
||||
li.appendChild(wasm_bytes_handle);
|
||||
}
|
||||
|
||||
const caps = document.createElement('ul');
|
||||
process.capabilities.forEach(cap => {
|
||||
const li = document.createElement('li');
|
||||
li.innerHTML = `${cap.issuer}(${JSON.stringify(JSON.parse(cap.params), null, 2)})`;
|
||||
caps.appendChild(li);
|
||||
});
|
||||
li.appendChild(caps);
|
||||
|
||||
ul.appendChild(li);
|
||||
});
|
||||
document.querySelectorAll('.kill-process').forEach(button => {
|
||||
let id = button.getAttribute('data-id');
|
||||
const do_not_kill = ['settings:setting:sys', 'main:app_store:sys'];
|
||||
if (!do_not_kill.includes(id)) {
|
||||
button.addEventListener('click', () => {
|
||||
api_call({ "KillProcess": id });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Call init to start the application
|
||||
init();
|
||||
|
||||
|
@ -43,6 +43,7 @@ struct SettingsState {
|
||||
pub diagnostics: Option<String>,
|
||||
pub eth_rpc_providers: Option<eth::SavedConfigs>,
|
||||
pub eth_rpc_access_settings: Option<eth::AccessSettings>,
|
||||
pub process_map: Option<kernel_types::ProcessMap>,
|
||||
}
|
||||
|
||||
impl SettingsState {
|
||||
@ -54,6 +55,7 @@ impl SettingsState {
|
||||
diagnostics: None,
|
||||
eth_rpc_providers: None,
|
||||
eth_rpc_access_settings: None,
|
||||
process_map: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,7 +129,29 @@ impl SettingsState {
|
||||
};
|
||||
self.eth_rpc_access_settings = Some(access_settings);
|
||||
|
||||
// TODO: running processes
|
||||
// running processes
|
||||
let Ok(Ok(Message::Response { body, .. })) =
|
||||
Request::to(("our", "kernel", "distro", "sys"))
|
||||
.body(
|
||||
serde_json::to_vec(&kernel_types::KernelCommand::Debug(
|
||||
kernel_types::KernelPrint::ProcessMap,
|
||||
))
|
||||
.unwrap(),
|
||||
)
|
||||
.send_and_await_response(5)
|
||||
else {
|
||||
return Err(anyhow::anyhow!(
|
||||
"failed to get running processes from kernel"
|
||||
));
|
||||
};
|
||||
let Ok(kernel_types::KernelResponse::Debug(kernel_types::KernelPrintResponse::ProcessMap(
|
||||
process_map,
|
||||
))) = serde_json::from_slice(&body)
|
||||
else {
|
||||
return Err(anyhow::anyhow!("got malformed response from kernel"));
|
||||
};
|
||||
self.process_map = Some(process_map);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -365,7 +365,6 @@ async fn handle_kernel_request(
|
||||
// skip the capabilities-cleanup RevokeAll, pass "no-revoke" in the metadata
|
||||
//
|
||||
t::KernelCommand::KillProcess(process_id) => {
|
||||
senders.remove(&process_id);
|
||||
let process_handle = match process_handles.remove(&process_id) {
|
||||
Some(ph) => ph,
|
||||
None => {
|
||||
@ -375,6 +374,7 @@ async fn handle_kernel_request(
|
||||
return None;
|
||||
}
|
||||
};
|
||||
senders.remove(&process_id);
|
||||
process_handle.abort();
|
||||
process_map.remove(&process_id);
|
||||
if request.metadata != Some("no-revoke".to_string()) {
|
||||
|
Loading…
Reference in New Issue
Block a user