Skip to content

Commit

Permalink
fixes + frontend changes
Browse files Browse the repository at this point in the history
  • Loading branch information
twallnerWaretec committed Jun 19, 2024
1 parent 45cdfac commit 9e5b0b0
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/repco-core/src/datasources/cba.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export class CbaDataSource implements DataSource {
const { posts: postsCursor = '1970-01-01T01:00:00' } = cursor
const perPage = this.config.pageLimit
let station = this.config.stationId
? `&station=${this.config.stationId}`
? `&station_id=${this.config.stationId}`
: ''
const url = this._url(
`/posts?multilingual${station}&page=1&per_page=${perPage}&_embed&orderby=modified&order=asc&modified_after=${postsCursor}`,
Expand Down
8 changes: 6 additions & 2 deletions packages/repco-core/src/datasources/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class RssDataSourcePlugin implements DataSourcePlugin {
const configSchema = zod.object({
endpoint: zod.string().url(),
repo: zod.string(),
language: zod.string().or(zod.null()).optional(),
})
type ConfigSchema = zod.infer<typeof configSchema>

Expand Down Expand Up @@ -106,6 +107,7 @@ export class RssDataSource extends BaseDataSource implements DataSource {
})
uriPrefix: string
repo: string
language: string | null | undefined
constructor(config: ConfigSchema) {
super()
const endpoint = new URL(config.endpoint)
Expand All @@ -114,10 +116,11 @@ export class RssDataSource extends BaseDataSource implements DataSource {
this.baseUri = removeProtocol(this.endpoint)
this.repo = config.repo
this.uriPrefix = `repco:rss:${this.endpoint.host}`
this.language = config.language
}

get config() {
return { endpoint: this.endpoint.toString() }
return { endpoint: this.endpoint.toString(), language: this.language }
}

get definition(): DataSourceDefinition {
Expand Down Expand Up @@ -431,7 +434,8 @@ export class RssDataSource extends BaseDataSource implements DataSource {
const itemUri = await this._deriveItemUri(item)
var licenseUri: string[] = []
var publicationServiceUri: string[] = []
var lang = item['frn:language'] || item['xml:lang'] || language
var lang =
item['frn:language'] || item['xml:lang'] || this.language || language
if (lang.length > 2) {
lang = lang.slice(0, 2)
}
Expand Down
3 changes: 3 additions & 0 deletions packages/repco-frontend/app/graphql/queries/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export const DashboardQuery = gql`
}
dataSources {
totalCount
nodes {
config
}
}
sourceRecords {
totalCount
Expand Down
7 changes: 6 additions & 1 deletion packages/repco-frontend/app/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5698,6 +5698,8 @@ export type RevisionConceptsByConceptRevisionIdAndSameAsUidManyToManyEdgeConcept
export type RevisionCondition = {
/** Checks for equality with the object’s `agentDid` field. */
agentDid?: InputMaybe<Scalars['String']>
/** Filters the list to Revisions that are in the list of uris. */
byEntityUris?: InputMaybe<Scalars['String']>
/** Checks for equality with the object’s `contentCid` field. */
contentCid?: InputMaybe<Scalars['String']>
/** Checks for equality with the object’s `dateCreated` field. */
Expand Down Expand Up @@ -7711,7 +7713,10 @@ export type LoadDashboardDataQuery = {
totalPublicationServices?: { totalCount: number } | null
totalContentItems?: { totalCount: number } | null
contentGroupings?: { totalCount: number } | null
dataSources?: { totalCount: number } | null
dataSources?: {
totalCount: number
nodes: Array<{ config?: any | null }>
} | null
sourceRecords?: { totalCount: number } | null
}

Expand Down
65 changes: 56 additions & 9 deletions packages/repco-frontend/app/routes/__layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const loader: LoaderFunction = async ({ request }) => {
}

const filteredRepoStats = repoStats.filter((result) => result !== null)

return {
data,
repoChartData,
Expand Down Expand Up @@ -227,6 +228,50 @@ export default function Index() {
)}
</div>
</div>

<div>
<h3 className="text-2xl">Datasources ({data?.dataSources.totalCount})</h3>
<div className="flex flex-col p-1">
{data?.dataSources.nodes.map(
(ds: { config: any; }, i: number) => (
<a key={i} href={ds.config.url} target={'_blank'}>
<ContentItemCard
aria-label={`Datasource ${ds.config.name}`}
>
<div className="flex items-baseline space-x-4">
<h3 className="text-brand-primary text-lg" key={i} style={{display: 'flex'}}>
<img src={ds.config.thumbnail} style={{display: 'block', margin: 'auto', paddingRight: '8px'}} />
{ds.config.name}
</h3>
<span className="text-xs italic">{ds.config.endpoint}</span>
</div>
</ContentItemCard>
</a>
),
)}
</div>
</div>

<div>
<h3 className="text-2xl">Publication Services ({data?.publicationServices.totalCount})</h3>
<div className="flex flex-col p-1">
{data?.publicationServices.nodes.map(
(ps: { name: any; contentItems: any }, i: number) => (
<ContentItemCard
aria-label={`Publicationservice ${ps.name[Object.keys(ps.name)[0]].value}`}
>
<div className="flex items-baseline space-x-4">
<h3 className="text-brand-primary text-lg" key={i} style={{display: 'flex'}}>
{ps.name[Object.keys(ps.name)[0]].value}
</h3>
<span className="text-xs italic">({ps.contentItems.totalCount})</span>
</div>
</ContentItemCard>
),
)}
</div>
</div>

<div className="flex flex-col space-y-4">
<div className="flex justify-between align-middle">
<div className="flex flex-col w-2/3 space-y-2">
Expand All @@ -248,16 +293,17 @@ export default function Index() {
</a>
</div>
</div>
<div className="flex flex-col w-1/3 space-y-2">
<div className="flex flex-col w-1/3 space-y-2" style={{marginBottom: '8px'}}>
<h4 className="text-xl">And kindly supported by:</h4>
<a className="flex w-1/3" href="https://culturalfoundation.eu">
<img
className=" object-contain"
src="https://culturalfoundation.eu/wp-content/themes/ecf/img/logo.svg"
alt="ecf-logo"
/>
</a>
<a href="#" className="w-1/3 flex">
<div className='flex'>
<a className="flex w-1/3" href="https://culturalfoundation.eu">
<img
className=" object-contain"
src="https://culturalfoundation.eu/wp-content/themes/ecf/img/logo.svg"
alt="ecf-logo"
/>
</a>
<a href="#" className="w-1/3 flex">
<img
className=" object-contain"
src="https://cba.media/wp-content/uploads/6/3/0000660636/eu-logo.png"
Expand All @@ -271,6 +317,7 @@ export default function Index() {
alt="rtr-logo"
/>
</a>
</div>
</div>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions packages/repco-graphql/generated/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9835,6 +9835,9 @@ input RevisionCondition {
"""Checks for equality with the object’s `agentDid` field."""
agentDid: String

"""Filters the list to Revisions that are in the list of uris."""
byEntityUris: String

"""Checks for equality with the object’s `contentCid` field."""
contentCid: String

Expand Down
2 changes: 2 additions & 0 deletions packages/repco-graphql/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ContentItemFilterPlugin from './plugins/content-item-filter.js'
import ExportSchemaPlugin from './plugins/export-schema.js'
// Change some inflection rules to better match our schema.
import CustomInflector from './plugins/inflector.js'
import RevisionsByEntityUris from './plugins/revisions-by-entity-uris.js'
// Add custom tags to omit all queries for the relation tables
import CustomTags from './plugins/tags.js'

Expand Down Expand Up @@ -59,6 +60,7 @@ export function getPostGraphileOptions() {
//ContentItemTitleFilterPlugin,
ConceptFilterPlugin,
ContentItemByUidsFilterPlugin,
RevisionsByEntityUris,
// ElasticTest,
// CustomFilterPlugin,
],
Expand Down
19 changes: 19 additions & 0 deletions packages/repco-graphql/src/plugins/revisions-by-entity-uris.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { makeAddPgTableConditionPlugin } from 'graphile-utils'

const RevisionsByEntityUris = makeAddPgTableConditionPlugin(
'public',
'Revision',
'byEntityUris',
(build) => ({
description: 'Filters the list to Revisions that are in the list of uris.',
type: build.graphql.GraphQLString,
}),
(value: any, helpers, build) => {
if (value == null) return
const { sql, sqlTableAlias } = helpers
var inValues = value.split(',')
return sql.raw(`uid IN ('{${inValues.join(`}','{`)}}')`)
},
)

export default RevisionsByEntityUris

0 comments on commit 9e5b0b0

Please sign in to comment.