Skip to content

Commit

Permalink
other: solved conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
paga16-hash committed Jan 30, 2024
2 parents 0fde3a2 + 34eeda5 commit 2173449
Show file tree
Hide file tree
Showing 50 changed files with 4,826 additions and 302 deletions.
7 changes: 4 additions & 3 deletions alarm/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}
"printWidth": 110,
"trailingComma": "none",
"arrowParens": "avoid"
}
12 changes: 2 additions & 10 deletions alarm/src/controller/anomaly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,8 @@ import { DeviceId } from '@domain/device/core/DeviceId.js'
import { Measure } from '@domain/device/core/impl/enum/Measure.js'
import { ObjectClass } from '@domain/security-rule/core/impl/enum/ObjectClass.js'

export const exceedingModel: Model<Exceeding> = model<Exceeding>(
'Exceeding',
exceedingSchema,
'anomaly'
)
export const intrusionModel: Model<Intrusion> = model<Intrusion>(
'Intrusion',
intrusionSchema,
'anomaly'
)
export const exceedingModel: Model<Exceeding> = model<Exceeding>('Exceeding', exceedingSchema, 'anomaly')
export const intrusionModel: Model<Intrusion> = model<Intrusion>('Intrusion', intrusionSchema, 'anomaly')

const anomalyManager: AnomalyRepository = new AnomalyRepositoryImpl(exceedingModel, intrusionModel)
const anomalyFactory: AnomalyFactory = new AnomalyFactoryImpl()
Expand Down
4 changes: 1 addition & 3 deletions alarm/src/controller/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export const notificationModel: Model<Notification> = model<Notification>(
'notification'
)

const notificationManager: NotificationRepository = new NotificationRepositoryImpl(
notificationModel
)
const notificationManager: NotificationRepository = new NotificationRepositoryImpl(notificationModel)
const notificationFactory: NotificationFactory = new NotificationFactoryImpl()
const anomalyFactory: AnomalyFactory = new AnomalyFactoryImpl()
export const notificationController = {
Expand Down
6 changes: 1 addition & 5 deletions alarm/src/controller/recognizingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ export const recognizingNodeController = {
},
updateRecognizingNode: async (req: Request): Promise<void> => {
await recognizingNodeManager.updateRecognizingNode(
recognizingNodeFactory.createRecognizingNode(
req.body.id,
req.body.ipAddress,
req.body.deviceIds
)
recognizingNodeFactory.createRecognizingNode(req.body.id, req.body.ipAddress, req.body.deviceIds)
)
},
deleteRecognizingNode: async (id: string): Promise<void> => {
Expand Down
2 changes: 1 addition & 1 deletion alarm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const mongoConnect = async (): Promise<void> => {
.then(async (): Promise<void> => {
console.log(`Connected to Mongo DB ${dbName} at ${host}`)
})
.catch((e) => console.log(e))
.catch(e => console.log(e))
}

if (process.env.NODE_ENV !== 'test') {
Expand Down
7 changes: 4 additions & 3 deletions auth/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}
"printWidth": 110,
"trailingComma": "none",
"arrowParens": "avoid"
}
19 changes: 7 additions & 12 deletions auth/src/controller/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,14 @@ export const userController = {
return await userManager.getUsers()
},
createUser: async (req: Request): Promise<void> => {
const contacts: Contact[] = req.body.contacts.map(
(contactObj: { value: string; type: string }) =>
contactFactory.createContact(
contactObj.value,
ContactTypeConverter.convertToContactType(contactObj.type)
)
const contacts: Contact[] = req.body.contacts.map((contactObj: { value: string; type: string }) =>
contactFactory.createContact(
contactObj.value,
ContactTypeConverter.convertToContactType(contactObj.type)
)
)
const deviceIds: DeviceId[] = req.body.deviceIds.map(
(deviceIdObj: { type: string; code: string }) =>
deviceIdFactory.createId(
DeviceTypeConverter.convertToDeviceType(deviceIdObj.type),
deviceIdObj.code
)
const deviceIds: DeviceId[] = req.body.deviceIds.map((deviceIdObj: { type: string; code: string }) =>
deviceIdFactory.createId(DeviceTypeConverter.convertToDeviceType(deviceIdObj.type), deviceIdObj.code)
)
const user: User = userFactory.createUser(
req.body.id,
Expand Down
2 changes: 1 addition & 1 deletion auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const mongoConnect = async (): Promise<void> => {
.then(async () => {
console.log(`Connected to Mongo DB ${dbName} at ${host}`)
})
.catch((e) => console.log(e))
.catch(e => console.log(e))
}

if (process.env.NODE_ENV !== 'test') {
Expand Down
7 changes: 4 additions & 3 deletions camera/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}
"printWidth": 110,
"trailingComma": "none",
"arrowParens": "avoid"
}
2 changes: 1 addition & 1 deletion camera/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"main": "dist/src/index.js",
"scripts": {
"serve": "node .",
"start": "npm run build && node .",
"dev": "npm run build && NODE_ENV=develop node --env-file=../.env .",
"build": "tsc && tsc-alias",
"watch": "tsc -w & tsc-alias -w & nodemon .",
"test": "vitest --run",
Expand Down
8 changes: 1 addition & 7 deletions camera/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@ import { produce } from './producer.js'
config()

export const app: Express = express()

app.use(express.json())

if (process.env.CAMERA_CODE === undefined) {
console.log('No camera code provided')
process.exit(1)
}
export const CAMERA_CODE: string = process.env.CAMERA_CODE
const PORT: number = Number(process.env.CAMERA_PORT) || 5001

app.use((req: Request, res: Response, next: NextFunction) => {
Expand All @@ -42,7 +36,7 @@ const mongoConnect = async () => {
`Connected to MongoDB database ${process.env.DB_NAME} at ${process.env.DB_HOST}:${process.env.DB_PORT}`
)
})
.catch((e) => console.log(e))
.catch(e => console.log(e))
}

if (process.env.NODE_ENV === 'test') {
Expand Down
24 changes: 20 additions & 4 deletions camera/src/producer.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
import { Kafka, Partitioners, Producer } from 'kafkajs'
import path from 'path'
import * as fs from 'fs'
import { CAMERA_CODE } from './index.js'

import { DeviceIdFactoryImpl } from '@domain/device/factories/impl/DeviceIdFactoryImpl.js'
import { DeviceFactoryImpl } from '@domain/device/factories/impl/DeviceFactoryImpl.js'
import { ResolutionFactoryImpl } from '@domain/device/factories/impl/ResolutionFactoryImpl.js'
import { Camera } from '@domain/device/core/Camera.js'

if (process.env.CAMERA_CODE === undefined && process.env.NODE_ENV !== 'develop') {
console.log('No camera code provided')
process.exit(1)
}
const CAMERA_CODE: string = process.env.CAMERA_CODE || 'cam-01'

const kafkaContainer: string = process.env.KAFKA_CONTAINER || 'revue-kafka'
const kafkaPort: string = process.env.KAFKA_PORT || '9092'

const kafka: Kafka = new Kafka({
clientId: 'camera', // TODO: Change this to Device ID
clientId: `CAMERA_${CAMERA_CODE}`,
brokers: [`${kafkaContainer}:${kafkaPort}`]
})

const sourceDevice: Camera = new DeviceFactoryImpl().createCamera(
new DeviceIdFactoryImpl().createCameraId(CAMERA_CODE),
'192.168.1.90',
new ResolutionFactoryImpl().createResolution(1920, 1080)
)

export const produce = async (): Promise<void> => {
// const videoPath: string = path.resolve('video.mp4')
const producer: Producer = kafka.producer({ createPartitioner: Partitioners.LegacyPartitioner })
Expand All @@ -32,9 +48,9 @@ export const produce = async (): Promise<void> => {
setInterval(async (): Promise<void> => {
if (index == files.length - 1) index = 0
console.log('Sending image ' + index)
console.log(`CAMERA_${CAMERA_CODE}`)
console.log(`CAMERA_${sourceDevice.deviceId.code}`)
await producer.send({
topic: `CAMERA_${CAMERA_CODE}`,
topic: `CAMERA_${sourceDevice.deviceId.code}`,
messages: [
{
value: frames[index],
Expand Down
2 changes: 1 addition & 1 deletion compose-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ for service in "${services[@]}"; do
compose_files+=("-f$service/docker-compose.yml")
done

dbs=()
dbs=("revue-kafka" "revue-zookeeper")
for service in "${services[@]}"; do
dbs+=("revue-$service-db")
done
Expand Down
7 changes: 4 additions & 3 deletions domain/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}
"printWidth": 110,
"trailingComma": "none",
"arrowParens": "avoid"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ import { RecognizingNode } from '../core/RecognizingNode.js'
import { DeviceId } from '../../device/core/DeviceId.js'

export interface RecognizingNodeFactory {
createRecognizingNode(
recognizingNodeId: string,
ipAddress: string,
deviceIds: DeviceId[]
): RecognizingNode
createRecognizingNode(recognizingNodeId: string, ipAddress: string, deviceIds: DeviceId[]): RecognizingNode
}
8 changes: 1 addition & 7 deletions domain/src/domain/anomaly/core/impl/ExceedingImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ export class ExceedingImpl implements Exceeding {
private _value: number
private _measure: Measure

constructor(
anomalyId: string,
deviceId: DeviceId,
timestamp: Date,
measure: Measure,
value: number
) {
constructor(anomalyId: string, deviceId: DeviceId, timestamp: Date, measure: Measure, value: number) {
this._anomalyId = anomalyId
this._deviceId = deviceId
this._timestamp = timestamp
Expand Down
7 changes: 1 addition & 6 deletions domain/src/domain/anomaly/core/impl/IntrusionImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ export class IntrusionImpl implements Intrusion {
private readonly _timestamp: Date
private _intrusionObject: ObjectClass

constructor(
anomalyId: string,
deviceId: DeviceId,
timestamp: Date,
intrusionObject: ObjectClass
) {
constructor(anomalyId: string, deviceId: DeviceId, timestamp: Date, intrusionObject: ObjectClass) {
this._anomalyId = anomalyId
this._deviceId = deviceId
this._timestamp = timestamp
Expand Down
8 changes: 1 addition & 7 deletions domain/src/domain/device/core/impl/EnvironmentDataImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ export class EnvironmentDataImpl implements EnvironmentData {
private _measureUnit: MeasureUnit
private readonly _timestamp: Date

constructor(
sourceDeviceId: DeviceId,
value: number,
measure: Measure,
unit: MeasureUnit,
timestamp: Date
) {
constructor(sourceDeviceId: DeviceId, value: number, measure: Measure, unit: MeasureUnit, timestamp: Date) {
this._sourceDeviceId = sourceDeviceId
this._value = value
this._measure = measure
Expand Down
7 changes: 1 addition & 6 deletions domain/src/domain/device/factories/DeviceFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@ import { Measure } from '../core/impl/enum/Measure.js'
export interface DeviceFactory {
createCamera(deviceId: DeviceId, ipAddress: string, resolution: Resolution): Camera

createSensor(
deviceId: DeviceId,
ipAddress: string,
intervalMillis: number,
measures: Measure[]
): Sensor
createSensor(deviceId: DeviceId, ipAddress: string, intervalMillis: number, measures: Measure[]): Sensor
}
7 changes: 1 addition & 6 deletions domain/src/domain/device/factories/impl/DeviceFactoryImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ export class DeviceFactoryImpl implements DeviceFactory {
return new CameraImpl(deviceId, ipAddress, resolution)
}

createSensor(
deviceId: DeviceId,
ipAddress: string,
intervalMillis: number,
measures: Measure[]
): Sensor {
createSensor(deviceId: DeviceId, ipAddress: string, intervalMillis: number, measures: Measure[]): Sensor {
return new SensorImpl(deviceId, ipAddress, intervalMillis, measures)
}
}
12 changes: 1 addition & 11 deletions domain/src/domain/monitoring/factories/impl/UserFactoryImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ export class UserFactoryImpl implements UserFactory {
contact: Contact[],
deviceIds: DeviceId[]
): User {
return new UserImpl(
id,
name,
surname,
username,
password,
token,
refreshToken,
contact,
deviceIds
)
return new UserImpl(id, name, surname, username, password, token, refreshToken, contact, deviceIds)
}
}
4 changes: 1 addition & 3 deletions domain/src/storage/anomaly/AnomalyRepositoryImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ export class AnomalyRepositoryImpl implements AnomalyRepository {
code: intrusion.deviceId.code
},
timestamp: intrusion.timestamp,
intrusionObject: ObjectClassConverter.convertToString(
(intrusion as IntrusionImpl).intrusionObject
)
intrusionObject: ObjectClassConverter.convertToString((intrusion as IntrusionImpl).intrusionObject)
})
.catch((err): void => {
throw err
Expand Down
5 changes: 3 additions & 2 deletions frontend/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
"printWidth": 110,
"trailingComma": "none",
"arrowParens": "avoid"
}
4 changes: 1 addition & 3 deletions frontend/src/components/NavbarComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ const logout = () => {
<router-link to="/monitoring" :class="routeName == 'Monitoring' ? 'selected' : ''"
>Monitoring
</router-link>
<router-link to="/devices" :class="routeName == 'Devices' ? 'selected' : ''"
>Devices
</router-link>
<router-link to="/devices" :class="routeName == 'Devices' ? 'selected' : ''">Devices </router-link>
<router-link to="/alarms" :class="routeName == 'Alarms' ? 'selected' : ''">Alarms</router-link>
<router-link to="/notifications" :class="routeName == 'Notifications' ? 'selected' : ''"
>Notifications
Expand Down
Loading

0 comments on commit 2173449

Please sign in to comment.