Fixed bug with custom css not persisting

This commit is contained in:
unknown 2021-07-17 23:11:24 +02:00
parent 4143ae8198
commit 88785aaa32
5 changed files with 40 additions and 12 deletions

View File

@ -1 +1 @@
REACT_APP_VERSION=1.5.2 REACT_APP_VERSION=1.6.0

View File

@ -145,6 +145,17 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value='orderId'>Custom order</option> <option value='orderId'>Custom order</option>
</select> </select>
</InputGroup> </InputGroup>
<InputGroup>
<label htmlFor='defaultSearchProvider'>Default Search Provider</label>
<select
id='defaultSearchProvider'
name='defaultSearchProvider'
value={formData.defaultSearchProvider}
onChange={(e) => inputChangeHandler(e)}
>
{queries.map((query: Query) => (<option value={query.prefix}>{query.name}</option>))}
</select>
</InputGroup>
<InputGroup> <InputGroup>
<label htmlFor='searchSameTab'>Open search results in the same tab</label> <label htmlFor='searchSameTab'>Open search results in the same tab</label>
<select <select
@ -196,17 +207,6 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value={0}>False</option> <option value={0}>False</option>
</select> </select>
</InputGroup> </InputGroup>
<InputGroup>
<label htmlFor='defaultSearchProvider'>Default Search Provider</label>
<select
id='defaultSearchProvider'
name='defaultSearchProvider'
value={formData.defaultSearchProvider}
onChange={(e) => inputChangeHandler(e)}
>
{queries.map((query: Query) => (<option value={query.prefix}>{query.name}</option>))}
</select>
</InputGroup>
<InputGroup> <InputGroup>
<label htmlFor='hideHeader'>Hide greeting and date</label> <label htmlFor='hideHeader'>Hide greeting and date</label>
<select <select

View File

@ -4,6 +4,7 @@ const Config = require('../models/Config');
const { Op } = require('sequelize'); const { Op } = require('sequelize');
const File = require('../utils/File'); const File = require('../utils/File');
const { join } = require('path'); const { join } = require('path');
const fs = require('fs');
// @desc Insert new key:value pair // @desc Insert new key:value pair
// @route POST /api/config // @route POST /api/config
@ -151,6 +152,9 @@ exports.updateCss = asyncWrapper(async (req, res, next) => {
const file = new File(join(__dirname, '../public/flame.css')); const file = new File(join(__dirname, '../public/flame.css'));
file.write(req.body.styles); file.write(req.body.styles);
// Copy file to docker volume
fs.copyFileSync(join(__dirname, '../public/flame.css'), join(__dirname, '../data/flame.css'));
res.status(200).json({ res.status(200).json({
success: true, success: true,
data: {} data: {}

View File

@ -7,6 +7,7 @@ const Socket = require('./Socket');
const Sockets = require('./Sockets'); const Sockets = require('./Sockets');
const associateModels = require('./models/associateModels'); const associateModels = require('./models/associateModels');
const initConfig = require('./utils/initConfig'); const initConfig = require('./utils/initConfig');
const findCss = require('./utils/findCss');
const Logger = require('./utils/Logger'); const Logger = require('./utils/Logger');
const logger = new Logger(); const logger = new Logger();
@ -16,6 +17,7 @@ const PORT = process.env.PORT || 5005;
await connectDB(); await connectDB();
await associateModels(); await associateModels();
await initConfig(); await initConfig();
findCss();
// Create server for Express API and WebSockets // Create server for Express API and WebSockets
const server = http.createServer(); const server = http.createServer();

22
utils/findCss.js Normal file
View File

@ -0,0 +1,22 @@
const fs = require('fs');
const { join } = require('path');
const Logger = require('./Logger');
const logger = new Logger();
// Check if flame.css exists in mounted docker volume. Create new file if not
const findCss = () => {
const srcPath = join(__dirname, '../data/flame.css');
const destPath = join(__dirname, '../public/flame.css');
if (fs.existsSync(srcPath)) {
fs.copyFileSync(srcPath, destPath);
logger.log('Custom CSS file found');
return;
}
logger.log('Creating empty CSS file');
fs.writeFileSync(destPath, '');
}
module.exports = findCss;