commit
f93659b661
7 changed files with 53 additions and 27 deletions
|
@ -1 +1 @@
|
||||||
REACT_APP_VERSION=1.5.2
|
REACT_APP_VERSION=1.6.0
|
|
@ -5,7 +5,7 @@ import { connect } from 'react-redux';
|
||||||
import { createNotification, updateConfig, sortApps, sortCategories } from '../../../store/actions';
|
import { createNotification, updateConfig, sortApps, sortCategories } from '../../../store/actions';
|
||||||
|
|
||||||
// Typescript
|
// Typescript
|
||||||
import { GlobalState, NewNotification, SettingsForm } from '../../../interfaces';
|
import { GlobalState, NewNotification, Query, SettingsForm } from '../../../interfaces';
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
import InputGroup from '../../UI/Forms/InputGroup/InputGroup';
|
import InputGroup from '../../UI/Forms/InputGroup/InputGroup';
|
||||||
|
@ -16,6 +16,7 @@ import classes from './OtherSettings.module.css';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { searchConfig } from '../../../utility';
|
import { searchConfig } from '../../../utility';
|
||||||
|
import { queries } from '../../../utility/searchQueries.json';
|
||||||
|
|
||||||
interface ComponentProps {
|
interface ComponentProps {
|
||||||
createNotification: (notification: NewNotification) => void;
|
createNotification: (notification: NewNotification) => void;
|
||||||
|
@ -144,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
|
||||||
|
@ -180,6 +192,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
||||||
<option value={0}>False</option>
|
<option value={0}>False</option>
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
{/* MODULES OPTIONS */}
|
{/* MODULES OPTIONS */}
|
||||||
<h2 className={classes.SettingsSection}>Modules</h2>
|
<h2 className={classes.SettingsSection}>Modules</h2>
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
|
@ -194,24 +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)}
|
|
||||||
>
|
|
||||||
<option value='d'>DuckDuckGo</option>
|
|
||||||
<option value='g'>Google</option>
|
|
||||||
<option value='s'>Disroot</option>
|
|
||||||
<option value='yt'>YouTube</option>
|
|
||||||
<option value='r'>Reddit</option>
|
|
||||||
<option value='im'>IMDb</option>
|
|
||||||
<option value='mv'>The Movie Database</option>
|
|
||||||
<option value='sp'>Spotify</option>
|
|
||||||
</select>
|
|
||||||
</InputGroup>
|
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor='hideHeader'>Hide greeting and date</label>
|
<label htmlFor='hideHeader'>Hide greeting and date</label>
|
||||||
<select
|
<select
|
||||||
|
@ -266,4 +261,4 @@ const actions = {
|
||||||
sortCategories
|
sortCategories
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, actions)(OtherSettings);
|
export default connect(mapStateToProps, actions)(OtherSettings);
|
|
@ -10,7 +10,6 @@ export const searchParser = (searchQuery: string): boolean => {
|
||||||
|
|
||||||
const query = queries.find((q: Query) => q.prefix === prefix);
|
const query = queries.find((q: Query) => q.prefix === prefix);
|
||||||
|
|
||||||
console.log("QUERY IS " + query);
|
|
||||||
if (query) {
|
if (query) {
|
||||||
const sameTab = searchConfig('searchSameTab', false);
|
const sameTab = searchConfig('searchSameTab', false);
|
||||||
|
|
||||||
|
@ -24,4 +23,4 @@ export const searchParser = (searchQuery: string): boolean => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
|
@ -2,8 +2,8 @@ export const urlParser = (url: string): string[] => {
|
||||||
let parsedUrl: string;
|
let parsedUrl: string;
|
||||||
let displayUrl: string;
|
let displayUrl: string;
|
||||||
|
|
||||||
if (/https?:\/\//.test(url)) {
|
if (/(https?|steam):\/\//.test(url)) {
|
||||||
// Url starts with http[s]:// -> leave it as it is
|
// Url starts with http[s]:// or steam:// -> leave it as it is
|
||||||
parsedUrl = url;
|
parsedUrl = url;
|
||||||
} else {
|
} else {
|
||||||
// No protocol -> apply http:// prefix
|
// No protocol -> apply http:// prefix
|
||||||
|
@ -11,10 +11,14 @@ export const urlParser = (url: string): string[] => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create simplified url to display as text
|
// Create simplified url to display as text
|
||||||
displayUrl = url
|
if (/steam:\/\//.test(url)) {
|
||||||
|
displayUrl = 'Run Steam App';
|
||||||
|
} else {
|
||||||
|
displayUrl = url
|
||||||
.replace(/https?:\/\//, '')
|
.replace(/https?:\/\//, '')
|
||||||
.replace('www.', '')
|
.replace('www.', '')
|
||||||
.replace(/\/$/, '');
|
.replace(/\/$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
return [displayUrl, parsedUrl]
|
return [displayUrl, parsedUrl]
|
||||||
}
|
}
|
|
@ -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: {}
|
||||||
|
|
|
@ -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
22
utils/findCss.js
Normal 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;
|
Loading…
Reference in a new issue