Skip to content
Open
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
3 changes: 3 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ try {

export default defineNuxtConfig({
ssr: true,
// let Nuxt add matching paths to .nuxt/tsconfig.json (used by `nuxt typecheck`, i.e. `yarn lint`)
alias,
// compatibilityDate: '2024-11-01',
debug: !!import.meta.env.NUXT_DEBUG, // fullstack backend use a DEBUG env that interfere with nuwt and cause log pollution
devtools: {
enabled: import.meta.dev,

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
"langchain": "1.2.14",
"leaflet": "1.9.4",
"leaflet.markercluster": "1.5.3",
"libphonenumber-js": "^1.13.12",
"lowlight": "3.3.0",
"mixpanel-browser": "2.71.0",
"nuxt": "3.21.8",
Expand All @@ -160,7 +161,7 @@
"pinia": "3.0.4",
"qrcode": "1.5.4",
"sass-migrator": "^2.6.1",
"shared-projects-frontend": "git+https://github.com/CyberCRI/shared-projects-frontend.git#0.4.2",
"shared-projects-frontend": "git+https://github.com/CyberCRI/shared-projects-frontend.git#user-modules-v0.0.1",
"sortablejs-vue3": "1.3.0",
"turndown": "^7.2.4",
"typescript": "6.0.3",
Expand Down
3 changes: 1 addition & 2 deletions src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const identifyUser = (userId: string) => {
export const setUserProperties = () => {
const usersStore = useUsersStore()
try {
const fullName = `${usersStore.user.name.firstname} ${usersStore.user.name.lastname}`
const fullName = `${usersStore.user.given_name} ${usersStore.user.family_name}`

Mixpanel.people.set({
// Only add user properties if not null
Expand All @@ -83,7 +83,6 @@ export const setUserProperties = () => {
// Custom properties on our side
id: usersStore.id,
roles: usersStore.user.roles,
orgs: usersStore.user.orgs,
}),
})
// Set "page_views" only if it doesn't exist yet, to not overwrite previous value
Expand Down
4 changes: 2 additions & 2 deletions src/api/v2/base.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ type useAsyncPaginationConfig = Parameters<typeof useAsyncPaginationAPI>['2']
export type UseAsyncApiConfig<Query = useAsyncConfig['query']> = {
query?: RefOrRaw<Query>
default?: () => any
} & Pick<useAsyncConfig, 'immediate'>
} & Pick<useAsyncConfig, 'immediate' | 'keyFixed' | 'checkArgs'>

export type UseAsyncPaginationApiConfig<Query = useAsyncConfig['query']> = {
// remove PaginationQuery (use paginationConfig)
query?: RefOrRaw<Omit<Query, keyof PaginationQuery>>
default?: () => any
} & Pick<useAsyncPaginationConfig, 'paginationConfig' | 'immediate'>
} & Pick<useAsyncPaginationConfig, 'paginationConfig' | 'immediate' | 'keyFixed' | 'checkArgs'>
12 changes: 6 additions & 6 deletions src/api/v2/crisalid.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type { RefOrRaw } from '~/interfaces/utils'
import {
getGroupResearchDocument as fetchGroupResearchDocument,
getGroupResearchDocumentAnalytics as fetchGroupResearchDocumentAnalytics,
getOwnResearchDocument as fetchOwnResearchDocument,
getOwnResearchDocumentAnalytics as fetchOwnResearchDocumentAnalytics,
getUserResearchDocument as fetchUserResearchDocument,
getUserResearchDocumentAnalytics as fetchUserResearchDocumentAnalytics,
getResearchDocumentSimilars as fetchResearchDocumentSimilars,
} from 'shared-projects-frontend/apis'
import type { UseAsyncApiConfig, UseAsyncPaginationApiConfig } from '~/api/v2/base.service'
Expand All @@ -27,7 +27,7 @@ const DEFAULT_CONFIG = {}
type Config = UseAsyncApiConfig
type ConfigPagination = UseAsyncPaginationApiConfig

export const getOwnResearchDocument = (
export const getUserResearchDocument = (
organizationCode: RefOrRaw<OrganizationModel['code']>,
researcherId: RefOrRaw<Researcher['id']>,
documenType: ResearcherDocumentType,
Expand All @@ -41,7 +41,7 @@ export const getOwnResearchDocument = (
return useAsyncPaginationAPI(
key,
({ config }) =>
fetchOwnResearchDocument(unref(organizationCode), unref(researcherId), unref(documenType), {
fetchUserResearchDocument(unref(organizationCode), unref(researcherId), unref(documenType), {
...DEFAULT_CONFIG,
...config,
}),
Expand Down Expand Up @@ -77,7 +77,7 @@ export const getGroupResearchDocument = (
)
}

export const getOwnResearchDocumentAnalytics = (
export const getUserResearchDocumentAnalytics = (
organizationCode: RefOrRaw<OrganizationModel['code']>,
researcherId: RefOrRaw<Researcher['id']>,
documenType: ResearcherDocumentType,
Expand All @@ -91,7 +91,7 @@ export const getOwnResearchDocumentAnalytics = (
return useAsyncAPI(
key,
({ config }) =>
fetchOwnResearchDocumentAnalytics(
fetchUserResearchDocumentAnalytics(
unref(organizationCode),
unref(researcherId),
unref(documenType),
Expand Down
61 changes: 61 additions & 0 deletions src/api/v2/notifications.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import type {
OrganizationModel,
QueryFilterNotification,
UserSlugOrId,
} from 'shared-projects-frontend/models'

import type { RefOrRaw } from '~/interfaces/utils'

import {
getNotifications as fetchNotifications,
getUserNotificationSettings as fetchUserNotificationSettings,
} from 'shared-projects-frontend/apis'
import type { UseAsyncPaginationApiConfig } from '~/api/v2/base.service'

import { onlyRefs } from '~/functs/onlyRefs'

const DEFAULT_CONFIG = {}

type ConfigPagination = UseAsyncPaginationApiConfig<QueryFilterNotification>

export const getNotifications = (
organizationCode: RefOrRaw<OrganizationModel['code']>,
userId: RefOrRaw<UserSlugOrId>,
config: ConfigPagination = {}
) => {
const key = computed(() => `${unref(organizationCode)}::user::${userId}::notifications`)

return useAsyncPaginationAPI(
key,
({ config }) =>
fetchNotifications(unref(organizationCode), unref(userId), {
...DEFAULT_CONFIG,
...config,
}),
{
watch: onlyRefs([organizationCode, userId]),
...config,
}
)
}

export const getUserNotificationSettings = (
organizationCode: RefOrRaw<OrganizationModel['code']>,
userId: RefOrRaw<UserSlugOrId>,
config: ConfigPagination = {}
) => {
const key = computed(() => `${unref(organizationCode)}::user::${userId}::notifications-settings`)

return useAsyncAPI(
key,
({ config }) =>
fetchUserNotificationSettings(unref(organizationCode), unref(userId), {
...DEFAULT_CONFIG,
...config,
}),
{
watch: onlyRefs([organizationCode, userId]),
...config,
}
)
}
33 changes: 0 additions & 33 deletions src/api/v2/people.service.ts

This file was deleted.

13 changes: 9 additions & 4 deletions src/api/v2/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
TranslatedSearchResultProject,
TranslatedSearchResultUser,
OrganizationModel,
TagClassificationModel,
} from 'shared-projects-frontend/models'
import {
searchAll,
Expand Down Expand Up @@ -222,22 +223,26 @@ export const getSearchGroup = (
// TODO change backend with prefix organization code in url
export const getSearchTag = (
organization: RefOrRaw<OrganizationModel['code']>,
classificationType: RefOrRaw<'enabled-for-projects' | 'enabled-for-skills'>,
classificationId: RefOrRaw<
TagClassificationModel['id'] | 'enabled-for-projects' | 'enabled-for-skills'
>,
config: ConfigPagination = {}
) => {
const key = computed(() => `${unref(organization)}::search::project::tags`)
const key = computed(
() => `${unref(organization)}::search::classifications::${unref(classificationId)}::tags`
)
const { translateTags } = useAutoTranslate()

return useAsyncPaginationAPI(
key,
({ config }) =>
getOrgClassificationTags(unref(organization), unref(classificationType), {
getOrgClassificationTags(unref(organization), unref(classificationId), {
...DEFAULT_CONFIG,
...config,
}),
{
translate: (data) => translateTags(data),
watch: onlyRefs([classificationType, organization]),
watch: onlyRefs([classificationId, organization]),
...config,
}
)
Expand Down
95 changes: 95 additions & 0 deletions src/api/v2/skills.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import {
getUserSkills as fetchUserSkills,
getUserSkill as fetchUserSkill,
getAllOrgClassifications as fetchAllOrgClassifications,
} from 'shared-projects-frontend/apis'
import type {
OrganizationModel,
QueryFilterSkill,
QueryFilterTagClassification,
SkillModel,
UserSlugOrId,
} from 'shared-projects-frontend/models'
import type { UseAsyncApiConfig, UseAsyncPaginationApiConfig } from '~/api/v2/base.service'
import type { RefOrRaw } from '~/interfaces/utils'
import { onlyRefs } from '~/functs/onlyRefs'

const DEFAULT_CONFIG = {}

type Config = UseAsyncApiConfig<QueryFilterSkill>
type ConfigPagination = UseAsyncPaginationApiConfig<QueryFilterSkill>

// TODO change backend with prefix organization code in url
export const getUserSkills = (
organization: RefOrRaw<OrganizationModel['code']>,
userId: RefOrRaw<UserSlugOrId>,
config: ConfigPagination = {}
) => {
const key = computed(() => `${unref(organization)}::user::${unref(userId)}::skills::all`)

const { translateSkills } = useAutoTranslate()

return useAsyncPaginationAPI(
key,
({ config }) =>
fetchUserSkills(unref(userId), {
...DEFAULT_CONFIG,
...config,
}),
{
translate: (skills) => translateSkills(skills),
watch: onlyRefs([organization, userId]),
...config,
}
)
}

export const getUserSkill = (
organization: RefOrRaw<OrganizationModel['code']>,
userId: RefOrRaw<UserSlugOrId>,
skillId: RefOrRaw<SkillModel['id']>,
config: Config = {}
) => {
const key = computed(
() => `${unref(organization)}::user::${unref(userId)}::skills::${unref(skillId)}`
)

const { translateSkill } = useAutoTranslate()

return useAsyncAPI(
key,
({ config }) =>
fetchUserSkill(unref(userId), unref(skillId), {
...DEFAULT_CONFIG,
...config,
}),
{
translate: (skill) => translateSkill(skill),
watch: onlyRefs([organization, userId, skillId]),
...config,
}
)
}

type ConfigPaginationClassification = UseAsyncPaginationApiConfig<QueryFilterTagClassification>
export const getAllOrgClassifications = (
organizationCode: RefOrRaw<OrganizationModel['code']>,
config: ConfigPaginationClassification = {}
) => {
const { translateClassifications } = useAutoTranslate()

const key = computed(() => `${unref(organizationCode)}::classifications::all`)

return useAsyncPaginationAPI(
key,
({ config }) =>
fetchAllOrgClassifications(unref(organizationCode), {
...DEFAULT_CONFIG,
...config,
}),
{
translate: (datas) => translateClassifications(datas),
...config,
}
)
}
Loading
Loading