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

Matt branch #19

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5f6adc6
Add files via upload
mbb10324 Dec 8, 2022
5bae1bc
testing branch push
mfouquier Dec 8, 2022
883f385
reverted knexfile
mfouquier Dec 8, 2022
4c3cb41
test branch push
mfouquier Dec 8, 2022
502387d
Merge pull request #1 from mbb10324/matt_branch
mfouquier Dec 8, 2022
4a9ee99
removed Testing line
mfouquier Dec 8, 2022
fbd943f
test
mbb10324 Dec 8, 2022
7872036
Merge pull request #2 from mbb10324/Miles-branch
mbb10324 Dec 8, 2022
3ed310f
add bash to api
mfouquier Dec 8, 2022
e88e2eb
Merge pull request #3 from mbb10324/matt_branch
mfouquier Dec 8, 2022
28bc441
sfd
mbb10324 Dec 8, 2022
c505c4a
Merge github.com:mbb10324/sdi-capstone-base into Miles-branch
mbb10324 Dec 8, 2022
d854661
before lunch commit
rommatt4 Dec 8, 2022
bb255bf
Merge pull request #4 from rommatt4/main
rommatt4 Dec 8, 2022
c9ec2cb
migrates and seeds done
mfouquier Dec 8, 2022
76a84f7
frontend links established
mbb10324 Dec 8, 2022
409ca98
initial links
mbb10324 Dec 8, 2022
1edc6f8
Merge pull request #5 from mbb10324/Miles-branch
mbb10324 Dec 8, 2022
c9defa7
changes
mbb10324 Dec 8, 2022
1247c47
ready for sidemenu
rommatt4 Dec 8, 2022
3b52704
Merge pull request #6 from mbb10324/Miles-branch
mbb10324 Dec 8, 2022
14207c8
Merge branch 'main' into main
rommatt4 Dec 8, 2022
943e11f
Merge pull request #7 from rommatt4/main
rommatt4 Dec 8, 2022
51f9652
migrate and seed complete
mfouquier Dec 8, 2022
4b13324
ready for that DB
rommatt4 Dec 8, 2022
dd4e43f
add
mfouquier Dec 8, 2022
793cb78
Merge pull request #9 from rommatt4/main
rommatt4 Dec 8, 2022
2dba9e3
add
mfouquier Dec 8, 2022
c984617
added
mfouquier Dec 8, 2022
d05ab3d
GET functions
mfouquier Dec 8, 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
Binary file added Approval.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Checkout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Home Page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ COPY . /app
RUN npm install -g [email protected] &&\
npm install

RUN apk add bash

EXPOSE 8082

CMD ["npm", "start"]
115 changes: 107 additions & 8 deletions api/db/migrations/20220316163937_creat_about_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,117 @@
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function(knex) {
return knex.schema.createTable('app_authors', table => {
table.increments();
table.string('first_name', 250);
table.string('last_name', 250);
})
exports.up = function (knex) {
return knex.schema
.createTable('user', table => {
table.increments('id');
table.string('first_name', 50);
table.string('last_name', 50);
table.string('username', 50);
table.string('unit', 50);
table.string('position', 50);
table.string('password', 100);
table.string('phone_number', 20);
table.string('email', 50);
})
.createTable('asset', table => {
table.increments('id');
table.string('asset_name', 150);
table.string('description', 255);
table.string('type', 50);
table.string('image_url', 255);
})
.createTable('sme_approver', table => {
table.increments('id');
table.string('first_name', 50);
table.string('last_name', 50);
table.string('username', 50);
table.string('unit', 50);
table.string('position', 50);
table.string('password', 100);
table.string('phone_number', 20);
table.string('email', 50);
table.string('type', 25);
table.integer('asset_id');
table.foreign('asset_id').references('asset.id')
.onDelete('CASCADE')
.onUpdate('CASCADE');
})
.createTable('cmd_approver', table => {
table.increments('id');
table.string('first_name', 50);
table.string('last_name', 50);
table.string('username', 50);
table.string('unit', 50);
table.string('position', 50);
table.string('password', 100);
table.string('phone_number', 20);
table.string('email', 50);
table.string('type', 25);
table.integer('user_id');
table.foreign('user_id').references('user.id')
.onDelete('CASCADE')
.onUpdate('CASCADE');
})
.createTable('request', table => {
table.increments('id');
table.string('date', 100);
table.string('location', 50);
table.string('mission_title', 50);
table.string('justification', 255);
table.string('status', 50);
table.integer('user_id');
table.foreign('user_id').references('user.id')
.onDelete('CASCADE')
.onUpdate('CASCADE');
table.integer('asset_id')
table.foreign('asset_id').references('asset.id')
.onDelete('CASCADE')
.onUpdate('CASCADE');
table.integer('sme_id');
table.foreign('sme_id').references('sme_approver.id')
.onDelete('CASCADE')
.onUpdate('CASCADE');
table.integer('cmd_id');
table.foreign('cmd_id').references('cmd_approver.id')
.onDelete('CASCADE')
.onUpdate('CASCADE');
})

};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function(knex) {
return knex.schema.dropTableIfExists('app_authors');
exports.down = function (knex) {
return knex.schema
.alterTable('sme_approver', table => {
table.dropForeign('asset_id');
})
.alterTable('cmd_approver', table => {
table.dropForeign('user_id');
})
.alterTable('request', table => {
table.dropForeign('user_id');
table.dropForeign('asset_id');
table.dropForeign('sme_id');
table.dropForeign('cmd_id');
})
.then(function () {
return knex.schema.dropTableIfExists('user')
})
.then(function () {
return knex.schema.dropTableIfExists('asset')
})
.then(function () {
return knex.schema.dropTableIfExists('sme_approver')
})
.then(function () {
return knex.schema.dropTableIfExists('cmd_approver')
})
.then(function () {
return knex.schema.dropTableIfExists('request')
})

};
33 changes: 33 additions & 0 deletions api/db/seeds/01_user_data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/

const { faker } = require('@faker-js/faker');

const createFakeUsers = () => {
const fakeUsers = [];

for (let i = 0; i < 10; i++) {
const user = {
first_name: faker.name.firstName(),
last_name: faker.name.lastName(),
username: faker.internet.userName(),
unit: faker.helpers.arrayElement(['A Co', 'B Co', 'C Co', 'D Co']),
position: faker.name.jobTitle(),
password: faker.internet.password(),
phone_number: faker.phone.number('813-###-###'),
email: faker.internet.email(),
}
fakeUsers.push(user)
}
return fakeUsers;
}

exports.seed = async function (knex) {
// Deletes ALL existing entries
await knex('user').del()
await knex('user').insert(
createFakeUsers()
);
};
34 changes: 34 additions & 0 deletions api/db/seeds/02_asset_data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/


exports.seed = async function (knex) {
// Deletes ALL existing entries
await knex('asset').insert([
{ id: 1, asset_name: 'Satellite', description: '', type: 'ISR', image_url: '' },
{ id: 2, asset_name: 'Aerial', description: '', type: 'ISR', image_url: '' },
{ id: 3, asset_name: 'Satcom', description: '', type: 'Communications', image_url: '' },
{ id: 4, asset_name: 'Networking', description: '', type: 'Communications', image_url: '' },
{ id: 5, asset_name: 'Mobile Device', description: '', type: 'Communications', image_url: '' },
{ id: 6, asset_name: 'Desktop', description: '', type: 'Communications', image_url: '' },
{ id: 7, asset_name: 'CSfC', description: '', type: 'Communications', image_url: '' },
{ id: 8, asset_name: 'Fixed Wing', description: '', type: 'Transportation', image_url: '' },
{ id: 9, asset_name: 'Rotary Wing', description: '', type: 'Transportation', image_url: '' },
{ id: 10, asset_name: 'Sea', description: '', type: 'Transportation', image_url: '' },
{ id: 11, asset_name: 'Ground', description: '', type: 'Transportation', image_url: '' },
{ id: 12, asset_name: 'SRT', description: '', type: 'Medical', image_url: '' },
{ id: 13, asset_name: 'Medic', description: '', type: 'Medical', image_url: '' },
{ id: 14, asset_name: 'Medical Equipment', description: '', type: 'Medical', image_url: '' },
{ id: 15, asset_name: 'Fixed Wing', description: '', type: 'Fires', image_url: '' },
{ id: 16, asset_name: 'Artillery', description: '', type: 'Fires', image_url: '' },
{ id: 17, asset_name: 'Rotary', description: '', type: 'Fires', image_url: '' },
{ id: 18, asset_name: 'Mortars', description: '', type: 'Fires', image_url: '' },
{ id: 19, asset_name: 'Naval', description: '', type: 'Fires', image_url: '' },
{ id: 20, asset_name: 'Cooks', description: '', type: 'Personnel', image_url: '' },
{ id: 21, asset_name: 'Maintenance', description: '', type: 'Personnel', image_url: '' },
{ id: 22, asset_name: 'QRF', description: '', type: 'Personnel', image_url: '' },
{ id: 23, asset_name: 'Recon', description: '', type: 'Personnel', image_url: '' },
]);
};
34 changes: 34 additions & 0 deletions api/db/seeds/03_cmd_data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/

const { faker } = require('@faker-js/faker');

const createFakeUsers = () => {
const fakeUsers = [];

for (let i = 0; i < 4; i++) {
const user = {
first_name: faker.name.firstName(),
last_name: faker.name.lastName(),
username: faker.internet.userName(),
unit: faker.helpers.arrayElement(['A Co', 'B Co', 'C Co', 'D Co']),
position: 'Commander',
password: faker.internet.password(),
phone_number: faker.phone.number('813-###-###'),
email: faker.internet.email(),
type: 'Commander',
user_id: faker.helpers.arrayElement([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
}
fakeUsers.push(user)
}
return fakeUsers;
}
exports.seed = async function (knex) {
// Deletes ALL existing entries
await knex('cmd_approver').del()
await knex('cmd_approver').insert(
createFakeUsers()
);
};
34 changes: 34 additions & 0 deletions api/db/seeds/04_sme_data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
const { faker } = require('@faker-js/faker');

const createFakeUsers = () => {
const fakeUsers = [];

for (let i = 0; i < 6; i++) {
const user = {
first_name: faker.name.firstName(),
last_name: faker.name.lastName(),
username: faker.internet.userName(),
unit: faker.helpers.arrayElement(['A Co', 'B Co', 'C Co', 'D Co']),
position: 'SME',
password: faker.internet.password(),
phone_number: faker.phone.number('813-###-###'),
email: faker.internet.email(),
type: 'SME',
asset_id: faker.helpers.arrayElement([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])
}
fakeUsers.push(user)
}
return fakeUsers;
}
exports.seed = async function (knex) {
// Deletes ALL existing entries
await knex('sme_approver').del()
await knex('sme_approver').insert(
createFakeUsers()
);
};

33 changes: 33 additions & 0 deletions api/db/seeds/05_request_data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
const { faker } = require('@faker-js/faker');

const createFakeRequests = () => {
const fakeRequests = [];

for (let i = 0; i < 10; i++) {
const request = {
date: faker.date.soon(90, '2022-12-10T00:00:00:.000Z'),
location: faker.address.country(),
mission_title: faker.commerce.productMaterial() + faker.commerce.productAdjective(),
justification: faker.commerce.productDescription(),
status: faker.helpers.arrayElement(['Pending', 'Approved', 'Rejected']),
user_id: faker.helpers.arrayElement([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
asset_id: faker.helpers.arrayElement([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]),
sme_id: faker.helpers.arrayElement([1, 2, 3, 4, 5, 6]),
cmd_id: faker.helpers.arrayElement([1, 2, 3, 4])
}
fakeRequests.push(request)
}
return fakeRequests;
}

exports.seed = async function (knex) {
// Deletes ALL existing entries
await knex('request').insert(
createFakeRequests()
);
};

15 changes: 0 additions & 15 deletions api/db/seeds/initial_app_author.js

This file was deleted.

6 changes: 3 additions & 3 deletions api/knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const HOST = process.env.DATABASE_HOST || '127.0.0.1';
const USER = process.env.POSTGRES_USER || 'postgres';
const PASSWORD = process.env.POSTGRES_PASSWORD || 'docker';
const DATABASE = process.env.POSTGRES_DB || 'capstone';
const DATABASE = process.env.POSTGRES_DB || 'fortis_bellator';
const PORT = process.env.PORT || 5432;

module.exports = {
Expand All @@ -32,7 +32,7 @@ module.exports = {
client: 'postgresql',
connection: {
database: 'my_db',
user: 'username',
user: 'username',
password: 'password'
},
pool: {
Expand All @@ -46,7 +46,7 @@ module.exports = {

production: {
client: 'postgresql',
connection: process.env.DATABASE_URL+'?ssl=no-verify',
connection: process.env.DATABASE_URL + '?ssl=no-verify',
pool: {
min: 2,
max: 10
Expand Down
17 changes: 17 additions & 0 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading