-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from Mala1180/feature/frontend-popups
feature/frontend-popups
- Loading branch information
Showing
16 changed files
with
231 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { type QVueGlobals } from 'quasar' | ||
export const popPositive = (q: QVueGlobals, message: string): void => { | ||
q.notify({ | ||
type: 'positive', | ||
message: message | ||
}) | ||
} | ||
|
||
export const popNegative = (q: QVueGlobals, message: string): void => { | ||
q.notify({ | ||
type: 'negative', | ||
message: message | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { type Camera, Measure, type Sensor } from 'domain/dist/domain/device/core' | ||
import { MeasureConverter } from 'domain/dist/utils' | ||
import { | ||
type DeviceFactory, | ||
DeviceFactoryImpl, | ||
type DeviceIdFactory, | ||
DeviceIdFactoryImpl, | ||
type ResolutionFactory, | ||
ResolutionFactoryImpl | ||
} from 'domain/dist/domain/device/factories' | ||
|
||
const deviceIdFactory: DeviceIdFactory = new DeviceIdFactoryImpl() | ||
const deviceFactory: DeviceFactory = new DeviceFactoryImpl() | ||
const resolutionFactory: ResolutionFactory = new ResolutionFactoryImpl() | ||
|
||
export const composeSensor = (sensor: any): Sensor => { | ||
return deviceFactory.createSensor( | ||
deviceIdFactory.createSensorId(sensor._id.code), | ||
sensor.ipAddress, | ||
sensor.intervalMillis, | ||
composeMeasure(sensor.measures) | ||
) | ||
} | ||
|
||
export const composeCamera = (camera: any): Camera => { | ||
return deviceFactory.createCamera( | ||
deviceIdFactory.createCameraId(camera._id.code), | ||
camera.ipAddress, | ||
resolutionFactory.createResolution(camera.resolution.width, camera.resolution.height) | ||
) | ||
} | ||
|
||
export function composeMeasure(measures: any): Measure[] { | ||
return measures.map((measure: any) => { | ||
return MeasureConverter.convertToMeasure(measure) | ||
}) | ||
} |
52 changes: 52 additions & 0 deletions
52
frontend/src/scripts/presentation/notification/ComposeNotification.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import RequestHelper, { alarmHost, alarmPort } from '@/utils/RequestHelper' | ||
import { DeviceTypeConverter, MeasureConverter, ObjectClassConverter } from 'domain/dist/utils' | ||
import { DeviceType } from 'domain/dist/domain/device/core' | ||
import type { Exceeding, Intrusion } from 'domain/dist/domain/anomaly/core' | ||
import type { NotificationFactory } from 'domain/dist/domain/alarm-system/factories' | ||
import { NotificationFactoryImpl } from 'domain/dist/domain/alarm-system/factories' | ||
import type { AnomalyFactory } from 'domain/dist/domain/anomaly/factories' | ||
import { AnomalyFactoryImpl } from 'domain/dist/domain/anomaly/factories' | ||
import type { DeviceIdFactory } from 'domain/dist/domain/device/factories' | ||
import { DeviceIdFactoryImpl } from 'domain/dist/domain/device/factories' | ||
import type { Notification } from 'domain/dist/domain/alarm-system/core' | ||
|
||
const notificationFactory: NotificationFactory = new NotificationFactoryImpl() | ||
const anomalyFactory: AnomalyFactory = new AnomalyFactoryImpl() | ||
const deviceIdFactory: DeviceIdFactory = new DeviceIdFactoryImpl() | ||
|
||
export const composeNotification = async (notification: any): Promise<Notification> => { | ||
const resAnomaly = await RequestHelper.get( | ||
`http://${alarmHost}:${alarmPort}/anomalies/` + notification.anomalyId | ||
) | ||
switch (DeviceTypeConverter.convertToDeviceType(resAnomaly.data.deviceId.type)) { | ||
case DeviceType.CAMERA: | ||
return notificationFactory.createIntrusionNotification( | ||
notification._id, | ||
composeIntrusion(resAnomaly.data) | ||
) | ||
case DeviceType.SENSOR: | ||
return notificationFactory.createExceedingNotification( | ||
notification._id, | ||
composeExceeding(resAnomaly.data) | ||
) | ||
} | ||
} | ||
|
||
function composeIntrusion(intrusion: any): Intrusion { | ||
return anomalyFactory.createIntrusion( | ||
intrusion._id, | ||
deviceIdFactory.createCameraId(intrusion.deviceId.code), | ||
new Date(intrusion.timestamp), | ||
ObjectClassConverter.convertToObjectClass(intrusion.intrusionObject) | ||
) | ||
} | ||
|
||
function composeExceeding(exceeding: any): Exceeding { | ||
return anomalyFactory.createExceeding( | ||
exceeding._id, | ||
deviceIdFactory.createSensorId(exceeding.deviceId.code), | ||
new Date(exceeding.timestamp), | ||
MeasureConverter.convertToMeasure(exceeding.measure), | ||
exceeding.value | ||
) | ||
} |
47 changes: 47 additions & 0 deletions
47
frontend/src/scripts/presentation/security-rule/ComposeSecurityRule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import type { ExceedingRule, IntrusionRule } from 'domain/dist/domain/security-rule/core' | ||
import { ContactTypeConverter, MeasureConverter, ObjectClassConverter } from 'domain/dist/utils' | ||
import type { Contact } from 'domain/dist/domain/monitoring/core' | ||
import { type SecurityRuleFactory, SecurityRuleFactoryImpl } from 'domain/dist/domain/security-rule/factories' | ||
import { type DeviceIdFactory, DeviceIdFactoryImpl } from 'domain/dist/domain/device/factories' | ||
import { type ContactFactory, ContactFactoryImpl } from 'domain/dist/domain/monitoring/factories' | ||
|
||
const securityRuleFactory: SecurityRuleFactory = new SecurityRuleFactoryImpl() | ||
const deviceIdFactory: DeviceIdFactory = new DeviceIdFactoryImpl() | ||
const contactFactory: ContactFactory = new ContactFactoryImpl() | ||
|
||
export function composeExceedingSecurityRule(exceedingRule: any): ExceedingRule { | ||
return securityRuleFactory.createExceedingRule( | ||
exceedingRule.minValue, | ||
exceedingRule.maxValue, | ||
MeasureConverter.convertToMeasure(exceedingRule.measure), | ||
exceedingRule._id, | ||
deviceIdFactory.createSensorId(exceedingRule.deviceId.code), | ||
exceedingRule.creatorId, | ||
composeContacts(exceedingRule.contacts), | ||
exceedingRule.description, | ||
new Date(exceedingRule.from), | ||
new Date(exceedingRule.to) | ||
) | ||
} | ||
|
||
export function composeIntrusionSecurityRule(intrusionRule: any): IntrusionRule { | ||
return securityRuleFactory.createIntrusionRule( | ||
ObjectClassConverter.convertToObjectClass(intrusionRule.objectClass), | ||
intrusionRule._id, | ||
deviceIdFactory.createCameraId(intrusionRule.deviceId.code), | ||
intrusionRule.creatorId, | ||
composeContacts(intrusionRule.contacts), | ||
intrusionRule.description, | ||
new Date(intrusionRule.from), | ||
new Date(intrusionRule.to) | ||
) | ||
} | ||
|
||
function composeContacts(contacts: any): Contact[] { | ||
return contacts.map((contact: any) => { | ||
return contactFactory.createContact( | ||
contact.value, | ||
ContactTypeConverter.convertToContactType(contact.type) | ||
) | ||
}) | ||
} |
Oops, something went wrong.