Skip to content

Commit

Permalink
Merge pull request #85 from NSWC-Crane/CHRIS_DEV
Browse files Browse the repository at this point in the history
Code cleanup
  • Loading branch information
crodriguez6497 authored Jul 9, 2024
2 parents a99c62a + 28c4581 commit f51cdad
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 90 deletions.
28 changes: 14 additions & 14 deletions api/Services/migrations/lib/mysql-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Importer {
* @returns {undefined}
*/
setEncoding(encoding) {
var supported_encodings = [
const supported_encodings = [
'utf8',
'ucs2',
'utf16le',
Expand Down Expand Up @@ -106,8 +106,8 @@ class Importer {
return new Promise(async (resolve, reject) => {
try {
await this._connect();
var files = await this._getSQLFilePaths(...input);
var error = null;
const files = await this._getSQLFilePaths(...input);
const error = null;
await slowLoop(files, (file, index, next) => {
if (error) {
next();
Expand Down Expand Up @@ -163,8 +163,8 @@ class Importer {
reject(err);
return;
}
var queries = new queryParser(queriesString).queries;
var error = null;
const queries = new queryParser(queriesString).queries;
const error = null;
slowLoop(queries, (query, index, next) => {
if (error) {
next();
Expand Down Expand Up @@ -260,8 +260,8 @@ class Importer {
*/
_getSQLFilePaths(...paths) {
return new Promise(async (resolve, reject) => {
var full_paths = [];
var error = null;
const full_paths = [];
const error = null;
paths = [].concat.apply([], paths); // flatten array of paths
await slowLoop(paths, async (filepath, index, next) => {
if (error) {
Expand All @@ -270,16 +270,16 @@ class Importer {
}
try {
await this._fileExists(filepath);
var stat = await this._statFile(filepath);
const stat = await this._statFile(filepath);
if (stat.isFile()) {
if (filepath.toLowerCase().substring(filepath.length - 4) === '.sql') {
full_paths.push(path.resolve(filepath));
}
next();
} else if (stat.isDirectory()) {
var more_paths = await this._readDir(filepath);
const more_paths = await this._readDir(filepath);
more_paths = more_paths.map(p => path.join(filepath, p));
var sql_files = await this._getSQLFilePaths(...more_paths);
const sql_files = await this._getSQLFilePaths(...more_paths);
full_paths.push(...sql_files);
next();
} else {
Expand Down Expand Up @@ -394,12 +394,12 @@ class queryParser {

// Check to see if a new delimiter is being assigned
checkNewDelimiter(char) {
var buffer_str = this.buffer.join('').toLowerCase().trim();
const buffer_str = this.buffer.join('').toLowerCase().trim();
if (buffer_str === 'delimiter' && !this.quoteType) {
this.seekingDelimiter = true;
this.buffer = [];
} else {
var isNewLine = char === "\n" || char === "\r";
const isNewLine = char === "\n" || char === "\r";
if (isNewLine && this.seekingDelimiter) {
this.seekingDelimiter = false;
this.delimiter = this.buffer.join('').trim();
Expand All @@ -410,7 +410,7 @@ class queryParser {

// Check if the current char is a quote
checkQuote(char) {
var isQuote = (char === '"' || char === "'") && !this.escaped;
const isQuote = (char === '"' || char === "'") && !this.escaped;
if (isQuote && this.quoteType === char) {
this.quoteType = false;
} else if (isQuote && !this.quoteType) {
Expand All @@ -420,7 +420,7 @@ class queryParser {

// Check if we're at the end of the query
checkEndOfQuery() {
var demiliterFound = false;
const 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/poamMilestoneService.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ exports.deletePoamMilestone = async function deletePoamMilestone(poamId, milesto
let sql = "DELETE FROM cpat.poammilestones WHERE poamId= ? AND milestoneId = ?";
await connection.query(sql, [poamId, milestoneId]);

const action = `Milestone Deleted.`;
let action = `Milestone Deleted.`;
if (requestBody.requestorId) {
if (requestBody.extension == true) {
action = `Extension milestone deleted.`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<i [class]="notification.icon"></i>
</div>
<h4>{{ notification.title }}</h4>
<i *ngIf="notification.notificationId" class="dismiss-icon pi pi-times" (click)="dismissNotification(notification)"></i>
<i *ngIf="notification.notificationId" class="dismiss-icon pi pi-times" (click)="dismissNotification(notification)" (onKeyUp)="dismissNotification(notification)"></i>
</div>
<p>{{ notification.message }}</p>
<small>{{ notification.timestamp | date:'short' }}</small>
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const routes: Routes = [
{ path: 'poam-processing', canActivate: [AuthGuard], loadChildren: () => import('./pages/poam-processing/poam-processing.module').then(m => m.PoamProcessingModule) },
{ path: 'marketplace', canActivate: [AuthGuard], loadChildren: () => import('./pages/marketplace/marketplace.module').then(m => m.MarketplaceModule) },
{ path: 'unauthorized', component: UnauthorizedComponent },
{ path: '' || '**', redirectTo: 'consent' },
{ path: '**', redirectTo: 'consent' },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
<app-config></app-config>
<div class="layout-topbar">
<div class="layout-topbar-left">
<img src="../assets/cpat.png" alt="C-PAT" (click)="reloadPage()" (keyup.enter)="reloadPage()" style="cursor: pointer;">
<img src="../assets/cpat.png" alt="C-PAT" (click)="reloadPage()" (onKeyUp)="reloadPage()" style="cursor: pointer;">
</div>
<div class="layout-topbar-right">
<button pButton type="button" icon="pi pi-palette text-2xl" class="p-button-text p-button-rounded p-button-plain" (click)="showConfig()"></button>
<p-button type="button"
icon="pi pi-bell text-2xl"
[badge]="notificationCount"
(click)="op.toggle($event)"
(onKeyUp)="op.toggle($event)"
styleClass="p-button-text p-button-rounded p-button-plain notification-button">
</p-button>
<p-overlayPanel #op class="overlay" [dismissable]="true" [showCloseIcon]="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<p-status-card [title]="statusCard.title"
[type]="statusCard.type"
[icon]="statusCard.icon"
(click)="statusCard.component ? openModal(statusCard.component) : triggerFileInput()">
(click)="statusCard.component ? openModal(statusCard.component) : triggerFileInput()"
(onKeyUp)="statusCard.component ? openModal(statusCard.component) : triggerFileInput()">
</p-status-card>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr>
<th id="col" *ngFor="let col of columns">
<th scope="col" *ngFor="let col of columns">
{{col}}
</th>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</div>
<!-- Buttons -->
<div class="buttons">
<p-button label="Submit" styleClass="p-button-primary p-button-outlined" [disabled]="!form.valid" (click)="onSubmit()"></p-button>
<p-button label="Cancel" styleClass="p-button-primary p-button-outlined" (click)="resetData()" [style]="{'margin-left':'20px'}"></p-button>
<p-button label="Submit" styleClass="p-button-primary p-button-outlined" [disabled]="!form.valid" (click)="onSubmit()" (onKeyUp)="onSubmit()"></p-button>
<p-button label="Cancel" styleClass="p-button-primary p-button-outlined" (click)="resetData()" (onKeyUp)="resetData()" [style]="{'margin-left':'20px'}"></p-button>
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
class="import-button"
styleClass="p-button-info"
(click)="importSTIGManagerCollection()"
(onKeyUp)="importSTIGManagerCollection()"
pTooltip="If a STIG Manager collection has previously been imported, importing again will update the collection and relative assets with current data from STIG Manager."
tooltipPosition="left"
[style]="{'width':'100%'}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr>
<th id="col" *ngFor="let col of columns">
<th scope="col" *ngFor="let col of columns">
{{col}}
</th>
</tr>
Expand All @@ -42,7 +42,7 @@
<p-table [value]="rowNode.children" [columns]="['Collection', 'Access Level']" [responsive]="true">
<ng-template pTemplate="header" let-columns>
<tr>
<th id="col" *ngFor="let col of columns">
<th scope="col" *ngFor="let col of columns">
{{col}}
</th>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@
<p-table [value]="collectionPermissions" [columns]="cols" editMode="row">
<ng-template pTemplate="header" let-columns>
<tr>
<th>
<th scope="col">
<button pButton icon="pi pi-plus" class="p-button-text" (click)="onAddNewPermission()"></button>
</th>
<th id="col" *ngFor="let col of columns">
<th scope="col" *ngFor="let col of columns">
{{col.header}}
</th>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<i class="pi pi-search"></i>
<input pInputText id="search" [(ngModel)]="filterValue" (input)="applyFilter($event)" placeholder="Search Assets" style="width: 300px;">
</span>
<p-button label="Clear" [outlined]="true" severity="info" class="ml-auto" icon="pi pi-filter-slash" (click)="clear()"></p-button>
<p-button label="Clear" [outlined]="true" severity="info" class="ml-auto" icon="pi pi-filter-slash" (click)="clear()" (onKeyUp)="clear()"></p-button>
</div>
<div class="scrollable-assets">
<p-table #assetTable
Expand All @@ -31,31 +31,31 @@
[globalFilterFields]="['assetId', 'assetName', 'description', 'ipAddress', 'macAddress']">
<ng-template pTemplate="header">
<tr>
<th style="min-width:5rem">
<th scope="col" style="min-width:5rem">
<div class="flex align-items-center">
Asset ID
<p-columnFilter type="text" field="assetId" display="menu" />
</div>
</th>
<th style="min-width:15rem">
<th scope="col" style="min-width:15rem">
<div class="flex align-items-center">
Asset Name
<p-columnFilter type="text" field="assetName" display="menu" />
</div>
</th>
<th style="min-width:15rem">
<th scope="col" style="min-width:15rem">
<div class="flex align-items-center">
Description
<p-columnFilter type="text" field="description" display="menu" />
</div>
</th>
<th style="min-width:15rem">
<th scope="col" style="min-width:15rem">
<div class="flex align-items-center">
IP Address
<p-columnFilter type="text" field="ipAddress" display="menu" />
</div>
</th>
<th style="min-width:15rem">
<th scope="col" style="min-width:15rem">
<div class="flex align-items-center">
MAC Address
<p-columnFilter type="text" field="macAddress" display="menu" />
Expand All @@ -64,7 +64,7 @@
</tr>
</ng-template>
<ng-template pTemplate="body" let-asset let-rowIndex="rowIndex">
<tr [pSelectableRow]="asset" [pSelectableRowIndex]="rowIndex" (click)="setAsset(asset.assetId)">
<tr [pSelectableRow]="asset" [pSelectableRowIndex]="rowIndex" (click)="setAsset(asset.assetId)" (onKeyUp)="setAsset(asset.assetId)">
<td>{{asset.assetId}}</td>
<td>{{asset.assetName}}</td>
<td>{{asset.description}}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
<p-table [value]="assetLabels" dataKey="labelId">
<ng-template pTemplate="header">
<tr>
<th style="width:8rem">
<th scope="col" style="width:8rem">
<button pButton pRipple type="button" icon="pi pi-plus" (click)="addNewRow()" class="p-button-rounded p-button-text"></button>
</th>
<th>Label</th>
<th scope="col">Label</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-label let-ri="rowIndex">
Expand Down Expand Up @@ -105,6 +105,6 @@
<p-dialog header="Invalid Data" [(visible)]="displayInvalidDataDialog" [modal]="true" [style]="{width: '300px'}" [baseZIndex]="10000">
<p>{{invalidDataMessage}}</p>
<ng-template pTemplate="footer">
<p-button icon="pi pi-check" (click)="displayInvalidDataDialog=false" label="OK" styleClass="p-button-full p-button-info w-full"></p-button>
<p-button icon="pi pi-check" (click)="displayInvalidDataDialog=false" (onKeyUp)="displayInvalidDataDialog=false" label="OK" styleClass="p-button-full p-button-info w-full"></p-button>
</ng-template>
</p-dialog>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<p-treeTable #stigFindingsTable sortMode="multiple" [value]="dataSource" [filterDelay]="0" [globalFilterFields]="['Group ID', 'Rule Title', 'Benchmark ID', 'Severity']" [columns]="allColumns" [sortMode]="'single'" [sortField]="sortColumn" [sortOrder]="sortDirection === 'asc' ? 1 : -1" (onSort)="updateSort($event)">
<ng-template pTemplate="header">
<tr>
<th id="col" *ngFor="let col of allColumns" [ttSortableColumn]="col">
<th scope="col" *ngFor="let col of allColumns" [ttSortableColumn]="col">
{{col}}
<p-treeTableSortIcon [field]="col" *ngIf="col !== 'Update POAM'"></p-treeTableSortIcon>
</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<i class="pi pi-search"></i>
<input pInputText id="search" [(ngModel)]="filterValue" (input)="applyFilter($event)" placeholder="Search Labels" style="width: 300px;">
</span>
<p-button label="Clear" [outlined]="true" severity="info" class="ml-auto" icon="pi pi-filter-slash" (click)="clear()"></p-button>
<p-button label="Clear" [outlined]="true" severity="info" class="ml-auto" icon="pi pi-filter-slash" (click)="clear()" (onKeyUp)="clear()"></p-button>
</div>
<div class="scrollable-labels">
<p-table #labelTable
Expand All @@ -29,19 +29,19 @@
[globalFilterFields]="['labelId', 'labelName', 'description']">
<ng-template pTemplate="header">
<tr>
<th style="min-width:5rem">
<th scope="col" style="min-width:5rem">
<div class="flex align-items-center">
Label ID
<p-columnFilter type="text" field="labelId" display="menu" />
</div>
</th>
<th style="min-width:15rem">
<th scope="col" style="min-width:15rem">
<div class="flex align-items-center">
Name
<p-columnFilter type="text" field="labelName" display="menu" />
</div>
</th>
<th style="min-width:15rem">
<th scope="col" style="min-width:15rem">
<div class="flex align-items-center">
Description
<p-columnFilter type="text" field="description" display="menu" />
Expand All @@ -50,7 +50,7 @@
</tr>
</ng-template>
<ng-template pTemplate="body" let-label let-rowIndex="rowIndex">
<tr [pSelectableRow]="label" [pSelectableRowIndex]="rowIndex" (click)="setLabel(label.labelId)">
<tr [pSelectableRow]="label" [pSelectableRowIndex]="rowIndex" (click)="setLabel(label.labelId)" (onKeyUp)="setLabel(label.labelId)">
<td>{{label.labelId}}</td>
<td>{{label.labelName}}</td>
<td>{{label.description}}</td>
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/pages/marketplace/marketplace.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="theme-card" *ngFor="let theme of themes">
<p-card [header]="theme.themeName">
<ng-template pTemplate="header">
<img [src]="themeImageUrls[theme.themeId]" [alt]="theme.themeName" (click)="openImageDialog(theme)" style="cursor: pointer; width: 100%;">
<img [src]="themeImageUrls[theme.themeId]" [alt]="theme.themeName" (click)="openImageDialog(theme)" (onKeyUp)="openImageDialog(theme)" style="cursor: pointer; width: 100%;">
</ng-template>
<p>{{ theme.themeDescription }}</p>
<p-chip [label]="theme.cost + ' Points'" styleClass="p-mr-2"></p-chip>
Expand All @@ -44,7 +44,7 @@
<div class="theme-card" *ngFor="let theme of purchasedThemes">
<p-card [header]="theme.themeName">
<ng-template pTemplate="header">
<img [src]="themeImageUrls[theme.themeId]" [alt]="theme.themeName" (click)="openImageDialog(theme)" style="cursor: pointer; width: 100%;">
<img [src]="themeImageUrls[theme.themeId]" [alt]="theme.themeName" (click)="openImageDialog(theme)" (onKeyUp)="openImageDialog(theme)" style="cursor: pointer; width: 100%;">
</ng-template>
<p>{{ theme.themeDescription }}</p>
<ng-template pTemplate="footer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ng-template>
<ng-template pTemplate="header">
<tr>
<th id="col" *ngFor="let col of assignedColumns">
<th scope="col" *ngFor="let col of assignedColumns">
{{ col }}
</th>
</tr>
Expand Down
Loading

0 comments on commit f51cdad

Please sign in to comment.