Skip to content

Commit

Permalink
saved stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebones committed Jun 18, 2021
1 parent 187afa0 commit dccb454
Show file tree
Hide file tree
Showing 22 changed files with 1,621 additions and 6,287 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/server/node_modules
/client/node_modules
/server/logs
/server/logs
.git
.gitignore
docker-compose*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/client/node_modules
node_modules
node_modules
.git
39 changes: 38 additions & 1 deletion client/dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
FROM baseImage
FROM node:12.20.1-stretch-slim AS builder
#FROM node:12.20.1-stretch-slim AS builder
#FROM node:12.18.3-alpine AS base
#RUN addgroup --gid 1024 mygroup
#RUN useradd -rm -d /home/jamie -s /bin/bash -g 1024 jamie

#RUN adduser -h /home/jamie -g 1024 jamie
#USER jamie

# set working directory
WORKDIR /home/jamie

# add `/app/node_modules/.bin` to $PATH
ENV PATH /home/jamie/node_modules/.bin:$PATH
#RUN chown -R jamie: /home/jamie

# install app dependencies
COPY package*.json ./
#COPY package-lock.json ./
RUN npm install
RUN npm install react-scripts@3.4.1 -g
#USER jamie


# add app
COPY . ./

RUN npm run build

FROM nginx:1.17.8-alpine

COPY --from=builder /home/jamie/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY ./nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 80
#RUN chown -R jamie: /home/jamie
#USER nginx
CMD ["nginx", "-g", "daemon off;"]
13 changes: 9 additions & 4 deletions client/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

upstream backend {

server graphql_api:8000 weight=1;
server graphql_api:8001 weight=1;
server api_server:9000 weight=1;
server api_server:9001 weight=1;

}

server {
# listen on port 80
listen 80;
#listen 80;
listen 8090;
# save logs here


Expand All @@ -21,8 +22,12 @@
index index.html index.htm;

location /graphql {
# proxy_pass http://server:8000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header HOST $http_host;
proxy_set_header X-Nginx-Proxy true;
proxy_pass http://backend;
#proxy_redirect off;
}

location / {
Expand Down
50 changes: 42 additions & 8 deletions client/src/components/adminDashboard.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { useState, useEffect } from "react";
import "react-tabs/style/react-tabs.css";
import { GetAdminDashboardStats } from "../graphql/queries";
import { useQuery } from "@apollo/client";
import { GetAdminDashboardStats, GetStatsByHall } from "../graphql/queries";
import { useQuery, useLazyQuery } from "@apollo/client";
import { SortAndMergeAsObjectBedStats } from "../modules/utils";
import styled from "styled-components";
import Loading from "./common/loading";
import HallSpaceStatsComponent from "./reuseableComponents/hallSpaceStats";

const AdminDashboardStyles = styled.div`
.account {
Expand Down Expand Up @@ -57,31 +59,55 @@ const AdminDashboardStyles = styled.div`
`;

const AdminDashboard = () => {
const [stats, setStats] = useState(null);
const [stats, setAdminStats] = useState(null);
const { error, data, loading } = useQuery(GetAdminDashboardStats);
const [errors, setErrors] = useState(null);
const [hallStats, setStats] = useState([]);
const [statsQuery, statsResult] = useLazyQuery(GetStatsByHall);
const [statsLoading, setStatsLoading] = useState(false);

useEffect(() => {
if (error) {
setErrors(error);
setErrors(error.message);
}

if (data) {
setStats(data.getAdminDashBoardStats);
setAdminStats(data.getAdminDashBoardStats);
setErrors(null);
}
}, [data, error]);

useEffect(() => {
setStatsLoading(true);
statsQuery();
}, []);

useEffect(() => {
if (statsResult.error) {
setStatsLoading(false);
setErrors(statsResult.error.message);
}

if (statsResult.data) {
const statsData = statsResult.data.getStatsByHall;
setStatsLoading(false);
setStats(SortAndMergeAsObjectBedStats(statsData));
}
}, [statsResult.error, statsResult.data]);

return (
<AdminDashboardStyles>
<div className="row">
<div className="col-md-12">
<div className="col-12">
<div className="text-center">
<h3>Welcome Admin</h3>
<h2>Welcome Admin</h2>
{errors && <p className="lead text-danger">{errors.message}</p>}
{loading && <Loading />}
</div>

</div>
</div>
<div className="row">
<div className="col-lg-6 col-lg-6 col-sm-12">
{stats && (
<React.Fragment>
<div className="stats account">
Expand Down Expand Up @@ -114,6 +140,14 @@ const AdminDashboard = () => {
</React.Fragment>
)}
</div>

<div className="col-lg-6 col-lg-6 col-sm-12">
<div className="text-center">{statsLoading && <Loading />}</div>

{hallStats && hallStats.length > 1 && (
<HallSpaceStatsComponent stats={hallStats} />
)}
</div>
</div>
</AdminDashboardStyles>
);
Expand Down
Loading

0 comments on commit dccb454

Please sign in to comment.