-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the organisation overview page with summary count and table list of projects
- Loading branch information
1 parent
fcf80bc
commit e2bf265
Showing
13 changed files
with
204 additions
and
58 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,40 @@ | ||
import { schemaOrgId } from '@specfy/core'; | ||
import { catalogSummary } from '@specfy/models'; | ||
import { z } from 'zod'; | ||
|
||
import type { GetCatalogSummary } from '@specfy/models'; | ||
|
||
import { validationError } from '../../../../common/errors.js'; | ||
import { valPermissions } from '../../../../common/zod.js'; | ||
|
||
import type { FastifyPluginCallback, FastifyRequest } from 'fastify'; | ||
|
||
function QueryVal(req: FastifyRequest) { | ||
return z | ||
.object({ org_id: schemaOrgId }) | ||
.strict() | ||
.superRefine(valPermissions(req, 'viewer')); | ||
} | ||
|
||
const fn: FastifyPluginCallback = (fastify, _, done) => { | ||
fastify.get<GetCatalogSummary>('/', async function (req, res) { | ||
const val = QueryVal(req).safeParse(req.query); | ||
if (!val.success) { | ||
return validationError(res, val.error); | ||
} | ||
|
||
const query: GetCatalogSummary['Querystring'] = val.data; | ||
|
||
const catalog = await catalogSummary({ orgId: query.org_id }); | ||
console.log(catalog); | ||
|
||
return res.status(200).send({ | ||
data: { | ||
count: catalog.aggregations?.count.value || 0, | ||
}, | ||
}); | ||
}); | ||
done(); | ||
}; | ||
|
||
export default fn; |
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,21 @@ | ||
.metric { | ||
display: flex; | ||
gap: var(--spc); | ||
align-items: baseline; | ||
|
||
&.column { | ||
flex-direction: column; | ||
gap: var(--spc-xs); | ||
} | ||
} | ||
|
||
.label { | ||
color: var(--text-secondary); | ||
} | ||
|
||
.number { | ||
font-size: var(--font-4xl); | ||
font-weight: 500; | ||
line-height: var(--lh-4xl); | ||
color: var(--text-number); | ||
} |
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,27 @@ | ||
import classNames from 'classnames'; | ||
|
||
import cls from './index.module.scss'; | ||
|
||
export const Metric: React.FC<{ | ||
number: number; | ||
label: React.ReactNode; | ||
unit?: string; | ||
labelPos?: 'right' | 'down'; | ||
className?: string; | ||
}> = ({ number, label, unit, className, labelPos = 'right' }) => { | ||
return ( | ||
<div | ||
className={classNames( | ||
cls.metric, | ||
labelPos === 'down' && cls.column, | ||
className | ||
)} | ||
> | ||
<div className={cls.number}> | ||
{number} | ||
{unit} | ||
</div> | ||
<div className={cls.label}>{label}</div> | ||
</div> | ||
); | ||
}; |
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
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,10 @@ | ||
.content { | ||
padding: var(--spc-6xl) var(--spc-6xl) 0; | ||
} | ||
|
||
.metric { | ||
flex-grow: 1; | ||
padding: var(--spc-m) var(--spc-xl); | ||
border: 1px solid var(--border1); | ||
border-radius: var(--radius1); | ||
} |
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.