mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-07-30 00:39:16 +02:00
change some plugin stuff and allow to hook into tx_search
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ require("./device");
|
|||||||
{
|
{
|
||||||
const helpers = require('./helpers');
|
const helpers = require('./helpers');
|
||||||
const plugins = helpers.findServerFiles(serverConfig.plugins);
|
const plugins = helpers.findServerFiles(serverConfig.plugins);
|
||||||
if (plugins.length > 0) setTimeout(helpers.startPluginsWithDelay, 4000, plugins, 3000);
|
if (plugins.length > 0) setTimeout(helpers.startPluginsWithDelay, 3000, plugins, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
require('./stream/index');
|
require('./stream/index');
|
||||||
|
|||||||
+7
-1
@@ -14,7 +14,13 @@ function parsePluginConfig(filePath) {
|
|||||||
const pluginExports = require(filePath);
|
const pluginExports = require(filePath);
|
||||||
Object.assign(pluginConfig, pluginExports.pluginConfig);
|
Object.assign(pluginConfig, pluginExports.pluginConfig);
|
||||||
|
|
||||||
// Check if pluginConfig has frontEndPath defined
|
if(pluginConfig.server_embedded) {
|
||||||
|
setTimeout(function() {
|
||||||
|
consoleCmd.logInfo(`Server plugin ${pluginConfig.name} ${pluginConfig.version} initialized successfully.`);
|
||||||
|
}, 500)
|
||||||
|
return pluginConfig;
|
||||||
|
}
|
||||||
|
|
||||||
if (pluginConfig.frontEndPath) {
|
if (pluginConfig.frontEndPath) {
|
||||||
const sourcePath = path.join(path.dirname(filePath), pluginConfig.frontEndPath);
|
const sourcePath = path.join(path.dirname(filePath), pluginConfig.frontEndPath);
|
||||||
const destinationDir = path.join(__dirname, '../web/js/plugins', path.dirname(pluginConfig.frontEndPath));
|
const destinationDir = path.join(__dirname, '../web/js/plugins', path.dirname(pluginConfig.frontEndPath));
|
||||||
|
|||||||
+2
-1
@@ -2,5 +2,6 @@ let connectedUsers = [];
|
|||||||
let chatHistory = [];
|
let chatHistory = [];
|
||||||
let websocket_delegation = new Map();
|
let websocket_delegation = new Map();
|
||||||
var ctl_output;
|
var ctl_output;
|
||||||
|
var tx_search_hook = {};
|
||||||
|
|
||||||
module.exports = { connectedUsers, chatHistory, websocket_delegation, ctl_output };
|
module.exports = { connectedUsers, chatHistory, websocket_delegation, ctl_output, tx_search_hook };
|
||||||
+3
-1
@@ -3,6 +3,7 @@ if(!configExists()) return;
|
|||||||
|
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
const consoleCmd = require('./console');
|
const consoleCmd = require('./console');
|
||||||
|
const storage = require('./storage');
|
||||||
|
|
||||||
let localDb = {};
|
let localDb = {};
|
||||||
let nextLocalDbUpdate = 0;
|
let nextLocalDbUpdate = 0;
|
||||||
@@ -217,7 +218,8 @@ async function fetchTx(freq, piCode, rdsPs) {
|
|||||||
if (serverConfig.webserver.rdsMode === true) await loadUsStatesGeoJson();
|
if (serverConfig.webserver.rdsMode === true) await loadUsStatesGeoJson();
|
||||||
|
|
||||||
const key = `${freq}|${piCode.toUpperCase()}`;
|
const key = `${freq}|${piCode.toUpperCase()}`;
|
||||||
let rawMatches = piFreqIndex[key] || [];
|
var rawMatches = piFreqIndex[key] || [];
|
||||||
|
rawMatches = [...storage.tx_search_hook[key], ...rawMatches];
|
||||||
|
|
||||||
// Format the results into the same structure as before
|
// Format the results into the same structure as before
|
||||||
let filteredLocations = rawMatches.map(({ station, ...locData }) => ({
|
let filteredLocations = rawMatches.map(({ station, ...locData }) => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user