feat: small improvements to instance info (#591)

* refactor: add typings to backend info

* refactor: write current version to project file

* feat: show location of css override
This commit is contained in:
Carlos Valente
2023-11-15 20:20:05 +01:00
committed by GitHub
parent 536e447eaa
commit 54def8b820
19 changed files with 105 additions and 58 deletions
@@ -11,7 +11,7 @@ describe('safeMerge', () => {
},
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
serverPort: 4001,
editorKey: null,
operatorKey: null,
@@ -84,7 +84,7 @@ describe('safeMerge', () => {
const mergedData = safeMerge(existing, newData);
expect(mergedData.settings).toEqual({
app: 'ontime',
version: 2,
version: '2.0.0',
serverPort: 3000,
operatorKey: null,
editorKey: null,
@@ -144,7 +144,7 @@ describe('safeMerge', () => {
},
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
serverPort: 4001,
operatorKey: null,
editorKey: null,
@@ -1,6 +1,6 @@
import { Alias, DatabaseModel, LogOrigin, ProjectData } from 'ontime-types';
import { Alias, DatabaseModel, GetInfo, LogOrigin, ProjectData } from 'ontime-types';
import { RequestHandler } from 'express';
import { RequestHandler, Request, Response } from 'express';
import fs from 'fs';
import { networkInterfaces } from 'os';
@@ -9,7 +9,7 @@ import { DataProvider } from '../classes/data-provider/DataProvider.js';
import { failEmptyObjects, failIsNotArray } from '../utils/routerUtils.js';
import { PlaybackService } from '../services/PlaybackService.js';
import { eventStore } from '../stores/EventStore.js';
import { isDocker, resolveDbPath } from '../setup.js';
import { isDocker, pathToStartStyles, resolveDbPath } from '../setup.js';
import { oscIntegration } from '../services/integration-service/OscIntegration.js';
import { logger } from '../classes/Logger.js';
import { deleteAllEvents, notifyChanges } from '../services/rundown-service/RundownService.js';
@@ -105,15 +105,16 @@ const getNetworkInterfaces = () => {
return results;
};
// Create controller for POST request to '/ontime/info'
// Create controller for GET request to '/ontime/info'
// Returns -
export const getInfo = async (req, res) => {
export const getInfo = async (req: Request, res: Response<GetInfo>) => {
const { version, serverPort } = DataProvider.getSettings();
const osc = DataProvider.getOsc();
// get nif and inject localhost
const ni = getNetworkInterfaces();
ni.unshift({ name: 'localhost', address: '127.0.0.1' });
const cssOverride = pathToStartStyles;
// send object with network information
res.status(200).send({
@@ -121,6 +122,7 @@ export const getInfo = async (req, res) => {
version,
serverPort,
osc,
cssOverride,
});
};
+2 -1
View File
@@ -1,4 +1,5 @@
import { DatabaseModel } from 'ontime-types';
import { ONTIME_VERSION } from '../ONTIME_VERSION.js';
export const dbModel: DatabaseModel = {
rundown: [],
@@ -12,7 +13,7 @@ export const dbModel: DatabaseModel = {
},
settings: {
app: 'ontime',
version: 2,
version: ONTIME_VERSION,
serverPort: 4001,
editorKey: null,
operatorKey: null,
+13 -13
View File
@@ -201,7 +201,7 @@ describe('test json parser with valid def', () => {
},
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
timeFormat: '24',
},
viewSettings: {},
@@ -260,7 +260,7 @@ describe('test json parser with valid def', () => {
it('settings are for right app and version', () => {
const settings = parseResponse?.settings;
expect(settings.app).toBe('ontime');
expect(settings.version).toBe(2);
expect(settings.version).toEqual(expect.any(String));
});
it('missing settings', () => {
@@ -387,7 +387,7 @@ describe('test corrupt data', () => {
},
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
serverPort: 4001,
lock: null,
timeFormat: '24',
@@ -410,7 +410,7 @@ describe('test corrupt data', () => {
},
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
serverPort: 4001,
lock: null,
timeFormat: '24',
@@ -427,7 +427,7 @@ describe('test corrupt data', () => {
project: {},
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
serverPort: 4001,
lock: null,
timeFormat: '24',
@@ -444,7 +444,7 @@ describe('test corrupt data', () => {
event: {},
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
},
};
@@ -734,7 +734,7 @@ describe('test aliases import', () => {
rundown: [],
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
},
aliases: [
{
@@ -773,7 +773,7 @@ describe('test userFields import', () => {
rundown: [],
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
},
userFields: testUserFields,
};
@@ -800,7 +800,7 @@ describe('test userFields import', () => {
rundown: [],
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
},
userFields: testUserFields,
};
@@ -814,7 +814,7 @@ describe('test userFields import', () => {
rundown: [],
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
},
};
@@ -828,7 +828,7 @@ describe('test userFields import', () => {
rundown: [],
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
},
userFields: {
notThis: 'this shouldng be accepted',
@@ -847,7 +847,7 @@ describe('test views import', () => {
rundown: [],
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
},
viewSettings: {
normalColor: '#ffffffcc',
@@ -881,7 +881,7 @@ describe('test views import', () => {
rundown: [],
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
},
};
const parsed = parseViewSettings(testData);
+1 -4
View File
@@ -241,7 +241,7 @@ export const parseExcel = (excelData: unknown[][], options?: Partial<ExcelImport
project: projectData,
settings: {
app: 'ontime',
version: 2,
version: '2.0.0',
},
userFields: customUserFields,
};
@@ -382,9 +382,6 @@ export const fileHandler = async (file: string, options: ExcelImportOptions): Pr
let uploadedJson = null;
uploadedJson = JSON.parse(rawdata);
if (uploadedJson.settings.version !== 2) {
throw new Error(`Project version unknown ${uploadedJson.settings.version}`);
}
res.data = await parseJson(uploadedJson);
// delete file
+1
View File
@@ -114,6 +114,7 @@ export const parseSettings = (data): Settings => {
console.log('ERROR: unknown app version, skipping');
} else {
const settings = {
version: dbModel.settings.version,
serverPort: s.serverPort || dbModel.settings.serverPort,
editorKey: s.editorKey || null,
operatorKey: s.operatorKey || null,