You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
1.6 KiB
81 lines
1.6 KiB
import { AnalyticUnit } from './analytic_unit_model'; |
|
import { AnalyticUnitId, AnalyticUnitStatus, DetectorType } from './types'; |
|
|
|
import { Metric } from '@corpglory/tsdb-kit'; |
|
|
|
|
|
export class PatternAnalyticUnit extends AnalyticUnit { |
|
constructor( |
|
name: string, |
|
grafanaUrl: string, |
|
panelId: string, |
|
type: string, |
|
metric?: Metric, |
|
alert?: boolean, |
|
id?: AnalyticUnitId, |
|
lastDetectionTime?: number, |
|
status?: AnalyticUnitStatus, |
|
error?: string, |
|
labeledColor?: string, |
|
deletedColor?: string, |
|
visible?: boolean, |
|
collapsed?: boolean |
|
) { |
|
super( |
|
name, |
|
grafanaUrl, |
|
panelId, |
|
type, |
|
metric, |
|
alert, |
|
id, |
|
lastDetectionTime, |
|
status, |
|
error, |
|
labeledColor, |
|
deletedColor, |
|
DetectorType.PATTERN, |
|
visible, |
|
collapsed |
|
); |
|
} |
|
|
|
toObject() { |
|
const baseObject = super.toObject(); |
|
return { |
|
...baseObject |
|
}; |
|
} |
|
|
|
toPanelObject() { |
|
const baseObject = super.toPanelObject(); |
|
return { |
|
...baseObject |
|
}; |
|
} |
|
|
|
static fromObject(obj: any) { |
|
// TODO: remove duplication |
|
let metric: Metric | undefined = undefined; |
|
if(obj.metric !== undefined) { |
|
metric = Metric.fromObject(obj.metric); |
|
} |
|
|
|
return new PatternAnalyticUnit( |
|
obj.name, |
|
obj.grafanaUrl, |
|
obj.panelId, |
|
obj.type, |
|
metric, |
|
obj.alert, |
|
obj._id, |
|
obj.lastDetectionTime, |
|
obj.status, |
|
obj.error, |
|
obj.labeledColor, |
|
obj.deletedColor, |
|
obj.visible, |
|
obj.collapsed |
|
); |
|
} |
|
}
|
|
|