Skip to content

Commit

Permalink
Add geo specific display on OGC service resources (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
maudetes authored Dec 2, 2024
1 parent 3e8a488 commit f989e20
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Current (in progress)

- Nothing yet
- Add geo specific display on OGC service resources [#609](https://github.com/datagouv/udata-front/pull/609)

## 6.0.5 (2024-11-29)

Expand Down
2 changes: 1 addition & 1 deletion udata_front/theme/gouvfr/datagouv-components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Current (in progress)

- Nothing yet
- Add geo specific display on OGC service resources [#609](https://github.com/datagouv/udata-front/pull/609)

## 2.0.2 (2024-11-19)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ export const ResourceBinary: StoryObj<typeof meta> = {
};


export const ResourceOGCService: StoryObj<typeof meta> = {
render: (args) => ({
components: { ResourceAccordion },
setup() {
return { args };
},
template: '<ResourceAccordion v-bind="args" />',
}),
args: { ...argsWithSchema, resource: { ...argsWithSchema.resource, format: "ogc:wms", title: "point_eau_qualito",
} },
};


export const ResourceUrl: StoryObj<typeof meta> = {
render: (args) => ({
components: { ResourceAccordion },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@
{{ $t('Visit') }}
</a>
</p>
<p class="fr-col-auto fr-ml-3v fr-m-0 z-2" v-else-if="ogcService">
<button
:id="resource.id + '-copy'"
:data-clipboard-text="resource.url"
class="fr-btn fr-btn--sm"
>
<span>
<OhVueIcon
:height="16"
:width="16"
name="ri-file-copy-line"
class="copy-icon fr-mr-2v"
/>
</span>
{{ t('Copy link') }}
</button>
</p>
<p class="fr-col-auto fr-ml-3v fr-m-0" v-else>
<a
:href="resource.latest"
Expand Down Expand Up @@ -171,6 +188,9 @@ import TabPanel from "../Tabs/TabPanel.vue";
import { trackEvent } from "../../helpers/matomo";
import CopyButton from "../CopyButton/CopyButton.vue";
import { getResourceFormatIconSvg } from "../../helpers/resources";
import { OhVueIcon } from 'oh-vue-icons';
const OGC_SERVICES_FORMATS = ['ogc:wfs', 'ogc:wms', 'wfs', 'wms'];
const props = withDefaults(defineProps<{
datasetId: string,
Expand All @@ -197,6 +217,8 @@ const hasPreview = computed(() => {
const format = computed(() => getResourceFormatIconSvg(props.resource) ? props.resource.format : t("File"))
const ogcService = computed(() => OGC_SERVICES_FORMATS.includes(props.resource.format))
const open = ref(props.expandedOnMount);
const toggle = () => {
open.value = ! open.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import archive from '../../../templates/svg/resources/archive.svg';
import documentation from '../../../templates/svg/resources/documentation.svg';
import link from '../../../templates/svg/resources/link.svg';
import table from '../../../templates/svg/resources/table.svg';
import map from '../../../templates/svg/resources/map.svg';
import globe from '../../../templates/svg/resources/globe.svg';

export function getResourceFormatIconSvg(resource: Resource): string | null {
switch (resource.format?.trim()?.toLowerCase()) {
Expand All @@ -25,7 +27,6 @@ export function getResourceFormatIconSvg(resource: Resource): string | null {
case 'gpx':
case 'shx':
case 'ovr':
case 'geojson':
case 'gpkg':
case 'grib2':
case 'dbf':
Expand Down Expand Up @@ -60,6 +61,13 @@ export function getResourceFormatIconSvg(resource: Resource): string | null {
case 'xlsx':
case 'parquet':
return table;
case 'geojson':
return map;
case 'ogc:wfs':
case 'ogc:wms':
case 'wfs':
case 'wms':
return globe;
default:
return null;
}
Expand Down
4 changes: 4 additions & 0 deletions udata_front/theme/gouvfr/templates/svg/resources/globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions udata_front/theme/gouvfr/templates/svg/resources/map.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f989e20

Please sign in to comment.