diff --git a/server/src/models/analytic_unit_model.ts b/server/src/models/analytic_unit_model.ts index 0fe89b4..24531f9 100644 --- a/server/src/models/analytic_unit_model.ts +++ b/server/src/models/analytic_unit_model.ts @@ -6,6 +6,37 @@ import { Metric } from 'grafana-datasource-kit'; let db = makeDBQ(Collection.ANALYTIC_UNITS); +export const ANALYTIC_UNIT_TYPES = { + pattern: [ + { + name: 'General', + value: 'GENERAL' + }, + { + name: 'Peaks', + value: 'PEAK' + }, + { + name: 'Troughs', + value: 'TROUGH' + }, + { + name: 'Jumps', + value: 'JUMP' + }, + { + name: 'Drops', + value: 'DROP' + } + ], + threshold: [ + { + name: 'Threshold', + value: 'THRESHOLD' + } + ] +}; + export type AnalyticUnitId = string; export enum AnalyticUnitStatus { READY = 'READY', diff --git a/server/src/routes/analytic_units_router.ts b/server/src/routes/analytic_units_router.ts index 367e0ff..6de6335 100644 --- a/server/src/routes/analytic_units_router.ts +++ b/server/src/routes/analytic_units_router.ts @@ -88,6 +88,10 @@ async function getUnits(ctx: Router.IRouterContext) { } } +function getTypes(ctx: Router.IRouterContext) { + ctx.response.body = AnalyticUnit.ANALYTIC_UNIT_TYPES; +} + async function createUnit(ctx: Router.IRouterContext) { try { let id = await createAnalyticUnitFromObject(ctx.request.body); @@ -112,7 +116,7 @@ async function setAlert(ctx: Router.IRouterContext) { if(alert === undefined) { throw new Error('Cannot set undefined alert status'); } - + await AnalyticsController.setAlert(analyticUnitId, alert); ctx.response.body = { @@ -155,6 +159,7 @@ export var router = new Router(); router.get('/', getUnit); router.get('/units', getUnits); router.get('/status', getStatus); +router.get('/types', getTypes); router.patch('/alert', setAlert); router.post('/', createUnit); router.delete('/', deleteUnit);