Adjusted classes
This commit is contained in:
parent
213e7fdd28
commit
a6d5530d6f
12
.vscode/settings.json
vendored
12
.vscode/settings.json
vendored
@ -1,5 +1,17 @@
|
|||||||
{
|
{
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
|
"**/.git": true,
|
||||||
|
"**/.svn": true,
|
||||||
|
"**/.hg": true,
|
||||||
|
"**/CVS": true,
|
||||||
|
"**/.DS_Store": true,
|
||||||
|
"**/Thumbs.db": true,
|
||||||
|
"**/__pycache__": true,
|
||||||
|
"**/.idea": true,
|
||||||
|
"**/.classpath": true,
|
||||||
|
"**/.project": true,
|
||||||
|
"**/.settings": true,
|
||||||
|
"**/.factorypath": true,
|
||||||
"**/.next": true,
|
"**/.next": true,
|
||||||
"**/node_modules": true
|
"**/node_modules": true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ export default function Widget({ options }) {
|
|||||||
: [data.fs.find((d) => d.mnt_point === options.disk)].filter((d) => d);
|
: [data.fs.find((d) => d.mnt_point === options.disk)].filter((d) => d);
|
||||||
}
|
}
|
||||||
|
|
||||||
const addedClasses = classNames('information-widget-glances', { 'information-widget-expanded': options.expanded })
|
const addedClasses = classNames('information-widget-glances', { 'expanded': options.expanded })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Resources options={options} target={settings.target ?? "_blank"} additionalClassNames={addedClasses}>
|
<Resources options={options} target={settings.target ?? "_blank"} additionalClassNames={addedClasses}>
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export default function Node({ data, expanded, labels }) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return <Resource
|
return <Resource
|
||||||
additionalClassNames="information-widget-node"
|
additionalClassNames="information-widget-longhorn-node"
|
||||||
icon={FaThermometerHalf}
|
icon={FaThermometerHalf}
|
||||||
value={t("common.bytes", { value: data.node.available })}
|
value={t("common.bytes", { value: data.node.available })}
|
||||||
label={t("resources.free")}
|
label={t("resources.free")}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ export default function Resource({ children, icon, value, label, expandedValue =
|
|||||||
|
|
||||||
return <div className={`flex-none flex flex-row items-center mr-3 py-1.5 information-widget-resource ${ additionalClassNames }`}>
|
return <div className={`flex-none flex flex-row items-center mr-3 py-1.5 information-widget-resource ${ additionalClassNames }`}>
|
||||||
<Icon className="text-theme-800 dark:text-theme-200 w-5 h-5 resource-icon"/>
|
<Icon className="text-theme-800 dark:text-theme-200 w-5 h-5 resource-icon"/>
|
||||||
<div className={ `flex flex-col ml-3 text-left min-w-[85px] resource-label${ expanded ? ' expanded' : ''}`}>
|
<div className={ `flex flex-col ml-3 text-left min-w-[85px] ${ expanded ? ' expanded' : ''}`}>
|
||||||
<div className="text-theme-800 dark:text-theme-200 text-xs flex flex-row justify-between">
|
<div className="text-theme-800 dark:text-theme-200 text-xs flex flex-row justify-between">
|
||||||
<div className="pl-0.5">{value}</div>
|
<div className="pl-0.5">{value}</div>
|
||||||
<div className="pr-1">{label}</div>
|
<div className="pr-1">{label}</div>
|
||||||
|
|||||||
@ -8,16 +8,6 @@ import createLogger from "utils/logger";
|
|||||||
|
|
||||||
const logger = createLogger("configFileService");
|
const logger = createLogger("configFileService");
|
||||||
|
|
||||||
/**
|
|
||||||
* Verifies that the config file paths are in subdirectory
|
|
||||||
* @param {string} parent Parent initial folder
|
|
||||||
* @param {string} child Supposed child path
|
|
||||||
* @returns {boolean} true if in a subdirectory
|
|
||||||
*/
|
|
||||||
function isSubDirectory(parent, child) {
|
|
||||||
return path.relative(child, parent).startsWith('..');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("next").NextApiRequest} req
|
* @param {import("next").NextApiRequest} req
|
||||||
* @param {import("next").NextApiResponse} res
|
* @param {import("next").NextApiResponse} res
|
||||||
@ -25,24 +15,19 @@ function isSubDirectory(parent, child) {
|
|||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
const { path: relativePath } = req.query;
|
const { path: relativePath } = req.query;
|
||||||
|
|
||||||
const filePath = path.join(CONF_DIR, relativePath);
|
if(relativePath !== 'custom.js' && relativePath !== 'custom.css')
|
||||||
|
|
||||||
if(!isSubDirectory(CONF_DIR, filePath))
|
|
||||||
{
|
{
|
||||||
logger.error(`Forbidden access to parent file: ${ filePath }`);
|
res.status(422).end('Incorrect file extension, expected custom.js or custom.css')
|
||||||
res.status(403).end('Forbidden access to parent file');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filePath = path.join(CONF_DIR, relativePath);
|
||||||
const mimeType = mime.getType(relativePath);
|
const mimeType = mime.getType(relativePath);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Read the content of the CSS file
|
// Read the content of the file or return empty content
|
||||||
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
const fileContent = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf-8') : '';
|
||||||
|
|
||||||
// Set the response header to indicate that this is a CSS file
|
|
||||||
res.setHeader('Content-Type', mimeType);
|
res.setHeader('Content-Type', mimeType);
|
||||||
|
|
||||||
// Send the CSS content as the API response
|
|
||||||
res.status(200).send(fileContent);
|
res.status(200).send(fileContent);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user