Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkpoint: pouring web into main #113

Open
wants to merge 70 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
50ab33d
Merge branch 'server' into mobile
gudmin0526 Oct 14, 2022
6c06e58
Feat: #87
gudmin0526 Oct 14, 2022
ef197d3
Feat: #88
gudmin0526 Oct 14, 2022
9c3685a
Refactor: Remove Notification Screen
gudmin0526 Oct 16, 2022
a9cd010
Merge pull request #3 from osamhack2022/back_dev
s3kim2018 Oct 16, 2022
94b7a82
Design: User Management Screen
gudmin0526 Oct 16, 2022
ea7a6f0
Feat: Add Unit Info Screen
gudmin0526 Oct 16, 2022
e1f5df9
Merge branch 'server' into mobile
gudmin0526 Oct 16, 2022
bac9f8a
Merge pull request #97 from osamhack2022-v2/web
s3kim2018 Oct 16, 2022
b1e5f10
Feat: delete addedUser func
gudmin0526 Oct 16, 2022
f70d091
Feat: osamhack2022#98
gudmin0526 Oct 16, 2022
2e5ea86
Design: modify report related screens design.
gudmin0526 Oct 17, 2022
4c76498
Refactor: refactor navigation structure
gudmin0526 Oct 17, 2022
813b43c
Merge pull request #8 from osamhack2022-v2/web
marunemo Oct 17, 2022
ca61107
Merge pull request #9 from osamhack2022-v2/web
marunemo Oct 17, 2022
1475b4c
Refactor: refactor Navigator
gudmin0526 Oct 17, 2022
547370d
Feat: Add unit, user update api
gudmin0526 Oct 17, 2022
65289b7
[Feat]Set drop down for memonote type
marunemo Oct 17, 2022
2a2e7d9
[Feat]: #101 login page enhancement complete
s3kim2018 Oct 18, 2022
17adf0f
[Feat]: #107 Register page enhanced
s3kim2018 Oct 18, 2022
de434f5
Merge pull request #13 from osamhack2022-v2/web
s3kim2018 Oct 18, 2022
c8c65f8
[Refactor]: changed database schema
s3kim2018 Oct 18, 2022
2c56aa0
Refactor: refactor apis.
gudmin0526 Oct 18, 2022
36d0ee0
Chore: Merge api/backend
gudmin0526 Oct 19, 2022
7698e4b
#108 User homepage Integration/keyvault testing
s3kim2018 Oct 19, 2022
34beb18
Feat: Add 'add person' feat in create report screen.
gudmin0526 Oct 19, 2022
b815680
[Feat]: #100 Integrated user settings with backend
s3kim2018 Oct 19, 2022
b9ad37f
Merge pull request #15 from osamhack2022-v2/backend/encryption
s3kim2018 Oct 19, 2022
26bda1b
[Feat]: #108 middleware encryption function completed
s3kim2018 Oct 20, 2022
c0b4cbe
Feat: Add some func to report related component
gudmin0526 Oct 20, 2022
7b35e57
Merge pull request #16 from osamhack2022-v2/web
marunemo Oct 21, 2022
0e323d3
[Feat]Fetch invited person data from userlist
marunemo Oct 21, 2022
83574d0
[Feat]Fetch user list by keyword searching
marunemo Oct 21, 2022
097acc2
[Feat]: #108 user encryption/decryption function completed
s3kim2018 Oct 21, 2022
cd67778
Merge pull request #17 from osamhack2022-v2/backend/encryption
s3kim2018 Oct 21, 2022
34ef2e2
[Feat]Activate memo submit
marunemo Oct 21, 2022
1775cf1
[Feat]Enable to fetch memo data
marunemo Oct 21, 2022
14e2a17
[Fix]Roll-back props field
marunemo Oct 21, 2022
12853a1
[Design]Create spinner for loading state
marunemo Oct 21, 2022
a661c97
[Feat]: #110 sidebar completed
s3kim2018 Oct 21, 2022
558e304
Merge pull request #18 from osamhack2022-v2/web_memo
s3kim2018 Oct 21, 2022
d541979
Merge pull request #19 from osamhack2022-v2/web
s3kim2018 Oct 21, 2022
031af39
[Feat]: #110 componentalized chat sidebar
s3kim2018 Oct 21, 2022
97c0882
[Feat]Create organizational chart api
marunemo Oct 21, 2022
75116af
[Fix]Activate read chart data
marunemo Oct 22, 2022
f23410f
[Fix]Activate to update DB for organizational chart
marunemo Oct 22, 2022
7ec9588
[Fix]Set send form field name as Capital Case
marunemo Oct 22, 2022
df46faa
Refactor: Refactor reportScreen's comment input.
gudmin0526 Oct 22, 2022
b486d58
[Fix]Change parent field name as capital case
marunemo Oct 22, 2022
c5f3134
[Fix]Show the deletion result of node
marunemo Oct 22, 2022
d386e6c
Merge branch 'web_orgtree' of https://github.com/osamhack2022-v2/WEB_…
marunemo Oct 22, 2022
de1b4d8
[Feat]Default value for null parent
marunemo Oct 22, 2022
af2974c
[Fix]Reflect response when adding
marunemo Oct 22, 2022
59842ab
[Feat]: #110 addchat done
s3kim2018 Oct 22, 2022
3ccf1bd
[Feat]: #110 changes to usercontroller to enable search by id
s3kim2018 Oct 22, 2022
d87fcac
[Fix]Prevent null from casting string
marunemo Oct 22, 2022
166a831
[Feat]: #110 Added message boxes
s3kim2018 Oct 22, 2022
df8d15f
Feat: Add getReportApi and test it.
gudmin0526 Oct 22, 2022
1b2c7c1
[Design]Style organizational chart
marunemo Oct 22, 2022
a542c2a
[Design]Style orgainzational card and form
marunemo Oct 22, 2022
b69121a
[Design]Style button group
marunemo Oct 22, 2022
d107b08
[Feat]: #110 Chatboxes created with user data
s3kim2018 Oct 22, 2022
b9c8e35
Merge pull request #20 from osamhack2022-v2/web_orgtree
s3kim2018 Oct 22, 2022
f6e55cc
Merge pull request #21 from osamhack2022-v2/web
s3kim2018 Oct 22, 2022
690c3fe
[Feat]Enable to use user custom picture as avatar
marunemo Oct 22, 2022
ea92107
Merge pull request #22 from osamhack2022-v2/web_chat
s3kim2018 Oct 22, 2022
5e85b18
Merge pull request #23 from osamhack2022-v2/mobile
s3kim2018 Oct 22, 2022
5ed2ff9
Merge pull request #25 from osamhack2022-v2/web_orgtree
s3kim2018 Oct 22, 2022
9a393d6
Merge branch 'osamhack2022:web' into web
s3kim2018 Oct 22, 2022
38a0b00
Merge pull request #112 from osamhack2022-v2/web
s3kim2018 Oct 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions back-end/controllers/chartController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
const asyncHandler = require("express-async-handler");
const UnitM = require("../models/unitModel");
const Chart = require("../models/chartModel");

//@description Get organizational chart as array list
//@route GET /api/chart
//@access Protected
const getChart = asyncHandler(async (req, res) => {
const currentUser = req.user;
const currentUnit = await UnitM.findOne({ _id: currentUser.Unit });

if (!currentUnit) {
res.status(400);
throw new Error('사용자의 부대가 설정되지 않았습니다.');
}

const unitOrganization = await Chart.find({ Unit: { $eq: currentUnit.Unitname } });
if (unitOrganization.length === 0) {
await Chart.create({
Avatar: currentUser.pic,
Name: currentUser.Name,
Rank: currentUser.Rank,
Unit: currentUnit.Unitname
})
}
res.send(unitOrganization);
});

//@description Add organizational chart
//@route POST /api/chart/add
//@access Protected
const addChart = asyncHandler(async (req, res) => {
const {
Avatar,
Name,
Rank,
Unit,
Position,
DoDID,
Number,
MilNumber,
Email,
Parent
} = req.body;

if (!Name || !Rank || !Unit) {
res.status(400);
throw new Error("모든 정보를 입력하세요.");
}

const newChart = await Chart.create({
Avatar,
Name,
Rank,
Unit,
Position,
DoDID,
Number,
MilNumber,
Email,
Parent,
});

if (newChart) {
res.status(201).json({
_id: newChart._id,
Avatar,
Name,
Rank,
Unit,
Position,
DoDID,
Number,
MilNumber,
Email,
Parent: Parent ?? null,
})
}
else {
res.send(400);
throw new Error('조직도를 추가/수정할 수 없습니다.')
}
});

//@description Edit organizational chart
//@route POST /api/chart/edit
//@access Protected
const editChart = asyncHandler(async (req, res) => {
const {
_id,
Avatar,
Name,
Rank,
Unit,
Position,
DoDID,
Number,
MilNumber,
Email,
Parent
} = req.body;

if (!_id || !Name || !Rank || !Unit) {
res.status(400);
throw new Error("모든 정보를 입력하세요.");
}

const updatedChart = await Chart.findByIdAndUpdate(_id, {
Avatar,
Name,
Rank,
Position,
DoDID,
Number,
MilNumber,
Email,
Parent,
Unit
});

if (updatedChart) {
res.status(200).json({
Avatar,
Name,
Rank,
Position,
DoDID,
Number,
MilNumber,
Email,
Parent,
Unit
})
}
else {
res.send(400);
throw new Error('조직도를 추가/수정할 수 없습니다.')
}
});

//@description Delete organizational chart
//@route POST /api/chart/delete
//@access Protected
const deleteChart = asyncHandler(async (req, res) => {
const { _id } = req.body;

if (!_id) {
res.status(400);
throw new Error("모든 정보를 입력하세요.");
}

const deleteChart = await Chart.findByIdAndDelete(_id);
if (deleteChart) {
res.send(200);
}
else {
res.send(400);
throw new Error('조직도를 추가/수정할 수 없습니다.')
}
});

module.exports = {
getChart,
addChart,
editChart,
deleteChart
};
24 changes: 12 additions & 12 deletions back-end/controllers/commentControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ const ReportM = require("../models/reportModel");
//@route POST /api/comment
//@access Protected
const addComment = asyncHandler(async (req, res) => {
const {
Type,
Content,
Title
} = req.body;
const { Type, Content, Title } = req.body;

if (!Type || !Content || !Title) {
res.status(400);
Expand All @@ -19,26 +15,30 @@ const addComment = asyncHandler(async (req, res) => {

User = req.user._id;

report = await Report.find({ Title: { $eq: keyword }}).find({Unit: {$eq: req.user.Unit}});
report = await Report.find({ Title: { $eq: keyword } }).find({
Unit: { $eq: req.user.Unit },
});

Report = report._id;

const comment = await Comment.create({
User,
Type,
Content,
report
report,
});

const editReport = await ReportM.findByIdAndUpdate(
report._id, {
report._id,
{
$push: {
Comments: comment
Comments: comment,
},
}, {
},
{
new: true,
}
)
);

if (editReport && editUnit && editUser) {
res.status(201).send(comment);
Expand All @@ -49,5 +49,5 @@ const addComment = asyncHandler(async (req, res) => {
});

module.exports = {
addComment
addComment,
};
61 changes: 37 additions & 24 deletions back-end/controllers/reportControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ const asyncHandler = require("express-async-handler");
const Report = require("../models/reportModel");
const Reportsys = require("../models/reportModel");
const UnitM = require("../models/unitModel");
const UserM = require("../models/unitModel");
const UserM = require("../models/userModel");
const getScore = require('../ai/classifier.js')
var mongoose = require('mongoose');

//@description Get all report cards
//@route GET /api/report
//@access Protected
const getReportCard = asyncHandler(async (req, res) => {

let reportCards = await Report.find({});
res.send(reportCards);
});

//@description Create new report card
//@route POST /api/report
Expand All @@ -15,49 +23,53 @@ const addReportCard = asyncHandler(async (req, res) => {
ReportingSystem,
Invited,
Content,
Title
Title,
} = req.body;

if (!Type || !ReportingSystem || !Invited || !Content || !Title) {
res.status(400);
throw new Error("모든 정보를 입력하세요.");
}

User = req.user._id
Unit = req.user.Unit._id;
Severity = await getScore(Content)
const currentUser = req.user;
let currentUnit = currentUser.Unit;
let Severity = await getScore(Content);
const report = await Report.create({
User,
User: currentUser,
Type,
ReportingSystem,
Invited,
Content,
Title,
Severity,
Unit
Unit: currentUnit
});


res.status(201).send(report);
return;

const editUnit = await UnitM.findByIdAndUpdate(
Unit, {
$push: {
reportCards: report._id
},
}, {
new: true,
}
UnitId, {
$push: {
reportCards: report._id
},
}, {
new: true,
}
)

const editUser = await UserM.findByIdAndUpdate(
req.user._id, {
$push: {
myReportCards: report._id
},
}, {
new: true,
}
UserId, {
$push: {
myReportCards: report._id
},
}, {
new: true,
}
)

if (editReport && editUnit && editUser) {
if (editUnit && editUser) {
res.status(201).send(report);
} else {
res.status(400);
Expand All @@ -66,5 +78,6 @@ const addReportCard = asyncHandler(async (req, res) => {
});

module.exports = {
addReportCard
addReportCard,
getReportCard
};
13 changes: 13 additions & 0 deletions back-end/controllers/unitControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ const asyncHandler = require("express-async-handler");
const User = require("../models/userModel");
const Unit = require("../models/unitModel");

//@description GET new unit
//@route GET /api/unit/get
//@access Protected
const getUnit = asyncHandler(async (req, res) => {
const keyword = req.query.search
if (keyword) {
res.send(await Unit.find({ _id: { $eq: keyword }})); //.find({ _id: { $ne: req.user._id } }));
} else {
res.status(400);
throw new Error("잘못된 요청입니다.");
}
})
//@description Add new unit
//@route POST /api/unit
//@access Protected
Expand Down Expand Up @@ -129,6 +141,7 @@ const updateLogo = asyncHandler(async (req, res) => {
});

module.exports = {
getUnit,
updateUnit,
updateLogo,
addUnit
Expand Down
Loading