Use configurable BAPSicle server info.
This commit is contained in:
parent
3895ea2988
commit
95f5917c40
8 changed files with 55 additions and 32 deletions
8
.env.baps-development
Normal file
8
.env.baps-development
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
HTTPS=false
|
||||||
|
HOST=localhost
|
||||||
|
REACT_APP_BAPSICLE_INTERFACE=true
|
||||||
|
# Fill the below if using custom BAPSicle server settings
|
||||||
|
#REACT_APP_BAPSICLE_PROTOCOL=https
|
||||||
|
#REACT_APP_BAPSICLE_HOST=localhost
|
||||||
|
REACT_APP_BAPSICLE_PORT=13500
|
||||||
|
#REACT_APP_WEBSOCKET_PORT=13501
|
|
@ -1,3 +1 @@
|
||||||
HTTPS=false
|
|
||||||
REACT_APP_BAPSICLE_INTERFACE=true
|
REACT_APP_BAPSICLE_INTERFACE=true
|
||||||
HOST=localhost
|
|
|
@ -7,7 +7,7 @@ process.env.NODE_ENV = "production";
|
||||||
// If we want BAPS, specify it as the first command line argument.
|
// If we want BAPS, specify it as the first command line argument.
|
||||||
var args = process.argv.slice(2); // Remove node start.js
|
var args = process.argv.slice(2); // Remove node start.js
|
||||||
if (args.length > 0 && args[0] === "baps") {
|
if (args.length > 0 && args[0] === "baps") {
|
||||||
process.env.NODE_ENV = "baps";
|
process.env.NODE_ENV = "baps-production";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Makes the script crash on unhandled rejections instead of silently
|
// Makes the script crash on unhandled rejections instead of silently
|
||||||
|
|
|
@ -7,7 +7,7 @@ process.env.NODE_ENV = "development";
|
||||||
// If we want BAPS, specify it as the first command line argument.
|
// If we want BAPS, specify it as the first command line argument.
|
||||||
var args = process.argv.slice(2); // Remove node start.js
|
var args = process.argv.slice(2); // Remove node start.js
|
||||||
if (args.length > 0 && args[0] === "baps") {
|
if (args.length > 0 && args[0] === "baps") {
|
||||||
process.env.NODE_ENV = "baps";
|
process.env.NODE_ENV = "baps-development";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Makes the script crash on unhandled rejections instead of silently
|
// Makes the script crash on unhandled rejections instead of silently
|
||||||
|
|
12
src/api.ts
12
src/api.ts
|
@ -60,11 +60,13 @@ export async function bapsicleApiRequest(
|
||||||
method: "GET" | "POST" | "PUT",
|
method: "GET" | "POST" | "PUT",
|
||||||
params: any
|
params: any
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const res = await apiRequest(
|
let server = store.getState().bapsSession.currentServer;
|
||||||
"http://" + window.location.hostname + ":13500" + endpoint,
|
|
||||||
method,
|
if (!server) {
|
||||||
params
|
throw new Error("Trying to call BAPSicle server without connection.");
|
||||||
);
|
}
|
||||||
|
const url = `${server.ui_protocol}://${server.hostname}:${server.ui_port}${endpoint}`;
|
||||||
|
const res = await apiRequest(url, method, params);
|
||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,9 @@ import { connectBAPSicle } from "../bapsicle";
|
||||||
|
|
||||||
interface bapsServer {
|
interface bapsServer {
|
||||||
hostname: String | null;
|
hostname: String | null;
|
||||||
port: Number | null;
|
ui_port: Number | null;
|
||||||
|
ui_protocol: String | null;
|
||||||
|
ws_port: Number | null;
|
||||||
name: String | null;
|
name: String | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,12 +54,24 @@ export const getCurrentServer = (): AppThunk => async (dispatch, getState) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getServer = (): AppThunk => async (dispatch) => {
|
export const getServer = (): AppThunk => async (dispatch) => {
|
||||||
// TODO Server Details Configurable
|
// Since BAPS Presenter is served by the BAPSicle web server, use the current window path unless custom defined.
|
||||||
let bapsServer: bapsServer = {
|
let bapsServer: bapsServer = {
|
||||||
hostname: window.location.hostname,
|
hostname: process.env.REACT_APP_BAPSICLE_HOST
|
||||||
port: 13501,
|
? process.env.REACT_APP_BAPSICLE_HOST
|
||||||
|
: window.location.hostname,
|
||||||
|
ws_port: process.env.REACT_APP_WEBSOCKET_PORT
|
||||||
|
? parseInt(process.env.REACT_APP_WEBSOCKET_PORT)
|
||||||
|
: 13501,
|
||||||
|
ui_protocol: process.env.REACT_APP_BAPSICLE_PROTOCOL
|
||||||
|
? process.env.REACT_APP_BAPSICLE_PROTOCOL
|
||||||
|
: "http",
|
||||||
|
ui_port: process.env.REACT_APP_BAPSICLE_PORT
|
||||||
|
? parseInt(process.env.REACT_APP_BAPSICLE_PORT)
|
||||||
|
: parseInt(window.location.port),
|
||||||
name: "Connecting...",
|
name: "Connecting...",
|
||||||
};
|
};
|
||||||
dispatch(sessionState.actions.setCurrentServer({ server: bapsServer }));
|
dispatch(sessionState.actions.setCurrentServer({ server: bapsServer }));
|
||||||
dispatch(connectBAPSicle("ws://" + window.location.hostname + ":13501"));
|
dispatch(
|
||||||
|
connectBAPSicle("ws://" + bapsServer.hostname + ":" + bapsServer.ws_port)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -475,31 +475,33 @@ export const load = (
|
||||||
|
|
||||||
let url;
|
let url;
|
||||||
|
|
||||||
|
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
|
||||||
|
let server = getState().bapsSession.currentServer;
|
||||||
|
|
||||||
|
if (!server) {
|
||||||
|
throw new Error(
|
||||||
|
"Trying to load audio file without BAPSicle server connection."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// If bapsicle, override the Myradio.
|
||||||
|
url = `${server.ui_protocol}://${server.hostname}:${server.ui_port}`;
|
||||||
|
} else {
|
||||||
|
url = MYRADIO_NON_API_BASE;
|
||||||
|
}
|
||||||
|
|
||||||
if (item.type === "central") {
|
if (item.type === "central") {
|
||||||
// track
|
// track
|
||||||
|
|
||||||
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
|
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
|
||||||
url =
|
url += "/audiofile/track/" + item.trackid;
|
||||||
"http://" +
|
|
||||||
getState().bapsSession.currentServer?.hostname +
|
|
||||||
":13500/audiofile/track/" +
|
|
||||||
item.trackid;
|
|
||||||
} else {
|
} else {
|
||||||
url =
|
url += "/NIPSWeb/secure_play?trackid=" + item.trackid;
|
||||||
MYRADIO_NON_API_BASE + "/NIPSWeb/secure_play?trackid=" + item.trackid;
|
|
||||||
}
|
}
|
||||||
} else if ("managedid" in item) {
|
} else if ("managedid" in item) {
|
||||||
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
|
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
|
||||||
url =
|
url += "/audiofile/managed/" + item.managedid;
|
||||||
"http://" +
|
|
||||||
getState().bapsSession.currentServer?.hostname +
|
|
||||||
":13500/audiofile/managed/" +
|
|
||||||
item.managedid;
|
|
||||||
} else {
|
} else {
|
||||||
url =
|
url += "/NIPSWeb/managed_play?managedid=" + item.managedid;
|
||||||
MYRADIO_NON_API_BASE +
|
|
||||||
"/NIPSWeb/managed_play?managedid=" +
|
|
||||||
item.managedid;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@ -511,7 +513,7 @@ export const load = (
|
||||||
|
|
||||||
let waveform = document.getElementById("waveform-" + player.toString());
|
let waveform = document.getElementById("waveform-" + player.toString());
|
||||||
if (waveform == null) {
|
if (waveform == null) {
|
||||||
throw new Error();
|
throw new Error("No waveform element found for player.");
|
||||||
}
|
}
|
||||||
audioEngine.destroyPlayerIfExists(player); // clear previous (ghost) wavesurfer and it's media elements.
|
audioEngine.destroyPlayerIfExists(player); // clear previous (ghost) wavesurfer and it's media elements.
|
||||||
// wavesurfer also sets the background white, remove for progress bar to work.
|
// wavesurfer also sets the background white, remove for progress bar to work.
|
||||||
|
|
|
@ -102,7 +102,6 @@ const showplan = createSlice({
|
||||||
action: PayloadAction<{ channel: Number; planItems: PlanItem[] }>
|
action: PayloadAction<{ channel: Number; planItems: PlanItem[] }>
|
||||||
) {
|
) {
|
||||||
// This is used for BAPSicle only to read in individual channels of show plan into the show state from the server.
|
// This is used for BAPSicle only to read in individual channels of show plan into the show state from the server.
|
||||||
// TODO: Does this need to be this complicated?
|
|
||||||
var newItems = state.plan?.filter(
|
var newItems = state.plan?.filter(
|
||||||
(item) => item.channel !== action.payload.channel
|
(item) => item.channel !== action.payload.channel
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue