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

[NRPTI-1045] - WIP - Update agency name in NRPTI #1114

Merged
merged 55 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
6126963
add menu item and page code - wip
davidclaveau Sep 11, 2023
32f14a4
Updated the front end to display list of agencies from drop down and …
Christopher-walsh22 Sep 11, 2023
346cf1b
create model and migration for agencies
davidclaveau Sep 11, 2023
f424e39
fix to model and migration - wip
davidclaveau Sep 12, 2023
1d99fe5
update agency code migration, add update issuingAgency
davidclaveau Sep 12, 2023
7e356ce
update model to only add to nrpti collection
davidclaveau Sep 12, 2023
8cf29f9
sample api added - list-agencies WIP
sanjaytkbabu Sep 12, 2023
5d55424
added api to list agencies, schema type
sanjaytkbabu Sep 13, 2023
23044bb
added get api
sanjaytkbabu Sep 13, 2023
8fe5785
put api added for updating agencies
sanjaytkbabu Sep 13, 2023
8711ada
New component to make request to new endpoint for issuing agencies
Christopher-walsh22 Sep 14, 2023
de0f22c
Options added
sanjaytkbabu Sep 14, 2023
1b8b7b0
Fixed component to properly display the information returned from get…
Christopher-walsh22 Sep 14, 2023
30be531
Update the agencyList array with selection from drop down menu. Creat…
Christopher-walsh22 Sep 14, 2023
8e41013
First steps of patch logic to the update agency service
Christopher-walsh22 Sep 14, 2023
58a0f7d
Front end component updates entries in for agency issuers through new…
Christopher-walsh22 Sep 14, 2023
70c6122
security token enabled, alerts removed, compile issue fixed
sanjaytkbabu Sep 15, 2023
c118d7f
toast added
sanjaytkbabu Sep 15, 2023
5688d72
button style updated
sanjaytkbabu Sep 15, 2023
edca104
Style added to dropdown
sanjaytkbabu Sep 15, 2023
8c58766
current selected agency removed
sanjaytkbabu Sep 15, 2023
d6982c3
wip - add agency service to app_init, change displayName
davidclaveau Sep 15, 2023
bf4856d
error message added
sanjaytkbabu Sep 15, 2023
d8ec256
removed logging and fixed indentation
sanjaytkbabu Sep 18, 2023
b5a1fc3
replaced hardcoded agency names with api calls
sanjaytkbabu Sep 18, 2023
99674df
api call moved to service layer
sanjaytkbabu Sep 18, 2023
6c93abd
issuing agency in add order replaced with api calls
sanjaytkbabu Sep 19, 2023
95608e6
add climate action secretariat to migrations
davidclaveau Sep 21, 2023
9376f16
wip - agencies are updated in factory, prelim update to components
davidclaveau Sep 22, 2023
d4d0ccd
wip - update picklist to allow dynamic update (admin penalty only)
davidclaveau Sep 25, 2023
c63f17b
wip - make buildForm for admin penalty async
davidclaveau Sep 25, 2023
318a469
wip - update to factory service, fix buildForm in admin penalty
davidclaveau Sep 25, 2023
f564dfa
refresh agencies after they are updated
davidclaveau Sep 25, 2023
370fcee
remove async ngOnInit, no longer needed
davidclaveau Sep 25, 2023
9ab27bb
update to more relevant terminology
davidclaveau Sep 25, 2023
c6528bf
update to agencies in components and modules
davidclaveau Sep 25, 2023
d231282
agency name translated to agency code on admin penalty save
sanjaytkbabu Sep 25, 2023
a5e456e
update admin penalty to show agency; linting updates
davidclaveau Sep 25, 2023
7f08537
linting updates
davidclaveau Sep 25, 2023
afea3a5
linting updates
davidclaveau Sep 25, 2023
0aeedfb
API unit tests fix
sanjaytkbabu Sep 29, 2023
af97202
linting fix for agency-data-service
davidclaveau Sep 29, 2023
cf47de5
Merge branch 'master' into feature/1045-issuing-agency-update
davidclaveau Sep 29, 2023
8874992
Agencies icon changed
sanjaytkbabu Sep 29, 2023
612536c
agency code updated
sanjaytkbabu Sep 29, 2023
0b51cf1
agency code updated
sanjaytkbabu Sep 29, 2023
0573f42
issuing agency replaced with api call
sanjaytkbabu Sep 29, 2023
e5bfc3a
update migration to change 'author' name to code; separate agency_env…
davidclaveau Sep 29, 2023
2f01e1d
update migration for ENV_EPD and update authors
davidclaveau Oct 2, 2023
d05a8c9
linting: white space added
sanjaytkbabu Oct 3, 2023
661d351
linting
sanjaytkbabu Oct 3, 2023
5d0f1e2
Update api/src/models/master/applicationAgency.js
sanjaytkbabu Oct 3, 2023
29ac607
Update api/src/swagger/swagger.yaml
sanjaytkbabu Oct 3, 2023
9f5ff8d
Update api/migrations/20230911220312-addApplicationAgenciesModel.js
sanjaytkbabu Oct 3, 2023
2bed555
comments added, unused function removed
sanjaytkbabu Oct 3, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<div class="container">
<h1>Update Agencies</h1>

<!-- Dropdown for selecting an agency -->
<div class="dropDownArea">
<label>Select The Agency You Would Like to Update:</label>
<br />
<!-- <select (change)="onSelected($event.target.value)">
<option *ngFor="let agency of agencyList" [value]="agency">{{ agency }}</option>
</select> -->

<select
_ngcontent-ity-c12=""
class="form-control ng-pristine ng-valid ng-touched"
(change)="onSelected($event.target.value)"
>
<option *ngFor="let agency of agencyList" [value]="agency">{{ agency }}</option>
</select>
</div>

<!-- Text field for entering a new agency -->
<div class="form-group">
<label for="newAgency">Updated Agency Name:</label>
<input type="text" id="newAgency" [(ngModel)]="newAgency" class="form-control" />
</div>

<!-- Submit button to update the selected agency -->
<!-- <button (click)="updateSelectedAgency()">Update Selected Agency</button> -->
<button _ngcontent-req-c21="" class="btn btn-primary" (click)="updateSelectedAgency()" title="Update Selected Agency">
Update Selected Agency
</button>

<!-- Displays current selection - Would probably remove before release -->
<!-- <div *ngIf="choiceMade">
<p>Selected Agency: {{ selectedAgency }}</p>
</div> -->
<!-- This div is just for debugging, Trying other ways to display the agencies -->
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "assets/styles/base/base.scss";
@import "assets/styles/components/add-edit.scss";
106 changes: 106 additions & 0 deletions angular/projects/admin-nrpti/src/app/agencies/agencies.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { Component, OnInit } from '@angular/core';
import { IssuingAgencyService } from '../services/issuingagency.service';
import { LoggerService } from 'nrpti-angular-components';
import { Constants } from '../utils/constants/misc';
import { ToastService } from '../services/toast.service';
import { FactoryService } from '../services/factory.service';

@Component({
selector: 'app-agencies',
templateUrl: './agencies.component.html',
styleUrls: ['./agencies.component.scss']
})
export class AgenciesComponent implements OnInit {
public loading = false;
selectedAgency = ''; // Initialize the selectedAgency
choiceMade = false;
newAgency = ''; // Initialize the new agency input field
agencies: { [key: string]: string } = { 'Kyle': 'Williams' };
agencyList: string[] = ['-Select-']; // Use a string array for agencyList
updatedData: any = {
agencies: []
};
constructor(
private issuingAgencyService: IssuingAgencyService,
private logger: LoggerService,
private toastService: ToastService,
private factoryService: FactoryService
) {}

onSelected(value: string): void {
this.selectedAgency = value;
this.choiceMade = true;
}
putRecords(agencyCode: any, agencyName: any) {
this.issuingAgencyService.updateAgency(agencyCode, agencyName).then(() => {
// Once record is updated, refresh the agencies
this.refreshAgencies();
});
}
refreshAgencies() {
this.factoryService.applicationAgencyService.refreshAgencies().subscribe();
}
updateSelectedAgency(): void {
try {
if (this.newAgency.trim() !== '') {
// Find the agency code that matches the selected agency name
const matchingCode = Object.keys(this.agencies).find(key => this.agencies[key] === this.selectedAgency);
if (matchingCode) {
// Update the agencyList with the new value at the same index
const index = this.agencyList.indexOf(this.selectedAgency);
if (index !== -1) {
this.agencyList[index] = this.newAgency;
}
// Update the selectedAgency with the new value
this.selectedAgency = this.newAgency;
// Clear the input field
this.newAgency = '';
this.choiceMade = true;
// Update the updatedData object to match the desired layout
this.updatedData.agencies.push({
agencyCode: matchingCode,
agencyName: this.selectedAgency
});
this.putRecords(matchingCode, this.selectedAgency);
this.updatedData.agencies = [];
}
this.toastService.addMessage('Agency Successfully Updated', 'Success Updated', Constants.ToastTypes.SUCCESS);
} else {
this.toastService.addMessage(
'Updated Agency Name Cannot be Empty',
'Save unsuccessful',
Constants.ToastTypes.ERROR
);
}
} catch (error) {
this.toastService.addMessage(
'An error has occured while saving',
'Save unsuccessful',
Constants.ToastTypes.ERROR
);
}
}

ngOnInit(): void {
this.issuingAgencyService
.getIssuingAgencies()
.then(response => {
const agencies = {};
if (response && Array.isArray(response)) {
response.forEach(agency => {
agencies[agency.agencyCode] = agency.agencyName;
});
}
this.agencies = agencies; // Assign the agencies object as an Observable
for (const key in agencies) {
if (agencies.hasOwnProperty(key)) {
this.agencyList.push(agencies[key]);
}
}
})
.catch(error => {
console.error('API call error:', error);
});
this.logger.level = 0;
}
}
32 changes: 32 additions & 0 deletions angular/projects/admin-nrpti/src/app/agencies/agencies.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// modules
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { BrowserModule } from '@angular/platform-browser';
import { EditorModule } from '@tinymce/tinymce-angular';
import { GlobalModule } from 'nrpti-angular-components';

import { CommonModule as NrptiCommonModule } from '../../../../common/src/app/common.module';
import { AgenciesComponent } from './agencies.component';
import { AgenciesResolver } from './agencies.resolver';

@NgModule({
imports: [
BrowserModule,
EditorModule,
FormsModule,
ReactiveFormsModule,
CommonModule,
GlobalModule,
NrptiCommonModule,
RouterModule,
NgbModule
],
declarations: [AgenciesComponent],
providers: [AgenciesResolver],
entryComponents: [AgenciesComponent],
exports: []
})
export class AgenciesModule {}
10 changes: 10 additions & 0 deletions angular/projects/admin-nrpti/src/app/agencies/agencies.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { Observable } from 'rxjs/Observable';

@Injectable()
export class AgenciesResolver implements Resolve<Observable<object>> {
resolve(route: ActivatedRouteSnapshot): Observable<object> {
return null;
}
}
13 changes: 13 additions & 0 deletions angular/projects/admin-nrpti/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { NewsResolver } from './news/news-resolver';
import { NewsListComponent } from './news/news-list.component';
import { CommunicationsComponent } from './communications/communications.component';
import { LngMapInfoResolver } from './communications/lng-map-info/lng-map-info-resolver';
import { AgenciesComponent } from './agencies/agencies.component';
import { AgenciesResolver } from './agencies/agencies.resolver';

const routes: Routes = [
{
Expand Down Expand Up @@ -60,6 +62,17 @@ const routes: Routes = [
}
]
},
{
path: 'agencies',
pathMatch: 'full',
component: AgenciesComponent,
resolve: {
records: AgenciesResolver
},
data: {
breadcrumb: 'Agencies'
}
},
{
// wildcard default route
path: '**',
Expand Down
16 changes: 12 additions & 4 deletions angular/projects/admin-nrpti/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { RecordsModule } from './records/records.module';
import { NewsModule } from './news/news.module';
import { MinesModule } from './mines/mines.module';
import { CommunicationsModule } from './communications/communications.module';
import { AgenciesModule } from './agencies/agencies.module';
import { ToastrModule } from 'ngx-toastr';

// components
Expand All @@ -43,6 +44,7 @@ import { RecordService } from './services/record.service';
import { TaskService } from './services/task.service';
import { ConfigService, LoggerService } from 'nrpti-angular-components';
import { NewsService } from './services/news.service';
import { ApplicationAgencyService } from './services/application-agency.service';

// resolvers
import { ImportListResolver } from './import/import-list-resolver';
Expand All @@ -58,11 +60,15 @@ import { TokenInterceptor } from './utils/token-interceptor';
import { RecordUtils } from './records/utils/record-utils';
import { CollectionService } from './services/collection.service';


export function initConfig(configService: ConfigService, keycloakService: KeycloakService) {
export function initConfig(
configService: ConfigService,
keycloakService: KeycloakService,
applicationAgency: ApplicationAgencyService
) {
return async () => {
await configService.init();
await keycloakService.init();
await applicationAgency.init();
};
}

Expand Down Expand Up @@ -98,6 +104,7 @@ export function overlayScrollFactory(overlay: Overlay): () => CloseScrollStrateg
NewsModule,
MinesModule,
CommunicationsModule,
AgenciesModule,
AppRoutingModule, // <-- module import order matters - https://angular.io/guide/router#module-import-order-matters
NgbModule.forRoot(),
NgxPaginationModule,
Expand All @@ -108,7 +115,7 @@ export function overlayScrollFactory(overlay: Overlay): () => CloseScrollStrateg
{
provide: APP_INITIALIZER,
useFactory: initConfig,
deps: [ConfigService, KeycloakService],
deps: [ConfigService, KeycloakService, ApplicationAgencyService],
multi: true
},
{
Expand All @@ -129,14 +136,15 @@ export function overlayScrollFactory(overlay: Overlay): () => CloseScrollStrateg
NewsService,
CollectionService,
KeycloakService,
ApplicationAgencyService,
LoggerService,
TaskService,
ImportListResolver,
NewsResolver,
NewsListResolver,
CanActivateGuard,
CanDeactivateGuard,
RecordUtils,
RecordUtils
],
entryComponents: [ConfirmComponent, HomeComponent, ImportComponent, ImportTableRowsComponent],
bootstrap: [AppComponent]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('HomeComponent', () => {
case Constants.Menus.ENTITIES: retVal = false; break;
case Constants.Menus.IMPORTS: retVal = true; break;
case Constants.Menus.COMMUNICATIONS: retVal = true; break;
case Constants.Menus.AGENCIES: retVal = true; break;
}
return retVal;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class MinesAdministrativePenaltyAddEditComponent extends AdministrativePe
);
}

ngOnInit() {
async ngOnInit() {
this.route.data.pipe(takeUntil(this.ngUnsubscribe)).subscribe((res: any) => {
this.isEditing = res.breadcrumb !== 'Add Administrative Penalty';
if (this.isEditing) {
Expand Down
Loading
Loading