Skip to content

Commit

Permalink
fix: disk data display
Browse files Browse the repository at this point in the history
  • Loading branch information
tautcony committed Apr 2, 2024
1 parent 69146db commit 9bf686f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion setup/dashboard/lang/lang_da.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"Summary": "Oversigt",
"THEME_CHANGE_TXT": "You are about to change themes. If the theme doesn't appear correctly for you after the refresh, you probably need to clear your browser cache and retry.",
"THEME_SELECT": "Select Theme",
"TORRENTS_LOADED": "Der er indlæst <b>{loaded}</b> torrents",
"TORRENTS_LOADED": "Der er indlæst <b>{{loaded}}</b> torrents",
"TOTAL_L": "total {{total}}",
"TOTAL_RAM": "Total System RAM",
"TRANSMISSION": "Transmission is designed for easy, powerful use. The defaults are set to Just Work and it only takes a few clicks to configure advanced features like watch directories, bad peer blocklists, and the web interface. When Ubuntu chose Transmission as its default BitTorrent client, one of the most-cited reasons was its easy learning curve.",
Expand Down
2 changes: 1 addition & 1 deletion setup/dashboard/lang/lang_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"Summary": "Zusammenfassung",
"THEME_CHANGE_TXT": "Sie sind dabei, Themen zu ändern. Wenn das Thema nach der Aktualisierung nicht korrekt für Sie erscheint, müssen Sie wahrscheinlich Ihren Browser-Cache löschen und erneut versuchen.",
"THEME_SELECT": "Thema wählen",
"TORRENTS_LOADED": "Es sind <b>{loaded}</b> Torrents im Moment geladen",
"TORRENTS_LOADED": "Es sind <b>{{loaded}}</b> Torrents im Moment geladen",
"TOTAL_L": "gesamt {{total}}",
"TOTAL_RAM": "Gesamter Arbeitsspeicher",
"TRANSMISSION": "Transmission ist für eine einfache, leistungsstarke verwendung ausgelegt. Die Standardeinstellungen sind auf „Just Work“ (Just Work) eingestellt. Die Konfiguration erweiterter Funktionen wie Watch-Verzeichnisse, fehlerhafte Peer-Blocklisten und die Webschnittstelle erfordert nur wenige Klicks. Als Ubuntu Transmission als Standard-BitTorrent-Client auswählte, war einer der am häufigsten genannten Gründe die einfache Lernkurve.",
Expand Down
2 changes: 1 addition & 1 deletion setup/dashboard/lang/lang_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"Summary": "Summary",
"THEME_CHANGE_TXT": "You are about to change themes. If the theme doesn't appear correctly for you after the refresh, you probably need to clear your browser cache and retry.",
"THEME_SELECT": "Select Theme",
"TORRENTS_LOADED": "There are <b>{loaded}</b> torrents loaded",
"TORRENTS_LOADED": "There are <b>{{loaded}}</b> torrents loaded",
"TOTAL_L": "total {{total}}",
"TOTAL_RAM": "Total System RAM",
"TRANSMISSION": "Transmission is designed for easy, powerful use. The defaults are set to Just Work and it only takes a few clicks to configure advanced features like watch directories, bad peer blocklists, and the web interface. When Ubuntu chose Transmission as its default BitTorrent client, one of the most-cited reasons was its easy learning curve.",
Expand Down
2 changes: 1 addition & 1 deletion setup/dashboard/lang/lang_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"Summary": "Resumen",
"THEME_CHANGE_TXT": "Estás a punto de cambiar de tema. Si el tema selecciona no se muestra correctamente después de refrescar la página, probablemente necesitas limpiar la memoria caché de tu navegador y reintentarlo.",
"THEME_SELECT": "Elige un tema",
"TORRENTS_LOADED": "Tienes <b>{loaded}</b> torrents compartiendo",
"TORRENTS_LOADED": "Tienes <b>{{loaded}}</b> torrents compartiendo",
"TOTAL_L": "total {{total}}",
"TOTAL_RAM": "RAM total del sistema",
"TRANSMISSION": "Transmission está diseñado para un uso sencillo pero potente. La configuración por defecto está establecida para funcionar de inicio, pero con unos pocos clicks se pueden añadir funciones avanzadas como monitorización de directorios, listas de bloqueo para pares malintencionados, y una interfaz web. Cuando Ubuntu establece Transmission como su cliente web por defecto, es debido a su cómoda curva de aprendizaje.",
Expand Down
2 changes: 1 addition & 1 deletion setup/dashboard/lang/lang_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"Summary": "Sommaire",
"THEME_CHANGE_TXT": "Vous allez changer de thème. Si le thème ne s'affiche pas correctement après le rafraîchissement, il vous faudra probablement effacer le cache de votre navigateur et réessayer.",
"THEME_SELECT": "Thème",
"TORRENTS_LOADED": "Il y a <b>{loaded}</b> torrents chargés",
"TORRENTS_LOADED": "Il y a <b>{{loaded}}</b> torrents chargés",
"TOTAL_L": "total {{total}}",
"TOTAL_RAM": "RAM Totale du Système: ",
"TRANSMISSION": "Transmission est conçue pour une utilisation facile et puissante. Les valeurs par défaut sont définies sur 'Just Work' et il suffit de quelques clics pour configurer les fonctionnalités avancées telles que les répertoires de surveillance, les listes de blocage des pairs et l'interface Web. Quand Ubuntu a choisi Transmission comme client BitTorrent par défaut, l'une des raisons les plus citées était sa courbe d'apprentissage facile.",
Expand Down
2 changes: 1 addition & 1 deletion setup/dashboard/lang/lang_zh-Hans-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"Summary": "概要",
"THEME_CHANGE_TXT": "即将改变主题. 如果主题在刷新后没有正确显示, 则可能需要清除浏览器缓存并重试.",
"THEME_SELECT": "选择主题",
"TORRENTS_LOADED": "总计加载了 <b>{loaded}</b> 个种子",
"TORRENTS_LOADED": "总计加载了 <b>{{loaded}}</b> 个种子",
"TOTAL_L": "总计 {{total}}",
"TOTAL_RAM": "系统内存总计",
"TRANSMISSION": "Transmission 被设计为功能强大而易于使用的客户端. 它的默认设置即可直接运行, 只需要简单的点击就可以配置例如如监视目录,不良 peers 拦截列表和 Web 界面等高级功能. Ubuntu 以它作为默认的 BitTorrent 客户端, 其中最重要的理由就是它简单易学.",
Expand Down
2 changes: 1 addition & 1 deletion setup/dashboard/ws/dist/server.js

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions setup/dashboard/ws/src/widgets/disk_data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ function getDiskClass(percent: number) {
}

async function countTorrent(path: string) {
const fileList = await fs.readdir(path);
return fileList.filter((file) => file.endsWith(".torrent")).length;
try {
const fileList = await fs.readdir(path);
return fileList.filter((file) => file.endsWith(".torrent")).length;
} catch (ex) {
console.error("Failed to count torrent", ex);
return 0;
}
}

async function exists(path: string) {
Expand Down Expand Up @@ -81,22 +86,22 @@ async function renderTorrentInfo() {
const torrentElement = (title: string, loaded: number) => (
<div>
<h4>{i18n.t(title)}</h4>
<p className="nomargin">{i18n.t("TORRENTS_LOADED", {loaded})}</p>
<p className="nomargin" dangerouslySetInnerHTML={{__html: i18n.t<string>("TORRENTS_LOADED", {loaded})}}></p>
</div>
);

const ret: React.JSX.Element[] = [];

if (await processExists("rtorrent", username) && await exists("/install/.rtorrent.lock")) {
const rtorrents = await countTorrent(`/home/.${username}/.sessions/`);
const rtorrents = await countTorrent(`/home/${username}/.sessions/`);
ret.push(torrentElement("RTORRENTS_TITLE", rtorrents));
}
if (await processExists("deluged", username) && await exists("/install/.deluge.lock")) {
const dtorrents = await countTorrent(`/home/.${username}/.config/deluge/state/`);
if (await processExists("deluge-web", username) && await exists("/install/.deluge.lock")) {
const dtorrents = await countTorrent(`/home/${username}/.config/deluge/state/`);
ret.push(torrentElement("DTORRENTS_TITLE", dtorrents));
}
if (await processExists("transmission", username) && await exists("/install/.transmission.lock")) {
const transtorrents = await countTorrent(`/home/.${username}/.config/transmission/torrents/`);
if (await processExists("transmission-daemon", username) && await exists("/install/.transmission.lock")) {
const transtorrents = await countTorrent(`/home/${username}/.config/transmission/torrents/`);
ret.push(torrentElement("TRTORRENTS_TITLE", transtorrents));
}
if (await processExists("qbittorrent-nox", username) && await exists("/install/.qbittorrent.lock")) {
Expand Down

0 comments on commit 9bf686f

Please sign in to comment.