Skip to content

Commit

Permalink
Merge branch 'main' into datahub-ign-2905
Browse files Browse the repository at this point in the history
  • Loading branch information
cdebarros committed Oct 23, 2024
2 parents 9583a2d + 8665bf5 commit f4757ff
Show file tree
Hide file tree
Showing 121 changed files with 9,162 additions and 1,391 deletions.
38 changes: 6 additions & 32 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
gh-pages:
needs: checks
if: github.event_name != 'issue_comment' || needs.checks.outputs.shouldRun
name: Deploy Storybook to GitHub Pages
name: Deploy docs, apps, Storybook to GitHub Pages
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{needs.checks.outputs.ref || 'main'}}
Expand Down Expand Up @@ -78,6 +78,10 @@ jobs:
- name: Build demo & web components
run: npm run build:demo

- name: Build metadata-converter app
if: github.event_name != 'issue_comment' # This is not done on PR, only on main branch
run: npx nx build metadata-converter --prod --base-href=./

- name: Build docs
run: npm run docs:build -- --base=/geonetwork-ui/${{env.BRANCH_NAME}}/docs/ && mkdir -p dist/docs && mv docs/.vitepress/dist/* dist/docs

Expand All @@ -99,39 +103,9 @@ jobs:
* (Documentation)[https://geonetwork.github.io/geonetwork-ui/${{env.BRANCH_NAME}}/docs/]
* (Demo & web components)[https://geonetwork.github.io/geonetwork-ui/${{env.BRANCH_NAME}}/demo/]
* (Web components demo)[https://geonetwork.github.io/geonetwork-ui/${{env.BRANCH_NAME}}/demo/webcomponents/]
* (UI components storybook)[https://geonetwork.github.io/geonetwork-ui/${{env.BRANCH_NAME}}/storybook/demo/]'
comment_tag: github-links
pr_number: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

apps:
needs: checks
if: github.event_name != 'issue_comment'
name: Deploy Apps to GitHub Pages
runs-on: ubuntu-latest
env:
BRANCH_NAME: main

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Install
run: npm ci

- name: Build metadata-converter
run: npx nx build metadata-converter --prod

- name: Deploy to directory ${{ env.BRANCH_NAME }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
npx gh-pages --dist dist/apps/ --dest ${{env.BRANCH_NAME}} --remove "${{env.BRANCH_NAME}}/**" --no-history --repo "https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ You can start it with `npm run storybook`.
You can either try complete applications or showcases of components using the following links:

- [Storybook of UI components](https://geonetwork.github.io/geonetwork-ui/main/storybook/demo/)
- [Storybook of Web components](https://geonetwork.github.io/geonetwork-ui/main/storybook-wc/)
- [Demo](https://geonetwork.github.io/geonetwork-ui/main/demo/)
- [Metadata Converter app](https://geonetwork.github.io/geonetwork-ui/main/apps/metadata-converter/)
- [Web Components demo](https://geonetwork.github.io/geonetwork-ui/main/demo/webcomponents/)

## More information

Expand Down
146 changes: 3 additions & 143 deletions apps/datahub/README.md
Original file line number Diff line number Diff line change
@@ -1,147 +1,7 @@
# Datahub

UI of the web application `datahub`.
The Datahub is an application to provide a default, pure and simple UI for metadata and dataset search.

`datahub` is an application to provide a default, pure and simple UI for metadata and dataset search.
More information here: https://geonetwork.github.io/geonetwork-ui/main/docs/apps/datahub.html

Inspire by Opendata catalogs (CKAN, Opendatasoft), the Hub will host geo and non-geo dataset. It will provide dataviz tool and focuses the experience on the dataset instead of on the metadata.

## How to run it

The Datahub application is available as a docker image or as a ZIP archive.

### With docker

The docker image is `geonetwork/geonetwork-ui-datahub`.

To run it on the 8080 port with a custom GN4 API url and proxy path, use:

```bash
$ docker run -p 8080:80 \
-e GN4_API_URL=https://gn4.custom/geonetwork/srv/api \
-e PROXY_PATH=/proxy?url= \
geonetwork/geonetwork-ui-datahub
```

Notice how the `GN4_API_URL` and `PROXY_PATH` variables are used to override any values present in the app configuration file.
**This override will happen everytime the docker container is started.**

The application will be available on http://localhost:8080/datahub/.

#### Specifying a custom configuration file

If the `GN4_API_URL` and `PROXY_PATH` environment variables are not enough and you want to specify a full configuration file,
you can do so like this:

```bash
# this assumes a file named `default.toml` is located in the /home/user/custom-conf directory:
$ docker run -p 8080:80 \
-v /home/user/custom-conf:/conf \
geonetwork/geonetwork-ui-datahub
```

If a file named `default.toml` is found in the `/conf` folder _of the app container_ at startup, it will be used by the application.

You can specify a different directory to look for the `default.toml` file using the `CONFIG_DIRECTORY_OVERRIDE` env variable, like so:

```bash
# this assumes a file named `default.toml` is located in the /home/user/custom-conf directory:
$ docker run -p 8080:80 \
-v /home/user/custom-conf:/some/random/path \
-e CONFIG_DIRECTORY_OVERRIDE=/some/random/path \
geonetwork/geonetwork-ui-datahub
```

This can be useful when dealing with existing volumes having their own directory structure.

#### Adding custom assets to the docker container

Any file found in the `/assets` folder _of the app container_ at startup will be copied along with the other assets already present. Existing assets with conflicting names will be
replaced. Directory structure in the `/assets` folder will be preserved.

For each image file present in the copied assets, a [preload link](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload) will be created in the `index.html` file of the application. This will help reducing the
time to first significant draw for new visitors, especially for header backgrounds and the like.

You can specify a different directory to look for the custom assets using the `ASSETS_DIRECTORY_OVERRIDE` env variable, like so:

```bash
# custom assets are located in the /home/user/my-assets directory:
$ docker run -p 8080:80 \
-v /home/user/my-assets:/some/random/path \
-e ASSETS_DIRECTORY_OVERRIDE=/some/random/path \
geonetwork/geonetwork-ui-datahub
```

#### Adding custom scripts when deploying Datahub

You can deploy custom executable sh scripts when deploying a container by setting the environment variable `CUSTOM_SCRIPTS_DIRECTORY` pointing to a mounted volume.

It can be used to deploy custom header by example.

```bash
$ docker run -p 8080:80 \
-v /home/user/my-scripts:/some/random/path \
-e CUSTOM_SCRIPTS_DIRECTORY=/some/random/path \
geonetwork/geonetwork-ui-datahub
```

### From the ZIP archive

Each release of GeoNetwork-UI comes with ZIP archives of all applications: https://github.com/geonetwork/geonetwork-ui/releases

Download the Datahub archive and simply serve its contents using an HTTP server like Apache or NGINX.

## Configuration

See the [main README section for more info](../../README.md#application-configuration).

## Development

> For the following instructions, make sure you are using Node v16+ and that you ran `npm install` before anything else.
Executing:

```
npx nx serve datahub
```

will run `datahub` as an Angular application available on [localhost:4200](http://localhost:4200/).

### Proxy

The Datahub app can use a reverse proxy for querying WMS and WFS capabilities (thus working around
CORS limitations).

By default it is disabled in order not to hide those issues to the user.

You can specify a custom proxy path using the `proxy_path` setting in the `[global]` section of the app configuration file. The proxy is disabled when
no path is defined.

Please note that during development a proxy is provided by webpack on the `/dev-proxy?` url path. **It is
not used by default in the Datahub app, you will have to set it up yourself.**

## Building without Docker

Before building, remember to edit the configuration file in [`conf/default.toml`](../../conf/default.toml) to fit your deployment. It indicates the `geonetwork4_api_url` and an optional `proxy_path` to use.

You can build the datahub app using the geonetwork-ui build command:

```shell script
npm install
npx nx build datahub
```

The build artifact will be stored in the `dist/apps/datahub` directory, that can be deployed on a common webserver. Use the `--prod` flag for a production build.

The build also includes the app configuration file (`dist/apps/datahub/assets/configuration`). Do not modify the configuration file here, as it is overwritten on each build.

## Building with Docker

You can build a docker image of the Datahub application like so:

```bash
npm install
npx nx run datahub:docker-build
```

This will build a docker image with the tag `geonetwork/geonetwork-ui-datahub`.
See the [GeoNetwork-UI documentation](https://geonetwork.github.io/geonetwork-ui/main/docs/guide/run.html) to learn how to run and deploy the Datahub.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<ng-container *ngIf="organization; else orgNotFound">
<ng-container
*ngIf="currentOrganization$ | async as organization; else orgNotFound"
>
<ng-container *ngrxLet="lastPublishedDatasets$ as lastPublishedDatasets">
<div id="organization-details-container" class="flex flex-col gap-[72px]">
<div class="h-full container-lg mx-auto px-[25px] w-full">
Expand All @@ -21,7 +23,7 @@
>
<div
data-test="organizationLogo"
class="bg-white border border-[#d8d8d8] w-full h-[185px] rounded-lg p-[30px] -mt-28"
class="border-solid border border-gray-300 rounded-md bg-white h-[185px] overflow-hidden -mt-28"
>
<gn-ui-thumbnail
class="relative"
Expand Down Expand Up @@ -94,12 +96,7 @@
</div>

<div id="lastPublishedDatasets" data-test="lastPubliDatasets">
<ng-container
*ngIf="
!isSearchFacadeLoading && lastPublishedDatasets.length > 0;
else orgHasNoDataset
"
>
<ng-container *ngIf="!isSearchFacadeLoading">
<div
class="mb-4 flex flex-wrap gap-9 justify-center sm:justify-start px-[25px]"
data-test="orgPageLasPubDat"
Expand Down Expand Up @@ -134,16 +131,6 @@
<gn-ui-spinning-loader></gn-ui-spinning-loader>
</div>
</ng-container>

<ng-template
#orgHasNoDataset
*ngIf="!isSearchFacadeLoading"
data-test="orgHasNoDataset"
>
<gn-ui-error
[type]="ErrorType.ORGANIZATION_HAS_NO_DATASET"
></gn-ui-error>
</ng-template>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,21 @@ describe('OrganizationDetailsComponent', () => {

expect(orgPageLasPubDat?.children.length).toEqual(1)
})
})
})

it('should display the orgHasNodataset error component if the org has no dataset', () => {
results.next([])
fixture.detectChanges()

const orgHasNoDataset = getHTMLElement('lastPubliDatasets')

console.log(orgHasNoDataset?.outerHTML)

expect(orgHasNoDataset).toBeTruthy()
describe('when organization changes', () => {
const anotherOrg = someOrganizationsFixture()[1]
beforeEach(() => {
jest.clearAllMocks()
component.organization = anotherOrg
fixture.detectChanges()
})
it('updates the search filters', () => {
expect(searchFacade.setFilters).toHaveBeenCalledWith({
orgs: {
[anotherOrg.name]: true,
},
})
})
})
Expand Down
Loading

0 comments on commit f4757ff

Please sign in to comment.