diff --git a/frontend/index.html b/frontend/index.html index 2c24acd..6d412e4 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -57,7 +57,7 @@ diff --git a/frontend/notebooks/df.nb b/frontend/notebooks/du.nb similarity index 89% rename from frontend/notebooks/df.nb rename to frontend/notebooks/du.nb index 992ff3f..37e6898 100644 --- a/frontend/notebooks/df.nb +++ b/frontend/notebooks/du.nb @@ -3,12 +3,12 @@ # %% [markdown] ### Directory Usage Overview -The following command lists directory sorted by size. You might want to modify the `-maxdepth 2` parameter for different details. **Note that this command can run for quite some time!** +The following command lists directory sorted by size. You might want to modify the `-maxdepth 3` parameter for more details. **Note that this command can run for quite some time!** # %%--- [shell] # properties: # bottom_hidden: true # ---%% -cd /usr/share; (find . -maxdepth 3 -type d ! -name "." -print0 | xargs -0 -n1 du -sm | sort -nr ) 2>/dev/null +cd /usr/lib; (find . -maxdepth 3 -type d -print0 | xargs -0 -n1 du -sm | sort -nr ) 2>/dev/null # %%--- [html] # properties: # run_on_load: true @@ -283,49 +283,41 @@ function uid(prefix) { } function getData(nr) { - // input data will be lines of " " + // input data will be lines of " " let data = {name: ".", children: []}; let pathByName = {}; // lookup hash for insertion - getCellOutput(nr).split(/\n/).forEach((line) => { - function createParents(dir) { - let d, name; - - if(pathByName[dir]) - return pathByName[dir]; - - if(-1 == dir.indexOf('/')) { + + function getOrCreateNode(dir) { + let d, name; + + if('.' === dir) + return data; + if(pathByName[dir]) + return pathByName[dir]; + + if(-1 == dir.indexOf('/')) { d = data; name = dir; - } else { + } else { let m, parentDir; [m, parentDir, name] = dir.match(/(.+)\/([^\/]+)/); - d = createParents(parentDir); - } - - return pathByName[dir] = d.children[d.children.push({name: name, children: []}) - 1]; + d = getOrCreateNode(parentDir); } - - try { - let path = line.split(/\s+/, 2)[1]; - if("" !== path) { - let d, name, m = path.match(/\.\/(.+)\/([^\/]+)/); - if(m) { - d = createParents(m[1]); - name = m[2]; - } else { - d = data; - name = path.splice(2, path.length); // FIXME: broken - } - - d.children.push({ name: name, value: line.split(/\s+/, 2)[0]}); + return pathByName[dir] = d.children[d.children.push({name: name, children: []}) - 1]; + } + + getCellOutput(nr).split(/\n/).forEach((line) => { + let path = line.split(/\s+/, 2)[1]; + if(path && "" !== path) { + if(path.match(/\.\/(.+)\/([^\/]+)/)) { + let node = getOrCreateNode(path); + node.value = line.split(/\s+/, 2)[0]; } - } catch(e) { - console.error(`Invalid line: ${line} (${e})`); - }; + } }); - return data; } + window.createRadialGraph = createRadialGraph; window.createTreeMap = createTreeMap; \ No newline at end of file diff --git a/frontend/worker.js b/frontend/worker.js index a2dab5e..54009c0 100644 --- a/frontend/worker.js +++ b/frontend/worker.js @@ -27,7 +27,7 @@ var filesToCache = [ '/js/renderer/perf-flamegraph.js', '/notebooks/default.nb', - '/notebooks/df.nb', + '/notebooks/du.nb', '/notebooks/arp.nb', '/notebooks/systemd.nb', 'default.json'