Notification system in frontend
- Heatmap worker now reports progress - Base for new altitude value - Phones can be marked active
This commit is contained in:
@@ -7,7 +7,7 @@ import { Phone } from "../models/phone/phone.model";
|
||||
export async function GetPhone(req: LivebeatRequest, res: Response) {
|
||||
const phoneId: String = req.params['id'];
|
||||
|
||||
// If none id provided, return all.
|
||||
// If no id provided, return all.
|
||||
if (phoneId === undefined) {
|
||||
const phone = await Phone.find({ user: req.user?._id });
|
||||
res.status(200).send(phone);
|
||||
@@ -48,8 +48,7 @@ export async function PostPhone(req: LivebeatRequest, res: Response) {
|
||||
const phone = await Phone.findOne({ androidId, user: req.user?._id });
|
||||
|
||||
if (phone !== null) {
|
||||
logger.debug("Request to /phone failed because phone already exists.");
|
||||
res.status(409).send();
|
||||
res.status(409).send({ message: "This phone already exists." });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,7 +59,8 @@ export async function PostPhone(req: LivebeatRequest, res: Response) {
|
||||
modelName,
|
||||
operatingSystem,
|
||||
architecture,
|
||||
user: req.user?._id
|
||||
user: req.user?._id,
|
||||
active: false
|
||||
});
|
||||
|
||||
logger.info(`New device (${displayName}) registered for ${req.user?.name}.`)
|
||||
|
||||
@@ -30,13 +30,14 @@ export class RabbitMQ {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info(`New beat from ${phone.displayName} with ${msg.gpsLocation[2]} accuracy and ${msg.battery}% battery`);
|
||||
logger.info(`New beat from ${phone.displayName} with ${msg.gpsLocation[2]}, ${msg.gpsLocation[3]}m height and accuracy and ${msg.battery}% battery`);
|
||||
|
||||
const newBeat = await Beat.create({
|
||||
phone: phone._id,
|
||||
coordinate: [msg.gpsLocation[0], msg.gpsLocation[1]],
|
||||
accuracy: msg.gpsLocation[2],
|
||||
speed: msg.gpsLocation[3],
|
||||
// [latitude, longitude, altitude]
|
||||
coordinate: [msg.gpsLocation[0], msg.gpsLocation[1], msg.gpsLocation[2]],
|
||||
accuracy: msg.gpsLocation[3],
|
||||
speed: msg.gpsLocation[4],
|
||||
battery: msg.battery,
|
||||
createdAt: msg.timestamp
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Document } from 'mongoose';
|
||||
import { IPhone } from '../phone/phone.interface';
|
||||
|
||||
export interface IBeat extends Document {
|
||||
// [latitude, longitude, altitude, accuracy, speed]
|
||||
coordinate?: number[],
|
||||
accuracy: number,
|
||||
speed: number,
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface IPhone extends Document {
|
||||
operatingSystem: String,
|
||||
architecture: String,
|
||||
user: IUser,
|
||||
active: Boolean,
|
||||
updatedAt?: Date,
|
||||
createdAt?: Date
|
||||
}
|
||||
@@ -7,7 +7,8 @@ const schemaPhone = new Schema({
|
||||
modelName: { type: String, required: false },
|
||||
operatingSystem: { type: String, required: false },
|
||||
architecture: { type: String, required: false },
|
||||
user: { type: SchemaTypes.ObjectId, required: true }
|
||||
user: { type: SchemaTypes.ObjectId, required: true },
|
||||
active: { type: Boolean, required: true }
|
||||
}, {
|
||||
timestamps: {
|
||||
createdAt: true,
|
||||
|
||||
Reference in New Issue
Block a user