Skip to content

Commit

Permalink
Merge pull request #454 from GSA/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
hatfieldjm4 authored Aug 13, 2024
2 parents 797a5d9 + d09374e commit 9b1d187
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 34 deletions.
12 changes: 7 additions & 5 deletions api/controllers/base.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,14 @@ function authorize(
requester,
key = null
) {
const { client_secret, client_id, redirect_uris } = credentials.installed;
var client_secret = credentials.client_secret;
var client_id = credentials.client_id;
var redirect_uris = credentials.redirect_uris;

const oAuth2Client = new google.auth.OAuth2(
client_id,
client_secret,
redirect_uris[0]
);
client_id, client_secret, redirect_uris
);

try {
// Check if we have previously stored a token.
fs.readFile(TOKEN_PATH, (err, token) => {
Expand Down
10 changes: 9 additions & 1 deletion api/controllers/search.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ exports.searchAll = (req, res) => {
'Investment' AS \`GEAR_Type\`,
'{}' AS \`Other\`
FROM
gear_schema.obj_investments as invest) AS global_search
gear_schema.obj_investments as invest
UNION SELECT
web.\`id\` AS \`Id\`,
web.\`domain\` AS \`Name\`,
web.\`notes\` AS \`Description\`,
'Website' AS \`GEAR_Type\`,
'{}' AS \`Other\`
FROM
gear_schema.obj_websites as web) AS global_search
WHERE Name LIKE '%${req.params.kw}%' or Description like '%${req.params.kw}%';`; // Removed cowboy_ods.obj_technology AS tech reference

res = ctrl.sendQuery(query, `global search of ${req.params.kw}`, res);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SELECT
w.office,
w.sub_office,
w.type_of_site,
w.digital_brand_category
w.digital_brand_category,
w.production_status
FROM obj_websites as w
INNER JOIN zk_websites_service_categories AS zk ON zk.obj_websites_id = w.id
1 change: 1 addition & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { DataDictionaryComponent } from './views/main/data-dictionary/data-dicti
const routes: Routes = [
{ path: '', component: HomeComponent, title: 'Home' },
{ path: 'search', component: GlobalSearchComponent, title: 'Search' },
{ path: 'search/:reportType/:id', component: GlobalSearchComponent, title: 'Search' },
{ path: 'about', component: AboutComponent, title: 'About' },
{ path: 'about/:tab', component: AboutComponent, title: 'About' },
{
Expand Down
25 changes: 9 additions & 16 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { distinctUntilChanged } from 'rxjs/operators';
import { distinctUntilChanged, filter } from 'rxjs/operators';

// Declare jQuery symbol
declare var $: any;
Expand All @@ -12,28 +12,21 @@ declare var gtag: Function;
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
constructor(private router: Router) { }
constructor(private router: Router) {
this.router.events.subscribe(event => {
// Send page_view event to GA
if (event instanceof NavigationEnd) {
gtag('event', 'page_view', { 'page_path': event.urlAfterRedirects });
}
});
}

title = 'gear3';

ngOnInit() {
// Pad main Module by how big the top navbar is
$(document).ready(this.setNavOffsets);
$(window).resize(this.setNavOffsets);

/*
** Send analytics if page changes and the route isn't the same
** distinctUntilChanged so the observer only emits when type NavigationEnd and
** doesn't have the same route as previously emitted
*/
this.router.events.pipe(distinctUntilChanged((previous: any, current: any) => {
if(current instanceof NavigationEnd) {
return previous.url === current.url;
}
return true;
})).subscribe((x: any) => {
gtag('config', 'G-PDPL5T61V1', {'page_path': x.url});
});
}

setNavOffsets() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export class WebsiteServiceCategoryModalComponent implements OnInit {
title: 'Sub-Office',
sortable: true,
},
{
field: 'production_status',
title: 'Production Status',
sortable: true,
},
];

ngOnInit(): void {
Expand Down
4 changes: 4 additions & 0 deletions src/app/services/shared/shared.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { set } from 'd3';

// Declare jQuery symbol
declare var $: any;
declare var gtag: Function;

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -337,6 +338,9 @@ export class SharedService {
public addIDtoURL(row, IDname) {
var normalizedURL = this.coreURL(this.router.url);
this.location.replaceState(`${normalizedURL}/${row[IDname]}`);

// Send page_view event to GA
gtag('event', 'page_view', { 'page_path': `${normalizedURL}/${row[IDname]}` });
};

// cookies functions ---------------------------------------
Expand Down
25 changes: 23 additions & 2 deletions src/app/services/tables/table.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Injectable, Component, ViewEncapsulation } from '@angular/core';
import { Location } from '@angular/common';

import { Globals } from '@common/globals';

Expand Down Expand Up @@ -132,7 +133,8 @@ export class TableService {
private apiService: ApiService,
private globals: Globals,
private modalService: ModalsService,
private sharedService: SharedService
private sharedService: SharedService,
private location: Location
) {}

public createTableOptions(definitions: any): {} {
Expand Down Expand Up @@ -182,6 +184,7 @@ export class TableService {
case 'Capability':
this.apiService.getOneCap(searchData.Id).subscribe((apiData: any[]) => {
this.capsTableClick(apiData[0]);
this.setGlobalSearchModalUrl(searchData.GEAR_Type, searchData.Id);
});
break;

Expand All @@ -190,6 +193,7 @@ export class TableService {
.getOneFISMASys(searchData.Id)
.subscribe((apiData: any[]) => {
this.fismaTableClick(apiData[0]);
this.setGlobalSearchModalUrl(searchData.GEAR_Type, searchData.Id);
});
break;

Expand All @@ -198,12 +202,14 @@ export class TableService {
.getOneInvest(searchData.Id)
.subscribe((apiData: any[]) => {
this.investTableClick(apiData[0]);
this.setGlobalSearchModalUrl(searchData.GEAR_Type, searchData.Id);
});
break;

case 'System': // TODO: need to change when gear_schema is fully transitioned
this.apiService.getOneSys(searchData.Id).subscribe((apiData: any[]) => {
this.systemsTableClick(apiData[0]);
this.setGlobalSearchModalUrl(searchData.GEAR_Type, searchData.Id);
});
break;

Expand All @@ -212,17 +218,27 @@ export class TableService {
.getOneITStandard(searchData.Id)
.subscribe((apiData: any[]) => {
this.itStandTableClick(apiData[0]);
this.setGlobalSearchModalUrl(searchData.GEAR_Type, searchData.Id);
});

break;

case 'Organization':
this.apiService
.getOneOrg(searchData.Id)
.subscribe((apiData: any[]) => {
this.orgsTableClick(apiData[0]);
this.setGlobalSearchModalUrl(searchData.GEAR_Type, searchData.Id);
});
break;
case 'Website':
this.apiService
.getOneWebsite(searchData.Id)
.subscribe((apiData: any[]) => {
this.websitesTableClick(apiData[0]);
this.setGlobalSearchModalUrl(searchData.GEAR_Type, searchData.Id);
});
break;

default:
break;
}
Expand Down Expand Up @@ -718,4 +734,9 @@ export class TableService {
});
}
}

// Set the gear_type and id in the url for global search
private setGlobalSearchModalUrl(gear_type: string, id: string) {
this.location.replaceState(`search/${gear_type}/${id}`);
}
}
11 changes: 6 additions & 5 deletions src/app/views/main/data-dictionary/data-dictionary.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class DataDictionaryComponent implements OnInit {
advancedSearch: false,
idTable: null,
classes: "table-hover table-dark",
showColumns: false,
showColumns: true,
showExport: true,
exportFileName: 'GEAR_Data_Dictionary',
headerStyle: null,
Expand All @@ -41,8 +41,7 @@ export class DataDictionaryComponent implements OnInit {
ddColumnDefs: any[] = [{
field: 'ReportName',
title: 'ReportName',
sortable: true,
visible: false
sortable: true
},
{
field: 'Term',
Expand All @@ -61,7 +60,8 @@ export class DataDictionaryComponent implements OnInit {
{
field: 'DefinitionSourceLink',
title: 'Definition Source Link',
formatter: this.sharedService.linksFormatter
formatter: this.sharedService.linksFormatter,
visible: false
},
{
field: 'DataSource',
Expand All @@ -71,7 +71,8 @@ export class DataDictionaryComponent implements OnInit {
{
field: 'DataSourceLink',
title: 'Data Source Link',
formatter: this.sharedService.linksFormatter
formatter: this.sharedService.linksFormatter,
visible: false
}
];

Expand Down
15 changes: 14 additions & 1 deletion src/app/views/main/global-search/global-search.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { SharedService } from '@services/shared/shared.service';
import { TableService } from '@services/tables/table.service';
Expand All @@ -17,7 +18,8 @@ export class GlobalSearchComponent implements OnInit {

constructor(
private sharedService: SharedService,
private tableService: TableService) { }
private tableService: TableService,
private route: ActivatedRoute) { }

// Global Search Table Options
tableOptions: {} = this.tableService.createTableOptions({
Expand Down Expand Up @@ -65,6 +67,17 @@ export class GlobalSearchComponent implements OnInit {
data: [],
}));

// If the user pastes in a global search url
this.route.params.subscribe((params) => {
if(params && (params['reportType'] && params['id'])) {
let searchData = {
Id: params['id'],
GEAR_Type: params['reportType']
};
this.tableService.globalSearchTableClick(searchData);
}
});

const self = this;
$(document).ready(() => {
// Method to handle click events on the Global Search table
Expand Down
9 changes: 6 additions & 3 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@

<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PDPL5T61V1"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DRCLWZLXKB"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

// moving this to app.component.ts so GA doesn't track initial load twice
// gtag('config', 'G-PDPL5T61V1');
/* Set send_page_view to false since we now need to
* manually send page views via a page_view event
* on route change and modal opens
*/
gtag('config', 'G-DRCLWZLXKB', { 'send_page_view': false });
</script>

<meta charset="utf-8">
Expand Down

0 comments on commit 9b1d187

Please sign in to comment.