Skip to content

Commit

Permalink
updated stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyantosch committed Jun 25, 2023
1 parent b4c4413 commit 392caa7
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 14 deletions.
59 changes: 58 additions & 1 deletion webApp/Backend/request_test/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,61 @@ async function testConnection(){
const response_body = await res.json(); // Parse the response body as JSON
console.log(response_body)
}
onSubmit()

async function testLogin(){
const res = await fetch("http://178.128.192.215:8000/api/signIn/", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "[email protected]", //username entered by the user in textbox
password: "gend55@opqqq" //password entered by the user in textbox
}), //"email": "[email protected]", password: "Sahar1364"
});
let json = await res.json();
console.log(json);

}
testLogin();

async function testSignup(){
const res = fetch("http://178.128.192.215:8000/api/signup/", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "[email protected]", //username entered by the user in textbox
password: "gend55@opqqq" //password entered by the user in textbox
}), //"email": "[email protected]", password: "Sahar1364"
}).then((response) => {
console.log("Test");
return response.json();
}).then((data) => {
console.log(data);
}).catch((error) => {
console.log(error);
});


}




async function testFilter(sensorData, container_id){
let containerLocations = sensorData.filter((sensor) => sensor.container_id == container_id && sensor.sensor_type == "GPS")
latestcontainerLocations = containerLocations.reduce((latest, current) => {
if (latest.timestamp > current.timestamp) {
return latest
} else {
return current
}

})
containerLocations = containerLocations.map((sensor) => sensor.sensor_data)
containerLocations = containerLocations.map((sensor) => sensor.split(","))


}
3 changes: 2 additions & 1 deletion webApp/Backend/sensor/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import path
from . import views
from rest_framework.routers import DefaultRouter
from sensor.views import ContainerViewset, SensorViewset, UserViewset, MyObtainTokenPairView
from sensor.views import ContainerViewset, SensorViewset, UserViewset
from django.urls import include
router = DefaultRouter()
router.register(r'container', ContainerViewset)
Expand All @@ -16,5 +16,6 @@
path("signUp/", views.RegisterView.as_view()),
path('signIn/', views.MyObtainTokenPairView.as_view()),
path('signIn/refresh/', TokenRefreshView.as_view()),
path("container_location/", views.ContainerLocation.as_view())
# path("signInWebJwt/", JwtViews.token_obtain_pair.as_view()),
]
2 changes: 2 additions & 0 deletions webApp/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
ports:
- "5432:5432"

frontend:
build:
Expand Down
17 changes: 5 additions & 12 deletions webApp/dockerfile_frontend
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine AS base
FROM node:18-alpine

# Install dependencies only when needed
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
Expand All @@ -23,26 +23,19 @@ WORKDIR /code
# RUN yarn build

# If using npm comment out above and use below instead
RUN npm run build
# RUN npm run build

# Production image, copy all the files and run next
WORKDIR /code

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD ["node", "server.js"]
CMD ["npm", "run", "dev"]

0 comments on commit 392caa7

Please sign in to comment.