From d4c59ce44433847218543f1333ddf7a77562ecdd Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Wed, 19 Apr 2023 14:03:26 -0400 Subject: [PATCH 01/49] Added Get services list button --- .../catalog-library.component.html | 10 ++++ .../catalog-library.component.scss | 6 ++ .../catalog-library.component.ts | 55 ++++++++++++++++++- packages/geo/src/locale/en.geo.json | 3 +- packages/geo/src/locale/fr.geo.json | 3 +- 5 files changed, 74 insertions(+), 3 deletions(-) diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.html b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.html index 1426a5cab2..e179611a3b 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.html +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.html @@ -22,3 +22,13 @@ +
+ +
diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss index d2b3731e5a..2c1386ef57 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss @@ -7,3 +7,9 @@ igo-list { display: flex; margin: 30px 0; } + +.btnGetCatalogList { + justify-content: center; + display: flex; + margin: 30px 0; +} diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index 0e9fa09215..defcc97f01 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -18,7 +18,10 @@ import { Md5 } from 'ts-md5'; import { CapabilitiesService } from '../../datasource'; import { IgoMap } from '../../map'; import { standardizeUrl } from '../../utils/id-generator'; + import { Catalog } from '../shared/catalog.abstract'; +import { CatalogItem } from '../shared/catalog.interface'; +import { CatalogService } from '../shared/catalog.service'; import { AddCatalogDialogComponent } from './add-catalog-dialog.component'; /** @@ -73,7 +76,8 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { private capabilitiesService: CapabilitiesService, private messageService: MessageService, private storageService: StorageService, - private dialog: MatDialog + private dialog: MatDialog, + private catalogService: CatalogService ) {} /** @@ -226,4 +230,53 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { this.addCatalog(catalog); }); } + + getCatalogList(){ + console.log("gatCatalogList() accessed"); + /*console.log("store", this.store); + console.log("store.entities$", this.store.entities$); + //let myEntities = this.store.entities$.subscribe(); + let myEntities = this.store.entities$.subscribe((newEntity)=>{ + console.log("new entity", newEntity) + }); + console.log("myEntities", myEntities); + console.log(this.store.entities$.getValue()); + console.log(this.store.entities$.value);*/ + + + + + //const ca = this.store.entities$.getValue()[0] + + + /* + this.catalogService.loadCatalogItems(ca) + .subscribe((items: CatalogItem[]) => { + console.log(items) + });*/ + + + + // id | url_igo | source | index | layer | minscaledenom | maxscaledenom | extern | catalog | sort_s | parent | sort_p | title | abstract | ressource + + const listeCatalog = new Document; + + for(var ca of this.store.entities$.getValue()){ + this.catalogService.loadCatalogItems(ca) + .subscribe((items: CatalogItem[]) => { + console.log(items) + items.map(item=>{ + console.log(item) + }); + + + + + }); + } + /* + var a; + a.msSaveBlob + */ + } } diff --git a/packages/geo/src/locale/en.geo.json b/packages/geo/src/locale/en.geo.json index 38d1ef796f..7cdb92937e 100644 --- a/packages/geo/src/locale/en.geo.json +++ b/packages/geo/src/locale/en.geo.json @@ -27,7 +27,8 @@ "message": "The catalog is already contained in the list." }, "library.addTitle": "Adding a catalog", - "library.addBtn": "Add a catalog" + "library.addBtn": "Add a catalog", + "library.getCatalogList": "Get the catalog services list" }, "clickOnMap": { "clickedFeature": "Clicked Feature" diff --git a/packages/geo/src/locale/fr.geo.json b/packages/geo/src/locale/fr.geo.json index 8dad2ce181..dcbd37221c 100644 --- a/packages/geo/src/locale/fr.geo.json +++ b/packages/geo/src/locale/fr.geo.json @@ -27,7 +27,8 @@ "message": "Le catalogue à ajouter est déjà dans la liste" }, "library.addTitle": "Ajout d'un catalogue", - "library.addBtn": "Ajouter un catalogue" + "library.addBtn": "Ajouter un catalogue", + "library.getCatalogList": "Obtenir la liste des services du catalogue" }, "clickOnMap": { "clickedFeature": "Entités cliquées" From b3e3b570781813035bf8ebe015017acdc946d260 Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Mon, 1 May 2023 11:47:35 -0400 Subject: [PATCH 02/49] Continue getCatalogList --- .../catalog-library.component.ts | 95 +++++++++++-------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index defcc97f01..4ead85e352 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -233,50 +233,63 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { getCatalogList(){ console.log("gatCatalogList() accessed"); - /*console.log("store", this.store); - console.log("store.entities$", this.store.entities$); - //let myEntities = this.store.entities$.subscribe(); - let myEntities = this.store.entities$.subscribe((newEntity)=>{ - console.log("new entity", newEntity) - }); - console.log("myEntities", myEntities); - console.log(this.store.entities$.getValue()); - console.log(this.store.entities$.value);*/ - - - - - //const ca = this.store.entities$.getValue()[0] - - - /* - this.catalogService.loadCatalogItems(ca) - .subscribe((items: CatalogItem[]) => { - console.log(items) - });*/ - - - // id | url_igo | source | index | layer | minscaledenom | maxscaledenom | extern | catalog | sort_s | parent | sort_p | title | abstract | ressource - - const listeCatalog = new Document; - - for(var ca of this.store.entities$.getValue()){ - this.catalogService.loadCatalogItems(ca) - .subscribe((items: CatalogItem[]) => { - console.log(items) - items.map(item=>{ - console.log(item) + /*id: string; + title: string; + type?: CatalogItemType; + address?: string; + externalProvider?:*/ + //const listCatalog = new Document; + let listCatalog = []; + let index = 0; + let bufferArray = []; + for (var ca of this.store.entities$.getValue()) { + this.catalogService.loadCatalogItems(ca) + .subscribe((items) => { + //console.log(items); + /*listCatalog[index] = items; + index++;*/ + items.map(item => { + bufferArray = []; + bufferArray.push(item.id); + bufferArray.push(item.type); + bufferArray.push(item.title); + bufferArray.push(item.address); + bufferArray.push(item.externalProvider); + //listCatalog[index] = item; + listCatalog[index] = bufferArray; + index++; + }); }); - - - - - }); } + console.log("listCatalog", listCatalog); + + //const mainCSV = listCatalog.map(row => row.join(',')).join('\n'); + //const mainCSV = listCatalog.map(row => row.join(',')).join('\n'); + //Array.from(listCatalog) + let csvContent = "data:text/csv;charset=utf-8," + listCatalog.map(e => e.join(",")).join("\n"); + + //var myRows = []; + //myRows = clipboard["copy"].concat(myRows) + //var myObj = { "myrows": myRows }; + + +/* + var saveText = function(filename, output){ + const headersCSV = Object.keys(output[0]).join(";"); + const contentCSV = listCatalog.map(r => Object.values(r).join(";")); + const textCVS = [headersCSV].concat(contentCSV).join("\\"); + + var universalBOM = "\\uFEFF"; + var a = document.createElement('a'); + //a.setAttribute('href', 'data:text/json;charset=utf-8,'+encodeURIComponent(universalBOM+output)); + a.setAttribute('href', 'data:text/csv;charset=utf-8,'+encodeURIComponent(universalBOM+textCVS)); + a.setAttribute('download', filename); + a.click() + + };*/ /* - var a; - a.msSaveBlob - */ + const mainCSV = listCatalog.map(row => row.join(',')).join('\n'); + console.log(mainCSV);*/ } } From eb5d0a548f1fbeaadd57aa976aa918de6c7a39bb Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Mon, 1 May 2023 14:01:53 -0400 Subject: [PATCH 03/49] Writes a CSV file --- .../catalog-library.component.ts | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index 4ead85e352..28eb295b64 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -269,13 +269,38 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { //Array.from(listCatalog) let csvContent = "data:text/csv;charset=utf-8," + listCatalog.map(e => e.join(",")).join("\n"); - //var myRows = []; - //myRows = clipboard["copy"].concat(myRows) - //var myObj = { "myrows": myRows }; + var encodedUri = encodeURI(csvContent); + var link = document.createElement("a"); + link.setAttribute("href", encodedUri); + link.setAttribute("download", "demo.csv"); + document.body.appendChild(link); // Required for FF + link.click(); // This will download the data file named "my_data.csv". + + document.body.removeChild(link); + + + + + + + + + + -/* - var saveText = function(filename, output){ + + + + + + + + + //var myRows = []; + //myRows = Clipboard["copy"].concat(myRows) + + /*var saveText = function(filename, output){ const headersCSV = Object.keys(output[0]).join(";"); const contentCSV = listCatalog.map(r => Object.values(r).join(";")); const textCVS = [headersCSV].concat(contentCSV).join("\\"); @@ -283,11 +308,12 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { var universalBOM = "\\uFEFF"; var a = document.createElement('a'); //a.setAttribute('href', 'data:text/json;charset=utf-8,'+encodeURIComponent(universalBOM+output)); - a.setAttribute('href', 'data:text/csv;charset=utf-8,'+encodeURIComponent(universalBOM+textCVS)); a.setAttribute('download', filename); a.click() };*/ + + //saveText( Clipboard["file"]+".csv", listCatalog ); /* const mainCSV = listCatalog.map(row => row.join(',')).join('\n'); console.log(mainCSV);*/ From d4a07008a27775b808c500c1ddb85ed70a32cf41 Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Mon, 1 May 2023 14:25:19 -0400 Subject: [PATCH 04/49] Manage to write special characters --- .../lib/catalog/catalog-library/catalog-library.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index 28eb295b64..5afab9044e 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -267,11 +267,11 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { //const mainCSV = listCatalog.map(row => row.join(',')).join('\n'); //const mainCSV = listCatalog.map(row => row.join(',')).join('\n'); //Array.from(listCatalog) - let csvContent = "data:text/csv;charset=utf-8," + listCatalog.map(e => e.join(",")).join("\n"); + let csvContent = listCatalog.map(e => e.join(",")).join("\n"); var encodedUri = encodeURI(csvContent); var link = document.createElement("a"); - link.setAttribute("href", encodedUri); + link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); link.setAttribute("download", "demo.csv"); document.body.appendChild(link); // Required for FF From d3338a3db5af6516fedc2eacba2593831ae48bdb Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Fri, 5 May 2023 10:21:42 -0400 Subject: [PATCH 05/49] Generate csv with columns --- .../catalog-library.component.ts | 119 +++++------------- 1 file changed, 34 insertions(+), 85 deletions(-) diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index 5afab9044e..b7b28e4fb4 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -12,14 +12,15 @@ import { MatDialog } from '@angular/material/dialog'; import { EntityStore } from '@igo2/common'; import { MessageService, StorageService } from '@igo2/core'; import { ObjectUtils } from '@igo2/utils'; -import { Observable, Subscription } from 'rxjs'; -import { catchError } from 'rxjs/operators'; +import { forkJoin, Observable, Subscription } from 'rxjs'; +import { catchError, switchMap } from 'rxjs/operators'; import { Md5 } from 'ts-md5'; import { CapabilitiesService } from '../../datasource'; import { IgoMap } from '../../map'; import { standardizeUrl } from '../../utils/id-generator'; import { Catalog } from '../shared/catalog.abstract'; +import { CatalogItemType } from '../shared/catalog.enum'; import { CatalogItem } from '../shared/catalog.interface'; import { CatalogService } from '../shared/catalog.service'; import { AddCatalogDialogComponent } from './add-catalog-dialog.component'; @@ -233,89 +234,37 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { getCatalogList(){ console.log("gatCatalogList() accessed"); - // id | url_igo | source | index | layer | minscaledenom | maxscaledenom | extern | catalog | sort_s | parent | sort_p | title | abstract | ressource - /*id: string; - title: string; - type?: CatalogItemType; - address?: string; - externalProvider?:*/ - //const listCatalog = new Document; - let listCatalog = []; - let index = 0; - let bufferArray = []; - for (var ca of this.store.entities$.getValue()) { - this.catalogService.loadCatalogItems(ca) - .subscribe((items) => { - //console.log(items); - /*listCatalog[index] = items; - index++;*/ - items.map(item => { - bufferArray = []; - bufferArray.push(item.id); - bufferArray.push(item.type); - bufferArray.push(item.title); - bufferArray.push(item.address); - bufferArray.push(item.externalProvider); - //listCatalog[index] = item; - listCatalog[index] = bufferArray; - index++; - }); - }); - } - console.log("listCatalog", listCatalog); - - //const mainCSV = listCatalog.map(row => row.join(',')).join('\n'); - //const mainCSV = listCatalog.map(row => row.join(',')).join('\n'); - //Array.from(listCatalog) - let csvContent = listCatalog.map(e => e.join(",")).join("\n"); - - var encodedUri = encodeURI(csvContent); - var link = document.createElement("a"); - link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); - link.setAttribute("download", "demo.csv"); - document.body.appendChild(link); // Required for FF - - link.click(); // This will download the data file named "my_data.csv". - - document.body.removeChild(link); - - - - - - - - - + // id | url_igo | source | index | layer | minscaledenom | maxscaledenom | extern | catalog | sort_s | parent | sort_p | title | abstract | ressource + /*id: string; + title: string; + type?: CatalogItemType; + address?: string; + externalProvider?:*/ + //const listCatalog = new Document; + let listCatalog = []; + let index = 0; + let bufferArray = [["id", "type", "title", "address"]]; + this.store.entities$.pipe(switchMap(catalogs => { + return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca))); + })).subscribe(res => { + //console.log('res', res); + + res.forEach(element=>{ + element.forEach(item=>bufferArray.push(Object.keys(item).map(key => item[key]))) + //bufferArray.push(Object.keys(element).map(key => element[key])); + }); + + console.log("bufferArray", bufferArray); + let csvContent = bufferArray.map(e => e.join(";")).join("\n"); + //console.log("csvContent", csvContent); + var encodedUri = encodeURI(csvContent); + var link = document.createElement("a"); + link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); + link.setAttribute("download", "demo.csv"); + document.body.appendChild(link); // Required for FF + link.click(); // This will download the data file named "my_data.csv". + document.body.removeChild(link); - - - - - - - - - - //var myRows = []; - //myRows = Clipboard["copy"].concat(myRows) - - /*var saveText = function(filename, output){ - const headersCSV = Object.keys(output[0]).join(";"); - const contentCSV = listCatalog.map(r => Object.values(r).join(";")); - const textCVS = [headersCSV].concat(contentCSV).join("\\"); - - var universalBOM = "\\uFEFF"; - var a = document.createElement('a'); - //a.setAttribute('href', 'data:text/json;charset=utf-8,'+encodeURIComponent(universalBOM+output)); - a.setAttribute('download', filename); - a.click() - - };*/ - - //saveText( Clipboard["file"]+".csv", listCatalog ); - /* - const mainCSV = listCatalog.map(row => row.join(',')).join('\n'); - console.log(mainCSV);*/ + }); } } From 2b134af9f77cd8b3237198d995673897af78e3f2 Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Mon, 8 May 2023 15:15:27 -0400 Subject: [PATCH 06/49] Added more informations to the csv --- .../catalog-library.component.ts | 80 ++++++++++++++++--- 1 file changed, 67 insertions(+), 13 deletions(-) diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index b7b28e4fb4..83487648d4 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -21,7 +21,7 @@ import { standardizeUrl } from '../../utils/id-generator'; import { Catalog } from '../shared/catalog.abstract'; import { CatalogItemType } from '../shared/catalog.enum'; -import { CatalogItem } from '../shared/catalog.interface'; +import { CatalogItem, CatalogItemGroup } from '../shared/catalog.interface'; import { CatalogService } from '../shared/catalog.service'; import { AddCatalogDialogComponent } from './add-catalog-dialog.component'; @@ -235,23 +235,73 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { getCatalogList(){ console.log("gatCatalogList() accessed"); // id | url_igo | source | index | layer | minscaledenom | maxscaledenom | extern | catalog | sort_s | parent | sort_p | title | abstract | ressource - /*id: string; - title: string; - type?: CatalogItemType; - address?: string; - externalProvider?:*/ - //const listCatalog = new Document; let listCatalog = []; let index = 0; - let bufferArray = [["id", "type", "title", "address"]]; + let bufferArray = [["id", "type", "title", "address", "external provider"]]; + var dataArray = []; this.store.entities$.pipe(switchMap(catalogs => { return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca))); })).subscribe(res => { - //console.log('res', res); - - res.forEach(element=>{ - element.forEach(item=>bufferArray.push(Object.keys(item).map(key => item[key]))) - //bufferArray.push(Object.keys(element).map(key => element[key])); + console.log('res', res); + //element = catalogItem[] + res.forEach(element=>{ + element.forEach(catalogItemGroup=>{ + var catalogItems: CatalogItemGroup = catalogItemGroup; + if(catalogItems.items){ + catalogItems.items.forEach(item=>{ + dataArray = []; + var data = Object.keys(item).map(key => item[key]); + console.log(data); + for(var a of data){ + dataArray.push(a);} + //dataArray.push(data); // itérer tous les items d'un gouvouvert + var metadata = data[data.length - 1]; + //(metadata) + console.log() + for(var b of Object.keys(metadata).map(key => metadata[key])){ + dataArray.push(b); + } + + + // ajout metadata + + // sourceoptions + + // layer type data + + //dataArray.push(Object.keys(metadata).map(key => metadata[key])); + //bufferArray.push(Object.keys(item[length-1]).map(key => item[length-1][key])); + //console.log(Object.keys(item[length-1][length-1]).map(key => item[length-1][length-1][key])); + //si item.options + /*if(item.options){ // s'il y a un truc defined comme dernier element de l'item )S'il y a des metadata + var metaDataArray = Object.keys(item[item.length-1]).map(key => item[item.length-1][key]); + metaDataArray.forEach(value=>bufferArray.push(value)); + + }*/ + }); + + // ajouter metadata + + //sourceOptions + + //bufferArray.push(Object.keys(catalogItems.items[0]).map(key => catalogItems.items[0][key])); + } + else{ + bufferArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); + } + + + + //Faire en sorte de refaire un forEach pour les items. Ceci push les Catégories dans GouvOuvert. Il faut les item d'item + //var myItem = Object.keys(catalogItemGroup).map(key=>catalogItemGroup[key]); + //myItem[myItem.length-1]; + //bufferArray.push(Object.keys(myItem[myItem.length-1]).map(key => myItem[myItem.length-1][key])) + //console.log("test", myItem[myItem.length-1]); + + + // ligne pour tout ce qui est dans ex: GouvOuvert + //bufferArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])) + }); }); console.log("bufferArray", bufferArray); @@ -266,5 +316,9 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { document.body.removeChild(link); }); + + + + } } From 4233f9152317a096c43851c850c12cd2a8042caa Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Wed, 10 May 2023 14:36:36 -0400 Subject: [PATCH 07/49] Added Metadata to the csv --- .../catalog-library.component.ts | 149 ++++++++---------- 1 file changed, 65 insertions(+), 84 deletions(-) diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index 83487648d4..ae3c3beece 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -234,91 +234,72 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { getCatalogList(){ console.log("gatCatalogList() accessed"); - // id | url_igo | source | index | layer | minscaledenom | maxscaledenom | extern | catalog | sort_s | parent | sort_p | title | abstract | ressource - let listCatalog = []; - let index = 0; - let bufferArray = [["id", "type", "title", "address", "external provider"]]; - var dataArray = []; - this.store.entities$.pipe(switchMap(catalogs => { - return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca))); - })).subscribe(res => { - console.log('res', res); - //element = catalogItem[] - res.forEach(element=>{ - element.forEach(catalogItemGroup=>{ - var catalogItems: CatalogItemGroup = catalogItemGroup; - if(catalogItems.items){ - catalogItems.items.forEach(item=>{ - dataArray = []; - var data = Object.keys(item).map(key => item[key]); - console.log(data); - for(var a of data){ - dataArray.push(a);} - //dataArray.push(data); // itérer tous les items d'un gouvouvert - var metadata = data[data.length - 1]; - //(metadata) - console.log() - for(var b of Object.keys(metadata).map(key => metadata[key])){ - dataArray.push(b); - } - - - // ajout metadata - - // sourceoptions - - // layer type data - - //dataArray.push(Object.keys(metadata).map(key => metadata[key])); - //bufferArray.push(Object.keys(item[length-1]).map(key => item[length-1][key])); - //console.log(Object.keys(item[length-1][length-1]).map(key => item[length-1][length-1][key])); - //si item.options - /*if(item.options){ // s'il y a un truc defined comme dernier element de l'item )S'il y a des metadata - var metaDataArray = Object.keys(item[item.length-1]).map(key => item[item.length-1][key]); - metaDataArray.forEach(value=>bufferArray.push(value)); - - }*/ - }); - - // ajouter metadata - - //sourceOptions - - //bufferArray.push(Object.keys(catalogItems.items[0]).map(key => catalogItems.items[0][key])); - } - else{ - bufferArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); - } - - - - //Faire en sorte de refaire un forEach pour les items. Ceci push les Catégories dans GouvOuvert. Il faut les item d'item - //var myItem = Object.keys(catalogItemGroup).map(key=>catalogItemGroup[key]); - //myItem[myItem.length-1]; - //bufferArray.push(Object.keys(myItem[myItem.length-1]).map(key => myItem[myItem.length-1][key])) - //console.log("test", myItem[myItem.length-1]); - - - // ligne pour tout ce qui est dans ex: GouvOuvert - //bufferArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])) + console.log("gatCatalogList() accessed"); + // id | url_igo | source | index | layer | minscaledenom | maxscaledenom | extern | catalog | sort_s | parent | sort_p | title | abstract | ressource + /*id: string; + title: string; + type?: CatalogItemType; + address?: string; + externalProvider?:*/ + //const listCatalog = new Document; + let listCatalog = []; + let index = 0; + let bufferArray = [["id", "type", "title", "address", "external provider"]]; + var dataArray = []; + this.store.entities$.pipe(switchMap(catalogs => { + return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca))); + })).subscribe(res => { + console.log('res', res); + res.forEach(element => { + element.forEach(catalogItemGroup => { + + var catalogItems: CatalogItemGroup = catalogItemGroup; + if (catalogItems.items) { + catalogItems.items.forEach(item => { + dataArray = []; + + // max res, minRes, metadata, tooltip, sourceOptions + var data = Object.keys(item).map(key => item[key]); + //console.log(data); + for(var a of data){ + if(a === data[data.length - 1]){ + var metadata = Object.keys(a).map(key => a[key]); + console.log(metadata.length); + for(var yolo of metadata){ + //console.log("yolo",yolo, typeof yolo, yolo) + if(typeof yolo === 'object'){ + for(var metadata2 of Object.keys(yolo).map(key => yolo[key])){ + //console.log(metadata2); + dataArray.push(metadata2); + } + } + else + dataArray.push(yolo); + } + } + else{ + dataArray.push(a); + } + } + }); + bufferArray.push(dataArray); + } + else { + dataArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); + } }); - }); - - console.log("bufferArray", bufferArray); - let csvContent = bufferArray.map(e => e.join(";")).join("\n"); - //console.log("csvContent", csvContent); - var encodedUri = encodeURI(csvContent); - var link = document.createElement("a"); - link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); - link.setAttribute("download", "demo.csv"); - document.body.appendChild(link); // Required for FF - link.click(); // This will download the data file named "my_data.csv". - document.body.removeChild(link); - + }); - - - - + console.log("bufferArray", bufferArray); + let csvContent = bufferArray.map(e => e.join(";")).join("\n"); + //console.log("csvContent", csvContent); + var encodedUri = encodeURI(csvContent); + var link = document.createElement("a"); + link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); + link.setAttribute("download", "demo.csv"); + document.body.appendChild(link); // Required for FF + link.click(); // This will download the data file named "my_data.csv". + document.body.removeChild(link); + }); } } From e94d0ea25dfdabad84d30b9bc8d3ac4a8a0d1c59 Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Thu, 18 May 2023 14:32:38 -0400 Subject: [PATCH 08/49] Now manages all items. Handles WMTS layers. --- .../catalog-library.component.ts | 204 ++++++++++++++---- 1 file changed, 162 insertions(+), 42 deletions(-) diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index ae3c3beece..be7de2400c 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -232,19 +232,24 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { }); } - getCatalogList(){ - console.log("gatCatalogList() accessed"); + private getItemList(itemObject){ + var returnItemObjectList = []; + for(var itemObjectList of Object.keys(itemObject).map(key => itemObject[key])){ + if(typeof itemObjectList === 'object'){ + returnItemObjectList.push(this.getItemList(itemObjectList)); + }else + returnItemObjectList.push(itemObjectList); + } + return returnItemObjectList; + } + + getCatalogList2(){ console.log("gatCatalogList() accessed"); // id | url_igo | source | index | layer | minscaledenom | maxscaledenom | extern | catalog | sort_s | parent | sort_p | title | abstract | ressource - /*id: string; - title: string; - type?: CatalogItemType; - address?: string; - externalProvider?:*/ - //const listCatalog = new Document; - let listCatalog = []; - let index = 0; - let bufferArray = [["id", "type", "title", "address", "external provider"]]; + + let bufferArray = [["id", "Group type", "Group title", "Group address", "external provider", + "item id", "item type", "item title", "item address", "external provider", "MaxRes", "MinRes", "Metadata url", + "Extern", "abstract", "type", "source type", "source url", "optionsFromCapabilities", "params"]]; var dataArray = []; this.store.entities$.pipe(switchMap(catalogs => { return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca))); @@ -252,47 +257,69 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { console.log('res', res); res.forEach(element => { element.forEach(catalogItemGroup => { - - var catalogItems: CatalogItemGroup = catalogItemGroup; - if (catalogItems.items) { - catalogItems.items.forEach(item => { - dataArray = []; - - // max res, minRes, metadata, tooltip, sourceOptions - var data = Object.keys(item).map(key => item[key]); - //console.log(data); - for(var a of data){ - if(a === data[data.length - 1]){ - var metadata = Object.keys(a).map(key => a[key]); - console.log(metadata.length); - for(var yolo of metadata){ - //console.log("yolo",yolo, typeof yolo, yolo) - if(typeof yolo === 'object'){ - for(var metadata2 of Object.keys(yolo).map(key => yolo[key])){ - //console.log(metadata2); - dataArray.push(metadata2); - } - } + var itemGroup: CatalogItemGroup = catalogItemGroup; + if (itemGroup.items) { + itemGroup.items.forEach(item => { + dataArray = []; + //push data de catalogItemGroup + var dataCatalogGroup = Object.keys(catalogItemGroup).map(key => catalogItemGroup[key]); + for(var dataCatalogGroupUnique of dataCatalogGroup){ + if((typeof dataCatalogGroupUnique != 'object') && (dataCatalogGroupUnique != undefined)){ + dataArray.push(dataCatalogGroupUnique); + } + } + // max res, minRes, metadata, tooltip, sourceOptions + var data = Object.keys(item).map(key => item[key]); + for (var a of data) { + if (typeof a === 'object') { + var metadata = Object.keys(a).map(key => a[key]); + //Metadata and SourceOptions + for (var metadataList of metadata) { + if (typeof metadataList === 'object') { + + //ajout de metadata et sourceoptions spécifiquement + //metadata + if(metadataList.abstract || metadataList.extern){ + if(metadataList.url) + dataArray.push(metadataList.url, metadataList.extern, metadataList.abstract, metadataList.type); else - dataArray.push(yolo); + dataArray.push(null, metadataList.extern, metadataList.abstract, metadataList.type); + } + + //sourceOptions + if(metadataList.optionsFromCapabilities || metadataList.params){ + dataArray.push(metadataList.type, metadataList.url, metadataList.optionsFromCapabilities); + //params + //var params = Object.keys(metadataList.params).map(key => metadataList.params[key]); + for(var params of (Object.keys(metadataList.params).map(key => metadataList.params[key]))){ + dataArray.push(params); + } + } + + /* + for (var metadataItem of Object.keys(metadataList).map(key => metadataList[key])) { + dataArray.push(metadataItem); + }*/ } - } - else{ - dataArray.push(a); - } + else + dataArray.push(metadataList); + }//Metadata and SourceOptions end } - }); - bufferArray.push(dataArray); + else { + dataArray.push(a); + } + } + }); + bufferArray.push(dataArray); } else { dataArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); } }); - }); console.log("bufferArray", bufferArray); + let csvContent = bufferArray.map(e => e.join(";")).join("\n"); - //console.log("csvContent", csvContent); var encodedUri = encodeURI(csvContent); var link = document.createElement("a"); link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); @@ -301,5 +328,98 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { link.click(); // This will download the data file named "my_data.csv". document.body.removeChild(link); }); - } +} + + getCatalogList() { + let bufferArray = [["id", "Group type", "Group title", "Group address", "external provider", + "item id", "item type", "item title", "item address", "external provider", "MaxRes", "MinRes", "Metadata url", + "Extern", "abstract", "type", "source type", "source url", "optionsFromCapabilities", "params"]]; + var dataArray = []; + this.store.entities$.pipe(switchMap(catalogs => { + return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca))); + })).subscribe(res => { + console.log('res', res); + res.forEach(element => { + element.forEach(catalogItemGroup => { + var itemGroup: CatalogItemGroup = catalogItemGroup; + if (itemGroup.items) { + itemGroup.items.forEach(item => { + + //à l'intérieur du array(22) Dans GouvOuvert + dataArray = []; + //push data de catalogItemGroup + var dataCatalogGroup = Object.keys(catalogItemGroup).map(key => catalogItemGroup[key]); + for (var dataCatalogGroupUnique of dataCatalogGroup) { + if ((typeof dataCatalogGroupUnique != 'object') && (dataCatalogGroupUnique != undefined)) { + dataArray.push(dataCatalogGroupUnique); + } + } + // max res, minRes, metadata, tooltip, sourceOptions + var data = Object.keys(item).map(key => item[key]); + for (var a of data) { // intérieur d'un item: address, external provider, id, options, title, type + if(a === 'a8401b172111523b6b8bc3285b49b19f'){ + console.log("s"); + } + if (typeof a === 'object') { // si c'est options + var options = Object.keys(a).map(key => a[key]); + for (var optionsObject of options) { + if(typeof optionsObject === 'object'){ + if (optionsObject.abstract || optionsObject.extern) { + //metadata + if (optionsObject.url) + dataArray.push(optionsObject.url, optionsObject.extern, optionsObject.abstract, optionsObject.type); + else + dataArray.push(null, optionsObject.extern, optionsObject.abstract, optionsObject.type); + } + else if (optionsObject.optionsFromCapabilities || optionsObject.params) { + //sourceOptions + if (optionsObject.url) + dataArray.push(optionsObject.type, optionsObject.url, optionsObject.optionsFromCapabilities, optionsObject.params); + else + dataArray.push(optionsObject.type, null, optionsObject.optionsFromCapabilities, optionsObject.params); + } + } + else + dataArray.push(optionsObject); // minRes, maxRes + } + + } //Metadata and SourceOptions end + else { + dataArray.push(a); + } + } + bufferArray.push(dataArray); + }); + } + else { + var itemGroupWMTS: any = itemGroup; + if(!itemGroupWMTS.options){ + dataArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); + bufferArray.push(dataArray); + } + else{ //wmts, items directement, avec options et + /*["id", "Group type", "Group title", "Group address", "external provider", + "item id", "item type", "item title", "item address", "external provider", "MaxRes", "MinRes", "Metadata url", + "Extern", "abstract", "type", "source type", "source url", "optionsFromCapabilities", "params"]*/ + dataArray = []; + dataArray.push(null, null, null, null, null, itemGroup.id, itemGroup.type, itemGroup.title, itemGroup.address, + null, null, null, null, itemGroupWMTS.options.metadata.extern, null, itemGroupWMTS.options.metadata.type, itemGroupWMTS.options.sourceOptions.type, + null, itemGroupWMTS.options.sourceOptions.optionsFromCapabilities, itemGroupWMTS.options.sourceOptions.params); + bufferArray.push(dataArray); + } + } + }); + }); + console.log("bufferArray", bufferArray); + + let csvContent = bufferArray.map(e => e.join(";")).join("\n"); + var encodedUri = encodeURI(csvContent); + var link = document.createElement("a"); + link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); + link.setAttribute("download", "demo.csv"); + document.body.appendChild(link); // Required for FF + link.click(); // This will download the data file named "my_data.csv". + document.body.removeChild(link); + }); +} } From 30ddcf88e776312a7c2b24473333ad4fceb63072 Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Tue, 23 May 2023 13:10:24 -0400 Subject: [PATCH 09/49] made it similar to end product --- .../catalog-library.component.ts | 204 ++++-------------- 1 file changed, 38 insertions(+), 166 deletions(-) diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index be7de2400c..9d35c32866 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -232,182 +232,54 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { }); } - private getItemList(itemObject){ - var returnItemObjectList = []; - for(var itemObjectList of Object.keys(itemObject).map(key => itemObject[key])){ - if(typeof itemObjectList === 'object'){ - returnItemObjectList.push(this.getItemList(itemObjectList)); - }else - returnItemObjectList.push(itemObjectList); - } - return returnItemObjectList; - } - - getCatalogList2(){ - console.log("gatCatalogList() accessed"); - // id | url_igo | source | index | layer | minscaledenom | maxscaledenom | extern | catalog | sort_s | parent | sort_p | title | abstract | ressource - - let bufferArray = [["id", "Group type", "Group title", "Group address", "external provider", - "item id", "item type", "item title", "item address", "external provider", "MaxRes", "MinRes", "Metadata url", - "Extern", "abstract", "type", "source type", "source url", "optionsFromCapabilities", "params"]]; + getCatalogList(){ + var catalogRank = 1; + let bufferArray = [["rang Catalog", "Nom de la couche - Catalogue", "Nom du groupe de couche - Catalogue", + "Nom de la thématique", "Gestionnaire du service", "URL (Intranet/Internet", "Nom du fichier - Service Web", + "Contexte/Thématique PlaniActifs", "Description de la donnée"]]; var dataArray = []; this.store.entities$.pipe(switchMap(catalogs => { return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca))); })).subscribe(res => { console.log('res', res); res.forEach(element => { - element.forEach(catalogItemGroup => { - var itemGroup: CatalogItemGroup = catalogItemGroup; - if (itemGroup.items) { - itemGroup.items.forEach(item => { + element.forEach((catalogItemGroup: CatalogItemGroup) => { + if (catalogItemGroup.items) { + catalogItemGroup.items.forEach((item: any) => { + //à l'intérieur du array(22) Dans GouvOuvert dataArray = []; - //push data de catalogItemGroup - var dataCatalogGroup = Object.keys(catalogItemGroup).map(key => catalogItemGroup[key]); - for(var dataCatalogGroupUnique of dataCatalogGroup){ - if((typeof dataCatalogGroupUnique != 'object') && (dataCatalogGroupUnique != undefined)){ - dataArray.push(dataCatalogGroupUnique); - } - } - // max res, minRes, metadata, tooltip, sourceOptions - var data = Object.keys(item).map(key => item[key]); - for (var a of data) { - if (typeof a === 'object') { - var metadata = Object.keys(a).map(key => a[key]); - //Metadata and SourceOptions - for (var metadataList of metadata) { - if (typeof metadataList === 'object') { - - //ajout de metadata et sourceoptions spécifiquement - //metadata - if(metadataList.abstract || metadataList.extern){ - if(metadataList.url) - dataArray.push(metadataList.url, metadataList.extern, metadataList.abstract, metadataList.type); - else - dataArray.push(null, metadataList.extern, metadataList.abstract, metadataList.type); - } - - //sourceOptions - if(metadataList.optionsFromCapabilities || metadataList.params){ - dataArray.push(metadataList.type, metadataList.url, metadataList.optionsFromCapabilities); - //params - //var params = Object.keys(metadataList.params).map(key => metadataList.params[key]); - for(var params of (Object.keys(metadataList.params).map(key => metadataList.params[key]))){ - dataArray.push(params); - } - } - - /* - for (var metadataItem of Object.keys(metadataList).map(key => metadataList[key])) { - dataArray.push(metadataItem); - }*/ - } - else - dataArray.push(metadataList); - }//Metadata and SourceOptions end - } - else { - dataArray.push(a); - } + var gestionnaire = "MTQ"; + if(item.externalProvider !== undefined){ + if(item.externalProvider === true) + gestionnaire = "Externe"; } - }); + dataArray.push(catalogRank, item.title, catalogItemGroup.address, "thématique", gestionnaire, item.options.sourceOptions.url, + item.options.sourceOptions.layer, "contexte/thematique planiactifs", item.options.metadata.abstract); bufferArray.push(dataArray); - } - else { - dataArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); - } - }); - }); - console.log("bufferArray", bufferArray); - - let csvContent = bufferArray.map(e => e.join(";")).join("\n"); - var encodedUri = encodeURI(csvContent); - var link = document.createElement("a"); - link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); - link.setAttribute("download", "demo.csv"); - document.body.appendChild(link); // Required for FF - link.click(); // This will download the data file named "my_data.csv". - document.body.removeChild(link); - }); -} - - getCatalogList() { - let bufferArray = [["id", "Group type", "Group title", "Group address", "external provider", - "item id", "item type", "item title", "item address", "external provider", "MaxRes", "MinRes", "Metadata url", - "Extern", "abstract", "type", "source type", "source url", "optionsFromCapabilities", "params"]]; - var dataArray = []; - this.store.entities$.pipe(switchMap(catalogs => { - return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca))); - })).subscribe(res => { - console.log('res', res); - res.forEach(element => { - element.forEach(catalogItemGroup => { - var itemGroup: CatalogItemGroup = catalogItemGroup; - if (itemGroup.items) { - itemGroup.items.forEach(item => { - - //à l'intérieur du array(22) Dans GouvOuvert - dataArray = []; - //push data de catalogItemGroup - var dataCatalogGroup = Object.keys(catalogItemGroup).map(key => catalogItemGroup[key]); - for (var dataCatalogGroupUnique of dataCatalogGroup) { - if ((typeof dataCatalogGroupUnique != 'object') && (dataCatalogGroupUnique != undefined)) { - dataArray.push(dataCatalogGroupUnique); - } - } - // max res, minRes, metadata, tooltip, sourceOptions - var data = Object.keys(item).map(key => item[key]); - for (var a of data) { // intérieur d'un item: address, external provider, id, options, title, type - if(a === 'a8401b172111523b6b8bc3285b49b19f'){ - console.log("s"); - } - if (typeof a === 'object') { // si c'est options - var options = Object.keys(a).map(key => a[key]); - for (var optionsObject of options) { - if(typeof optionsObject === 'object'){ - if (optionsObject.abstract || optionsObject.extern) { - //metadata - if (optionsObject.url) - dataArray.push(optionsObject.url, optionsObject.extern, optionsObject.abstract, optionsObject.type); - else - dataArray.push(null, optionsObject.extern, optionsObject.abstract, optionsObject.type); - } - else if (optionsObject.optionsFromCapabilities || optionsObject.params) { - //sourceOptions - if (optionsObject.url) - dataArray.push(optionsObject.type, optionsObject.url, optionsObject.optionsFromCapabilities, optionsObject.params); - else - dataArray.push(optionsObject.type, null, optionsObject.optionsFromCapabilities, optionsObject.params); - } - } - else - dataArray.push(optionsObject); // minRes, maxRes - } - - } //Metadata and SourceOptions end - else { - dataArray.push(a); - } - } - bufferArray.push(dataArray); + catalogRank++; }); - } - else { - var itemGroupWMTS: any = itemGroup; - if(!itemGroupWMTS.options){ - dataArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); - bufferArray.push(dataArray); - } - else{ //wmts, items directement, avec options et - /*["id", "Group type", "Group title", "Group address", "external provider", - "item id", "item type", "item title", "item address", "external provider", "MaxRes", "MinRes", "Metadata url", - "Extern", "abstract", "type", "source type", "source url", "optionsFromCapabilities", "params"]*/ - dataArray = []; - dataArray.push(null, null, null, null, null, itemGroup.id, itemGroup.type, itemGroup.title, itemGroup.address, - null, null, null, null, itemGroupWMTS.options.metadata.extern, null, itemGroupWMTS.options.metadata.type, itemGroupWMTS.options.sourceOptions.type, - null, itemGroupWMTS.options.sourceOptions.optionsFromCapabilities, itemGroupWMTS.options.sourceOptions.params); - bufferArray.push(dataArray); + } + else{ //is directly an item + var itemGroupWMTS: any = catalogItemGroup; + if(!itemGroupWMTS.options){ + dataArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); + bufferArray.push(dataArray); } + else{ + //wmts, items directement, avec options + dataArray = []; + var gestionnaire = "MTQ"; + if(itemGroupWMTS.externalProvider !== undefined){ + if(itemGroupWMTS.externalProvider === true) + gestionnaire = "Externe"; + } + dataArray.push(catalogRank, itemGroupWMTS.title, itemGroupWMTS.address, "thématique", gestionnaire, itemGroupWMTS.options.sourceOptions.url, + itemGroupWMTS.options.sourceOptions.layer, "contextethematique planiactifs", itemGroupWMTS.options.metadata.abstract); + + bufferArray.push(dataArray); + catalogRank++; } + } }); }); console.log("bufferArray", bufferArray); @@ -416,10 +288,10 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { var encodedUri = encodeURI(csvContent); var link = document.createElement("a"); link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); - link.setAttribute("download", "demo.csv"); + link.setAttribute("download", "liste_couches.csv"); document.body.appendChild(link); // Required for FF link.click(); // This will download the data file named "my_data.csv". document.body.removeChild(link); }); -} + } } From 9664a31236b2dc04b2133fc280aa16d53fb2257d Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Fri, 2 Jun 2023 13:40:53 -0400 Subject: [PATCH 10/49] From geo to integration. CatalogGroup title is ok --- .../catalog-library.component.html | 11 +- .../catalog-library.component.ts | 62 --------- packages/geo/src/locale/en.geo.json | 3 +- packages/geo/src/locale/fr.geo.json | 3 +- .../catalog-library-tool.component.html | 10 ++ .../catalog-library-tool.component.ts | 118 +++++++++++++++++- .../catalog-library-tool.module.ts | 10 +- .../src/locale/en.integration.json | 3 + .../src/locale/fr.integration.json | 3 + 9 files changed, 144 insertions(+), 79 deletions(-) diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.html b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.html index e179611a3b..020b2b4d01 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.html +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.html @@ -22,13 +22,4 @@ -
- -
+ diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index 9d35c32866..d5770989a5 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -232,66 +232,4 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { }); } - getCatalogList(){ - var catalogRank = 1; - let bufferArray = [["rang Catalog", "Nom de la couche - Catalogue", "Nom du groupe de couche - Catalogue", - "Nom de la thématique", "Gestionnaire du service", "URL (Intranet/Internet", "Nom du fichier - Service Web", - "Contexte/Thématique PlaniActifs", "Description de la donnée"]]; - var dataArray = []; - this.store.entities$.pipe(switchMap(catalogs => { - return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca))); - })).subscribe(res => { - console.log('res', res); - res.forEach(element => { - element.forEach((catalogItemGroup: CatalogItemGroup) => { - if (catalogItemGroup.items) { - catalogItemGroup.items.forEach((item: any) => { - //à l'intérieur du array(22) Dans GouvOuvert - dataArray = []; - var gestionnaire = "MTQ"; - if(item.externalProvider !== undefined){ - if(item.externalProvider === true) - gestionnaire = "Externe"; - } - dataArray.push(catalogRank, item.title, catalogItemGroup.address, "thématique", gestionnaire, item.options.sourceOptions.url, - item.options.sourceOptions.layer, "contexte/thematique planiactifs", item.options.metadata.abstract); - bufferArray.push(dataArray); - catalogRank++; - }); - } - else{ //is directly an item - var itemGroupWMTS: any = catalogItemGroup; - if(!itemGroupWMTS.options){ - dataArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); - bufferArray.push(dataArray); - } - else{ - //wmts, items directement, avec options - dataArray = []; - var gestionnaire = "MTQ"; - if(itemGroupWMTS.externalProvider !== undefined){ - if(itemGroupWMTS.externalProvider === true) - gestionnaire = "Externe"; - } - dataArray.push(catalogRank, itemGroupWMTS.title, itemGroupWMTS.address, "thématique", gestionnaire, itemGroupWMTS.options.sourceOptions.url, - itemGroupWMTS.options.sourceOptions.layer, "contextethematique planiactifs", itemGroupWMTS.options.metadata.abstract); - - bufferArray.push(dataArray); - catalogRank++; - } - } - }); - }); - console.log("bufferArray", bufferArray); - - let csvContent = bufferArray.map(e => e.join(";")).join("\n"); - var encodedUri = encodeURI(csvContent); - var link = document.createElement("a"); - link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); - link.setAttribute("download", "liste_couches.csv"); - document.body.appendChild(link); // Required for FF - link.click(); // This will download the data file named "my_data.csv". - document.body.removeChild(link); - }); - } } diff --git a/packages/geo/src/locale/en.geo.json b/packages/geo/src/locale/en.geo.json index cd3142e5c6..b0a708a5f5 100644 --- a/packages/geo/src/locale/en.geo.json +++ b/packages/geo/src/locale/en.geo.json @@ -27,8 +27,7 @@ "message": "The catalog is already contained in the list." }, "library.addTitle": "Adding a catalog", - "library.addBtn": "Add a catalog", - "library.getCatalogList": "Get the catalog services list" + "library.addBtn": "Add a catalog" }, "clickOnMap": { "clickedFeature": "Clicked Feature" diff --git a/packages/geo/src/locale/fr.geo.json b/packages/geo/src/locale/fr.geo.json index 37e97ef38a..278b5b3802 100644 --- a/packages/geo/src/locale/fr.geo.json +++ b/packages/geo/src/locale/fr.geo.json @@ -27,8 +27,7 @@ "message": "Le catalogue à ajouter est déjà dans la liste" }, "library.addTitle": "Ajout d'un catalogue", - "library.addBtn": "Ajouter un catalogue", - "library.getCatalogList": "Obtenir la liste des services du catalogue" + "library.addBtn": "Ajouter un catalogue" }, "clickOnMap": { "clickedFeature": "Entités cliquées" diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html index 37e079e48c..390eca84bc 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html @@ -4,3 +4,13 @@ [store]="store" (catalogSelectChange)="onCatalogSelectChange($event)"> +
+ +
\ No newline at end of file diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts index b52b660101..2fab7b5513 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts @@ -1,14 +1,17 @@ import { Component, OnInit, ChangeDetectionStrategy, Input } from '@angular/core'; -import { take } from 'rxjs/operators'; +import { catchError, map, switchMap, take } from 'rxjs/operators'; import { ToolComponent } from '@igo2/common'; import { EntityStore } from '@igo2/common'; -import { Catalog, CatalogService } from '@igo2/geo'; +import { Catalog, CatalogItem, CatalogItemGroup, CatalogService, DDtoDMS } from '@igo2/geo'; import { StorageService } from '@igo2/core'; import { ToolState } from '../../tool/tool.state'; import { CatalogState } from '../catalog.state'; +import { forkJoin, of, zip } from 'rxjs'; +import { HttpClient } from '@angular/common/http'; +import { ContextService, DetailedContext } from '@igo2/context'; /** * Tool to browse the list of available catalogs. @@ -43,6 +46,8 @@ export class CatalogLibraryToolComponent implements OnInit { @Input() predefinedCatalogs: Catalog[] = []; constructor( + private http: HttpClient, + private contextService: ContextService, private catalogService: CatalogService, private catalogState: CatalogState, private toolState: ToolState, @@ -80,4 +85,113 @@ export class CatalogLibraryToolComponent implements OnInit { this.store.load(catalogs.concat((this.storageService.get('addedCatalogs') || []) as Catalog[])); }); } + + private getThematic(itemTitle: string){ + this.contextService.getLocalContexts().pipe( + switchMap(contextsList => + forkJoin(contextsList.ours.map(context => this.contextService.getLocalContext(context.uri))) + )).subscribe(contextLayers =>{ + contextLayers.forEach(layerContextList=>{ + layerContextList.layers.forEach(layersName=>{ + if(itemTitle === layersName.title){ + console.log("itemTitle === layersName"); + return layersName.title; + } + }); + }); + }); + return null; + } + + getCatalogList(){ + var catalogRank = 1; + let bufferArray = [["rang Catalog", "Nom de la couche - Catalogue", "Nom du groupe de couche - Catalogue", + "Nom de la thématique - Catalogue", "Gestionnaire du service", "URL (Intranet/Internet", "Nom du fichier - Service Web", + "Contexte/Thématique PlaniActifs", "Description de la donnée"]]; + var dataArray = []; + this.store.entities$.pipe(switchMap(catalogs => { + return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca).pipe(map(lci => [ca, lci])) )); + })).subscribe(res=> { + + console.log('res', res); + res.forEach((catalogs:Object) => { + //console.log(catalogs[1]) + var catalogsList = Object.keys(catalogs[1]).map(key => catalogs[1][key]); + var catalogTitle = Object.keys(catalogs[0]).map(key => catalogs[0][key])[1]; + console.log(catalogs[0], catalogs[0].title); + catalogsList.forEach(catalogItemGroup=>{ + //console.log(catalogItemGroup); + if (catalogItemGroup.items) { + catalogItemGroup.items.forEach((item: any) => { + //à l'intérieur du array(22) Dans GouvOuvert + dataArray = []; + var gestionnaire = "MTQ"; + if(item.externalProvider !== undefined){ + if(item.externalProvider === true) + gestionnaire = "Externe"; + }//cataloggroup.address + //catalogs[0].title + + const absUrl = item.options.sourceOptions.url.charAt(0) === '/' ? window.location.origin + item.options.sourceOptions.url : item.options.sourceOptions.url; + dataArray.push(catalogRank, item.title, catalogItemGroup.title, catalogTitle, gestionnaire, absUrl, + item.options.sourceOptions.params.LAYERS, "", item.options.metadata.abstract); + bufferArray.push(dataArray); + dataArray = []; + catalogRank++; + }); + } + else{ //is directly an item + var itemGroupWMTS: any = catalogItemGroup; + if(!itemGroupWMTS.options){ + dataArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); + bufferArray.push(dataArray); + dataArray = []; + } + else{ + //wmts, items directement, avec options + dataArray = []; + var gestionnaire = "MTQ"; + if(itemGroupWMTS.externalProvider !== undefined){ + if(itemGroupWMTS.externalProvider === true) + gestionnaire = "Externe"; + } + dataArray.push(catalogRank, itemGroupWMTS.title, itemGroupWMTS.title, itemGroupWMTS.address, gestionnaire, itemGroupWMTS.options.sourceOptions.url, + itemGroupWMTS.options.sourceOptions.layer, "contextethematique planiactifs", itemGroupWMTS.options.metadata.abstract); + + bufferArray.push(dataArray); + dataArray = []; + catalogRank++; + } + } + + }); + }); + + this.contextService.getLocalContexts().pipe(switchMap(contextsList => forkJoin(contextsList.ours.map(context => + this.contextService.getLocalContext(context.uri))))).subscribe(contextLayers => { + + console.log("contextLayers", contextLayers); + //itérer bufferArray + for (var index in bufferArray) { + for(var layerContextList of contextLayers){ + //contextLayers.forEach(layerContextList => { + layerContextList.layers.forEach(layersName => { + if (bufferArray[index][6] === layersName.title) { + console.log("bufferArrayElement === layersName"); + bufferArray[index][7] = layersName.title; + } + }); + }; + } + let csvContent = bufferArray.map(e => e.join(";")).join("\n"); + var encodedUri = encodeURI(csvContent); + var link = document.createElement("a"); + link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); + link.setAttribute("download", "liste_couches.csv"); + document.body.appendChild(link); // Required for FF + link.click(); // This will download the data file named "my_data.csv". + document.body.removeChild(link); + }); //end subscribe + }); + } } diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.module.ts b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.module.ts index b76c75120f..2d860e86d2 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.module.ts +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.module.ts @@ -3,6 +3,10 @@ import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { IgoCatalogLibraryModule } from '@igo2/geo'; import { CatalogLibraryToolComponent } from './catalog-library-tool.component'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { IgoLanguageModule } from '@igo2/core'; +import { MatButtonModule } from '@angular/material/button'; +import { IgoListModule } from '@igo2/common'; /** * @ignore @@ -10,7 +14,11 @@ import { CatalogLibraryToolComponent } from './catalog-library-tool.component'; @NgModule({ imports: [ CommonModule, - IgoCatalogLibraryModule + IgoCatalogLibraryModule, + MatButtonModule, + MatTooltipModule, + IgoListModule, + IgoLanguageModule ], declarations: [CatalogLibraryToolComponent], exports: [CatalogLibraryToolComponent], diff --git a/packages/integration/src/locale/en.integration.json b/packages/integration/src/locale/en.integration.json index b150c5fd50..6a4f2b9372 100644 --- a/packages/integration/src/locale/en.integration.json +++ b/packages/integration/src/locale/en.integration.json @@ -21,6 +21,9 @@ "advancedMap": "Advanced map tools", "closestFeature": "Closest feature tool" }, + "catalog":{ + "library.getCatalogList": "Get the catalog services list" + }, "searchResultsTool": { "noResults": "No results", "doSearch": "", diff --git a/packages/integration/src/locale/fr.integration.json b/packages/integration/src/locale/fr.integration.json index 138a903e04..3be4393d15 100644 --- a/packages/integration/src/locale/fr.integration.json +++ b/packages/integration/src/locale/fr.integration.json @@ -21,6 +21,9 @@ "advancedMap": "Outils avancés", "closestFeature": "Entités à proximité" }, + "catalog":{ + "library.getCatalogList": "Obtenir la liste des services du catalogue" + }, "searchResultsTool": { "noResults": "Aucun résultat", "doSearch": "Veuillez effectuer une recherche dans la barre de recherche ci-dessus.", From 9548f6183ca64d847310902c8f53337c5d671735 Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Mon, 5 Jun 2023 15:03:23 -0400 Subject: [PATCH 11/49] Centered the button --- .../catalog-library.component.scss | 6 +--- .../catalog-library-tool.component.html | 2 +- .../catalog-library-tool.component.scss | 5 +++ .../catalog-library-tool.component.ts | 36 ++++++++++--------- 4 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.scss diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss index 2c1386ef57..74d7b6c354 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss @@ -8,8 +8,4 @@ igo-list { margin: 30px 0; } -.btnGetCatalogList { - justify-content: center; - display: flex; - margin: 30px 0; -} + diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html index 390eca84bc..b86b7ed283 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html @@ -8,7 +8,7 @@ - diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss index 74d7b6c354..d2b3731e5a 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.scss @@ -7,5 +7,3 @@ igo-list { display: flex; margin: 30px 0; } - - diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index 441e279b3c..37b86339c9 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -18,7 +18,6 @@ import { Md5 } from 'ts-md5'; import { CapabilitiesService } from '../../datasource'; import { IgoMap } from '../../map'; import { standardizeUrl } from '../../utils/id-generator'; - import { Catalog } from '../shared/catalog.abstract'; import { CatalogService } from '../shared/catalog.service'; import { AddCatalogDialogComponent } from './add-catalog-dialog.component'; @@ -229,5 +228,4 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { this.addCatalog(catalog); }); } - } From a559222288aa3dac0be76bb765010739ca904a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Thu, 19 Oct 2023 12:02:38 -0400 Subject: [PATCH 18/49] wip formatting --- .../catalog-library-tool.component.ts | 175 ++++++++++++------ 1 file changed, 114 insertions(+), 61 deletions(-) diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts index 608e2c81c5..5aab26d6d5 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts @@ -4,19 +4,18 @@ import { Input, OnInit } from '@angular/core'; -import { map, switchMap, take } from 'rxjs/operators'; import { ToolComponent } from '@igo2/common'; import { EntityStore } from '@igo2/common'; +import { ContextService } from '@igo2/context'; import { StorageService } from '@igo2/core'; import { Catalog, CatalogService } from '@igo2/geo'; -import { take } from 'rxjs/operators'; +import { forkJoin } from 'rxjs'; +import { map, switchMap, take } from 'rxjs/operators'; import { ToolState } from '../../tool/tool.state'; import { CatalogState } from '../catalog.state'; -import { forkJoin } from 'rxjs'; -import { ContextService } from '@igo2/context'; /** * Tool to browse the list of available catalogs. @@ -101,67 +100,107 @@ export class CatalogLibraryToolComponent implements OnInit { /** * Get the item description for getCatalogList */ - private getDescription(item: any){ - if(item.options.metadata.abstract){ - if(item.options.metadata.abstract.includes("\n")){ - return item.options.metadata.abstract.replaceAll("\n", ""); - } - else{ + private getDescription(item: any) { + if (item.options.metadata.abstract) { + if (item.options.metadata.abstract.includes('\n')) { + return item.options.metadata.abstract.replaceAll('\n', ''); + } else { return item.options.metadata.abstract; } - } - else{ - return ""; + } else { + return ''; } } - getCatalogList(){ + getCatalogList() { var catalogRank = 1; - let bufferArray = [["rang Catalog", "Nom de la couche - Catalogue", "Nom du groupe de couche - Catalogue", - "Nom de la thématique - Catalogue", "Gestionnaire du service", "URL (Intranet/Internet", "Nom du fichier - Service Web", - "Contexte/Thématique PlaniActifs", "Description de la donnée"]]; + let bufferArray = [ + [ + 'rang Catalog', + 'Nom de la couche - Catalogue', + 'Nom du groupe de couche - Catalogue', + 'Nom de la thématique - Catalogue', + 'Gestionnaire du service', + 'URL (Intranet/Internet', + 'Nom du fichier - Service Web', + 'Contexte/Thématique PlaniActifs', + 'Description de la donnée' + ] + ]; var dataArray = []; - this.store.entities$.pipe(switchMap(catalogs => { - return forkJoin(catalogs.map(ca => this.catalogService.loadCatalogItems(ca).pipe(map(lci => [ca, lci])))); - })).subscribe(res => { - res.forEach((catalogs:Object) => { - var catalogsList = Object.keys(catalogs[1]).map(key => catalogs[1][key]); + this.store.entities$ + .pipe( + switchMap((catalogs) => { + return forkJoin( + catalogs.map((ca) => + this.catalogService + .loadCatalogItems(ca) + .pipe(map((lci) => [ca, lci])) + ) + ); + }) + ) + .subscribe((res) => { + res.forEach((catalogs: Object) => { + var catalogsList = Object.keys(catalogs[1]).map( + (key) => catalogs[1][key] + ); var catalogTitle = catalogs[0].title ? catalogs[0].title : null; - catalogsList.forEach(catalogItemGroup => { + catalogsList.forEach((catalogItemGroup) => { if (catalogItemGroup.items) { catalogItemGroup.items.forEach((item: any) => { dataArray = []; - var gestionnaire = "MTQ"; - if(item.externalProvider !== undefined){ - if(item.externalProvider === true) - gestionnaire = "Externe"; + var gestionnaire = 'MTQ'; + if (item.externalProvider !== undefined) { + if (item.externalProvider === true) gestionnaire = 'Externe'; } - const absUrl = item.options.sourceOptions.url.charAt(0) === '/' ? window.location.origin + - item.options.sourceOptions.url : item.options.sourceOptions.url; - dataArray.push(catalogRank, item.title, catalogItemGroup.title, catalogTitle, gestionnaire, - absUrl, item.options.sourceOptions.params.LAYERS, "", this.getDescription(item)); + const absUrl = + item.options.sourceOptions.url.charAt(0) === '/' + ? window.location.origin + item.options.sourceOptions.url + : item.options.sourceOptions.url; + dataArray.push( + catalogRank, + item.title, + catalogItemGroup.title, + catalogTitle, + gestionnaire, + absUrl, + item.options.sourceOptions.params.LAYERS, + '', + this.getDescription(item) + ); bufferArray.push(dataArray); dataArray = []; catalogRank++; }); - } - else{ + } else { var itemGroupWMTS: any = catalogItemGroup; - if(!itemGroupWMTS.options){ - dataArray.push(Object.keys(catalogItemGroup).map(key => catalogItemGroup[key])); + if (!itemGroupWMTS.options) { + dataArray.push( + Object.keys(catalogItemGroup).map( + (key) => catalogItemGroup[key] + ) + ); bufferArray.push(dataArray); dataArray = []; - } - else{ + } else { dataArray = []; - var gestionnaire = "MTQ"; - if(itemGroupWMTS.externalProvider !== undefined){ - if(itemGroupWMTS.externalProvider === true) - gestionnaire = "Externe"; + var gestionnaire = 'MTQ'; + if (itemGroupWMTS.externalProvider !== undefined) { + if (itemGroupWMTS.externalProvider === true) + gestionnaire = 'Externe'; } - dataArray.push(catalogRank, itemGroupWMTS.title, itemGroupWMTS.title, catalogTitle, gestionnaire, - itemGroupWMTS.options.sourceOptions.url, itemGroupWMTS.options.sourceOptions.layer, "", - this.getDescription(itemGroupWMTS)); + dataArray.push( + catalogRank, + itemGroupWMTS.title, + itemGroupWMTS.title, + catalogTitle, + gestionnaire, + itemGroupWMTS.options.sourceOptions.url, + itemGroupWMTS.options.sourceOptions.layer, + '', + this.getDescription(itemGroupWMTS) + ); bufferArray.push(dataArray); dataArray = []; catalogRank++; @@ -169,29 +208,43 @@ export class CatalogLibraryToolComponent implements OnInit { } }); }); - this.contextService.getLocalContexts().pipe(switchMap(contextsList => forkJoin(contextsList.ours.map(context => - this.contextService.getLocalContext(context.uri))))).subscribe(contextLayers => { + this.contextService + .getLocalContexts() + .pipe( + switchMap((contextsList) => + forkJoin( + contextsList.ours.map((context) => + this.contextService.getLocalContext(context.uri) + ) + ) + ) + ) + .subscribe((contextLayers) => { for (var index in bufferArray) { - if(index !== "0"){ - var contextLayersList = []; - for(var layerContextList of contextLayers){ - layerContextList.layers.forEach(layersName => { - if (bufferArray[index][6] === layersName.id) { - contextLayersList.push(layerContextList.title); - } + if (index !== '0') { + var contextLayersList = []; + for (var layerContextList of contextLayers) { + layerContextList.layers.forEach((layersName) => { + if (bufferArray[index][6] === layersName.id) { + contextLayersList.push(layerContextList.title); + } }); - }; - bufferArray[index][7] = contextLayersList.toString(); - }} - let csvContent = bufferArray.map(e => e.join(";")).join("\n"); + } + bufferArray[index][7] = contextLayersList.toString(); + } + } + let csvContent = bufferArray.map((e) => e.join(';')).join('\n'); var encodedUri = encodeURI(csvContent); - var link = document.createElement("a"); - link.setAttribute("href", "data:text/csv;charset=utf-8,%EF%BB%BF" + encodedUri); - link.setAttribute("download", "liste_couches.csv"); + var link = document.createElement('a'); + link.setAttribute( + 'href', + 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodedUri + ); + link.setAttribute('download', 'liste_couches.csv'); document.body.appendChild(link); link.click(); document.body.removeChild(link); + }); }); - }); } } From 19368ab02c40ab5adeeeb1ea3d112bea1ccfed6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Thu, 19 Oct 2023 12:04:53 -0400 Subject: [PATCH 19/49] formatting --- packages/auth/src/lib/shared/admin.guard.ts | 2 +- packages/auth/src/lib/shared/auth.guard.ts | 2 +- .../auth/src/lib/shared/auth.interceptor.ts | 2 +- packages/auth/src/lib/shared/logged.guard.ts | 2 +- packages/auth/src/lib/shared/profils.guard.ts | 2 +- .../color-picker-form-field.module.ts | 9 +-- .../lib/environment/environment.interface.ts | 3 +- .../src/lib/message/shared/message.service.ts | 2 +- .../lib/catalog/shared/catalog.interface.ts | 6 +- .../shared/datasources/wms-wfs.utils.ts | 2 +- .../lib/environment/environment.interface.ts | 3 +- .../geo/src/lib/filter/shared/ogc-filter.ts | 2 +- .../src/lib/search/shared/sources/icherche.ts | 65 ++++++++++--------- .../shared/feature-workspace.service.ts | 5 +- .../workspace/shared/wfs-workspace.service.ts | 5 +- .../workspace/shared/wms-workspace.service.ts | 8 +-- packages/geo/src/locale/en.geo.json | 16 ++--- packages/geo/src/locale/fr.geo.json | 16 ++--- .../about/about-tool/about-tool.component.ts | 1 + .../catalog-library-tool.component.html | 7 +- .../catalog-library-tool.component.scss | 8 +-- .../catalog-library-tool.module.ts | 8 +-- .../lib/environment/environment.interface.ts | 2 +- .../src/locale/en.integration.json | 2 +- .../src/locale/fr.integration.json | 2 +- 25 files changed, 99 insertions(+), 83 deletions(-) diff --git a/packages/auth/src/lib/shared/admin.guard.ts b/packages/auth/src/lib/shared/admin.guard.ts index de48bcdb68..ebc12c02e4 100644 --- a/packages/auth/src/lib/shared/admin.guard.ts +++ b/packages/auth/src/lib/shared/admin.guard.ts @@ -7,8 +7,8 @@ import { import { ConfigService } from '@igo2/core'; -import { AuthService } from './auth.service'; import { AuthOptions } from './auth.interface'; +import { AuthService } from './auth.service'; @Injectable({ providedIn: 'root' diff --git a/packages/auth/src/lib/shared/auth.guard.ts b/packages/auth/src/lib/shared/auth.guard.ts index 78ba0868d9..85bd6d3b81 100644 --- a/packages/auth/src/lib/shared/auth.guard.ts +++ b/packages/auth/src/lib/shared/auth.guard.ts @@ -7,8 +7,8 @@ import { import { ConfigService } from '@igo2/core'; -import { AuthService } from './auth.service'; import { AuthOptions } from './auth.interface'; +import { AuthService } from './auth.service'; @Injectable({ providedIn: 'root' diff --git a/packages/auth/src/lib/shared/auth.interceptor.ts b/packages/auth/src/lib/shared/auth.interceptor.ts index 0e805432c5..0b17df25c6 100644 --- a/packages/auth/src/lib/shared/auth.interceptor.ts +++ b/packages/auth/src/lib/shared/auth.interceptor.ts @@ -12,12 +12,12 @@ import { ConfigService } from '@igo2/core'; import { Observable } from 'rxjs'; import { Md5 } from 'ts-md5'; -import { TokenService } from './token.service'; import { AuthByKeyOptions, AuthOptions, WithCredentialsOptions } from './auth.interface'; +import { TokenService } from './token.service'; @Injectable({ providedIn: 'root' diff --git a/packages/auth/src/lib/shared/logged.guard.ts b/packages/auth/src/lib/shared/logged.guard.ts index cd56a6d1c3..643b70ceed 100644 --- a/packages/auth/src/lib/shared/logged.guard.ts +++ b/packages/auth/src/lib/shared/logged.guard.ts @@ -7,8 +7,8 @@ import { import { ConfigService } from '@igo2/core'; -import { AuthService } from './auth.service'; import { AuthOptions } from './auth.interface'; +import { AuthService } from './auth.service'; @Injectable({ providedIn: 'root' diff --git a/packages/auth/src/lib/shared/profils.guard.ts b/packages/auth/src/lib/shared/profils.guard.ts index c808b83b8d..1bc6424f9b 100644 --- a/packages/auth/src/lib/shared/profils.guard.ts +++ b/packages/auth/src/lib/shared/profils.guard.ts @@ -9,8 +9,8 @@ import { ConfigService } from '@igo2/core'; import { map } from 'rxjs/operators'; -import { AuthService } from './auth.service'; import { AuthOptions } from './auth.interface'; +import { AuthService } from './auth.service'; @Injectable({ providedIn: 'root' diff --git a/packages/common/src/lib/color-picker-form-field/color-picker-form-field.module.ts b/packages/common/src/lib/color-picker-form-field/color-picker-form-field.module.ts index 9c0662133f..9b3964b9ba 100644 --- a/packages/common/src/lib/color-picker-form-field/color-picker-form-field.module.ts +++ b/packages/common/src/lib/color-picker-form-field/color-picker-form-field.module.ts @@ -1,12 +1,13 @@ +import { OverlayModule } from '@angular/cdk/overlay'; +import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatButtonModule } from '@angular/material/button'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; -import { CommonModule } from '@angular/common'; -import { OverlayModule } from '@angular/cdk/overlay'; -import { ColorChromeModule } from 'ngx-color/chrome'; -import { MatButtonModule } from '@angular/material/button'; + import { TranslateModule } from '@ngx-translate/core'; +import { ColorChromeModule } from 'ngx-color/chrome'; import { ColorPickerFormFieldComponent } from './color-picker-form-field.component'; diff --git a/packages/context/src/lib/environment/environment.interface.ts b/packages/context/src/lib/environment/environment.interface.ts index 8f18bf6cfe..af78cc507d 100644 --- a/packages/context/src/lib/environment/environment.interface.ts +++ b/packages/context/src/lib/environment/environment.interface.ts @@ -1,6 +1,7 @@ +import { AuthOptions } from '@igo2/auth'; import { ImportExportServiceOptions } from '@igo2/geo'; + import { ContextServiceOptions } from '../context-manager'; -import { AuthOptions } from '@igo2/auth'; export interface EnvironmentOptions { auth?: AuthOptions; diff --git a/packages/core/src/lib/message/shared/message.service.ts b/packages/core/src/lib/message/shared/message.service.ts index 00b387ca82..862828f5bb 100644 --- a/packages/core/src/lib/message/shared/message.service.ts +++ b/packages/core/src/lib/message/shared/message.service.ts @@ -313,7 +313,7 @@ export class MessageService { if (k) { const value = titleInterpolateParams[k]; translatedTitlenterpolateParams[k] = - typeof value === "string" + typeof value === 'string' ? this.languageService.translate.instant(value) : value; } diff --git a/packages/geo/src/lib/catalog/shared/catalog.interface.ts b/packages/geo/src/lib/catalog/shared/catalog.interface.ts index 2c0672a9e3..c4dc229a99 100644 --- a/packages/geo/src/lib/catalog/shared/catalog.interface.ts +++ b/packages/geo/src/lib/catalog/shared/catalog.interface.ts @@ -3,7 +3,11 @@ import { EntityState } from '@igo2/common'; import { TooltipType } from '../../layer'; import { QueryFormat } from '../../query'; import { MetadataLayerOptions } from './../../metadata/shared/metadata.interface'; -import { CatalogItemType, CatalogQueryFormatTypes, TypeCatalogStrings } from './catalog.enum'; +import { + CatalogItemType, + CatalogQueryFormatTypes, + TypeCatalogStrings +} from './catalog.enum'; export interface AddedChangeEmitter { added: boolean; diff --git a/packages/geo/src/lib/datasource/shared/datasources/wms-wfs.utils.ts b/packages/geo/src/lib/datasource/shared/datasources/wms-wfs.utils.ts index 0f41dbe804..827e60fcf3 100644 --- a/packages/geo/src/lib/datasource/shared/datasources/wms-wfs.utils.ts +++ b/packages/geo/src/lib/datasource/shared/datasources/wms-wfs.utils.ts @@ -1,10 +1,10 @@ +import { Extent } from 'ol/extent'; import * as OlFormat from 'ol/format'; import olFormatGML2 from 'ol/format/GML2'; import olFormatGML3 from 'ol/format/GML3'; import olFormatGML32 from 'ol/format/GML32'; import olFormatOSMXML from 'ol/format/OSMXML'; import olProjection from 'ol/proj/Projection'; -import { Extent } from 'ol/extent'; import { OgcFilterWriter } from '../../../filter/shared/ogc-filter'; import { OgcFiltersOptions } from '../../../filter/shared/ogc-filter.interface'; diff --git a/packages/geo/src/lib/environment/environment.interface.ts b/packages/geo/src/lib/environment/environment.interface.ts index f547fdfcfb..2fd2802675 100644 --- a/packages/geo/src/lib/environment/environment.interface.ts +++ b/packages/geo/src/lib/environment/environment.interface.ts @@ -1,4 +1,6 @@ import { DOMOptions, DepotOptions } from '@igo2/common'; + +import { CatalogServiceOptions } from '../catalog'; import { OptionsApiOptions } from '../datasource'; import { DirectionsSourceOptions } from '../directions'; import { DrawOptions } from '../draw/shared/draw.interface'; @@ -15,7 +17,6 @@ import { StoredQueriesSearchSourceOptions } from '../search'; import { OverlayStyleOptions } from '../style'; -import { CatalogServiceOptions } from '../catalog'; export interface EnvironmentOptions { catalog?: CatalogServiceOptions; diff --git a/packages/geo/src/lib/filter/shared/ogc-filter.ts b/packages/geo/src/lib/filter/shared/ogc-filter.ts index 5e61910dce..9167855706 100644 --- a/packages/geo/src/lib/filter/shared/ogc-filter.ts +++ b/packages/geo/src/lib/filter/shared/ogc-filter.ts @@ -1,5 +1,6 @@ import { ObjectUtils, uuid } from '@igo2/utils'; +import { Extent } from 'ol/extent'; import olFormatWFS, { WriteGetFeatureOptions } from 'ol/format/WFS'; import olFormatWKT from 'ol/format/WKT'; import * as olfilter from 'ol/format/filter'; @@ -21,7 +22,6 @@ import { OgcSelectorBundle, SelectorGroup } from './ogc-filter.interface'; -import { Extent } from 'ol/extent'; export class OgcFilterWriter { private filterSequence: OgcInterfaceFilterOptions[] = []; diff --git a/packages/geo/src/lib/search/shared/sources/icherche.ts b/packages/geo/src/lib/search/shared/sources/icherche.ts index a293424622..b36ac4da40 100644 --- a/packages/geo/src/lib/search/shared/sources/icherche.ts +++ b/packages/geo/src/lib/search/shared/sources/icherche.ts @@ -309,38 +309,39 @@ export class IChercheSearchSource extends SearchSource implements TextSearch { } ] } satisfies SearchSourceSettings, - showAdvancedParams && { - type: 'radiobutton', - title: 'ecmax', - name: 'ecmax', - values: [ - { - title: '10 %', - value: 10, - enabled: ecmax === 10 - }, - { - title: '30 %', - value: 30, - enabled: ecmax === 30 || !ecmax - }, - { - title: '50 %', - value: 50, - enabled: ecmax === 50 - }, - { - title: '75 %', - value: 75, - enabled: ecmax === 75 - }, - { - title: '100 %', - value: 100, - enabled: ecmax === 100 - } - ] - } satisfies SearchSourceSettings, + showAdvancedParams && + ({ + type: 'radiobutton', + title: 'ecmax', + name: 'ecmax', + values: [ + { + title: '10 %', + value: 10, + enabled: ecmax === 10 + }, + { + title: '30 %', + value: 30, + enabled: ecmax === 30 || !ecmax + }, + { + title: '50 %', + value: 50, + enabled: ecmax === 50 + }, + { + title: '75 %', + value: 75, + enabled: ecmax === 75 + }, + { + title: '100 %', + value: 100, + enabled: ecmax === 100 + } + ] + } satisfies SearchSourceSettings), { type: 'radiobutton', title: 'restrictExtent', diff --git a/packages/geo/src/lib/workspace/shared/feature-workspace.service.ts b/packages/geo/src/lib/workspace/shared/feature-workspace.service.ts index 1eeccbc6ba..192ed2e3ce 100644 --- a/packages/geo/src/lib/workspace/shared/feature-workspace.service.ts +++ b/packages/geo/src/lib/workspace/shared/feature-workspace.service.ts @@ -19,6 +19,10 @@ import { import { LayerService, VectorLayer } from '../../layer/shared'; import { GeoWorkspaceOptions } from '../../layer/shared/layers/layer.interface'; import { IgoMap } from '../../map/shared'; +import { + FeatureCommonVectorStyleOptions, + OverlayStyleOptions +} from '../../style'; import { getCommonVectorSelectedStyle } from '../../style/shared/vector/commonVectorStyle'; import { PropertyTypeDetectorService } from '../../utils/propertyTypeDetector/propertyTypeDetector.service'; import { FeatureWorkspace } from './feature-workspace'; @@ -26,7 +30,6 @@ import { createFilterInMapExtentOrResolutionStrategy, createTableTemplate } from './workspace.utils'; -import { FeatureCommonVectorStyleOptions, OverlayStyleOptions } from '../../style'; @Injectable({ providedIn: 'root' diff --git a/packages/geo/src/lib/workspace/shared/wfs-workspace.service.ts b/packages/geo/src/lib/workspace/shared/wfs-workspace.service.ts index 7306d4449e..4fc1b9fb37 100644 --- a/packages/geo/src/lib/workspace/shared/wfs-workspace.service.ts +++ b/packages/geo/src/lib/workspace/shared/wfs-workspace.service.ts @@ -18,6 +18,10 @@ import { import { LayerService, VectorLayer } from '../../layer/shared'; import { GeoWorkspaceOptions } from '../../layer/shared/layers/layer.interface'; import { IgoMap } from '../../map/shared'; +import { + FeatureCommonVectorStyleOptions, + OverlayStyleOptions +} from '../../style'; import { getCommonVectorSelectedStyle } from '../../style/shared/vector/commonVectorStyle'; import { PropertyTypeDetectorService } from '../../utils/propertyTypeDetector'; import { WfsWorkspace } from './wfs-workspace'; @@ -25,7 +29,6 @@ import { createFilterInMapExtentOrResolutionStrategy, createTableTemplate } from './workspace.utils'; -import { FeatureCommonVectorStyleOptions, OverlayStyleOptions } from '../../style'; @Injectable({ providedIn: 'root' diff --git a/packages/geo/src/lib/workspace/shared/wms-workspace.service.ts b/packages/geo/src/lib/workspace/shared/wms-workspace.service.ts index ffd789fe4f..5f03d37747 100644 --- a/packages/geo/src/lib/workspace/shared/wms-workspace.service.ts +++ b/packages/geo/src/lib/workspace/shared/wms-workspace.service.ts @@ -29,6 +29,10 @@ import { GeoWorkspaceOptions } from '../../layer/shared/layers/layer.interface'; import { IgoMap } from '../../map/shared'; import { QueryableDataSourceOptions } from '../../query/shared/query.interfaces'; import { getCommonVectorSelectedStyle } from '../../style/shared/vector/commonVectorStyle'; +import { + FeatureCommonVectorStyleOptions, + OverlayStyleOptions +} from '../../style/shared/vector/vector-style.interface'; import { StyleService } from '../../style/style-service/style.service'; import { PropertyTypeDetectorService } from '../../utils/propertyTypeDetector/propertyTypeDetector.service'; import { WfsWorkspace } from './wfs-workspace'; @@ -36,10 +40,6 @@ import { createFilterInMapExtentOrResolutionStrategy, createTableTemplate } from './workspace.utils'; -import { - FeatureCommonVectorStyleOptions, - OverlayStyleOptions -} from '../../style/shared/vector/vector-style.interface'; @Injectable({ providedIn: 'root' diff --git a/packages/geo/src/locale/en.geo.json b/packages/geo/src/locale/en.geo.json index 94e40baf0c..a046db4164 100644 --- a/packages/geo/src/locale/en.geo.json +++ b/packages/geo/src/locale/en.geo.json @@ -645,14 +645,14 @@ "geographie": "Natural sites", "parc": "Parks", "secteur": "Sector", - "sites-archeologiques":"Complete archaeological sites (centroid and reservation)", - "sites-archeologiques-partiel-s":"Archaeological sites - surface area (partial)", - "zones-inf-archeologique":"Archaeological information zones", - "grille-borden":"Grille borden", - "immeubles-patrimoniaux":"Heritage buildings (classified and cited)", - "immeubles-patrimoniaux-s":"Protected land and protection area (of listed heritage buildings)", - "sites-patrimoniaux-declares":"Heritage sites (classified, declared, national)", - "sites-patrimoniaux":"Heritage sites cited", + "sites-archeologiques": "Complete archaeological sites (centroid and reservation)", + "sites-archeologiques-partiel-s": "Archaeological sites - surface area (partial)", + "zones-inf-archeologique": "Archaeological information zones", + "grille-borden": "Grille borden", + "immeubles-patrimoniaux": "Heritage buildings (classified and cited)", + "immeubles-patrimoniaux-s": "Protected land and protection area (of listed heritage buildings)", + "sites-patrimoniaux-declares": "Heritage sites (classified, declared, national)", + "sites-patrimoniaux": "Heritage sites cited", "service-garde": "Child care", "public": "Public schools", "prive": "Private school", diff --git a/packages/geo/src/locale/fr.geo.json b/packages/geo/src/locale/fr.geo.json index 2f06a335b5..7d912c8e0b 100644 --- a/packages/geo/src/locale/fr.geo.json +++ b/packages/geo/src/locale/fr.geo.json @@ -646,14 +646,14 @@ "geographie": "Lieux naturels", "parc": "Parcs", "secteur": "Secteurs", - "sites-archeologiques":"Sites archéologiques complet (centroide et réservation)", - "sites-archeologiques-partiel-s":"Sites archéologiques - surfacique (partiel)", - "zones-inf-archeologique":"Zones d'information archéologiques", - "grille-borden":"Grille borden", - "immeubles-patrimoniaux":"Immeubles patrimoniaux (classés et cités)", - "immeubles-patrimoniaux-s":"Terrain protégé et aire de protection (d'immeuble patrimoniaux classé)", - "sites-patrimoniaux-declares":"Sites patrimoniaux (classés,déclarés,nationaux)", - "sites-patrimoniaux":"Sites patrimoniaux cités", + "sites-archeologiques": "Sites archéologiques complet (centroide et réservation)", + "sites-archeologiques-partiel-s": "Sites archéologiques - surfacique (partiel)", + "zones-inf-archeologique": "Zones d'information archéologiques", + "grille-borden": "Grille borden", + "immeubles-patrimoniaux": "Immeubles patrimoniaux (classés et cités)", + "immeubles-patrimoniaux-s": "Terrain protégé et aire de protection (d'immeuble patrimoniaux classé)", + "sites-patrimoniaux-declares": "Sites patrimoniaux (classés,déclarés,nationaux)", + "sites-patrimoniaux": "Sites patrimoniaux cités", "service-garde": "Services de garde", "public": "Écoles publiques", "prive": "Écoles privées", diff --git a/packages/integration/src/lib/about/about-tool/about-tool.component.ts b/packages/integration/src/lib/about/about-tool/about-tool.component.ts index 43487eee82..ef86833144 100644 --- a/packages/integration/src/lib/about/about-tool/about-tool.component.ts +++ b/packages/integration/src/lib/about/about-tool/about-tool.component.ts @@ -7,6 +7,7 @@ import { ConfigService, LanguageService, version } from '@igo2/core'; import { of } from 'rxjs'; import type { Observable } from 'rxjs'; + import { AllEnvironmentOptions } from '../../environment'; @ToolComponent({ diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html index f8068e0660..e3296e310d 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html @@ -11,7 +11,8 @@ [matTooltip]="'igo.integration.catalog.library.getCatalogList' | translate" matTooltipPosition="above" color="primary" - (click)="getCatalogList()"> - {{'igo.integration.catalog.library.getCatalogList' | translate}} + (click)="getCatalogList()" + > + {{ 'igo.integration.catalog.library.getCatalogList' | translate }} - \ No newline at end of file + diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.scss b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.scss index 713b1dc993..852b611d3d 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.scss +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.scss @@ -1,5 +1,5 @@ .btnGetCatalogList { - display: flex; - justify-content: center; - align-items: center; - } \ No newline at end of file + display: flex; + justify-content: center; + align-items: center; +} diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.module.ts b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.module.ts index 787c0fb534..a0cb978931 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.module.ts +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.module.ts @@ -1,13 +1,13 @@ import { CommonModule } from '@angular/common'; import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; +import { MatButtonModule } from '@angular/material/button'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { IgoListModule } from '@igo2/common'; +import { IgoLanguageModule } from '@igo2/core'; import { IgoCatalogLibraryModule } from '@igo2/geo'; import { CatalogLibraryToolComponent } from './catalog-library-tool.component'; -import { MatTooltipModule } from '@angular/material/tooltip'; -import { IgoLanguageModule } from '@igo2/core'; -import { MatButtonModule } from '@angular/material/button'; -import { IgoListModule } from '@igo2/common'; /** * @ignore diff --git a/packages/integration/src/lib/environment/environment.interface.ts b/packages/integration/src/lib/environment/environment.interface.ts index 1ca3ccf1fa..bd439f1e48 100644 --- a/packages/integration/src/lib/environment/environment.interface.ts +++ b/packages/integration/src/lib/environment/environment.interface.ts @@ -1,6 +1,6 @@ import { EnvironmentOptions as AuthEnvironmentOptions } from '@igo2/auth'; -import { EnvironmentOptions as ContextEnvironmentOptions } from '@igo2/context'; import { EnvironmentOptions as CommonEnvironmentOptions } from '@igo2/common'; +import { EnvironmentOptions as ContextEnvironmentOptions } from '@igo2/context'; import { BaseEnvironmentOptions, EnvironmentOptions as CoreEnvironmentOptions diff --git a/packages/integration/src/locale/en.integration.json b/packages/integration/src/locale/en.integration.json index 48b21b0dc6..a5408bcfa4 100644 --- a/packages/integration/src/locale/en.integration.json +++ b/packages/integration/src/locale/en.integration.json @@ -21,7 +21,7 @@ "advancedMap": "Advanced map tools", "closestFeature": "Closest feature tool" }, - "catalog":{ + "catalog": { "library.getCatalogList": "Get the catalog services list" }, "searchResultsTool": { diff --git a/packages/integration/src/locale/fr.integration.json b/packages/integration/src/locale/fr.integration.json index ef15688af6..b5b9ced8e3 100644 --- a/packages/integration/src/locale/fr.integration.json +++ b/packages/integration/src/locale/fr.integration.json @@ -21,7 +21,7 @@ "advancedMap": "Outils avancés", "closestFeature": "Entités à proximité" }, - "catalog":{ + "catalog": { "library.getCatalogList": "Obtenir la liste des services du catalogue" }, "searchResultsTool": { From 0f0ca2c78925b70bd6327e70f246cc6fede586fb Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Mon, 20 Nov 2023 09:20:54 -0500 Subject: [PATCH 20/49] update packages/auth --- package-lock.json | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index dcea256d71..19568c485d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27834,7 +27834,7 @@ }, "packages/auth": { "name": "@igo2/auth", - "version": "16.0.0-rc.3", + "version": "16.0.0-rc.4", "license": "MIT", "dependencies": { "jwt-decode": "^2.2.0", @@ -27853,14 +27853,14 @@ "@angular/material": "^16.2.4", "@angular/router": "^16.2.5", "@azure/msal-angular": "^3.0.4", - "@igo2/core": "^16.0.0-rc.3", - "@igo2/utils": "^16.0.0-rc.3", + "@igo2/core": "^16.0.0-rc.4", + "@igo2/utils": "^16.0.0-rc.4", "rxjs": "^7.5.6" } }, "packages/common": { "name": "@igo2/common", - "version": "16.0.0-rc.3", + "version": "16.0.0-rc.4", "license": "MIT", "dependencies": { "tslib": "^2.6.0" @@ -27877,8 +27877,8 @@ "@angular/material": "^16.2.4", "@angular/platform-browser": "^16.2.5", "@floating-ui/utils": "^0.1.4", - "@igo2/core": "^16.0.0-rc.3", - "@igo2/utils": "^16.0.0-rc.3", + "@igo2/core": "^16.0.0-rc.4", + "@igo2/utils": "^16.0.0-rc.4", "angular-shepherd": "16.0.0", "ngx-color": "^9.0.0", "scroll-into-view-if-needed": "^3.0.0", @@ -27888,7 +27888,7 @@ }, "packages/context": { "name": "@igo2/context", - "version": "16.0.0-rc.3", + "version": "16.0.0-rc.4", "license": "MIT", "dependencies": { "tslib": "^2.6.0" @@ -27903,18 +27903,18 @@ "@angular/forms": "^16.2.5", "@angular/material": "^16.2.4", "@angular/platform-browser": "^16.2.5", - "@igo2/auth": "^16.0.0-rc.3", - "@igo2/common": "^16.0.0-rc.3", - "@igo2/core": "^16.0.0-rc.3", - "@igo2/geo": "^16.0.0-rc.3", - "@igo2/utils": "^16.0.0-rc.3", + "@igo2/auth": "^16.0.0-rc.4", + "@igo2/common": "^16.0.0-rc.4", + "@igo2/core": "^16.0.0-rc.4", + "@igo2/geo": "^16.0.0-rc.4", + "@igo2/utils": "^16.0.0-rc.4", "ol": "^7.5.2", "rxjs": "^7.8.0" } }, "packages/core": { "name": "@igo2/core", - "version": "16.0.0-rc.3", + "version": "16.0.0-rc.4", "license": "MIT", "dependencies": { "@ngx-translate/core": "^15.0.0", @@ -27929,7 +27929,7 @@ "@angular/core": "^16.2.5", "@angular/platform-browser": "^16.2.5", "@angular/router": "^16.2.5", - "@igo2/utils": "^16.0.0-rc.3", + "@igo2/utils": "^16.0.0-rc.4", "ngx-indexed-db": "^11.0.2", "ngx-toastr": "^17.0.0", "rxjs": "^7.8.0" @@ -27937,7 +27937,7 @@ }, "packages/geo": { "name": "@igo2/geo", - "version": "16.0.0-rc.3", + "version": "16.0.0-rc.4", "license": "MIT", "dependencies": { "@turf/helpers": "^6.5.0", @@ -27966,9 +27966,9 @@ "@angular/forms": "^16.2.5", "@angular/material": "^16.2.4", "@angular/platform-browser": "^16.2.5", - "@igo2/common": "^16.0.0-rc.3", - "@igo2/core": "^16.0.0-rc.3", - "@igo2/utils": "^16.0.0-rc.3", + "@igo2/common": "^16.0.0-rc.4", + "@igo2/core": "^16.0.0-rc.4", + "@igo2/utils": "^16.0.0-rc.4", "@mat-datetimepicker/core": "~12.0.0", "flexsearch": "0.7.21", "ngx-indexed-db": "^11.0.2", @@ -27981,7 +27981,7 @@ }, "packages/integration": { "name": "@igo2/integration", - "version": "16.0.0-rc.3", + "version": "16.0.0-rc.4", "license": "MIT", "dependencies": { "tslib": "^2.6.0" @@ -27992,8 +27992,8 @@ "peerDependencies": { "@angular/common": "^16.2.5", "@angular/core": "^16.2.5", - "@igo2/context": "16.0.0-rc.3", - "@igo2/geo": "16.0.0-rc.3", + "@igo2/context": "16.0.0-rc.4", + "@igo2/geo": "16.0.0-rc.4", "jspdf": "^2.5.1", "jspdf-autotable": "^3.5.29", "rxjs": "^7.8.0" @@ -28001,7 +28001,7 @@ }, "packages/utils": { "name": "@igo2/utils", - "version": "16.0.0-rc.3", + "version": "16.0.0-rc.4", "license": "MIT", "dependencies": { "bowser": "^2.10.0", From 175a664a58df89f65470c847f8be71321e8dfb25 Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Mon, 18 Dec 2023 14:47:28 -0500 Subject: [PATCH 21/49] Added correction following the pull request. Added calls to the languageService for traductions --- .../catalog-library-tool.component.ts | 249 ++++++++++-------- .../src/locale/en.integration.json | 14 +- .../src/locale/fr.integration.json | 14 +- 3 files changed, 160 insertions(+), 117 deletions(-) diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts index 5aab26d6d5..40de759538 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts @@ -8,10 +8,10 @@ import { import { ToolComponent } from '@igo2/common'; import { EntityStore } from '@igo2/common'; import { ContextService } from '@igo2/context'; -import { StorageService } from '@igo2/core'; +import { LanguageService, StorageService } from '@igo2/core'; import { Catalog, CatalogService } from '@igo2/geo'; -import { forkJoin } from 'rxjs'; +import { forkJoin, zip } from 'rxjs'; import { map, switchMap, take } from 'rxjs/operators'; import { ToolState } from '../../tool/tool.state'; @@ -55,7 +55,8 @@ export class CatalogLibraryToolComponent implements OnInit { private catalogService: CatalogService, private catalogState: CatalogState, private toolState: ToolState, - private storageService: StorageService + private storageService: StorageService, + private languageService: LanguageService ) {} /** @@ -116,20 +117,38 @@ export class CatalogLibraryToolComponent implements OnInit { var catalogRank = 1; let bufferArray = [ [ - 'rang Catalog', - 'Nom de la couche - Catalogue', - 'Nom du groupe de couche - Catalogue', - 'Nom de la thématique - Catalogue', - 'Gestionnaire du service', - 'URL (Intranet/Internet', - 'Nom du fichier - Service Web', - 'Contexte/Thématique PlaniActifs', - 'Description de la donnée' + this.languageService.translate.instant( + 'igo.integration.catalog.csv.rank' + ), + this.languageService.translate.instant( + 'igo.integration.catalog.csv.layerName' + ), + this.languageService.translate.instant( + 'igo.integration.catalog.csv.layerGroup' + ), + this.languageService.translate.instant( + 'igo.integration.catalog.csv.thematic' + ), + this.languageService.translate.instant( + 'igo.integration.catalog.csv.externalProvider' + ), + this.languageService.translate.instant( + 'igo.integration.catalog.csv.url' + ), + this.languageService.translate.instant( + 'igo.integration.catalog.csv.fileName' + ), + this.languageService.translate.instant( + 'igo.integration.catalog.csv.PlaniactifsContext' + ), + this.languageService.translate.instant( + 'igo.integration.catalog.csv.dataDescription' + ) ] ]; var dataArray = []; - this.store.entities$ - .pipe( + zip([ + this.store.entities$.pipe( switchMap((catalogs) => { return forkJoin( catalogs.map((ca) => @@ -139,112 +158,112 @@ export class CatalogLibraryToolComponent implements OnInit { ) ); }) - ) - .subscribe((res) => { - res.forEach((catalogs: Object) => { - var catalogsList = Object.keys(catalogs[1]).map( - (key) => catalogs[1][key] - ); - var catalogTitle = catalogs[0].title ? catalogs[0].title : null; - catalogsList.forEach((catalogItemGroup) => { - if (catalogItemGroup.items) { - catalogItemGroup.items.forEach((item: any) => { - dataArray = []; - var gestionnaire = 'MTQ'; - if (item.externalProvider !== undefined) { - if (item.externalProvider === true) gestionnaire = 'Externe'; - } - const absUrl = - item.options.sourceOptions.url.charAt(0) === '/' - ? window.location.origin + item.options.sourceOptions.url - : item.options.sourceOptions.url; - dataArray.push( - catalogRank, - item.title, - catalogItemGroup.title, - catalogTitle, - gestionnaire, - absUrl, - item.options.sourceOptions.params.LAYERS, - '', - this.getDescription(item) - ); - bufferArray.push(dataArray); - dataArray = []; - catalogRank++; - }); - } else { - var itemGroupWMTS: any = catalogItemGroup; - if (!itemGroupWMTS.options) { - dataArray.push( - Object.keys(catalogItemGroup).map( - (key) => catalogItemGroup[key] - ) - ); - bufferArray.push(dataArray); - dataArray = []; - } else { - dataArray = []; - var gestionnaire = 'MTQ'; - if (itemGroupWMTS.externalProvider !== undefined) { - if (itemGroupWMTS.externalProvider === true) - gestionnaire = 'Externe'; - } - dataArray.push( - catalogRank, - itemGroupWMTS.title, - itemGroupWMTS.title, - catalogTitle, - gestionnaire, - itemGroupWMTS.options.sourceOptions.url, - itemGroupWMTS.options.sourceOptions.layer, - '', - this.getDescription(itemGroupWMTS) - ); - bufferArray.push(dataArray); - dataArray = []; - catalogRank++; - } - } - }); - }); - this.contextService - .getLocalContexts() - .pipe( - switchMap((contextsList) => - forkJoin( - contextsList.ours.map((context) => - this.contextService.getLocalContext(context.uri) - ) + ), + this.contextService + .getLocalContexts() + .pipe( + switchMap((contextsList) => + forkJoin( + contextsList.ours.map((context) => + this.contextService.getLocalContext(context.uri) ) ) ) - .subscribe((contextLayers) => { - for (var index in bufferArray) { - if (index !== '0') { - var contextLayersList = []; - for (var layerContextList of contextLayers) { - layerContextList.layers.forEach((layersName) => { - if (bufferArray[index][6] === layersName.id) { - contextLayersList.push(layerContextList.title); - } - }); - } - bufferArray[index][7] = contextLayersList.toString(); + ) + ]).subscribe((returnv) => { + const res = returnv[0]; + const layersfromContexts = returnv[1]; + res.forEach((catalogs: Object) => { + var catalogsList = Object.keys(catalogs[1]).map( + (key) => catalogs[1][key] + ); + var catalogTitle = catalogs[0].title ? catalogs[0].title : null; + catalogsList.forEach((catalogItemGroup) => { + if (catalogItemGroup.items) { + catalogItemGroup.items.forEach((item: any) => { + dataArray = []; + var administrator = item.externalProvider ? 'Externe' : 'MTQ'; + const absUrl = + item.options.sourceOptions.url.charAt(0) === '/' + ? window.location.origin + item.options.sourceOptions.url + : item.options.sourceOptions.url; + dataArray.push( + catalogRank, + item.title, + catalogItemGroup.title, + catalogTitle, + administrator, + absUrl, + item.options.sourceOptions.params.LAYERS, + '', + this.getDescription(item) + ); + bufferArray.push(dataArray); + dataArray = []; + catalogRank++; + }); + } else { + var itemGroupWMTS: any = catalogItemGroup; + if (!itemGroupWMTS.options) { + dataArray.push( + Object.keys(catalogItemGroup).map( + (key) => catalogItemGroup[key] + ) + ); + bufferArray.push(dataArray); + dataArray = []; + } else { + dataArray = []; + var administrator = itemGroupWMTS.externalProvider + ? 'Externe' + : 'MTQ'; + dataArray.push( + catalogRank, + itemGroupWMTS.title, + itemGroupWMTS.title, + catalogTitle, + administrator, + itemGroupWMTS.options.sourceOptions.url, + itemGroupWMTS.options.sourceOptions.layer, + '', + this.getDescription(itemGroupWMTS) + ); + bufferArray.push(dataArray); + dataArray = []; + catalogRank++; + } + } + }); + }); + for (var index = 1; index < bufferArray.length; index++) { + var contextLayersList = []; + for (var layerContextList of layersfromContexts) { + layerContextList.layers.forEach((layersName) => { + if (bufferArray[index][6] === layersName.id) { + if (layerContextList.title !== undefined) { + contextLayersList.push(layerContextList.title); } } - let csvContent = bufferArray.map((e) => e.join(';')).join('\n'); - var encodedUri = encodeURI(csvContent); - var link = document.createElement('a'); - link.setAttribute( - 'href', - 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodedUri - ); - link.setAttribute('download', 'liste_couches.csv'); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); }); - }); + } + bufferArray[index][7] = contextLayersList.toString(); + } + let csvContent = bufferArray.map((e) => e.join(';')).join('\n'); + var encodedUri = encodeURI(csvContent); + var exportDocument = document.createElement('a'); + exportDocument.setAttribute( + 'href', + 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodedUri + ); + exportDocument.setAttribute( + 'download', + this.languageService.translate.instant( + 'igo.integration.catalog.csv.documentName' + ) + ); + document.body.appendChild(exportDocument); + exportDocument.click(); + document.body.removeChild(exportDocument); + }); } } diff --git a/packages/integration/src/locale/en.integration.json b/packages/integration/src/locale/en.integration.json index a5408bcfa4..4629794bc5 100644 --- a/packages/integration/src/locale/en.integration.json +++ b/packages/integration/src/locale/en.integration.json @@ -22,7 +22,19 @@ "closestFeature": "Closest feature tool" }, "catalog": { - "library.getCatalogList": "Get the catalog services list" + "library.getCatalogList": "Get the catalog services list", + "csv": { + "rank": "Rank", + "layerName": "Layer name", + "layerGroup": "Layer Group", + "thematic": "Thematic", + "externalProvider": "Provider", + "url": "URL (Intranet/Internet)", + "fileName": "File name - Web service", + "PlaniactifsContext": "Context/Thematic PlaniActifs", + "dataDescription": "Data description", + "documentName": "catalogList.csv" + } }, "searchResultsTool": { "noResults": "No results", diff --git a/packages/integration/src/locale/fr.integration.json b/packages/integration/src/locale/fr.integration.json index b5b9ced8e3..26459c85de 100644 --- a/packages/integration/src/locale/fr.integration.json +++ b/packages/integration/src/locale/fr.integration.json @@ -22,7 +22,19 @@ "closestFeature": "Entités à proximité" }, "catalog": { - "library.getCatalogList": "Obtenir la liste des services du catalogue" + "library.getCatalogList": "Obtenir la liste des services du catalogue", + "csv": { + "rank": "Rang", + "layerName": "Nom de la couche", + "layerGroup": "Nom du groupe de couches", + "thematic": "Thématique", + "externalProvider": "Fournisseur", + "url": "URL (Intranet/Internet)", + "fileName": "Nom du fichier - Service Web", + "PlaniactifsContext": "Contexte/Thématique PlaniActifs", + "dataDescription": "Description de la donnée", + "documentName": "listeCatalogue.csv" + } }, "searchResultsTool": { "noResults": "Aucun résultat", From ec1891f853b834c2e381cb095b90ca5bbf8e675b Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Tue, 19 Dec 2023 13:54:44 -0500 Subject: [PATCH 22/49] Corrected names for language service --- .../catalog-library-tool/catalog-library-tool.component.ts | 4 ++-- packages/integration/src/locale/en.integration.json | 4 ++-- packages/integration/src/locale/fr.integration.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts index 40de759538..10bbf41973 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts @@ -127,7 +127,7 @@ export class CatalogLibraryToolComponent implements OnInit { 'igo.integration.catalog.csv.layerGroup' ), this.languageService.translate.instant( - 'igo.integration.catalog.csv.thematic' + 'igo.integration.catalog.csv.catalog' ), this.languageService.translate.instant( 'igo.integration.catalog.csv.externalProvider' @@ -139,7 +139,7 @@ export class CatalogLibraryToolComponent implements OnInit { 'igo.integration.catalog.csv.fileName' ), this.languageService.translate.instant( - 'igo.integration.catalog.csv.PlaniactifsContext' + 'igo.integration.catalog.csv.context' ), this.languageService.translate.instant( 'igo.integration.catalog.csv.dataDescription' diff --git a/packages/integration/src/locale/en.integration.json b/packages/integration/src/locale/en.integration.json index 4629794bc5..e50e04c2ab 100644 --- a/packages/integration/src/locale/en.integration.json +++ b/packages/integration/src/locale/en.integration.json @@ -27,11 +27,11 @@ "rank": "Rank", "layerName": "Layer name", "layerGroup": "Layer Group", - "thematic": "Thematic", + "catalog": "Catalog", "externalProvider": "Provider", "url": "URL (Intranet/Internet)", "fileName": "File name - Web service", - "PlaniactifsContext": "Context/Thematic PlaniActifs", + "context": "Context/Thematic", "dataDescription": "Data description", "documentName": "catalogList.csv" } diff --git a/packages/integration/src/locale/fr.integration.json b/packages/integration/src/locale/fr.integration.json index 26459c85de..bc0220c6a2 100644 --- a/packages/integration/src/locale/fr.integration.json +++ b/packages/integration/src/locale/fr.integration.json @@ -27,11 +27,11 @@ "rank": "Rang", "layerName": "Nom de la couche", "layerGroup": "Nom du groupe de couches", - "thematic": "Thématique", + "catalog": "Catalogue", "externalProvider": "Fournisseur", "url": "URL (Intranet/Internet)", "fileName": "Nom du fichier - Service Web", - "PlaniactifsContext": "Contexte/Thématique PlaniActifs", + "context": "Contexte/Thématique", "dataDescription": "Description de la donnée", "documentName": "listeCatalogue.csv" } From f875b5282190cddbd32a59d4eb29ed6fbc8e9d95 Mon Sep 17 00:00:00 2001 From: Thierry Normand Date: Mon, 29 Jan 2024 11:30:58 -0500 Subject: [PATCH 23/49] Added corrections and date format for file name --- .../catalog-library-tool.component.ts | 31 +++++++++++++++---- .../src/locale/en.integration.json | 2 +- .../src/locale/fr.integration.json | 4 +-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts index 10bbf41973..6eb8777f3c 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts @@ -2,6 +2,7 @@ import { ChangeDetectionStrategy, Component, Input, + OnDestroy, OnInit } from '@angular/core'; @@ -9,9 +10,9 @@ import { ToolComponent } from '@igo2/common'; import { EntityStore } from '@igo2/common'; import { ContextService } from '@igo2/context'; import { LanguageService, StorageService } from '@igo2/core'; -import { Catalog, CatalogService } from '@igo2/geo'; +import { Catalog, CatalogItemLayer, CatalogService } from '@igo2/geo'; -import { forkJoin, zip } from 'rxjs'; +import { Subscription, forkJoin, zip } from 'rxjs'; import { map, switchMap, take } from 'rxjs/operators'; import { ToolState } from '../../tool/tool.state'; @@ -31,7 +32,8 @@ import { CatalogState } from '../catalog.state'; styleUrls: ['./catalog-library-tool.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush }) -export class CatalogLibraryToolComponent implements OnInit { +export class CatalogLibraryToolComponent implements OnInit, OnDestroy { + private generatelist$$: Subscription; /** * Store that contains the catalogs * @internal @@ -68,6 +70,12 @@ export class CatalogLibraryToolComponent implements OnInit { } } + ngOnDestroy() { + if (this.generatelist$$) { + this.generatelist$$.unsubscribe(); + } + } + /** * When the selected catalog changes, toggle the the CatalogBrowser tool. * @internal @@ -101,7 +109,7 @@ export class CatalogLibraryToolComponent implements OnInit { /** * Get the item description for getCatalogList */ - private getDescription(item: any) { + private getDescription(item: CatalogItemLayer) { if (item.options.metadata.abstract) { if (item.options.metadata.abstract.includes('\n')) { return item.options.metadata.abstract.replaceAll('\n', ''); @@ -147,7 +155,7 @@ export class CatalogLibraryToolComponent implements OnInit { ] ]; var dataArray = []; - zip([ + this.generatelist$$ = zip([ this.store.entities$.pipe( switchMap((catalogs) => { return forkJoin( @@ -251,6 +259,7 @@ export class CatalogLibraryToolComponent implements OnInit { let csvContent = bufferArray.map((e) => e.join(';')).join('\n'); var encodedUri = encodeURI(csvContent); var exportDocument = document.createElement('a'); + var date = new Date(); exportDocument.setAttribute( 'href', 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodedUri @@ -259,11 +268,21 @@ export class CatalogLibraryToolComponent implements OnInit { 'download', this.languageService.translate.instant( 'igo.integration.catalog.csv.documentName' - ) + ) + + '_' + + this.getFormatedDate(date) ); document.body.appendChild(exportDocument); exportDocument.click(); document.body.removeChild(exportDocument); }); } + private getFormatedDate(date: Date) { + var year = date.getFullYear(); + var month = (date.getMonth() + 1).toString().padStart(2, '0'); + var day = date.getDate().toString(); + var hours = date.getHours().toString(); + var minutes = date.getMinutes().toString(); + return `${year}-${month}-${day}:${hours}h${minutes}`; + } } diff --git a/packages/integration/src/locale/en.integration.json b/packages/integration/src/locale/en.integration.json index e50e04c2ab..ede1d049ef 100644 --- a/packages/integration/src/locale/en.integration.json +++ b/packages/integration/src/locale/en.integration.json @@ -29,7 +29,7 @@ "layerGroup": "Layer Group", "catalog": "Catalog", "externalProvider": "Provider", - "url": "URL (Intranet/Internet)", + "url": "URL", "fileName": "File name - Web service", "context": "Context/Thematic", "dataDescription": "Data description", diff --git a/packages/integration/src/locale/fr.integration.json b/packages/integration/src/locale/fr.integration.json index bc0220c6a2..4daef271b9 100644 --- a/packages/integration/src/locale/fr.integration.json +++ b/packages/integration/src/locale/fr.integration.json @@ -29,11 +29,11 @@ "layerGroup": "Nom du groupe de couches", "catalog": "Catalogue", "externalProvider": "Fournisseur", - "url": "URL (Intranet/Internet)", + "url": "URL", "fileName": "Nom du fichier - Service Web", "context": "Contexte/Thématique", "dataDescription": "Description de la donnée", - "documentName": "listeCatalogue.csv" + "documentName": "ListeCouchesInformation" } }, "searchResultsTool": { From 0712f490673764ba38fc8210f16631a1ecd8a3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Mon, 29 Jan 2024 14:38:44 -0500 Subject: [PATCH 24/49] wip --- .../integration/src/locale/en.integration.json | 15 --------------- .../integration/src/locale/fr.integration.json | 15 --------------- 2 files changed, 30 deletions(-) diff --git a/packages/integration/src/locale/en.integration.json b/packages/integration/src/locale/en.integration.json index ede1d049ef..4f8bce9d57 100644 --- a/packages/integration/src/locale/en.integration.json +++ b/packages/integration/src/locale/en.integration.json @@ -21,21 +21,6 @@ "advancedMap": "Advanced map tools", "closestFeature": "Closest feature tool" }, - "catalog": { - "library.getCatalogList": "Get the catalog services list", - "csv": { - "rank": "Rank", - "layerName": "Layer name", - "layerGroup": "Layer Group", - "catalog": "Catalog", - "externalProvider": "Provider", - "url": "URL", - "fileName": "File name - Web service", - "context": "Context/Thematic", - "dataDescription": "Data description", - "documentName": "catalogList.csv" - } - }, "searchResultsTool": { "noResults": "No results", "doSearch": "", diff --git a/packages/integration/src/locale/fr.integration.json b/packages/integration/src/locale/fr.integration.json index 4daef271b9..bf3e17d5eb 100644 --- a/packages/integration/src/locale/fr.integration.json +++ b/packages/integration/src/locale/fr.integration.json @@ -21,21 +21,6 @@ "advancedMap": "Outils avancés", "closestFeature": "Entités à proximité" }, - "catalog": { - "library.getCatalogList": "Obtenir la liste des services du catalogue", - "csv": { - "rank": "Rang", - "layerName": "Nom de la couche", - "layerGroup": "Nom du groupe de couches", - "catalog": "Catalogue", - "externalProvider": "Fournisseur", - "url": "URL", - "fileName": "Nom du fichier - Service Web", - "context": "Contexte/Thématique", - "dataDescription": "Description de la donnée", - "documentName": "ListeCouchesInformation" - } - }, "searchResultsTool": { "noResults": "Aucun résultat", "doSearch": "Veuillez effectuer une recherche dans la barre de recherche ci-dessus.", From 7340fbe58be98563448012b757c586e0a9c9244d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 30 Jan 2024 09:34:11 -0500 Subject: [PATCH 25/49] var to let or const --- .../catalog-library-tool.component.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts index 6eb8777f3c..3c78a02c86 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts @@ -154,7 +154,7 @@ export class CatalogLibraryToolComponent implements OnInit, OnDestroy { ) ] ]; - var dataArray = []; + let dataArray = []; this.generatelist$$ = zip([ this.store.entities$.pipe( switchMap((catalogs) => { @@ -178,19 +178,19 @@ export class CatalogLibraryToolComponent implements OnInit, OnDestroy { ) ) ) - ]).subscribe((returnv) => { + ]).subscribe((returnv: [CatalogItem[][], DetailedContext[]]) => { const res = returnv[0]; const layersfromContexts = returnv[1]; res.forEach((catalogs: Object) => { - var catalogsList = Object.keys(catalogs[1]).map( + const catalogsList = Object.keys(catalogs[1]).map( (key) => catalogs[1][key] ); - var catalogTitle = catalogs[0].title ? catalogs[0].title : null; + const catalogTitle = catalogs[0].title ? catalogs[0].title : null; catalogsList.forEach((catalogItemGroup) => { if (catalogItemGroup.items) { catalogItemGroup.items.forEach((item: any) => { dataArray = []; - var administrator = item.externalProvider ? 'Externe' : 'MTQ'; + const administrator = item.externalProvider ? 'Externe' : 'MTQ'; const absUrl = item.options.sourceOptions.url.charAt(0) === '/' ? window.location.origin + item.options.sourceOptions.url @@ -211,7 +211,7 @@ export class CatalogLibraryToolComponent implements OnInit, OnDestroy { catalogRank++; }); } else { - var itemGroupWMTS: any = catalogItemGroup; + const itemGroupWMTS: any = catalogItemGroup; if (!itemGroupWMTS.options) { dataArray.push( Object.keys(catalogItemGroup).map( @@ -222,7 +222,7 @@ export class CatalogLibraryToolComponent implements OnInit, OnDestroy { dataArray = []; } else { dataArray = []; - var administrator = itemGroupWMTS.externalProvider + const administrator = itemGroupWMTS.externalProvider ? 'Externe' : 'MTQ'; dataArray.push( @@ -244,7 +244,7 @@ export class CatalogLibraryToolComponent implements OnInit, OnDestroy { }); }); for (var index = 1; index < bufferArray.length; index++) { - var contextLayersList = []; + const contextLayersList = []; for (var layerContextList of layersfromContexts) { layerContextList.layers.forEach((layersName) => { if (bufferArray[index][6] === layersName.id) { @@ -257,9 +257,9 @@ export class CatalogLibraryToolComponent implements OnInit, OnDestroy { bufferArray[index][7] = contextLayersList.toString(); } let csvContent = bufferArray.map((e) => e.join(';')).join('\n'); - var encodedUri = encodeURI(csvContent); - var exportDocument = document.createElement('a'); - var date = new Date(); + const encodedUri = encodeURI(csvContent); + const exportDocument = document.createElement('a'); + const date = new Date(); exportDocument.setAttribute( 'href', 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodedUri @@ -278,11 +278,11 @@ export class CatalogLibraryToolComponent implements OnInit, OnDestroy { }); } private getFormatedDate(date: Date) { - var year = date.getFullYear(); - var month = (date.getMonth() + 1).toString().padStart(2, '0'); - var day = date.getDate().toString(); - var hours = date.getHours().toString(); - var minutes = date.getMinutes().toString(); + const year = date.getFullYear(); + const month = (date.getMonth() + 1).toString().padStart(2, '0'); + const day = date.getDate().toString(); + const hours = date.getHours().toString(); + const minutes = date.getMinutes().toString(); return `${year}-${month}-${day}:${hours}h${minutes}`; } } From 1dc02432a37e6614a20c1062f59b6f3239fa1629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 30 Jan 2024 09:34:20 -0500 Subject: [PATCH 26/49] locale --- .../integration/src/locale/en.integration.json | 17 +++++++++++++++++ .../integration/src/locale/fr.integration.json | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/packages/integration/src/locale/en.integration.json b/packages/integration/src/locale/en.integration.json index 153e4ed39b..1368b26e30 100644 --- a/packages/integration/src/locale/en.integration.json +++ b/packages/integration/src/locale/en.integration.json @@ -22,6 +22,23 @@ "advancedMap": "Advanced map tools", "closestFeature": "Closest feature tool" }, + "catalog": { + "library.getCatalogList": "Get the catalog services list", + "csv": { + "rank": "Rank", + "layerName": "Layer name", + "layerGroup": "Layer Group", + "catalog": "Catalog", + "externalProvider": "Provider", + "url": "URL", + "fileName": "File name - Web service", + "context": "Context/Thematic", + "dataDescription": "Data description", + "documentName": "LayerList_{{value}}", + "internal": "Internal", + "external": "External" + } + }, "dataIssueReporterTool": { "submit": { "title": "Submit a data inconsistency", diff --git a/packages/integration/src/locale/fr.integration.json b/packages/integration/src/locale/fr.integration.json index 359a8f9f61..157f691f76 100644 --- a/packages/integration/src/locale/fr.integration.json +++ b/packages/integration/src/locale/fr.integration.json @@ -22,6 +22,23 @@ "advancedMap": "Outils avancés", "closestFeature": "Entités à proximité" }, + "catalog": { + "library.getCatalogList": "Obtenir la liste des services du catalogue", + "csv": { + "rank": "Rang", + "layerName": "Nom de la couche", + "layerGroup": "Nom du groupe de couches", + "catalog": "Catalogue", + "externalProvider": "Fournisseur", + "url": "URL", + "fileName": "Nom du fichier - Service Web", + "context": "Contexte/Thématique", + "dataDescription": "Description de la donnée", + "documentName": "ListeCouchesInformation_{{value}}", + "internal": "Interne", + "external": "Externe" + } + }, "dataIssueReporterTool": { "submit": { "title": "Soumettre une incohérence de donnée", From 41af724033d26c364d8d06e2e7b5454249517953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 30 Jan 2024 15:41:07 -0500 Subject: [PATCH 27/49] refactor(catalog-library-tool): enhance typing --- .../catalog-library-tool.component.ts | 402 ++++++++++++------ .../catalog-library-tool.interface.ts | 20 + .../src/locale/en.integration.json | 4 +- .../src/locale/fr.integration.json | 4 +- 4 files changed, 291 insertions(+), 139 deletions(-) create mode 100644 packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.interface.ts diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts index 3c78a02c86..f4e4aa9078 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.ts @@ -1,3 +1,4 @@ +import { DatePipe } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -8,15 +9,38 @@ import { import { ToolComponent } from '@igo2/common'; import { EntityStore } from '@igo2/common'; -import { ContextService } from '@igo2/context'; +import { ContextService, DetailedContext } from '@igo2/context'; import { LanguageService, StorageService } from '@igo2/core'; -import { Catalog, CatalogItemLayer, CatalogService } from '@igo2/geo'; +import { + AnyDataSourceOptions, + ArcGISRestDataSourceOptions, + CartoDataSourceOptions, + Catalog, + CatalogItem, + CatalogItemGroup, + CatalogItemLayer, + CatalogItemType, + CatalogService, + ClusterDataSourceOptions, + FeatureDataSourceOptions, + MVTDataSourceOptions, + OSMDataSourceOptions, + WFSDataSourceOptions, + WMSDataSourceOptions, + WMTSDataSourceOptions, + XYZDataSourceOptions, + generateIdFromSourceOptions +} from '@igo2/geo'; import { Subscription, forkJoin, zip } from 'rxjs'; import { map, switchMap, take } from 'rxjs/operators'; import { ToolState } from '../../tool/tool.state'; import { CatalogState } from '../catalog.state'; +import { + CsvOutput, + InfoFromSourceOptions +} from './catalog-library-tool.interface'; /** * Tool to browse the list of available catalogs. @@ -58,7 +82,8 @@ export class CatalogLibraryToolComponent implements OnInit, OnDestroy { private catalogState: CatalogState, private toolState: ToolState, private storageService: StorageService, - private languageService: LanguageService + private languageService: LanguageService, + private datePipe: DatePipe ) {} /** @@ -121,48 +146,130 @@ export class CatalogLibraryToolComponent implements OnInit, OnDestroy { } } - getCatalogList() { + private getLayerInfosFromSourceOptions( + so: AnyDataSourceOptions, + context?: string + ): InfoFromSourceOptions { + const rv: InfoFromSourceOptions = { + id: undefined, + layerName: undefined, + url: undefined, + so: undefined, + context + }; + + switch (so.type) { + case 'imagearcgisrest': + case 'arcgisrest': + case 'tilearcgisrest': + const argisSo = so as ArcGISRestDataSourceOptions; + rv.layerName = argisSo.layer; + rv.url = argisSo.url; + rv.so = argisSo; + break; + case 'wmts': + const wmtsSo = so as WMTSDataSourceOptions; + rv.layerName = wmtsSo.layer; + rv.url = wmtsSo.url; + rv.so = wmtsSo; + break; + case 'xyz': + const xyzSo = so as XYZDataSourceOptions; + rv.layerName = ''; + rv.url = xyzSo.url; + rv.so = xyzSo; + break; + case 'wms': + const wmsSo = so as WMSDataSourceOptions; + wmsSo.params.LAYERS = + wmsSo.params.LAYERS ?? (wmsSo.params as any).layers; + rv.layerName = wmsSo.params.LAYERS; + + rv.url = wmsSo.url; + rv.so = wmsSo; + break; + case 'osm': + const osmSo = so as OSMDataSourceOptions; + rv.layerName = ''; + rv.url = osmSo.url + ? osmSo.url + : 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'; + rv.so = osmSo; + break; + case 'wfs': + const wfsSo = so as WFSDataSourceOptions; + rv.layerName = wfsSo.params.featureTypes; + rv.url = wfsSo.url; + rv.so = wfsSo; + break; + case 'vector': + const featureSo = so as FeatureDataSourceOptions; + rv.layerName = ''; + rv.url = featureSo.url; + rv.so = featureSo; + break; + case 'cluster': + const clusterSo = so as ClusterDataSourceOptions; + rv.layerName = ''; + rv.url = clusterSo.url; + rv.so = clusterSo; + break; + case 'mvt': + const mvtSo = so as MVTDataSourceOptions; + rv.layerName = ''; + rv.url = mvtSo.url; + rv.so = mvtSo; + break; + case 'carto': + const cartoSo = so as CartoDataSourceOptions; + rv.layerName = cartoSo.config.layers + .map((layer) => layer.options.sql) + .join(' '); + rv.url = `https://${cartoSo.account}.carto.com/api/v1/map`; + rv.so = cartoSo; + break; + default: + break; + } + if (rv.so) { + rv.id = generateIdFromSourceOptions(rv.so); + rv.url = rv.url?.startsWith('/') + ? window.location.origin + rv.url + : rv.url; + } + + return rv; + } + + getCatalogList(): void { var catalogRank = 1; - let bufferArray = [ - [ - this.languageService.translate.instant( - 'igo.integration.catalog.csv.rank' - ), - this.languageService.translate.instant( - 'igo.integration.catalog.csv.layerName' - ), - this.languageService.translate.instant( - 'igo.integration.catalog.csv.layerGroup' - ), - this.languageService.translate.instant( - 'igo.integration.catalog.csv.catalog' - ), - this.languageService.translate.instant( - 'igo.integration.catalog.csv.externalProvider' - ), - this.languageService.translate.instant( - 'igo.integration.catalog.csv.url' - ), - this.languageService.translate.instant( - 'igo.integration.catalog.csv.fileName' - ), - this.languageService.translate.instant( - 'igo.integration.catalog.csv.context' - ), - this.languageService.translate.instant( + const t = this.languageService.translate; + let bufferArray: CsvOutput[] = [ + { + id: 'csvHeader', + rank: t.instant('igo.integration.catalog.csv.rank'), + layerTitle: t.instant('igo.integration.catalog.csv.layerTitle'), + layerGroup: t.instant('igo.integration.catalog.csv.layerGroup'), + catalog: t.instant('igo.integration.catalog.csv.catalog'), + provider: t.instant('igo.integration.catalog.csv.externalProvider'), + url: t.instant('igo.integration.catalog.csv.url'), + layerName: t.instant('igo.integration.catalog.csv.layerName'), + context: t.instant('igo.integration.catalog.csv.context'), + dataDescription: t.instant( 'igo.integration.catalog.csv.dataDescription' ) - ] + } ]; - let dataArray = []; this.generatelist$$ = zip([ this.store.entities$.pipe( switchMap((catalogs) => { return forkJoin( - catalogs.map((ca) => - this.catalogService - .loadCatalogItems(ca) - .pipe(map((lci) => [ca, lci])) + catalogs.map((catalog) => + this.catalogService.loadCatalogItems(catalog).pipe( + map((loadedCatalogItems) => { + return { catalog, loadedCatalogItems }; + }) + ) ) ); }) @@ -178,111 +285,136 @@ export class CatalogLibraryToolComponent implements OnInit, OnDestroy { ) ) ) - ]).subscribe((returnv: [CatalogItem[][], DetailedContext[]]) => { - const res = returnv[0]; - const layersfromContexts = returnv[1]; - res.forEach((catalogs: Object) => { - const catalogsList = Object.keys(catalogs[1]).map( - (key) => catalogs[1][key] + ]).subscribe( + ( + returnv: [ + { + catalog: Catalog; + loadedCatalogItems: CatalogItem[]; + }[], + DetailedContext[] + ] + ) => { + const catalogsAndItems = returnv[0]; + const detailedContexts = returnv[1]; + + const layerInfosFromDetailedContexts: InfoFromSourceOptions[] = []; + detailedContexts.map((detailedContext) => + detailedContext.layers.map((layer) => + layerInfosFromDetailedContexts.push( + this.getLayerInfosFromSourceOptions( + layer.sourceOptions, + detailedContext.title ?? detailedContext.uri + ) + ) + ) ); - const catalogTitle = catalogs[0].title ? catalogs[0].title : null; - catalogsList.forEach((catalogItemGroup) => { - if (catalogItemGroup.items) { - catalogItemGroup.items.forEach((item: any) => { - dataArray = []; - const administrator = item.externalProvider ? 'Externe' : 'MTQ'; - const absUrl = - item.options.sourceOptions.url.charAt(0) === '/' - ? window.location.origin + item.options.sourceOptions.url - : item.options.sourceOptions.url; - dataArray.push( - catalogRank, - item.title, - catalogItemGroup.title, - catalogTitle, - administrator, - absUrl, - item.options.sourceOptions.params.LAYERS, - '', - this.getDescription(item) - ); - bufferArray.push(dataArray); - dataArray = []; - catalogRank++; + console.log(layerInfosFromDetailedContexts); + + catalogsAndItems.map((catalogAndItems) => { + const catalog = catalogAndItems.catalog; + const loadedCatalogItems = catalogAndItems.loadedCatalogItems; + + let groups = loadedCatalogItems.filter( + (i) => i.type === CatalogItemType.Group + ); + let layers = loadedCatalogItems.filter( + (i) => i.type === CatalogItemType.Layer + ); + + let layersToProcess: CatalogItemLayer[]; + let groupsToProcess: CatalogItemGroup[]; + + layersToProcess = layers.map((layer) => layer as CatalogItemLayer); + groupsToProcess = groups.map((group) => group as CatalogItemGroup); + + layersToProcess.map((layer) => { + const infos = this.getLayerInfosFromSourceOptions( + layer.options.sourceOptions + ); + bufferArray.push({ + id: infos.id, + rank: catalogRank.toString(), + layerTitle: layer.title, + layerGroup: '', + catalog: catalog.title, + provider: + layer.externalProvider ?? catalog.externalProvider + ? t.instant('igo.integration.catalog.csv.external') + : t.instant('igo.integration.catalog.csv.internal'), + url: infos.url, + layerName: infos.layerName, + context: '', + dataDescription: this.getDescription(layer) }); - } else { - const itemGroupWMTS: any = catalogItemGroup; - if (!itemGroupWMTS.options) { - dataArray.push( - Object.keys(catalogItemGroup).map( - (key) => catalogItemGroup[key] - ) - ); - bufferArray.push(dataArray); - dataArray = []; - } else { - dataArray = []; - const administrator = itemGroupWMTS.externalProvider - ? 'Externe' - : 'MTQ'; - dataArray.push( - catalogRank, - itemGroupWMTS.title, - itemGroupWMTS.title, - catalogTitle, - administrator, - itemGroupWMTS.options.sourceOptions.url, - itemGroupWMTS.options.sourceOptions.layer, - '', - this.getDescription(itemGroupWMTS) + catalogRank++; + }); + + groupsToProcess.map((group) => { + group.items.map((layer) => { + const layerToProcess = layer as CatalogItemLayer; + const infos = this.getLayerInfosFromSourceOptions( + layerToProcess.options.sourceOptions, + layer.id ); - bufferArray.push(dataArray); - dataArray = []; + bufferArray.push({ + id: infos.id, + rank: catalogRank.toString(), + layerTitle: layerToProcess.title, + layerGroup: group.title, + catalog: catalog.title, + provider: layerToProcess.externalProvider + ? t.instant('igo.integration.catalog.csv.external') + : t.instant('igo.integration.catalog.csv.internal'), + url: infos.url, + layerName: infos.layerName, + context: '', + dataDescription: this.getDescription(layerToProcess) + }); catalogRank++; - } - } + }); + }); }); - }); - for (var index = 1; index < bufferArray.length; index++) { - const contextLayersList = []; - for (var layerContextList of layersfromContexts) { - layerContextList.layers.forEach((layersName) => { - if (bufferArray[index][6] === layersName.id) { - if (layerContextList.title !== undefined) { - contextLayersList.push(layerContextList.title); - } - } + + const sep = this.languageService.getLanguage() === 'fr' ? ',' : ';'; + bufferArray + .filter((b) => b.id !== 'csvHeader') + .map((buff) => { + const matchingLayersFromContext = layerInfosFromDetailedContexts + .filter((l) => l.id === buff.id) + // TODO + .map((f) => f.context); + buff.context = matchingLayersFromContext.join(sep); }); - } - bufferArray[index][7] = contextLayersList.toString(); + + this.downloadCsv(bufferArray); } - let csvContent = bufferArray.map((e) => e.join(';')).join('\n'); - const encodedUri = encodeURI(csvContent); - const exportDocument = document.createElement('a'); - const date = new Date(); - exportDocument.setAttribute( - 'href', - 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodedUri - ); - exportDocument.setAttribute( - 'download', - this.languageService.translate.instant( - 'igo.integration.catalog.csv.documentName' - ) + - '_' + - this.getFormatedDate(date) - ); - document.body.appendChild(exportDocument); - exportDocument.click(); - document.body.removeChild(exportDocument); - }); + ); } - private getFormatedDate(date: Date) { - const year = date.getFullYear(); - const month = (date.getMonth() + 1).toString().padStart(2, '0'); - const day = date.getDate().toString(); - const hours = date.getHours().toString(); - const minutes = date.getMinutes().toString(); - return `${year}-${month}-${day}:${hours}h${minutes}`; + + private downloadCsv(csvOutput: CsvOutput[]) { + const sep = this.languageService.getLanguage() === 'fr' ? ';' : ','; + let csvContent = csvOutput + .map((e) => { + return `${e.rank}${sep}${e.layerTitle}${sep}${e.layerGroup}${sep}${e.catalog}${sep}${e.provider}${sep}${e.url}${sep}${e.layerName}${sep}${e.context}${sep}${e.dataDescription}`; + }) + .join('\n'); + + const encodedUri = encodeURI(csvContent); + const exportDocument = document.createElement('a'); + exportDocument.setAttribute( + 'href', + 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodedUri + ); + exportDocument.setAttribute( + 'download', + this.languageService.translate.instant( + 'igo.integration.catalog.csv.documentName', + { value: this.datePipe.transform(Date.now(), 'YYYY-MM-dd-H_mm') } + ) + ); + document.body.appendChild(exportDocument); + exportDocument.click(); + document.body.removeChild(exportDocument); } } diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.interface.ts b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.interface.ts new file mode 100644 index 0000000000..414405527a --- /dev/null +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.interface.ts @@ -0,0 +1,20 @@ +export interface CsvOutput { + id: string; + rank: string; + layerTitle: string; + layerGroup: string; + catalog: string; + provider: string; + url: string; + layerName: string; + context: string; + dataDescription: string; +} + +export interface InfoFromSourceOptions { + id: string; + layerName: string; + url: string; + so: unknown; + context: string; +} diff --git a/packages/integration/src/locale/en.integration.json b/packages/integration/src/locale/en.integration.json index 1368b26e30..aa65ebdc38 100644 --- a/packages/integration/src/locale/en.integration.json +++ b/packages/integration/src/locale/en.integration.json @@ -26,12 +26,12 @@ "library.getCatalogList": "Get the catalog services list", "csv": { "rank": "Rank", - "layerName": "Layer name", + "layerTitle": "Layer Title", "layerGroup": "Layer Group", "catalog": "Catalog", "externalProvider": "Provider", "url": "URL", - "fileName": "File name - Web service", + "layerName": "File name - Web service", "context": "Context/Thematic", "dataDescription": "Data description", "documentName": "LayerList_{{value}}", diff --git a/packages/integration/src/locale/fr.integration.json b/packages/integration/src/locale/fr.integration.json index 157f691f76..39c741034d 100644 --- a/packages/integration/src/locale/fr.integration.json +++ b/packages/integration/src/locale/fr.integration.json @@ -26,12 +26,12 @@ "library.getCatalogList": "Obtenir la liste des services du catalogue", "csv": { "rank": "Rang", - "layerName": "Nom de la couche", + "layerTitle": "Titre de la couche", "layerGroup": "Nom du groupe de couches", "catalog": "Catalogue", "externalProvider": "Fournisseur", "url": "URL", - "fileName": "Nom du fichier - Service Web", + "layerName": "Nom du fichier - Service Web", "context": "Contexte/Thématique", "dataDescription": "Description de la donnée", "documentName": "ListeCouchesInformation_{{value}}", From 3b66d62da3befe4657dbe0c56f15858bfc8a195b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 6 Feb 2024 12:33:29 -0500 Subject: [PATCH 28/49] review comment --- .../catalog-library.component.ts | 4 +- .../datasources/any-datasource.interface.ts | 8 + .../datasources/any-datasource.utils.ts | 112 ++++++ .../datasource/shared/datasources/index.ts | 1 + .../catalog-library-tool.component.html | 2 +- .../catalog-library-tool.component.scss | 2 +- .../catalog-library-tool.component.ts | 366 +++++++----------- .../catalog-library-tool.interface.ts | 8 - 8 files changed, 262 insertions(+), 241 deletions(-) create mode 100644 packages/geo/src/lib/datasource/shared/datasources/any-datasource.utils.ts diff --git a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts index bb9a2c8047..8d284e659c 100644 --- a/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts +++ b/packages/geo/src/lib/catalog/catalog-library/catalog-library.component.ts @@ -21,7 +21,6 @@ import { CapabilitiesService } from '../../datasource/shared/capabilities.servic import { IgoMap } from '../../map/shared/map'; import { standardizeUrl } from '../../utils/id-generator'; import { Catalog } from '../shared/catalog.abstract'; -import { CatalogService } from '../shared/catalog.service'; import { AddCatalogDialogComponent } from './add-catalog-dialog.component'; /** @@ -76,8 +75,7 @@ export class CatalogLibaryComponent implements OnInit, OnDestroy { private capabilitiesService: CapabilitiesService, private messageService: MessageService, private storageService: StorageService, - private dialog: MatDialog, - private catalogService: CatalogService + private dialog: MatDialog ) {} /** diff --git a/packages/geo/src/lib/datasource/shared/datasources/any-datasource.interface.ts b/packages/geo/src/lib/datasource/shared/datasources/any-datasource.interface.ts index fcdbd13c90..d913511e8a 100644 --- a/packages/geo/src/lib/datasource/shared/datasources/any-datasource.interface.ts +++ b/packages/geo/src/lib/datasource/shared/datasources/any-datasource.interface.ts @@ -28,3 +28,11 @@ export type AnyDataSourceOptions = | TileArcGISRestDataSourceOptions | MVTDataSourceOptions | ClusterDataSourceOptions; + +export interface InfoFromSourceOptions { + id: string; + layerName: string; + url: string; + sourceOptions: AnyDataSourceOptions; + context: string; +} diff --git a/packages/geo/src/lib/datasource/shared/datasources/any-datasource.utils.ts b/packages/geo/src/lib/datasource/shared/datasources/any-datasource.utils.ts new file mode 100644 index 0000000000..8189f6c0e7 --- /dev/null +++ b/packages/geo/src/lib/datasource/shared/datasources/any-datasource.utils.ts @@ -0,0 +1,112 @@ +import { generateIdFromSourceOptions } from '../../../utils/id-generator'; +import { + AnyDataSourceOptions, + InfoFromSourceOptions +} from './any-datasource.interface'; +import { ArcGISRestDataSourceOptions } from './arcgisrest-datasource.interface'; +import { CartoDataSourceOptions } from './carto-datasource.interface'; +import { ClusterDataSourceOptions } from './cluster-datasource.interface'; +import { FeatureDataSourceOptions } from './feature-datasource.interface'; +import { MVTDataSourceOptions } from './mvt-datasource.interface'; +import { OSMDataSourceOptions } from './osm-datasource.interface'; +import { WFSDataSourceOptions } from './wfs-datasource.interface'; +import { WMSDataSourceOptions } from './wms-datasource.interface'; +import { WMTSDataSourceOptions } from './wmts-datasource.interface'; +import { XYZDataSourceOptions } from './xyz-datasource.interface'; + +export function getInfoFromSourceOptions( + sourceOptions: AnyDataSourceOptions, + context?: string +): InfoFromSourceOptions { + const infoFromSourceOptions: InfoFromSourceOptions = { + id: undefined, + layerName: undefined, + url: undefined, + sourceOptions: undefined, + context + }; + const so = sourceOptions; + + switch (so.type) { + case 'imagearcgisrest': + case 'arcgisrest': + case 'tilearcgisrest': + const argisSo = so as ArcGISRestDataSourceOptions; + infoFromSourceOptions.layerName = argisSo.layer; + infoFromSourceOptions.url = argisSo.url; + infoFromSourceOptions.sourceOptions = argisSo; + break; + case 'wmts': + const wmtsSo = so as WMTSDataSourceOptions; + infoFromSourceOptions.layerName = wmtsSo.layer; + infoFromSourceOptions.url = wmtsSo.url; + infoFromSourceOptions.sourceOptions = wmtsSo; + break; + case 'xyz': + const xyzSo = so as XYZDataSourceOptions; + infoFromSourceOptions.layerName = ''; + infoFromSourceOptions.url = xyzSo.url; + infoFromSourceOptions.sourceOptions = xyzSo; + break; + case 'wms': + const wmsSo = so as WMSDataSourceOptions; + wmsSo.params.LAYERS = wmsSo.params.LAYERS ?? (wmsSo.params as any).layers; + infoFromSourceOptions.layerName = wmsSo.params.LAYERS; + + infoFromSourceOptions.url = wmsSo.url; + infoFromSourceOptions.sourceOptions = wmsSo; + break; + case 'osm': + const osmSo = so as OSMDataSourceOptions; + infoFromSourceOptions.layerName = ''; + infoFromSourceOptions.url = osmSo.url + ? osmSo.url + : 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'; + infoFromSourceOptions.sourceOptions = osmSo; + break; + case 'wfs': + const wfsSo = so as WFSDataSourceOptions; + infoFromSourceOptions.layerName = wfsSo.params.featureTypes; + infoFromSourceOptions.url = wfsSo.url; + infoFromSourceOptions.sourceOptions = wfsSo; + break; + case 'vector': + const featureSo = so as FeatureDataSourceOptions; + infoFromSourceOptions.layerName = ''; + infoFromSourceOptions.url = featureSo.url; + infoFromSourceOptions.sourceOptions = featureSo; + break; + case 'cluster': + const clusterSo = so as ClusterDataSourceOptions; + infoFromSourceOptions.layerName = ''; + infoFromSourceOptions.url = clusterSo.url; + infoFromSourceOptions.sourceOptions = clusterSo; + break; + case 'mvt': + const mvtSo = so as MVTDataSourceOptions; + infoFromSourceOptions.layerName = ''; + infoFromSourceOptions.url = mvtSo.url; + infoFromSourceOptions.sourceOptions = mvtSo; + break; + case 'carto': + const cartoSo = so as CartoDataSourceOptions; + infoFromSourceOptions.layerName = cartoSo.config.layers + .map((layer) => layer.options.sql) + .join(' '); + infoFromSourceOptions.url = `https://${cartoSo.account}.carto.com/api/v1/map`; + infoFromSourceOptions.sourceOptions = cartoSo; + break; + default: + break; + } + if (infoFromSourceOptions.sourceOptions) { + infoFromSourceOptions.id = generateIdFromSourceOptions( + infoFromSourceOptions.sourceOptions + ); + infoFromSourceOptions.url = infoFromSourceOptions.url?.startsWith('/') + ? window.location.origin + infoFromSourceOptions.url + : infoFromSourceOptions.url; + } + + return infoFromSourceOptions; +} diff --git a/packages/geo/src/lib/datasource/shared/datasources/index.ts b/packages/geo/src/lib/datasource/shared/datasources/index.ts index bb00a607db..324ba35283 100644 --- a/packages/geo/src/lib/datasource/shared/datasources/index.ts +++ b/packages/geo/src/lib/datasource/shared/datasources/index.ts @@ -33,3 +33,4 @@ export * from './cluster-datasource'; export * from './cluster-datasource.interface'; export * from './any-datasource'; export * from './any-datasource.interface'; +export * from './any-datasource.utils'; diff --git a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html index e3296e310d..cf2097b4dc 100644 --- a/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html +++ b/packages/integration/src/lib/catalog/catalog-library-tool/catalog-library-tool.component.html @@ -5,7 +5,7 @@ (catalogSelectChange)="onCatalogSelectChange($event)" > -
+