Skip to content

Commit

Permalink
feat: Ajout du nom du service à partir de son type (WMS-VECTOR => Web…
Browse files Browse the repository at this point in the history
… Map Service Vecteur ...)
  • Loading branch information
pprev94 committed Oct 24, 2023
1 parent de361df commit 1583e34
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { useQueryClient } from "@tanstack/react-query";
import { FC } from "react";
import { createPortal } from "react-dom";
import { symToStr } from "tsafe/symToStr";

import api from "../../../../api";
import MenuList from "../../../../components/Utils/MenuList";
import functions from "../../../../functions";
import RQKeys from "../../../../modules/RQKeys";
import { routes } from "../../../../router/router";
import { Service } from "../../../../types/app";
import { offeringTypeDisplayName } from "../../../../utils";

const unpublishServiceConfirmModal = createModal({
id: "unpublish-service-confirm-modal",
Expand Down Expand Up @@ -41,17 +41,16 @@ const ServicesListItem: FC<ServicesListItemProps> = ({ service, datasheetName, d
return (
<>
<div key={service._id} className={fr.cx("fr-grid-row", "fr-grid-row--middle", "fr-mt-2v")}>
<div className={fr.cx("fr-col")}>
<div className={fr.cx("fr-col", "fr-col-md-4")}>
<div className={fr.cx("fr-grid-row", "fr-grid-row--middle")}>
<Button iconId="ri-add-box-fill" title="Voir les données liées" className={fr.cx("fr-mr-2v")} />
{service.configuration.name}
</div>
</div>

<div className={fr.cx("fr-col")}>
<div className={fr.cx("fr-col", "fr-col-md-8")}>
<div className={fr.cx("fr-grid-row", "fr-grid-row--right", "fr-grid-row--middle")}>
{/* TODO : afficher le bon type de service */}
<Badge>Web Feature Service</Badge>
<Badge>{offeringTypeDisplayName(service.type)}</Badge>
<p className={fr.cx("fr-m-auto", "fr-mr-2v")}>
{service?.configuration?.last_event?.date && functions.date.format(service?.configuration?.last_event?.date)}
</p>
Expand Down
26 changes: 25 additions & 1 deletion assets/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import charsets from "./data/charset_list.json";
// Langues iso639-2
// https://github.com/haliaeetus/iso-639/blob/master/data/iso_639-2.json
import langs from "./data/iso_639-2.json";
import { OfferingDetailResponseDtoTypeEnum } from "./types/entrepot";

export type LanguageType = {
language: string;
Expand Down Expand Up @@ -93,4 +94,27 @@ const decodeContentRange = (contentRange: string): ContentRangeType => {
return { first: parseInt(parts[0], 10), last: parseInt(parts[1], 10), total: total };
};

export { getInspireKeywords, getLanguages, charsets, removeDiacritics, regex, decodeContentRange };
const offeringTypeDisplayName = (type: OfferingDetailResponseDtoTypeEnum): string => {
switch (type) {
case "WMS-VECTOR":
return "Web Map Service Vecteur";
case "WFS":
return "Web Feature Service";
case "WFS-INSPIRE":
return "Web Feature Service Inspire";
case "WMTS-TMS":
return "Web Map Tile Service - Tile Map Service";
case "WMS-RASTER":
return "Web Map Service Raster";
case "DOWNLOAD":
return "Service de Téléchargement";
case "ITINERARY-ISOCURVE":
return "Service de calcul d'itinéraire / isochrone";
case "ALTIMETRY":
return "Service d'altimétrie";
default:
return "";
}
};

export { getInspireKeywords, getLanguages, charsets, removeDiacritics, regex, decodeContentRange, offeringTypeDisplayName };
2 changes: 1 addition & 1 deletion src/Controller/Api/DatasheetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getDetailed(string $datastoreId, string $datasheetName): JsonRes
$data = $this->getBasicInfo($datastoreId, $datasheetName);

// recherche de services (configuration et offering)
$storedDataList = array_merge($vectorDbList/* autres données */);
$storedDataList = array_merge($vectorDbList, $pyramidList);
$services = $this->getServices($datastoreId, $storedDataList);

return $this->json([
Expand Down

0 comments on commit 1583e34

Please sign in to comment.