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