Skip to content

Commit

Permalink
Merge branch 'main' into ofmcc-636-setup-uat-environment
Browse files Browse the repository at this point in the history
  • Loading branch information
SoLetsDev committed Nov 14, 2023
2 parents 64d4ca4 + eea43cd commit 8eeacb7
Show file tree
Hide file tree
Showing 22 changed files with 419 additions and 636 deletions.
21 changes: 5 additions & 16 deletions backend/src/components/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async function getUserInfo(req, res) {

let user = new MappableObjectForFront(userResponse, UserProfileMappings).data
let organization = new MappableObjectForFront(userResponse.organization, UserProfileOrganizationMappings).data
resData.facilityPermission = parseFacilityPermissions(userResponse)
resData.facilities = parseFacilityPermissions(userResponse)

let results = {
...resData,
Expand Down Expand Up @@ -151,21 +151,10 @@ async function getUserProfile(userGuid, userName) {
}

function parseFacilityPermissions(userResponse) {
const facilityList = Object.entries(userResponse.facility_permission)
.map(([key, value]) => {
// Only add facilities that have portal access
if (value.ofm_portal_access === true) {
const facilityPermission = new MappableObjectForFront(value, UserProfileFacilityPermissionMappings).data
const facility = new MappableObjectForFront(value.facility, UserProfileFacilityMappings).data
const combinedData = { ...facilityPermission, ...facility }
if (!_.isEmpty(combinedData)) {
return combinedData
}
}
return null
})
.filter((facility) => facility !== null)
return facilityList
return userResponse.facility_permission
.filter((fp) => fp.ofm_portal_access)
.map((fp) => new MappableObjectForFront(fp.facility, UserProfileFacilityMappings).data)
.sort((a, b) => a.facilityName.localeCompare(b.facilityName))
}

module.exports = {
Expand Down
1 change: 1 addition & 0 deletions backend/src/util/mapping/Mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const UserProfileOrganizationMappings = [
{ back: 'statuscode', front: 'organizationStatus' },
]

// TODO (weskubo-cgi) Remove this
const UserProfileFacilityPermissionMappings = [
{ back: 'statecode', front: 'stateCode' },
{ back: 'statuscode', front: 'statusCode' },
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<v-navigation-drawer class="site-menu" :width="200" :model-value="showMenu" :scrim="false" v-if="isAuthenticated && userInfo">
<TheMenu />
</v-navigation-drawer>
<TheFacilityHeader v-if="isActingProvider" />
<router-view class="align-start pt-8 px-8 mb-0" />
</v-main>
<TheFooter />
Expand All @@ -22,8 +23,10 @@
<script>
import { mapActions, mapState } from 'pinia'
import TheEnvBar from '@/components/TheEnvBar.vue'
import TheHeader from '@/components/TheHeader.vue'

import TheFacilityHeader from '@/components/TheFacilityHeader.vue'
import TheFooter from '@/components/TheFooter.vue'
import TheHeader from '@/components/TheHeader.vue'
import TheMenu from './components/TheMenu.vue'
import TheModalIdle from '@/components/TheModalIdle.vue'
import TheNavBar from '@/components/TheNavBar.vue'
Expand All @@ -42,6 +45,7 @@ export default {
TheModalIdle,
TheFooter,
TheMenu,
TheFacilityHeader,
},

data() {
Expand All @@ -52,7 +56,7 @@ export default {
}
},
computed: {
...mapState(useAuthStore, ['jwtToken', 'isUserInfoLoaded', 'isAuthenticated', 'userInfo', 'isAuthorizedWebsocketUser']),
...mapState(useAuthStore, ['jwtToken', 'isAuthenticated', 'userInfo', 'isAuthorizedWebsocketUser', 'isActingProvider']),
...mapState(useAppStore, ['pageTitle', 'showNavBar']),
mobile() {
return this.$vuetify.display.mobile
Expand Down
59 changes: 59 additions & 0 deletions frontend/src/components/TheFacilityHeader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<v-container class="pa-2 ma-0 facility-container" v-if="isAuthenticated && userInfo">
<v-row align="end" justify="space-between">
<v-col cols="6" class="header-org">
{{ userInfo.organizationName }}
</v-col>
<v-col class="header-facility" cols="6">
Facility: {{ currentFacility?.facilityName }}
<v-menu id="facilityMenu">
<template v-slot:activator="{ props }">
<v-btn color="primary" id="changeFacility" variant="text" v-bind="props">(change)</v-btn>
</template>
<v-list>
<v-list-item v-for="facility in userInfo.facilities" :key="facility.facilityId" @click="changeFacility(facility)">
<v-list-item-title>{{ facility.facilityName }}</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</v-col>
</v-row>
</v-container>
</template>
<script>
import { mapState, mapWritableState } from 'pinia'
import { useAuthStore } from '@/stores/auth'
export default {
computed: {
...mapState(useAuthStore, ['isAuthenticated', 'userInfo']),
...mapWritableState(useAuthStore, ['currentFacility']),
},
methods: {
changeFacility(facility) {
this.currentFacility = facility
},
},
}
</script>
<style scoped>
.facility-container {
max-width: 100%;
}
.header-org {
display: flex;
align-items: flex-end;
justify-content: flex-start;
color: #003366;
font-weight: 600;
font-size: 1.5em;
}
.header-facility {
display: flex;
align-items: flex-end;
justify-content: flex-end;
color: #003366;
font-weight: 600;
font-size: 1.3em;
}
</style>
13 changes: 6 additions & 7 deletions frontend/src/components/TheMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
<AppMenuItem icon="mdi-home-outline" :to="{ name: 'home' }">Home</AppMenuItem>
<AppMenuItem :to="{ name: 'messaging' }">
<div class="badge-wrapper">
<v-badge v-if="unreadNotificationCount > 0" :content="unreadNotificationCount" color="red" offset-x="18"
offset-y="17">
<v-badge v-if="unreadNotificationCount > 0" :content="unreadNotificationCount" color="red" offset-x="18" offset-y="17">
<v-icon class="badge-icon" aria-hidden="false" icon="mdi-email-outline" size="30" />
</v-badge>
<v-icon v-else class="badge-icon" aria-hidden="false" icon="mdi-email-outline" size="30" />
Messaging
</div>
</AppMenuItem>
<AppMenuItem icon="mdi-text-box-outline">Reporting</AppMenuItem>
<AppMenuItem icon="mdi-currency-usd">Funding</AppMenuItem>
<AppMenuItem icon="mdi-folder-outline">Documents</AppMenuItem>
<AppMenuItem icon="mdi-file-document-edit-outline">Applications</AppMenuItem>
<AppMenuItem icon="mdi-text-box-outline" :to="{ name: 'reporting' }">Reporting</AppMenuItem>
<AppMenuItem icon="mdi-currency-usd" :to="{ name: 'funding' }">Funding</AppMenuItem>
<AppMenuItem icon="mdi-folder-outline" :to="{ name: 'documents' }">Documents</AppMenuItem>
<AppMenuItem icon="mdi-file-document-edit-outline" :to="{ name: 'applications' }">Applications</AppMenuItem>
<AppMenuItem icon="mdi-help" :to="{ name: 'resources' }">Resources</AppMenuItem>
<AppMenuItem icon="mdi-cog-outline">Settings</AppMenuItem>
<AppMenuItem icon="mdi-cog-outline" :to="{ name: 'settings' }">Settings</AppMenuItem>
</div>
</template>

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/messages/NewRequestDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default {
...mapState(useAppStore, ['requestCategories']),
...mapState(useAuthStore, ['userInfo']),
facilities() {
return this.userInfo?.facilityPermission
return this.userInfo?.facilities
},
},
watch: {
Expand Down
129 changes: 60 additions & 69 deletions frontend/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ import { createRouter, createWebHistory } from 'vue-router'
import { useAppStore } from '@/stores/app'
import { useAuthStore } from '@/stores/auth'
import { PAGE_TITLES } from '@/utils/constants'
import ApplicationsView from '@/views/ApplicationsView.vue'
import BackendSessionExpiredView from '@/views/BackendSessionExpiredView.vue'
import DocumentsView from '@/views/DocumentsView.vue'
import ErrorView from '@/views/ErrorView.vue'
import FundingView from '@/views/FundingView.vue'
import HomeView from '@/views/HomeView.vue'
import ImpersonateView from '@/views/ImpersonateView.vue'
import LoginView from '@/views/LoginView.vue'
import LogoutView from '@/views/LogoutView.vue'
import MessagingView from '@/views/MessagingView.vue'
import MinistryLoginView from '@/views/MinistryLoginView.vue'
import ReportingView from '@/views/ReportingView.vue'
import ResourcesView from '@/views/ResourcesView.vue'
import SessionExpiredView from '@/views/SessionExpiredView.vue'
import SettingsView from '@/views/SettingsView.vue'
import UnAuthorizedPageView from '@/views/UnAuthorizedPageView.vue'
import UnAuthorizedView from '@/views/UnAuthorizedView.vue'

Expand Down Expand Up @@ -73,6 +78,42 @@ const router = createRouter({
requiresAuth: true,
},
},
{
path: '/reporting',
name: 'reporting',
component: ReportingView,
meta: {
pageTitle: 'Reporting',
requiresAuth: true,
},
},
{
path: '/funding',
name: 'funding',
component: FundingView,
meta: {
pageTitle: 'Funding',
requiresAuth: true,
},
},
{
path: '/documents',
name: 'documents',
component: DocumentsView,
meta: {
pageTitle: 'Documents',
requiresAuth: true,
},
},
{
path: '/applications',
name: 'applications',
component: ApplicationsView,
meta: {
pageTitle: 'Applications',
requiresAuth: true,
},
},
{
path: '/resources',
name: 'resources',
Expand All @@ -82,6 +123,15 @@ const router = createRouter({
requiresAuth: true,
},
},
{
path: '/settings',
name: 'settings',
component: SettingsView,
meta: {
pageTitle: 'Settings',
requiresAuth: true,
},
},
{
path: '/session-expired',
name: 'session-expired',
Expand Down Expand Up @@ -140,71 +190,6 @@ const router = createRouter({
role: 'CCP_ROLE',
},
},
//TODO: the following is a temp route which doesn't resolve to a component, its only purpose
// to provide example content to the navbar in the 1st draft of frontend and is expacted to
// eventually be removed...
{
path: '/contractManagement',
name: 'contractManagement',
//component: ContractManagement,
meta: {
pageTitle: PAGE_TITLES.CONTRACT_MANAGEMENT,
requiresAuth: true,
role: 'OPS_ROLE',
},
},
//TODO: the following is a temp route which doesn't resolve to a component, its only purpose
// to provide example content to the navbar in the 1st draft of frontend and is expacted to
// be removed...
{
path: '/payments',
name: 'payments',
//component: Payments,
meta: {
pageTitle: PAGE_TITLES.PAYMENTS,
requiresAuth: true,
role: 'PCM_ROLE',
},
},
//TODO: the following is a temp route which doesn't resolve to a component, its only purpose
// to provide example content to the navbar in the 1st draft of frontend and is expacted to
// be removed...
{
path: '/reporting',
name: 'reporting',
//component: Reporting,
meta: {
pageTitle: PAGE_TITLES.REPORTING,
requiresAuth: true,
role: 'OPS_ROLE',
},
},
//TODO: the following is a temp route which doesn't resolve to a component, its only purpose
// to provide example content to the navbar in the 1st draft of frontend and is expacted to
// be removed...
{
path: '/accountMaintenance',
name: 'accountMaintenance',
//component: AccountMaintenance,
meta: {
pageTitle: PAGE_TITLES.ACCOUNT_MAINTENANCE,
requiresAuth: true,
role: 'PCM_ROLE',
},
},
//TODO: the following is a temp route which doesn't resolve to a component, its only purpose
// to provide example content to the navbar in the 1st draft of frontend and is expacted to
// be removed...
{
path: '/maintRequetExceptionSream',
name: 'maintRequetExceptionStream',
//component: MaintenanceRequestExceptionStream,
meta: {
pageTitle: PAGE_TITLES.MAINTENANCE_REQUEST_EXCEPTION_STREAM,
requiresAuth: true,
role: 'PCM_ROLE',
},
},
],
})

Expand All @@ -217,7 +202,7 @@ router.beforeEach((to, _from, next) => {
appStore.setPageTitle('')
}

// TODO (weskubo)
// TODO (weskubo-cgi)
// 1. Don't allow access to Logout page if not logged in
// 2. Don't allow access to Login if Logged in
// 3. Don't allow access to Internal if logged in
Expand All @@ -234,9 +219,15 @@ router.beforeEach((to, _from, next) => {
authStore
.getUserInfo()
.then(() => {
if (!authStore.userHasRoles && !authStore.isMinistryUser) {
next('unauthorized')
return
if (!authStore.isMinistryUser) {
// Validate Provider roles
if (!authStore.hasRoles) {
return next('unauthorized')
}
// Validate Provider facilities
if (!authStore.hasFacilities) {
return next('unauthorized')
}
}
next()
})
Expand Down
Loading

0 comments on commit 8eeacb7

Please sign in to comment.