Skip to content

Commit

Permalink
A2agc improvements (#142)
Browse files Browse the repository at this point in the history
* Move project files to correct folder

* Remove DODs from maps of health data

* Change DOD to DOD_PERIOD

* Remove DOD from Vis4 data

* Tweaks to age group calculations

* Update scripts

* Fix paths

* Disable Data Distributions in menu if no aggregate table data

* Exit script if no source data

* Move logic that checks for data

* Remove unwanted text

* Move data source check out of run.sh

* Add documentation coverage

* More Compodoc setup

* Remove unneeded workaround

* Add documentation to angular files

* Fixes

* Fixes to workflows

* Fix conflicts

* Fix conflicts

* Change to workflows
  • Loading branch information
edlu77 authored and bherr2 committed Jun 24, 2024
1 parent db587e3 commit d83b10f
Show file tree
Hide file tree
Showing 220 changed files with 3,450 additions and 287 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:
${{ runner.os }}-node-
- name: npm ci for website
run: npm ci
- run: npm run lint
- run: npm run test
- run: npm run lint a2agc
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ speed-measure-plugin*.json
/.sass-cache
/connect.lock
/coverage
/documentation
/libpeerconnection.log
npm-debug.log
yarn-error.log
Expand Down
43 changes: 23 additions & 20 deletions project.json → apps/a2agc/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "node_modules/nx/schemas/project-schema.json",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"name": "a2agc",
"projectType": "application",
"generators": {
Expand All @@ -10,27 +10,27 @@
"strict": true
}
},
"sourceRoot": "src",
"sourceRoot": "apps/a2agc/src",
"prefix": "agc",
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/a2agc",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"index": "apps/a2agc/src/index.html",
"main": "apps/a2agc/src/main.ts",
"polyfills": "apps/a2agc/src/polyfills.ts",
"tsConfig": "apps/a2agc/tsconfig.app.json",
"allowedCommonJsDependencies": [
"css-element-queries"
],
"assets": [
"src/favicon.ico",
"src/assets"
"apps/a2agc/src/favicon.ico",
"apps/a2agc/src/assets"
],
"styles": [
"src/styles.scss",
"src/themes.scss",
"apps/a2agc/src/styles.scss",
"apps/a2agc/src/themes.scss",
"node_modules/prismjs/themes/prism-okaidia.css",
"node_modules/prismjs/plugins/line-numbers/prism-line-numbers.css"
],
Expand All @@ -51,8 +51,8 @@
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
"replace": "apps/a2agc/src/environments/environment.ts",
"with": "apps/a2agc/src/environments/environment.prod.ts"
}
],
"optimization": true,
Expand Down Expand Up @@ -104,17 +104,17 @@
"test": {
"executor": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"main": "apps/a2agc/src/test.ts",
"polyfills": "apps/a2agc/src/polyfills.ts",
"tsConfig": "apps/a2agc/tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"codeCoverage": true,
"assets": [
"src/favicon.ico",
"src/assets"
"apps/a2agc/src/favicon.ico",
"apps/a2agc/src/assets"
],
"styles": [
"src/styles.scss"
"apps/a2agc/src/styles.scss"
],
"scripts": []
}
Expand All @@ -123,8 +123,8 @@
"executor": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
"apps/a2agc/src/**/*.ts",
"apps/a2agc/src/**/*.html"
]
},
"outputs": [
Expand All @@ -145,6 +145,9 @@
}
},
"defaultConfiguration": "development"
},
"test-doc-coverage": {
"command": "npx compodoc -p apps/a2agc/tsconfig.doc.json -e json --coverageTest --coverageMinimumPerFile 100 --coverageTestShowOnlyFailed -t"
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<mat-sidenav-container>
<mat-sidenav mode="over" [(opened)]="menuOpen" (closedStart)="menuOpen = false">
<agc-page-menu [header]="menuHeader" [pages]="pages">
<agc-page-menu [header]="menuHeader" [pages]="pages" [showData]="showData">
</agc-page-menu>
</mat-sidenav>

Expand Down
File renamed without changes.
36 changes: 35 additions & 1 deletion src/app/app.component.ts → apps/a2agc/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,71 @@ import { MatSidenavContainer } from '@angular/material/sidenav';

import { buildInfo } from './build-info';
import { PageLink } from './core/models/pages.model';
import { DatasetsState } from './core/state/data/datasets.state';
import { RouterState } from './core/state/router/router.state';
import { visualizations } from './core/state/visualizations/visualizations';
import { MarkdownModalComponent, MarkdownModalData } from './shared/components/markdown-modal/markdown-modal.component';


/**
* A2AGC app component
*/
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
@Component({
selector: 'agc-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements AfterViewInit {
/** HTML class name */
@HostBinding('class') readonly clsName = 'agc-root';

/** Sidenav container component element */
@ViewChild(MatSidenavContainer)
readonly sidenavContainer!: MatSidenavContainer;

/** Whether or not sidenav should include data distributions */
showData = true;

// TODO move these values to state
/** Sidenav menu header */
readonly menuHeader = 'Marion County Opioid Addiction Report';
/** Page options to include in the sidenav menu */
readonly pages: PageLink[] = visualizations.map(v => ({
path: v.id, title: v.title, description: v.description
}));

/** Whether or not to show the subbar under the page header */
subBarVisible = true;
/** True if menu is open */
menuOpen = false;
/** Build date of app component */
buildDate = buildInfo.buildDate;

/**
* Creates an instance of app component.
* @param router Router state
* @param datasetsState Datasets state
* @param dialog Mat dialog service
* @param zone NgZone
*/
constructor(
router: RouterState,
datasetsState: DatasetsState,
private readonly dialog: MatDialog,
private readonly zone: NgZone
) {
router.navigationStart$.subscribe(() => {
this.menuOpen = false;
});

datasetsState.entitiesArray$.subscribe((datasets) => {
this.showData = datasets.length > 0;
});
}

/**
* Sets sidenav after view init
*/
ngAfterViewInit(): void {
// NOTE: Scrollable is not available in ngOnInit even if @ViewChild has `static: true`
this.sidenavContainer.scrollable.elementScrolled().subscribe(() => {
Expand All @@ -56,6 +84,9 @@ export class AppComponent implements AfterViewInit {
});
}

/**
* Opens contact form
*/
openContactUs(): void {
this.dialog.open<MarkdownModalComponent, MarkdownModalData>(MarkdownModalComponent, {
width: '800px',
Expand All @@ -67,6 +98,9 @@ export class AppComponent implements AfterViewInit {
});
}

/**
* Opens privacy policy dialog
*/
openPrivacyPolicy(): void {
this.dialog.open<MarkdownModalComponent, MarkdownModalData>(MarkdownModalComponent, {
width: '800px',
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/app/build-info.ts → apps/a2agc/src/app/build-info.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** Build info */
export const buildInfo = {
version: '1.0.0',
lastCommitDate: new Date(1603996553000),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { ChangeDetectionStrategy, Component, HostBinding } from '@angular/core';


/**
* Page banner component
*/
@Component({
selector: 'agc-banner',
templateUrl: './banner.component.html',
styleUrls: ['./banner.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class BannerComponent {
/** HTML class name */
@HostBinding('class') readonly clsName = 'agc-banner';
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import { ChangeDetectionStrategy, Component, EventEmitter, HostBinding, Input, Output } from '@angular/core';


/**
* Page footer component
*/
@Component({
selector: 'agc-page-footer',
templateUrl: './page-footer.component.html',
styleUrls: ['./page-footer.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class PageFooterComponent {
/** HTML class name */
@HostBinding('class') readonly clsName = 'agc-page-footer';

/** Build date */
@Input() buildDate = new Date();

/** Emits when contact button clicked */
@Output() readonly contactClick = new EventEmitter<void>();
/** Emits when privacy policy button clicked */
@Output() readonly privacyClick = new EventEmitter<void>();
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import { ChangeDetectionStrategy, Component, EventEmitter, HostBinding, Input, Output } from '@angular/core';


/**
* Page header component
*/
@Component({
selector: 'agc-page-header',
templateUrl: './page-header.component.html',
styleUrls: ['./page-header.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class PageHeaderComponent {
/** HTML class name */
@HostBinding('class') readonly clsName = 'agc-page-header';
@HostBinding('class.mat-elevation-z3') readonly elevation = true;

/** True if the menu is open */
@Input() menuOpen = false;
/** Emits menuOpen value */
@Output() readonly menuOpenChange = new EventEmitter<boolean>();

/**
* Opens/closes the menu and emits the menu state
*/
toggleMenuOpen(): void {
this.menuOpen = !this.menuOpen;
this.menuOpenChange.emit(this.menuOpen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</nav>

<div class="info">
<a class="link distributions" routerLink="/data-distributions" routerLinkActive="active">
<a *ngIf="showData" class="link distributions" routerLink="/data-distributions" routerLinkActive="active">
<mat-icon svgIcon="menu:data-distributions"></mat-icon>
<span class="title">Data Distributions</span>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,32 @@ import { ChangeDetectionStrategy, Component, HostBinding, Input } from '@angular
import { PageLink } from '../../models/pages.model';


/**
* Page menu component
*/
@Component({
selector: 'agc-page-menu',
templateUrl: './page-menu.component.html',
styleUrls: ['./page-menu.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class PageMenuComponent {
/** HTML class name */
@HostBinding('class') readonly clsName = 'agc-page-menu';

/** Header text */
@Input() header = '';
/** Page menu link info */
@Input() pages: PageLink[] = [];
/** Whether to show the data distributions option */
@Input() showData = true;

/**
* Gets path from PageLink item
* @param _index page index
* @param link page link item
* @returns path name
*/
linkId(_index: number, link: PageLink): string {
return link.path;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { ChangeDetectionStrategy, Component, HostBinding, Input } from '@angular/core';


/**
* Header sub bar component
*/
@Component({
selector: 'agc-sub-bar',
template: '',
styleUrls: ['./sub-bar.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class SubBarComponent {
/** HTML class name */
@HostBinding('class') readonly clsName = 'agc-sub-bar';

/** If sub bar is visible */
@Input() @HostBinding('class.visible') visible = true;
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit d83b10f

Please sign in to comment.