Skip to content

Commit

Permalink
Merge branch 'develop' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
neophyte57 committed Jan 19, 2024
2 parents 80c8fc6 + b9d3fdd commit a9e0798
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
{{ user?.preferredLastName | default }}
</app-enrollee-property>
</ng-container>

<app-enrollee-property title="Submitted Date">
{{ user?.submittedDate | formatDate | default }}
</app-enrollee-property>
</app-overview-section>

<app-address-view title="Verified Address"
Expand Down Expand Up @@ -70,9 +74,18 @@
[disabled]="!(Role.SUPER_ADMIN | inRole)"
(click)="onBack()">Back
</button>
<button mat-flat-button
color="primary"
[disabled]="!(Role.SUPER_ADMIN | inRole) || user?.status === AccessStatusEnum.APPROVED"
(click)="onApprove()">Approve Authorized User
</button>
<div>
<button mat-flat-button
color="warn"
*ngIf="user?.status !== AccessStatusEnum.APPROVED"
[disabled]="!(Role.SUPER_ADMIN | inRole)"
(click)="onDelete()">Delete Authorized User
</button>
<button mat-flat-button
color="primary"
class="ml-1"
[disabled]="!(Role.SUPER_ADMIN | inRole) || user?.status === AccessStatusEnum.APPROVED"
(click)="onApprove()">Approve Authorized User
</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';

import { Subscription } from 'rxjs';

import { RouteUtils } from '@lib/utils/route-utils.class';
import { ConfirmDialogComponent } from '@shared/components/dialogs/confirm-dialog/confirm-dialog.component';

import { DialogOptions } from '@shared/components/dialogs/dialog-options.model';
import { Config } from '@config/config.model';
import { ConfigService } from '@config/config.service';
import { AuthorizedUserResource } from '@core/resources/authorized-user-resource.service';
Expand All @@ -31,6 +34,7 @@ export class AuthorizedUserReviewComponent implements OnInit {
private route: ActivatedRoute,
private authorizedUserResource: AuthorizedUserResource,
private configService: ConfigService,
private dialog: MatDialog,
private router: Router
) {
this.routeUtils = new RouteUtils(route, router, AdjudicationRoutes.HEALTH_AUTHORITIES);
Expand All @@ -43,6 +47,25 @@ export class AuthorizedUserReviewComponent implements OnInit {
.subscribe(() => this.routeUtils.routeRelativeTo(['../', AdjudicationRoutes.HEALTH_AUTH_AUTHORIZED_USERS]));
}

public onDelete() {

const data: DialogOptions = {
title: 'Delete Authorized User',
message: 'Are you sure you want to delete this authorized user request?',
actionText: "Yes"
};

this.dialog.open(ConfirmDialogComponent, { data })
.afterClosed()
.subscribe((result: boolean) => {
if (result) {
this.authorizedUserResource
.deleteAuthorizedUser(this.route.snapshot.params.auid)
.subscribe(() => this.routeUtils.routeRelativeTo(['../', AdjudicationRoutes.HEALTH_AUTH_AUTHORIZED_USERS]));
}
});
}

public onBack() {
this.routeUtils.routeRelativeTo(['../', AdjudicationRoutes.HEALTH_AUTH_AUTHORIZED_USERS]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Subscription } from 'rxjs';

import { RouteUtils } from '@lib/utils/route-utils.class';

import { FormatDatePipe } from '@shared/pipes/format-date.pipe';

import { HealthAuthorityResource } from '@core/resources/health-authority-resource.service';
import { AuthorizedUser } from '@shared/models/authorized-user.model';

Expand All @@ -14,7 +16,8 @@ import { AccessStatusEnum } from '@health-auth/shared/enums/access-status.enum';
@Component({
selector: 'app-health-auth-authorized-users-view',
templateUrl: './health-auth-authorized-users-view.component.html',
styleUrls: ['./health-auth-authorized-users-view.component.scss']
styleUrls: ['./health-auth-authorized-users-view.component.scss'],
providers: [FormatDatePipe]
})
export class HealthAuthAuthorizedUsersViewComponent implements OnInit {
public busy: Subscription;
Expand All @@ -26,6 +29,7 @@ export class HealthAuthAuthorizedUsersViewComponent implements OnInit {
private route: ActivatedRoute,
private router: Router,
private healthAuthorityResource: HealthAuthorityResource,
private formatDatePipe: FormatDatePipe,
) {
this.routeUtils = new RouteUtils(route, router, AdjudicationRoutes.routePath(AdjudicationRoutes.SITE_REGISTRATIONS));
}
Expand All @@ -47,7 +51,11 @@ export class HealthAuthAuthorizedUsersViewComponent implements OnInit {
{
key: 'Job Title',
value: user.jobRoleTitle
}
},
{
key: 'Submitted Date',
value: this.formatDatePipe.transform(user.submittedDate)
},
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
<div class="col-sm-auto tab-mid"
[ngClass]="{'selected-tab': mode === 'community'}"
(click)="goTo(this.communitySiteUrl)">
Community sites
Community site registration
</div>
<div class="col-sm-auto tab"
[ngClass]="{'selected-tab': mode === 'health-authority'}"
(click)="goTo(this.healthAuthorityUrl)">
Health authority sites
Health authority site registration
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import { AccessStatusEnum } from '@health-auth/shared/enums/access-status.enum';
export interface AuthorizedUser extends Party {
healthAuthorityCode: HealthAuthorityEnum;
status: AccessStatusEnum;
submittedDate: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class MockAuthorizedUserService implements IAuthorizedUserService {
healthAuthorityCode: HealthAuthorityEnum.FRASER_HEALTH,
phone: faker.phone.phoneNumber(),
status: AccessStatusEnum.UNDER_REVIEW,
submittedDate: faker.date.past().toISOString(),
});
}

Expand Down
1 change: 1 addition & 0 deletions prime-dotnet-webapi/ApiDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ IHttpContextAccessor context
public DbSet<Party> Parties { get; set; }
public DbSet<PartySubmission> PartySubmissions { get; set; }
public DbSet<PartyCertification> PartyCertifications { get; set; }
public DbSet<PartyEnrolment> PartyEnrolments { get; set; }

// PLR Integration
public DbSet<PlrProvider> PlrProviders { get; set; }
Expand Down
29 changes: 29 additions & 0 deletions prime-dotnet-webapi/Controllers/AuthorizedUsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,34 @@ public async Task<ActionResult> ApproveAuthorizedUser(int authorizedUserId)

return NoContent();
}


// DELETE: api/parties/authorized-user/5
/// <summary>
/// Delete the authorized user.
/// </summary>
/// <param name="authorizedUserId"></param>
[HttpDelete("{authorizedUserId}", Name = nameof(DeleteAuthorizedUser))]
[Authorize(Roles = Roles.PrimeSuperAdmin)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ApiMessageResponse), StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<ActionResult> DeleteAuthorizedUser(int authorizedUserId)
{
var authorizedUser = await _authorizedUserService.GetAuthorizedUserAsync(authorizedUserId);
if (authorizedUser == null)
{
return NotFound($"AuthorizedUser not found with id {authorizedUserId}");
}
if (!authorizedUser.PermissionsRecord().AccessableBy(User))
{
return Forbid();
}

await _authorizedUserService.DeleteAuthorizedUserAsync(authorizedUserId);

return NoContent();
}
}
}
2 changes: 2 additions & 0 deletions prime-dotnet-webapi/Models/Parties/PartyEnrolment.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;

namespace Prime.Models
{
[Table("PartyEnrolment")]
public class PartyEnrolment : BaseAuditable
{
[Key]
Expand Down
16 changes: 15 additions & 1 deletion prime-dotnet-webapi/Services/AuthorizedUserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,21 @@ public async Task DeleteAuthorizedUserAsync(int authorizedUserId)
return;
}

await _partyService.DeletePartyAsync(authorizedUser.Party.Id);
var auPartyEnrolment = await _context.PartyEnrolments.Where(p => p.PartyId == authorizedUser.PartyId && p.PartyType == PartyType.AuthorizedUser).FirstOrDefaultAsync();
var nonAUPartyEnrolment = await _context.PartyEnrolments.Where(p => p.PartyId == authorizedUser.PartyId && p.PartyType != PartyType.AuthorizedUser).FirstOrDefaultAsync();

if (nonAUPartyEnrolment == null)
{
var party = await _context.Parties.Where(p => p.Id == authorizedUser.PartyId).FirstOrDefaultAsync();
if (party != null)
{
_context.Parties.Remove(party);
}
}
_context.AuthorizedUsers.Remove(authorizedUser);
_context.PartyEnrolments.Remove(auPartyEnrolment);

await _context.SaveChangesAsync();
}

private IQueryable<AuthorizedUser> GetBaseAuthorizedUserQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ public class AuthorizedUserViewModel : IUserBoundModel
public string JobRoleTitle { get; set; }
public HealthAuthorityCode HealthAuthorityCode { get; set; }
public AccessStatusType Status { get; set; }
public DateTimeOffset SubmittedDate { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public HealthAuthorityMappingProfile()
CreateMap<IContactViewModel, Contact>();

CreateMap<AuthorizedUser, AuthorizedUserViewModel>()
.IncludeMembers(src => src.Party);
.IncludeMembers(src => src.Party)
.ForMember(dest => dest.SubmittedDate, opt => opt.MapFrom(src => src.CreatedTimeStamp));

CreateMap<Party, AuthorizedUserViewModel>();
}
}
Expand Down
25 changes: 25 additions & 0 deletions prime-dotnet-webapi/prime-dotnet-webapi.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "prime", "prime.csproj", "{3FC7F06B-7A36-4197-BB77-3095B85CDC1B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3FC7F06B-7A36-4197-BB77-3095B85CDC1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FC7F06B-7A36-4197-BB77-3095B85CDC1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FC7F06B-7A36-4197-BB77-3095B85CDC1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FC7F06B-7A36-4197-BB77-3095B85CDC1B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {834C8FA2-C341-4A5E-A920-56EAA1A00294}
EndGlobalSection
EndGlobal

0 comments on commit a9e0798

Please sign in to comment.