Skip to content

Commit

Permalink
Merge branch 'main' into grady/improve-audit-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gbdubs committed Jan 22, 2024
2 parents cce8dda + 8b1a5af commit cf86524
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 18 deletions.
7 changes: 7 additions & 0 deletions cmd/server/pactasrv/portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ func (s *Server) UpdatePortfolio(ctx context.Context, request api.UpdatePortfoli
if request.Body.Description != nil {
mutations = append(mutations, db.SetPortfolioDescription(*request.Body.Description))
}
if request.Body.PropertyHoldingsDate != nil {
hd, err := conv.HoldingsDateFromOAPI(request.Body.PropertyHoldingsDate)
if err != nil {
return nil, err
}
mutations = append(mutations, db.SetPortfolioPropertyHoldingsDate(hd))
}
if request.Body.PropertyESG != nil {
mutations = append(mutations, db.SetPortfolioPropertyESG(conv.OptionalBoolFromOAPI(*request.Body.PropertyESG)))
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/form/FieldHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const helpTextTextClass = computed(() => helpTextExpanded.value ? 'mb-2' : 'h-0'
<div
v-if="helpTextExists"
:class="helpTextTextClass"
class="overflow-hidden ml-1 text-sm help-text-animate"
class="overflow-hidden text-sm help-text-animate"
>
<slot name="help-text" />
{{ props.helpText }}
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions frontend/components/portfolio/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ const evs = computed({
auto-resize
/>
</FormEditorField>
<FormEditorField
:editor-field="efs.propertyHoldingsDate"
:editor-value="evs.propertyHoldingsDate"
>
<InputsHoldingsDate
v-model:value="evs.propertyHoldingsDate.currentValue"
/>
</FormEditorField>
<FormEditorField
:editor-field="efs.propertyESG"
:editor-value="evs.propertyESG"
Expand Down
20 changes: 20 additions & 0 deletions frontend/components/standard/Avatar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script setup lang="ts">
const props = defineProps<{
name?: string | undefined
}>()
const singleCharacter = computed(() => {
return props.name?.[0] || 'U'
})
</script>

<template>
<div
class="flex align-items-center justify-content-center border-circle bg-teal-400"
style="height: 2.5rem; width: 2.5rem;"
>
<span class="text-2xl text-white font-bold">
{{ singleCharacter }}
</span>
</div>
</template>
129 changes: 115 additions & 14 deletions frontend/components/standard/Nav.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { type MenuItem } from 'primevue/menuitem'
import type * as PrimeVueMenu from 'primevue/menu'
const { t } = useI18n()
const localePath = useLocalePath()
Expand All @@ -15,6 +16,14 @@ const { isAdmin, maybeMe } = await getMaybeMe()
const prefix = 'components/standard/Nav'
const tt = (s: string) => t(`${prefix}.${s}`)
const menuHidden = useState<boolean>(`${prefix}.menuHidden`, () => false)
const userMenu = useState<{ toggle: (e: Event) => void } | null>(`${prefix}.userMenu`, () => null)
const userMenuVisible = useState<boolean>(`${prefix}.userMenuVisible`, () => false)
const toggleUserMenu = (e: Event) => {
if (userMenu.value) {
userMenu.value.toggle(e)
}
}
const menuStyles = computed(() => {
return {
Expand Down Expand Up @@ -44,17 +53,11 @@ const menuItems = computed(() => {
to: localePath('/admin'),
})
}
if (maybeMe.value) {
if (isAuthenticated.value) {
result.push({
label: tt('My Data'),
to: localePath('/my-data'),
})
}
if (isAuthenticated.value) {
result.push({
label: tt('Sign Out'),
command: () => { void signOut() },
})
} else {
result.push({
label: tt('Sign In'),
Expand All @@ -63,6 +66,26 @@ const menuItems = computed(() => {
}
return result
})
const userMenuItems = computed(() => {
const result: MenuItem[] = [{
label: tt('Account'),
icon: 'pi pi-cog',
to: localePath('/user/me'),
}, {
label: tt('My Data'),
icon: 'pi pi-list',
to: localePath('/my-data'),
}, {
label: tt('Audit Logs'),
icon: 'pi pi-lock',
to: localePath('/audit-logs'),
}, {
label: tt('Sign Out'),
icon: 'pi pi-sign-out',
command: () => { void signOut() },
}]
return result
})
</script>

<template>
Expand All @@ -74,15 +97,26 @@ const menuItems = computed(() => {
class="h-3rem pb-2"
@click="() => router.push(localePath('/'))"
/>
<PVButton
:icon="menuHidden ? 'pi pi-bars' : 'pi pi-times'"
:class="menuHidden ? 'p-button-text' : 'border-bottom-noround p-button-primary'"
class="sm:hidden p-button-lg h-3rem"
@click="() => menuHidden = !menuHidden"
/>
<div class="flex gap-1 align-items-center">
<PVButton
v-show="maybeMe !== undefined"
v-tooltip="tt('Settings')"
icon="pi pi-user"
class="sm:hidden ml-2 flex-shrink-0"
rounded
:class="userMenuVisible ? 'p-button-primary' : 'p-button-text'"
@click="toggleUserMenu"
/>
<PVButton
:icon="menuHidden ? 'pi pi-bars' : 'pi pi-times'"
:class="menuHidden ? 'p-button-text' : 'border-bottom-noround p-button-primary'"
class="sm:hidden p-button-lg h-3rem"
@click="() => menuHidden = !menuHidden"
/>
</div>
</div>
<div
class="flex gap-2 sm:p-1 flex-1 flex-column sm:flex-row border-primary sm:border-none sm:max-h-full border-round justify-content-end"
class="flex gap-2 sm:p-1 flex-1 flex-column sm:flex-row border-primary sm:border-none sm:max-h-full border-round justify-content-end align-items-center"
:style="menuStyles"
>
<template
Expand All @@ -93,6 +127,7 @@ const menuItems = computed(() => {
:key="index"
:class="mi.to === router.currentRoute.value.fullPath ? 'border-noround sm:border-round' : 'p-button-text'"
:to="mi.to"
:external="mi.external"
:label="`${mi.label}`"
/>
<PVButton
Expand All @@ -103,6 +138,72 @@ const menuItems = computed(() => {
@click="mi.command"
/>
</template>
<PVButton
v-show="maybeMe !== undefined"
v-tooltip.left="tt('Settings')"
icon="pi pi-user"
class="hidden sm:flex ml-2 flex-shrink-0"
rounded
:class="userMenuVisible ? 'p-button-primary' : 'p-button-outlined'"
@click="toggleUserMenu"
/>
<PVOverlayPanel
ref="userMenu"
:pt="{
content: 'p-0',
}"
class="caret-primary"
@hide="() => userMenuVisible = false"
@show="() => userMenuVisible = true"
>
<div class="bg-primary p-3">
<div class="flex gap-3 align-items-center">
<StandardAvatar :name="maybeMe?.name" />
<div class="flex flex-column gap-1">
<span class="font-bold text-lg text-white">
{{ maybeMe?.name }}
</span>
<span class="text-sm text-white">
{{ maybeMe?.enteredEmail }}
</span>
</div>
</div>
</div>
<div
class="flex flex-column gap-1 p-2"
@click="toggleUserMenu"
>
<template
v-for="(mi, index) in userMenuItems"
>
<LinkButton
v-if="mi.to"
:key="index"
:class="mi.to === router.currentRoute.value.fullPath ? 'border-noround sm:border-round' : 'p-button-text'"
:to="mi.to"
:external="mi.external"
:icon="mi.icon"
:label="`${mi.label}`"
/>
<PVButton
v-else
:key="mi.label"
:label="mi.label"
:icon="mi.icon"
class="p-button-text"
@click="mi.command"
/>
</template>
</div>
</PVOverlayPanel>
</div>
</div>
</template>

<style lang="scss">
.caret-primary.p-overlaypanel{
&::before, &::after {
border-bottom-color: var(--primary-color)
}
}
</style>
9 changes: 7 additions & 2 deletions frontend/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@
"Home": "Portfolio Analysis Tool",
"My Data": "My Data",
"Sign In": "Sign In",
"Sign Out": "Sign Out"
"Sign Out": "Sign Out",
"Account": "Account",
"Audit Logs": "Audit Logs",
"Settings": "Settings"
},
"components/user/Editor": {
"The name that will be associated with": "The name that will be associated with ",
Expand Down Expand Up @@ -314,7 +317,9 @@
"External": "External",
"ExternalHelpText": "If enabled, this portfolio represents external data. If disabled, this portfolio represents internal data.",
"Engagement Strategy": "Engagement Strategy",
"EngagementStrategyHelpText": "If enabled, this portfolio represents engagement strategy data. If disabled, this portfolio represents non-engagement strategy data."
"EngagementStrategyHelpText": "If enabled, this portfolio represents engagement strategy data. If disabled, this portfolio represents non-engagement strategy data.",
"Holdings Date": "Holdings Date",
"HoldingsDateHelpText": "The date that the holdings in this portfolio are being evaluated at."
},
"lib/editor/portfolio_group": {
"Created At": "Created At",
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ const cleanUpIncompleteUploads = async () => {
label="Holdings Date"
help-text="The holdings date for the portfolio"
>
<InputsHoldingDate
<InputsHoldingsDate
v-model:value="holdingsDate"
:disabled="isProcessing"
/>
Expand Down
2 changes: 2 additions & 0 deletions frontend/plugins/primevue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import InputNumber from 'primevue/inputnumber'
import InputSwitch from 'primevue/inputswitch'
import InputText from 'primevue/inputtext'
import Message from 'primevue/message'
import Menu from 'primevue/menu'
import MultiSelect from 'primevue/multiselect'
import OverlayPanel from 'primevue/overlaypanel'
import ProgressSpinner from 'primevue/progressspinner'
Expand Down Expand Up @@ -50,6 +51,7 @@ export default defineNuxtPlugin(({ vueApp }) => {
vueApp.component('PVInputSwitch', InputSwitch)
vueApp.component('PVInputText', InputText)
vueApp.component('PVMessage', Message)
vueApp.component('PVMenu', Menu)
vueApp.component('PVMultiSelect', MultiSelect)
vueApp.component('PVOverlayPanel', OverlayPanel)
vueApp.component('PVProgressSpinner', ProgressSpinner)
Expand Down

0 comments on commit cf86524

Please sign in to comment.