Skip to content

Commit

Permalink
Finish preparing settings app for localization
Browse files Browse the repository at this point in the history
  • Loading branch information
datkat21 committed Jan 21, 2024
1 parent e1681dc commit 1e2fbe9
Showing 1 changed file with 111 additions and 72 deletions.
183 changes: 111 additions & 72 deletions pkgs/apps/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ export default {
storageUsed: "Storage used",
coreVersion: "Core version",
supportedVersions: "Supported versions",
errorCouldNotFetch: "Could not fetch from account service",
loginWithZeon: "Login with Zeon Account",
logOut: "Log out",
zeonAccount: "Zeon Account",
useThemeWallpaper: "Use the theme's wallpaper",
toolbarPosition: "Toolbar position",
toolbarPositionVertical: "Vertical",
toolbarPositionHorizontal: "Horizontal",
dockStyle: "Dock style",
dockStyleFull: "Full",
dockStyleCompact: "Compact",
dockStyleMinimal: "Minimal",
testNetwork: "Test Network",
networkTestSuccess: "You're online and good to go!",
networkTestResult: "Your internet is {status}",
networkTestMs: "Average response time: {responseTime}ms.",
networkTestError:
"Network is not working. Status code: {req1Status}, {req2Status}",
noInstalledApps: "There are no installed applications.",
securityCheck: "Security Check",
securityCheckEveryStartup: "Check every startup?",
securityTableItemName: "Name",
securityTableItemSafe: "Safe",
securityTableItemDelete: "Delete App"
},
de_DE: {
thisSystem: "Dieses System",
Expand Down Expand Up @@ -93,10 +117,7 @@ export default {
Root.Core.processList
.filter((x) => x !== null)
.find(
(x) =>
x.name &&
x.name === "apps:Settings" &&
x.proc !== null
(x) => x.name && x.name === "apps:Settings" && x.proc !== null
) !== undefined)
) {
Root.Lib.onEnd();
Expand Down Expand Up @@ -249,7 +270,7 @@ export default {

if (!service && !service.ref)
return new Html("span")
.text("Could not fetch from account service")
.text(Root.Lib.getString("errorCouldNotFetch"))
.appendTo(container);

const userData = service.ref.getUserData();
Expand Down Expand Up @@ -277,7 +298,7 @@ export default {
if (result === undefined) {
new Html("button")
.class("primary", "small", "mc")
.text("Login with Zeon Account")
.text(Root.Lib.getString("loginWithZeon"))
.on("click", async (e) => {
let x = await Root.Modal.input(
"Login with Zeon",
Expand Down Expand Up @@ -320,7 +341,7 @@ export default {
} else {
new Html("button")
.class("danger", "mc")
.text("Log out")
.text(Root.Lib.getString("logOut"))
.on("click", async (e) => {
const a = await Root.Modal.prompt("Are you sure?", "Log out?");
if (a === true) {
Expand Down Expand Up @@ -352,7 +373,7 @@ export default {
")",
});
userBoxName.text(userData.user);
userBoxType.text("Zeon Account");
userBoxType.text(Root.Lib.getString("zeonAccount"));
}
} catch (e) {
Root.Modal.alert("Something went wrong loading your user data.");
Expand Down Expand Up @@ -388,7 +409,7 @@ export default {
for (let i = 0; i < allKeys.length; i++) {
let value = await localforage.getItem(allKeys[i]);

if (typeof value === 'string') {
if (typeof value === "string") {
totalStorage += value.length;
} else if (value instanceof Blob) {
totalStorage += value.size;
Expand Down Expand Up @@ -637,23 +658,25 @@ export default {
.filter((r) => r.type === "file" && r.item.endsWith(".theme"))
.map((r) => r.item);

await Promise.all(themeFileList.map(async (itm) => {
const theme = await vfs.readFile(
`Root/Pluto/config/themes/${itm}`
);
const result = themeLib.validateTheme(theme);
if (result.success === true) {
themes.push(
new Html("option").text(result.data.name).attr({
value: themes.length,
selected: desktopConfig.theme === itm ? true : null,
})
await Promise.all(
themeFileList.map(async (itm) => {
const theme = await vfs.readFile(
`Root/Pluto/config/themes/${itm}`
);
themeData.push(Object.assign({ fileName: itm }, result.data));
} else {
alert("failed parsing theme data due to " + result.message);
}
}));
const result = themeLib.validateTheme(theme);
if (result.success === true) {
themes.push(
new Html("option").text(result.data.name).attr({
value: themes.length,
selected: desktopConfig.theme === itm ? true : null,
})
);
themeData.push(Object.assign({ fileName: itm }, result.data));
} else {
alert("failed parsing theme data due to " + result.message);
}
})
);
}

new Html("select")
Expand Down Expand Up @@ -715,7 +738,7 @@ export default {
.attr({
for: Root.PID + "lc",
})
.text("Use wallpaper from theme")
.text(Root.Lib.getString("useThemeWallpaper"))
)
.appendTo(container);

Expand All @@ -724,19 +747,23 @@ export default {
.appendTo(container);

sidebarTypeSpan.appendMany(
new Html("span").text("Toolbar position"),
new Html("span").text(Root.Lib.getString("toolbarPosition")),
new Html("select")
.appendMany(
new Html("option").text("Vertical").attr({
value: "vertical",
selected:
desktopConfig.sidebarType === "vertical" ? true : null,
}),
new Html("option").text("Horizontal").attr({
value: "horizontal",
selected:
desktopConfig.sidebarType === "horizontal" ? true : null,
})
new Html("option")
.text(Root.Lib.getString("toolbarPositionVertical"))
.attr({
value: "vertical",
selected:
desktopConfig.sidebarType === "vertical" ? true : null,
}),
new Html("option")
.text(Root.Lib.getString("toolbarPositionHorizontal"))
.attr({
value: "horizontal",
selected:
desktopConfig.sidebarType === "horizontal" ? true : null,
})
)
.on("input", (e) => {
desktopConfig.sidebarType = e.target.value;
Expand All @@ -751,21 +778,29 @@ export default {
.appendTo(container);

dockStyleSpan.appendMany(
new Html("span").text("Dock style"),
new Html("span").text(Root.Lib.getString("dockStyle")),
new Html("select")
.appendMany(
new Html("option").text("Full").attr({
value: "full",
selected: desktopConfig.dockStyle === "full" ? true : null,
}),
new Html("option").text("Compact").attr({
value: "compact",
selected: desktopConfig.dockStyle === "compact" ? true : null,
}),
new Html("option").text("Minimal").attr({
value: "minimal",
selected: desktopConfig.dockStyle === "minimal" ? true : null,
})
new Html("option")
.text(Root.Lib.getString("dockStyleFull"))
.attr({
value: "full",
selected: desktopConfig.dockStyle === "full" ? true : null,
}),
new Html("option")
.text(Root.Lib.getString("dockStyleCompact"))
.attr({
value: "compact",
selected:
desktopConfig.dockStyle === "compact" ? true : null,
}),
new Html("option")
.text(Root.Lib.getString("dockStyleMinimal"))
.attr({
value: "minimal",
selected:
desktopConfig.dockStyle === "minimal" ? true : null,
})
)
.on("input", (e) => {
desktopConfig.dockStyle = e.target.value;
Expand Down Expand Up @@ -815,7 +850,7 @@ export default {
resultTab.class("row", "ac", "js", "gap");
resultTab.clear();
new Html("button")
.text("Test Network")
.text(Root.Lib.getString("testNetwork"))
.class("primary", "mc", "small")
.on("click", async (e) => {
resultTab.clear();
Expand Down Expand Up @@ -863,24 +898,28 @@ export default {
new Html("span")
.class("h2")
.style({ "margin-bottom": "8px" })
.text("You're online and good to go!"),
.text(Root.Lib.getString("networkTestSuccess")),
new Html("span").text(
"Your internet is " + averageResponse + "\n"
Root.Lib.getString("networkTestResult", {
status: averageResponse,
}) + '\n'
),
new Html("span")
.class("muted")
.text(
"Average response time: " + averageResponseTime + "ms"
Root.Lib.getString("networkTestMs", {
responseTime: averageResponseTime,
})
)
)
.appendTo(resultTab);
} else {
Root.Modal.alert(
"Failed",
"Network is not working. Status code: " +
req1.status +
", " +
req2.status
Root.Lib.getString("error"),
Root.Lib.getString("networkTestError", {
req1Status: req1.status,
req2Status: req2.status,
})
);
}
})
Expand Down Expand Up @@ -929,7 +968,7 @@ export default {
});
} else {
new Html("span")
.text("You have no installed applications.")
.text(Root.Lib.getString("noInstalledApps"))
.appendTo(container);
}
},
Expand All @@ -941,9 +980,9 @@ export default {
new Html("thead")
.appendMany(
new Html("tr").appendMany(
new Html("th").text("Name"),
new Html("th").text("Safe"),
new Html("th").text("Delete App")
new Html("th").text(Root.Lib.getString('securityTableItemName')),
new Html("th").text(Root.Lib.getString('securityTableItemSafe')),
new Html("th").text(Root.Lib.getString('securityTableItemDelete'))
)
)
.appendTo(table);
Expand All @@ -957,19 +996,19 @@ export default {
new Html("tr").appendMany(
new Html("td").text(dc[i].filename),
new Html("td").text(
dc[i].dangerous === true ? "No" : "Yes"
dc[i].dangerous === true ? Root.Lib.getString('no') : Root.Lib.getString('yes')
),
new Html("td").appendMany(
dc[i].dangerous === true
? new Html("button")
.text("Delete")
.text(Root.Lib.getString('delete'))
.on("click", async (_) => {
await dc[i].delete();
await performSecurityScan();
})
: new Html("button")
.attr({ disabled: true })
.text("Delete")
.text(Root.Lib.getString('delete'))
)
)
)
Expand All @@ -985,7 +1024,7 @@ export default {
.appendMany()
.appendTo(container);
new Html("button")
.text("Security Check")
.text(Root.Lib.getString("securityCheck"))
.class("primary", "mc", "small")
.on("click", async (_) => performSecurityScan())
.appendTo(container);
Expand Down Expand Up @@ -1023,7 +1062,7 @@ export default {
.attr({
for: Root.PID + "lc",
})
.text("Check every startup?")
.text(Root.Lib.getString("securityCheckEveryStartup"))
)
.appendTo(container);
},
Expand All @@ -1036,15 +1075,15 @@ export default {

setupSettingsApp();

settingsWin.setTitle(Root.Lib.getString('systemApp_Settings'));
this.name = Root.Lib.getString('systemApp_Settings');
settingsWin.setTitle(Root.Lib.getString("systemApp_Settings"));
this.name = Root.Lib.getString("systemApp_Settings");

return Root.Lib.setupReturns(async (m) => {
if (m && m.type) {
if (m.type === "refresh") {
Root.Lib.getString = m.data;
settingsWin.setTitle(Root.Lib.getString('systemApp_Settings'));
Root.Lib.updateProcTitle(Root.Lib.getString('systemApp_Settings'));
settingsWin.setTitle(Root.Lib.getString("systemApp_Settings"));
Root.Lib.updateProcTitle(Root.Lib.getString("systemApp_Settings"));
setupSettingsApp();
}
if (m.type === "goPage") {
Expand Down

0 comments on commit 1e2fbe9

Please sign in to comment.