Skip to content

Commit

Permalink
Merge pull request #86 from NSWC-Crane/CHRIS_DEV
Browse files Browse the repository at this point in the history
Reference pull request for full details
  • Loading branch information
crodriguez6497 authored Jul 17, 2024
2 parents f51cdad + 1ebd1ad commit bd52c57
Show file tree
Hide file tree
Showing 389 changed files with 5,452 additions and 107,257 deletions.
1 change: 0 additions & 1 deletion api/Controllers/Operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module.exports.getConfiguration = async function getConfiguration(req, res, next
try {
let dbConfigs = await operationService.getConfiguration()
let version = { version: config.version }
let commit = { commit: config.commit }
let response = { ...version, ...dbConfigs }
res.json(response)
}
Expand Down
1 change: 0 additions & 1 deletion api/Services/collectionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ exports.getCollections = async function getCollections(userNameInput, req, res,
let [row] = await connection.query(sql, [userNameInput]);
userId = row[0].userId;
isAdmin = row[0].isAdmin;
userName = row[0].userName;

const user = {
collections: []
Expand Down
9 changes: 3 additions & 6 deletions api/Services/importService.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,9 @@ async function processPoamWorksheet(worksheet, userId) {
let headers;
const poamData = [];
const eMassCollection = await db.Collection.findOne({ where: { collectionName: 'eMASS' } });
if (eMassCollection.collectionId) {
const eMassCollectionId = eMassCollection.collectionId;
} else {
if (!eMassCollection.collectionId) {
throw new Error("eMASS collection not found");
}

worksheet.eachRow({ includeEmpty: true }, (row, rowNumber) => {
if (rowNumber === 7) {
headers = row.values;
Expand Down Expand Up @@ -156,7 +153,7 @@ async function processPoamWorksheet(worksheet, userId) {
});

if (!isEmptyRow) {
poamEntry.collectionId = eMassCollectionId;
poamEntry.collectionId = eMassCollection.collectionId;
poamEntry.submitterId = userId;

const comments = poamEntry.notes || '';
Expand Down Expand Up @@ -212,7 +209,7 @@ async function processPoamWorksheet(worksheet, userId) {
if (!asset) {
asset = await db.Asset.create({
assetName: trimmedDeviceName,
collectionId: eMassCollectionId,
collectionId: eMassCollection.collectionId,
assetOrigin: 'eMASS'
});
}
Expand Down
10 changes: 5 additions & 5 deletions api/Services/migrations/lib/mysql-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Importer {
try {
await this._connect();
const files = await this._getSQLFilePaths(...input);
const error = null;
let error = null;
await slowLoop(files, (file, index, next) => {
if (error) {
next();
Expand Down Expand Up @@ -164,7 +164,7 @@ class Importer {
return;
}
const queries = new queryParser(queriesString).queries;
const error = null;
let error = null;
slowLoop(queries, (query, index, next) => {
if (error) {
next();
Expand Down Expand Up @@ -261,7 +261,7 @@ class Importer {
_getSQLFilePaths(...paths) {
return new Promise(async (resolve, reject) => {
const full_paths = [];
const error = null;
let error = null;
paths = [].concat.apply([], paths); // flatten array of paths
await slowLoop(paths, async (filepath, index, next) => {
if (error) {
Expand All @@ -277,7 +277,7 @@ class Importer {
}
next();
} else if (stat.isDirectory()) {
const more_paths = await this._readDir(filepath);
let more_paths = await this._readDir(filepath);
more_paths = more_paths.map(p => path.join(filepath, p));
const sql_files = await this._getSQLFilePaths(...more_paths);
full_paths.push(...sql_files);
Expand Down Expand Up @@ -420,7 +420,7 @@ class queryParser {

// Check if we're at the end of the query
checkEndOfQuery() {
const demiliterFound = false;
let demiliterFound = false;
if (!this.quoteType && this.buffer.length >= this.delimiter.length) {
demiliterFound = this.buffer.slice(-this.delimiter.length).join('') === this.delimiter;
}
Expand Down
2 changes: 1 addition & 1 deletion api/Services/migrations/sql/current/10-cpat-tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ CREATE TABLE `user` (
`accountStatus` varchar(25) NOT NULL DEFAULT 'PENDING',
`fullName` varchar(100) DEFAULT NULL,
`officeOrg` varchar(100) DEFAULT 'UNKNOWN',
`defaultTheme` varchar(20) DEFAULT 'dark',
`defaultTheme` varchar(50) DEFAULT 'dark',
`isAdmin` int NOT NULL DEFAULT '0',
`lastClaims` json DEFAULT (_utf8mb4'{}'),
`points` int NOT NULL DEFAULT '0',
Expand Down
2 changes: 1 addition & 1 deletion api/Services/poamAssetService.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports.getPoamAssets = async function getPoamAssets(req, res, next) {
INNER JOIN cpat.asset t2 ON t1.assetId = t2.assetId
`;
let [rowPoamAssets] = await connection.query(sql);
const poamAssets = rowPoamAssets.map(row => ({
var poamAssets = rowPoamAssets.map(row => ({
assetId: row.assetId,
assetName: row.assetName,
poamId: row.poamId,
Expand Down
8 changes: 1 addition & 7 deletions api/Services/poamExtensionMilestoneService.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,8 @@ exports.deletePoamExtensionMilestone = async function deletePoamExtensionMilesto
let sql = "DELETE FROM cpat.poamExtensionMilestones WHERE poamId= ? AND extensionMilestoneId = ?";
await connection.query(sql, [poamId, extensionMilestoneId]);

let action = `ExtensionMilestone Deleted.`;
if (requestBody.requestorId) {
if (requestBody.extension == true) {
action = `Extension ExtensionMilestone deleted.`;
}
else {
action = `POAM ExtensionMilestone deleted.`;
}
let action = `Extension Milestone deleted.`;
let logSql = "INSERT INTO cpat.poamlogs (poamId, action, userId) VALUES (?, ?, ?)";
await connection.query(logSql, [poamId, action, requestBody.requestorId]);
}
Expand Down
10 changes: 0 additions & 10 deletions api/Services/poamService.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,6 @@ exports.updatePoamStatus = async function updatePoamStatus(req, res, next) {
return res.status(404).json({ errors: 'POAM not found' });
}

const existingPoam = existingPoamRow[0];

const existingPoamNormalized = {
...existingPoam,
submittedDate: normalizeDate(existingPoam.submittedDate) || null,
scheduledCompletionDate: normalizeDate(existingPoam.scheduledCompletionDate) || null,
closedDate: normalizeDate(existingPoam.closedDate) || null,
iavComplyByDate: normalizeDate(existingPoam.iavComplyByDate) || null,
};

const sqlUpdatePoam = `UPDATE cpat.poam SET status = ? WHERE poamId = ?`;
await connection.query(sqlUpdatePoam, [req.body.status, req.params.poamId]);

Expand Down
2 changes: 1 addition & 1 deletion api/utils/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function getKey(header, callback) {
try {
client.getSigningKey(header.kid, function (err, key) {
if (!err) {
var signingKey = key.publicKey || key.rsaPublicKey;
let signingKey = key.publicKey || key.rsaPublicKey;
callback(null, signingKey);
} else {
callback(err, null);
Expand Down
2 changes: 1 addition & 1 deletion api/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function requestLogger(req, res, next) {
res._startTime = undefined;
res.svcStatus = {};

let responseBody = undefined;
let responseBody;
if (req.query.elevate === true || req.query.elevate === 'true') {
responseBody = ''
const originalSend = res.send
Expand Down
118 changes: 59 additions & 59 deletions api/utils/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,77 +9,77 @@
*/

let ResponsePayload = function (code, payload) {
this.code = code;
this.payload = payload;
this.code = code;
this.payload = payload;
}

exports.respondWithCode = function(code, payload) {
return new ResponsePayload(code, payload);
exports.respondWithCode = function (code, payload) {
return new ResponsePayload(code, payload);
}

let writeJson = exports.writeJson = function(response, arg1, arg2) {
let code;
let payload;

if(arg1 && arg1 instanceof ResponsePayload) {
writeJson(response, arg1.payload, arg1.code);
return;
}

if(arg2 && Number.isInteger(arg2)) {
code = arg2;
} else if(arg1 && Number.isInteger(arg1)) {
code = arg1;
}
if(arg1) {
payload = arg1;
}

if(!code) {
// if no response code given, we default to 200
code = 200;
}
if (typeof payload == 'undefined') {
code = 204
}
if (payload instanceof Error) {
payload = JSON.stringify(payload, Object.getOwnPropertyNames(payload), 2);
code = 500
}
else {
payload = JSON.stringify(payload);
}
response.writeHead(code, {
'Content-Type': 'application/json',
'Cache-control': 'no-store'
});
response.end(payload);
let writeJson = exports.writeJson = function (response, arg1, arg2) {
let code;
let payload;
if (arg1 && arg1 instanceof ResponsePayload) {
writeJson(response, arg1.payload, arg1.code);
return;
}
if (arg2 && Number.isInteger(arg2)) {
code = arg2;
} else if (arg1 && Number.isInteger(arg1)) {
code = arg1;
}
if (arg1) {
payload = arg1;
}
if (!code) {
// if no response code given, we default to 200
code = 200;
}
if (typeof payload == 'undefined') {
code = 204
}
if (payload instanceof Error) {
payload = JSON.stringify(payload, Object.getOwnPropertyNames(payload), 2);
code = 500
}
else {
payload = JSON.stringify(payload);
}
response.writeHead(code, {
'Content-Type': 'application/json',
'Cache-control': 'no-store'
});
response.end(payload);
}

const charToHexStr = (c) => `%${c.charCodeAt(0).toString(16).padStart(2, '0')}`

const goodFilename = (string) =>
string.replace(/[<>:"/\\|?*\x00-\x1F]| +$/g, charToHexStr)
string.replace(/([<>:"/\\|?*]|[\x00-\x1F])|( +$)/g, (match, controlChar, trailingSpace) => {
if (controlChar) return charToHexStr(controlChar);
if (trailingSpace) return '';
return match;
});

exports.writeInlineFile = function(response, payload, filename, contentType) {
response.writeHead(200, {
'Content-Type': contentType,
'Content-Disposition': `inline; filename="${goodFilename(filename)}"`,
'Access-Control-Expose-Headers': 'Content-Disposition'
})
response.write(payload)
response.end()
exports.writeInlineFile = function (response, payload, filename, contentType) {
response.writeHead(200, {
'Content-Type': contentType,
'Content-Disposition': `inline; filename="${goodFilename(filename)}"`,
'Access-Control-Expose-Headers': 'Content-Disposition'
})
response.write(payload)
response.end()
}

exports.writeWithContentType = function(response, {payload, status = "200", contentType = "application/json"}) {
response.writeHead(status, {
'Content-Type': contentType
})
response.end(payload)
exports.writeWithContentType = function (response, { payload, status = "200", contentType = "application/json" }) {
response.writeHead(status, {
'Content-Type': contentType
})
response.end(payload)
}

exports.writeNoContent = function (response) {
response.writeHead(204)
response.end()
}

response.writeHead(204)
response.end()
}
8 changes: 4 additions & 4 deletions client/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"src/assets",
{
"glob": "**/*",
"input": "src/assets/components/themes",
"output": "assets/components/themes"
"input": "src/app/styles/themes",
"output": "app/styles/themes"
}
],
"styles": [
"src/app/theme/styles/styles.scss",
"src/app/theme/styles/_primeng-overrides.scss",
"src/app/styles/styles.scss",
"src/app/styles/_primeng-overrides.scss",
"node_modules/pace-js/templates/pace-theme-flash.tmpl.css",
"node_modules/@fortawesome/fontawesome-free/css/all.css",
"node_modules/primeng/resources/primeng.min.css",
Expand Down
Loading

0 comments on commit bd52c57

Please sign in to comment.