diff --git a/alarm/db/alarm-init.js b/alarm/db/alarm-init.js index f77e0e157..0b4b82a09 100644 --- a/alarm/db/alarm-init.js +++ b/alarm/db/alarm-init.js @@ -68,8 +68,8 @@ db.securityRule.insert([ value: 'email@gmail.com' } ], - from: new Date("2020-01-01T03:00:00.000Z"), - to: new Date("2030-01-01T01:00:00.000Z"), + from: new Date("2020-01-01T01:00:00.000Z"), + to: new Date("2030-01-01T05:00:00.000Z"), __v: 0 }, { @@ -92,7 +92,7 @@ db.securityRule.insert([ } ], from: new Date("2020-01-01T01:00:00.000Z"), - to: new Date("2030-01-01T01:00:00.000Z"), + to: new Date("2030-01-01T05:00:00.000Z"), __v: 0 } ]) diff --git a/alarm/src/routes/securityRule.ts b/alarm/src/routes/securityRule.ts index 7d6708013..01c271a17 100644 --- a/alarm/src/routes/securityRule.ts +++ b/alarm/src/routes/securityRule.ts @@ -61,8 +61,7 @@ securityRuleRouter.route('/exceedings').post((req: Request, res: Response): void .then((): void => { res.status(HttpStatusCode.CREATED).send({ success: 'Exceeding rule created' }) }) - .catch((err): void => { - console.log(err) + .catch((): void => { res.send({ error: 'Exceeding rule not created' }) }) }) @@ -81,7 +80,8 @@ securityRuleRouter.route('/intrusions').post((req: Request, res: Response): void .then((): void => { res.status(HttpStatusCode.CREATED).send({ success: 'Intrusion rule created' }) }) - .catch((): void => { + .catch((err): void => { + console.log(err) res.send({ error: 'Intrusion rule not created' }) }) }) diff --git a/frontend/src/components/devices/DeviceBadge.vue b/frontend/src/components/devices/DeviceBadge.vue index c70eaaf05..f7d9da74d 100644 --- a/frontend/src/components/devices/DeviceBadge.vue +++ b/frontend/src/components/devices/DeviceBadge.vue @@ -23,6 +23,7 @@ const $q = useQuasar() const updateSensor = async (sensor: Sensor) => { await RequestHelper.put(`http://${monitoringHost}:${monitoringPort}/devices/sensors`, { code: sensor.deviceId.code, + isCapturing: sensor.isCapturing, ipAddress: sensor.ipAddress, intervalMillis: sensor.intervalMillis, measures: sensor.measures.map((m: Measure) => { @@ -41,6 +42,7 @@ const updateSensor = async (sensor: Sensor) => { const updateCamera = async (camera: Camera) => { await RequestHelper.put(`http://${monitoringHost}:${monitoringPort}/devices/cameras`, { code: camera.deviceId.code, + isCapturing: camera.isCapturing, ipAddress: camera.ipAddress, resolution: { width: parseInt(camera.resolution.width.toString()), diff --git a/frontend/src/components/devices/UpdateDevicePopup.vue b/frontend/src/components/devices/UpdateDevicePopup.vue index 92919a264..c34bf2471 100644 --- a/frontend/src/components/devices/UpdateDevicePopup.vue +++ b/frontend/src/components/devices/UpdateDevicePopup.vue @@ -20,6 +20,10 @@ const resolutionFactory: ResolutionFactory = new ResolutionFactoryImpl() const measures: ref = ref([]) +if (device.deviceId.type == DeviceType.SENSOR) { + measures.value = (device as Sensor).measures +} + const options = ref([ { label: 'Temperature', @@ -39,6 +43,7 @@ const updateDevice = () => { if (device.deviceId.type == DeviceType.SENSOR) { const updatedSensor: Sensor = deviceFactory.createSensor( deviceIdFactory.createSensorId(device.deviceId.code), + device.isCapturing, device.ipAddress, (device as Sensor).intervalMillis, measures.value @@ -47,6 +52,7 @@ const updateDevice = () => { } else if (device.deviceId.type == DeviceType.CAMERA) { const updatedCamera: Camera = deviceFactory.createCamera( deviceIdFactory.createCameraId(device.deviceId.code), + device.isCapturing, device.ipAddress, resolutionFactory.createResolution( (device as Camera).resolution.width, diff --git a/frontend/src/components/security-rule/NewSecurityRulePopup.vue b/frontend/src/components/security-rule/NewSecurityRulePopup.vue index da70a14e2..f164201a6 100644 --- a/frontend/src/components/security-rule/NewSecurityRulePopup.vue +++ b/frontend/src/components/security-rule/NewSecurityRulePopup.vue @@ -90,7 +90,9 @@ const getSensorCodes = async () => { const optionsContacts: ref<{ label: string; value: string }> = ref([]) const getContacts = async () => { - await RequestHelper.get(`http://${authHost}:${authPort}/users/aaaaaaaaaaaaaaaaaaaaaaaa`) //to put the id of the user taken from the pinia storage + console.log('TOKEN') + console.log(useUserStore().userId) + await RequestHelper.get(`http://${authHost}:${authPort}/users/${useUserStore().userId}`) .then((res: any) => { optionsContacts.value = [] for (let i = 0; i < res.data.contacts.length; i++) { @@ -133,7 +135,7 @@ const addNewSecurityRule = () => { useUserStore().userId, toRaw(contacts.value).map((c: { label: string; value: string }) => { return { - type: toRaw(c).label, + type: toRaw(c).label.split(':')[0], value: toRaw(c).value } }), diff --git a/frontend/src/utils/RequestHelper.ts b/frontend/src/utils/RequestHelper.ts index c7d681334..65ce616e2 100644 --- a/frontend/src/utils/RequestHelper.ts +++ b/frontend/src/utils/RequestHelper.ts @@ -21,7 +21,7 @@ export const alarmPort: string = import.meta.env.VITE_ALARM_PORT || '4002' export default class RequestHelper { static getHeaders(): Headers { - return { headers: { Authorization: `Bearer apikey-dev` } } //${userStore().accessToken} + return { headers: { Authorization: `Bearer ${userStore().accessToken}` } } } static async get(url: string, params?: any): Promise { diff --git a/frontend/src/views/LoginView.vue b/frontend/src/views/LoginView.vue index d56f32970..6b17d68d7 100644 --- a/frontend/src/views/LoginView.vue +++ b/frontend/src/views/LoginView.vue @@ -1,30 +1,35 @@