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

fix(frontend): Authorization Docs Link #202

Merged
merged 9 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -164,19 +164,20 @@ export class AmsOracleConnectorService implements OnModuleInit {
// else create a new document array and add it to the authorization number
const omrrAuthzDocsResponseScoped: OmrrAuthzDocsResponse[] = []
for (const row of result) {
const authNum = row['Authorization Number']
const authNum: number = Number(row['Authorization Number'])
const doc = {
DocumentObjectID: row['DocumentObjectID'],
DocumentObjectID: Number(row['DocumentObjectID']),
Description: row['Description'],
Publiclyviewable: row['Publiclyviewable'],
}
if(omrrAuthzDocsResponseScoped?.length > 0) {
const authNumIndex = omrrAuthzDocsResponseScoped.findIndex((auth) => auth['Authorization Number'] === authNum)
if (authNumIndex === -1) {
omrrAuthzDocsResponseScoped.push({
const omrrAuthzDoc: OmrrAuthzDocsResponse = {
'Authorization Number': authNum,
doc_links: [doc],
})
}
omrrAuthzDocsResponseScoped.push(omrrAuthzDoc)
} else {
omrrAuthzDocsResponseScoped[authNumIndex].doc_links.push(doc)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
export const OMRR_AUTHZ_DOCS_QUERY = `SELECT AUTHORIZATIONOBJECT.AuthorizationNumber as "Authorization Number",
EM_AuthorizationDocuments.DocumentObjectID,
EM_AuthorizationDocuments.DocumentObjectID AS "DocumentObjectID",
CASE
WHEN EM_AuthorizationDocuments.Description is not null
THEN EM_AuthorizationDocuments.Description
ELSE EM_AuthorizationDocuments.Filename
END As "Description",
EM_AuthorizationDocuments.Publiclyviewable
EM_AuthorizationDocuments.Publiclyviewable AS "Publiclyviewable"
FROM corral_generated_views.authorizationobject,
corral_generated_views.Em_Authorizationdocuments
where authorizationobject.objectID = Em_Authorizationdocuments.authorizationobjectID
UNION ALL
SELECT REGISTRATION.REGAUTHORIZATIONNUMBER as "Authorization Number",
EM_AuthorizationDocuments.DocumentObjectID,
EM_AuthorizationDocuments.DocumentObjectID AS "DocumentObjectID",
CASE
WHEN EM_AuthorizationDocuments.Description is not null
THEN EM_AuthorizationDocuments.Description
ELSE EM_AuthorizationDocuments.Filename
END As "Description",
EM_AuthorizationDocuments.Publiclyviewable
EM_AuthorizationDocuments.Publiclyviewable AS "Publiclyviewable"
FROM CORRAL_GENERATED_VIEWS.REGISTRATION,
corral_generated_views.Em_Authorizationdocuments
where REGISTRATION.ObjectID = Em_Authorizationdocuments.authorizationobjectID`;
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ spec:
- name: LOG_LEVEL
value: "info"
- name: VITE_AMS_URL
value: {{ .Values.global.amsURL }}
value: {{ .Values.global.amsURL | quote }}
- name: VITE_AMS_DOCS_FLAG
value: {{ .Values.backend.env.omrrAuthzDocsFlag | quote }}
ports:
- name: http
containerPort: 3000
Expand Down
2 changes: 1 addition & 1 deletion charts/nr-epd-organics-info/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ backend:
memory: 100Mi
containerResources:
limits:
cpu: 60m
cpu: 50m
memory: 200Mi
requests:
cpu: 30m
Expand Down
2 changes: 1 addition & 1 deletion frontend/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
header {
Content-Type text/javascript
}
respond `window.config={"VITE_AMS_URL":"{$VITE_AMS_URL}"};`
respond `window.config={"VITE_AMS_URL":"{$VITE_AMS_URL}", "VITE_AMS_DOCS_FLAG":"{$VITE_AMS_DOCS_FLAG}"};`
}
root * /srv
encode zstd gzip
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/pages/authorizationDetails/DocumentsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Stack, Typography } from '@mui/material'
import { Link, Stack, Typography } from '@mui/material'
import {env} from '@/env'
import clsx from 'clsx'

import {
Expand All @@ -23,7 +24,7 @@ export function DocumentsSection({ item }: Readonly<Props>) {

const count = documents.length
// When the documents can be downloaded - change to a link
const canDownload = false
const canDownload = env.VITE_AMS_DOCS_FLAG === 'true'
return (
<Stack
direction="column"
Expand All @@ -48,15 +49,18 @@ export function DocumentsSection({ item }: Readonly<Props>) {
</div>
)}
{documents.map((doc: OmrrAuthzDocs) => (
<div
<Link
key={`DocumentRow-${doc.DocumentObjectID}`}
className={clsx(
'documents-table-cell',
canDownload && 'documents-table-cell--link',
)}
href={env.VITE_AMS_URL +'download.aspx?PosseObjectId='+ doc.DocumentObjectID}
target="_blank"
rel={canDownload ? 'noopener noreferrer' : ''}
>
{doc.Description}
</div>
</Link>
))}
</Stack>
</Stack>
Expand Down