Browse Source

Endpoint for analytic unit types #328 (#329)

pull/1/head
rozetko 6 years ago committed by GitHub
parent
commit
b5d21db702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      server/src/models/analytic_unit_model.ts
  2. 5
      server/src/routes/analytic_units_router.ts

31
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',

5
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);
@ -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);

Loading…
Cancel
Save