mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-01 13:09:31 +01:00
QNAP code style, temp formatting
This commit is contained in:
parent
b4f700c185
commit
df19ad7016
@ -36,8 +36,6 @@ export default function Component({ service }) {
|
||||
const volumeTotalSize = statusData.volume.volumeUse.total_size._cdata;
|
||||
const volumeFreeSize = statusData.volume.volumeUse.free_size._cdata;
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block
|
||||
@ -50,7 +48,7 @@ export default function Component({ service }) {
|
||||
/>
|
||||
<Block
|
||||
label="qnap.systemTempC"
|
||||
value={`${systemTempC} °C`}
|
||||
value={t("common.number", { value: systemTempC, maximumFractionDigits: 1, style: "unit", unit: "celsius" })}
|
||||
/>
|
||||
<Block
|
||||
label="qnap.poolUsage"
|
||||
|
@ -14,7 +14,7 @@ const logger = createLogger(proxyName);
|
||||
|
||||
async function login(widget, service) {
|
||||
const endpoint = "{url}/cgi-bin/authLogin.cgi";
|
||||
const loginUrl = new URL(formatApiCall(endpoint, widget ));
|
||||
const loginUrl = new URL(formatApiCall(endpoint, widget));
|
||||
const headers = { "Content-Type": "application/x-www-form-urlencoded" };
|
||||
|
||||
const [, , data,] = await httpProxy(loginUrl, {
|
||||
@ -41,20 +41,15 @@ async function login(widget, service) {
|
||||
|
||||
async function apiCall(widget, endpoint, service) {
|
||||
let key = cache.get(`${sessionTokenCacheKey}.${service}`);
|
||||
const method = "GET";
|
||||
|
||||
let apiUrl = new URL(formatApiCall(`${endpoint}&sid=${key}`, widget));
|
||||
let [status, contentType, data, responseHeaders] = await httpProxy(apiUrl, {
|
||||
method
|
||||
});
|
||||
let [status, contentType, data, responseHeaders] = await httpProxy(apiUrl);
|
||||
|
||||
if (status === 404) {
|
||||
logger.error("QNAP API rejected the request, attempting to obtain new session token");
|
||||
key = await login(widget, service);
|
||||
apiUrl = new URL(formatApiCall(`${endpoint}&sid=${key}`, widget));
|
||||
[status, contentType, data, responseHeaders] = await httpProxy(apiUrl, {
|
||||
method
|
||||
});
|
||||
[status, contentType, data, responseHeaders] = await httpProxy(apiUrl);
|
||||
}
|
||||
|
||||
if (status !== 200) {
|
||||
@ -63,7 +58,6 @@ async function apiCall(widget, endpoint, service) {
|
||||
}
|
||||
|
||||
const dataDecoded = xml2json(data.toString(), { compact: true });
|
||||
logger.debug("Dayta '%s'", dataDecoded);
|
||||
return { status, contentType, data: JSON.parse(dataDecoded.toString()), responseHeaders };
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user