Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
Hotfix for app icons and names within settings (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
nevets963 authored Nov 2, 2022
1 parent 1b2be42 commit 75ce9aa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion logic/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,6 @@ module.exports = {
get,
install,
uninstall,
update
update,
getInstalled
};
27 changes: 27 additions & 0 deletions logic/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const semverMinVersion = require('semver/ranges/min-version');
const encode = require('lndconnect').encode;

const diskLogic = require('logic/disk.js');
const appsLogic = require('logic/apps.js');
const constants = require('utils/const.js');
const NodeError = require('models/errors.js').NodeError;

Expand Down Expand Up @@ -381,6 +382,31 @@ async function clearMemoryWarning() {
}
};

async function getComputeResourceUsage(resource) {
const user = await diskLogic.readUserFile();

const installedApps = await appsLogic.getInstalled(user);

const update = await diskLogic.readSystemStatusFile(resource);

if(Array.isArray(update.breakdown)) {
update.breakdown = update.breakdown.map(function(row){
if(row.id === 'umbrel') return row;

const appMetadata = installedApps.find(app => app.id === row.id)

if(appMetadata) {
row.name = appMetadata.name;
row.icon = appMetadata.icon;
}

return row;
});
}

return update;
}

module.exports = {
getInfo,
getHiddenServiceUrl,
Expand All @@ -400,4 +426,5 @@ module.exports = {
setRemoteTorAccess,
status,
clearMemoryWarning,
getComputeResourceUsage
};
4 changes: 2 additions & 2 deletions routes/v1/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ router.post('/remote-tor-access', auth.jwt, safeHandler(async (req, res) => {
}));

router.get('/storage', auth.jwt, safeHandler(async (req, res) => {
const update = await diskLogic.readSystemStatusFile('storage');
const update = await systemLogic.getComputeResourceUsage('storage');

return res.status(constants.STATUS_CODES.OK).json(update);
}));

router.get('/memory', auth.jwt, safeHandler(async (req, res) => {
const update = await diskLogic.readSystemStatusFile('memory');
const update = await systemLogic.getComputeResourceUsage('memory');

return res.status(constants.STATUS_CODES.OK).json(update);
}));
Expand Down

0 comments on commit 75ce9aa

Please sign in to comment.