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": {
|
||||
"**/.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,
|
||||
"**/node_modules": true
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ export default function Widget({ options }) {
|
||||
: [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 (
|
||||
<Resources options={options} target={settings.target ?? "_blank"} additionalClassNames={addedClasses}>
|
||||
|
||||
@ -8,7 +8,7 @@ export default function Node({ data, expanded, labels }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return <Resource
|
||||
additionalClassNames="information-widget-node"
|
||||
additionalClassNames="information-widget-longhorn-node"
|
||||
icon={FaThermometerHalf}
|
||||
value={t("common.bytes", { value: data.node.available })}
|
||||
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 }`}>
|
||||
<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="pl-0.5">{value}</div>
|
||||
<div className="pr-1">{label}</div>
|
||||
|
||||
@ -8,16 +8,6 @@ import createLogger from "utils/logger";
|
||||
|
||||
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").NextApiResponse} res
|
||||
@ -25,24 +15,19 @@ function isSubDirectory(parent, child) {
|
||||
export default async function handler(req, res) {
|
||||
const { path: relativePath } = req.query;
|
||||
|
||||
const filePath = path.join(CONF_DIR, relativePath);
|
||||
|
||||
if(!isSubDirectory(CONF_DIR, filePath))
|
||||
if(relativePath !== 'custom.js' && relativePath !== 'custom.css')
|
||||
{
|
||||
logger.error(`Forbidden access to parent file: ${ filePath }`);
|
||||
res.status(403).end('Forbidden access to parent file');
|
||||
res.status(422).end('Incorrect file extension, expected custom.js or custom.css')
|
||||
}
|
||||
|
||||
const filePath = path.join(CONF_DIR, relativePath);
|
||||
const mimeType = mime.getType(relativePath);
|
||||
|
||||
try {
|
||||
// Read the content of the CSS file
|
||||
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
||||
// Read the content of the file or return empty content
|
||||
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);
|
||||
|
||||
// Send the CSS content as the API response
|
||||
res.status(200).send(fileContent);
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user