generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PI-2035: Activity log
- Loading branch information
Showing
31 changed files
with
1,416 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.app-card { | ||
background-color: govuk-colour("light-grey"); | ||
display: block; | ||
padding: govuk-spacing(2); | ||
text-decoration: none; | ||
@include govuk-font($size: 19); | ||
|
||
@include govuk-media-query($from: desktop) { | ||
padding: govuk-spacing(4); | ||
} | ||
} | ||
|
||
.app-card--blue { | ||
background: govuk-colour("blue"); | ||
color: govuk-colour("white"); | ||
} | ||
|
||
.app-card--grey { | ||
color: govuk-shade(govuk-colour("dark-grey", $legacy: "grey-1"), 30); | ||
background: govuk-tint(govuk-colour("dark-grey", $legacy: "grey-1"), 90); | ||
} | ||
|
||
.note-panel { | ||
background-color: #f3f2f1; | ||
padding: 1.5rem | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Page from '../pages/page' | ||
import ActivityLogPage from '../pages/activityLog' | ||
|
||
context('Activity log', () => { | ||
it('Activity log page is rendered in default view', () => { | ||
cy.visit('/case/X000001/activity-log') | ||
const page = Page.verifyOnPage(ActivityLogPage) | ||
page.getRowData('timeline1', 'enforcement', 'Value').should('contain.text', 'Warning letter sent') | ||
page.getRowData('timeline2', 'rarActivity', 'Value').should('contain.text', 'Stepping Stones') | ||
page.getCardHeader('timeline3').should('contain.text', 'Waiting for evidence') | ||
page.getRowData('timeline4', 'reschedule', 'Value').should('contain.text', 'Requested by Terry Jones') | ||
page.getCardHeader('timeline5').should('contain.text', 'Office appointment at 10:15am') | ||
page.getCardHeader('timeline6').should('contain.text', 'Phone call at 8:15am') | ||
page.getCardHeader('timeline7').should('contain.text', 'Office appointment at 10:15am') | ||
page.getCardHeader('timeline8').should('contain.text', 'Video call at 10:15am') | ||
}) | ||
it('Activity log page is rendered in compact view', () => { | ||
cy.visit('/case/X000001/activity-log?view=compact') | ||
const page = Page.verifyOnPage(ActivityLogPage) | ||
page.getActivity('1').should('contain.text', 'Video call') | ||
page.getActivity('2').should('contain.text', 'Phone call from Eula Schmeler') | ||
page.getActivity('3').should('contain.text', 'Planned appointment') | ||
page.getActivity('4').should('contain.text', 'Initial appointment') | ||
page.getActivity('5').should('contain.text', 'Office appointment') | ||
page.getActivity('6').should('contain.text', 'Phone call') | ||
page.getActivity('7').should('contain.text', 'Office appointment') | ||
page.getActivity('8').should('contain.text', 'Video call') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Page, { PageElement } from './page' | ||
|
||
export default class ActivityLogPage extends Page { | ||
constructor() { | ||
super('Activity log') | ||
} | ||
|
||
getActivity = (index: string): PageElement => cy.get(`[data-qa=timeline${index}Card]`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { PersonSummary } from './common' | ||
import { Activity } from './schedule' | ||
|
||
export interface PersonActivity { | ||
personSummary: PersonSummary | ||
activities: Activity[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { type RequestHandler, Router } from 'express' | ||
import { auditService } from '@ministryofjustice/hmpps-audit-client' | ||
import { v4 } from 'uuid' | ||
import asyncMiddleware from '../middleware/asyncMiddleware' | ||
import type { Services } from '../services' | ||
import MasApiClient from '../data/masApiClient' | ||
|
||
export default function activityLogRoutes(router: Router, { hmppsAuthClient }: Services) { | ||
const get = (path: string | string[], handler: RequestHandler) => router.get(path, asyncMiddleware(handler)) | ||
|
||
get('/case/:crn/activity-log', async (req, res, _next) => { | ||
const { crn } = req.params | ||
const token = await hmppsAuthClient.getSystemClientToken(res.locals.user.username) | ||
const masClient = new MasApiClient(token) | ||
|
||
if (req.query.view === 'compact') { | ||
res.locals.compactView = true | ||
} else { | ||
res.locals.defaultView = true | ||
} | ||
|
||
const personActivity = await masClient.getPersonActivityLog(crn) | ||
|
||
await auditService.sendAuditMessage({ | ||
action: 'VIEW_MAS_ACTIVITY_LOG', | ||
who: res.locals.user.username, | ||
subjectId: crn, | ||
subjectType: 'CRN', | ||
correlationId: v4(), | ||
service: 'hmpps-manage-a-supervision-ui', | ||
}) | ||
res.render('pages/activity-log', { | ||
personActivity, | ||
crn, | ||
}) | ||
}) | ||
|
||
get('/case/:crn/activity-log/:category', async (req, res, _next) => { | ||
const { crn, category } = req.params | ||
const token = await hmppsAuthClient.getSystemClientToken(res.locals.user.username) | ||
|
||
await auditService.sendAuditMessage({ | ||
action: 'VIEW_MAS_ACTIVITY_LOG_CATEGORY', | ||
who: res.locals.user.username, | ||
subjectId: crn, | ||
subjectType: 'CRN', | ||
correlationId: v4(), | ||
service: 'hmpps-manage-a-supervision-ui', | ||
}) | ||
|
||
const masClient = new MasApiClient(token) | ||
|
||
const personActivity = await masClient.getPersonActivityLog(crn) | ||
|
||
if (req.query.view === 'compact') { | ||
res.locals.compactView = true | ||
} else { | ||
res.locals.defaultView = true | ||
} | ||
|
||
res.render('pages/activity-log', { | ||
category, | ||
personActivity, | ||
crn, | ||
}) | ||
}) | ||
|
||
get('/case/:crn/activity-log/activity/:id', async (req, res, _next) => { | ||
const { crn, id } = req.params | ||
const token = await hmppsAuthClient.getSystemClientToken(res.locals.user.username) | ||
|
||
const masClient = new MasApiClient(token) | ||
const personAppointment = await masClient.getPersonAppointment(crn, id) | ||
const isActivityLog = true | ||
const queryParams: string[] = [] | ||
|
||
const { category } = req.query | ||
if (req.query.view) { | ||
queryParams.push(`view=${req.query.view}`) | ||
} | ||
|
||
await auditService.sendAuditMessage({ | ||
action: 'VIEW_MAS_ACTIVITY_LOG_DETAIL', | ||
who: res.locals.user.username, | ||
subjectId: crn, | ||
subjectType: 'CRN', | ||
correlationId: v4(), | ||
service: 'hmpps-manage-a-supervision-ui', | ||
}) | ||
|
||
res.render('pages/schedule/appointment', { | ||
category, | ||
queryParams, | ||
personAppointment, | ||
crn, | ||
isActivityLog, | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.