Browse Source

client improvements

master
Milan Pässler 11 months ago
parent
commit
99308e6742
2 changed files with 24 additions and 8 deletions
  1. +22
    -5
      client/src/index.js
  2. +2
    -3
      server/void.js

+ 22
- 5
client/src/index.js View File

@@ -8,8 +8,6 @@ let currentRequestNumber = 0;
let loadedGraph;

const go = async (backend, name, selected) => {
document.querySelector('#backend [value="' + backend + '"]').selected = true;

document.getElementById("name").blur();
document.getElementById("name").value = name;

@@ -22,8 +20,10 @@ const go = async (backend, name, selected) => {
.then(resp => resp.json());
} catch(err) {
console.log(err)
document.getElementById("loading").classList.add("hidden");
return;
newGraph = {
nodes: {},
links: [],
};
}
if (currentRequestNumber !== thisRequest) return;

@@ -71,8 +71,10 @@ const handleSubmit = (evt) => {

const handleHashChange = () => {
const hash = window.location.hash.substr(1).split(":");
if (hash.length < 2) return;
if (hash.length < 1) return;
const backend = hash[0];
document.querySelector('#backend [value="' + backend + '"]').selected = true;
if (hash.length < 2) return;
const name = hash[1];
const selected = hash[2];
const graphId = `${backend}:${name}`;
@@ -98,6 +100,20 @@ const fetchBackendList = async () => {
document.querySelector("option:first-child").selected = true;
};

const handleBackendChange = () => {
const hash = window.location.hash.substr(1).split(":");
const backend = backendSelect[backendSelect.selectedIndex].value;
const name = hash[1];
const selected = hash[2];
if (selected) {
window.location.hash = `#${backend}:${name}:${selected}`;
} else if (name) {
window.location.hash = `#${backend}:${name}`;
} else {
window.location.hash = `#${backend}`;
}
};

/* initialization */

fetchBackendList().then(() => {
@@ -110,6 +126,7 @@ fetchBackendList().then(() => {
}
});

backendSelect.addEventListener("change", handleBackendChange);
document.getElementById("inputs").addEventListener("submit", handleSubmit);
window.addEventListener("hashchange", handleHashChange);


+ 2
- 3
server/void.js View File

@@ -34,13 +34,12 @@ const getPackageLists = async () => {
Object.keys(packageList).forEach(name => {
const pkg = packageList[name];
const p = {
name,
name: pkg["pkgver"],
deps: (pkg["run_depends"] || []).map(stripVersion),
id: pkg["pkgver"],
id: name,
size: pkg["installed_size"],
};
newPackages[name] = p;
//newPackages[pkg["pkgver"]] = p;
});
}



Loading…
Cancel
Save