From 0e81a90cb92bfe98f7164c4f2cbccf12a0e89333 Mon Sep 17 00:00:00 2001
From: Matthieu Benoist <mbenoist@ausy-group.com>
Date: Thu, 25 Mar 2021 08:13:22 +0100
Subject: [PATCH] cahnge dataset url, tab orders, robots rules (exemple)

---
 .../dataset-detail.component.html             | 36 +++++++++----------
 .../dataset-detail.component.ts               | 13 ++++---
 .../filter-list/filter-list.component.ts      |  2 +-
 .../result-dataset.component.ts               |  2 +-
 src/app/datasets/datasets-routing.module.ts   |  4 +--
 .../services/dataset-research.service.ts      |  6 ++--
 .../datasets/services/research-url.service.ts |  6 ++--
 .../cms-posts-list.component.ts               | 27 ++++----------
 .../components/home/home.component.html       |  2 +-
 .../components/home/home.component.ts         |  2 +-
 .../site-map/site-map.component.html          |  2 +-
 src/robots.txt                                | 25 +++++++++++++
 12 files changed, 71 insertions(+), 56 deletions(-)

diff --git a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html
index 1a5c67bc..d1157f57 100644
--- a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html
+++ b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html
@@ -3,25 +3,8 @@
     <app-page-header [pageInfo]="pageHeaderInfo" [customGoToPreviousPage]="goToPreviousPage"></app-page-header>
   </div>
 
-  <div class="tabulations">
+  <div class="tabulations" *ngIf="!isRendertron">
     <ul class="navigation-tabs">
-      <li [routerLinkActive]="'is-active'" *ngIf="hasTable || hasMap">
-        <a (click)="setPosition()" [routerLink]="[AppRoutes.data.uri]" class="tab-link">
-          <svg class="tab-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 38 32" aria-hidden="true">
-            <path class="primary"
-              d="M19 0L4.5 6.4v19.4L19 32l14.5-6.4V6.4L19 0zm13.5 24.9l-13 5.7-.5.3-13.5-5.8v-18l13.5-6 13.1 5.8L19 13l.5.2v.6l13-6.1v17.2z" />
-            <path class="secondary" d="M19 30.9l.5-.2V13.2L5.9 6.9l-.4.2v.7l13 6.1v16.8z" />
-          </svg>
-          <div class="tab-text-wrapper">
-            <div>
-              <span class="tab-title" i18n="@@dataset.detail.data">Data</span>
-            </div>
-            <div>
-              <span class="tab-subtitle" i18n="@@dataset.detail.lines">{{ datasetDataNumber }} lines</span>
-            </div>
-          </div>
-        </a>
-      </li>
       <li [routerLinkActive]="'is-active'">
         <a (click)="setPosition()" [routerLink]="[AppRoutes.info.uri]" class="tab-link">
           <svg class="tab-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 37 37" aria-hidden="true">
@@ -47,6 +30,23 @@
           </div>
         </a>
       </li>
+      <li [routerLinkActive]="'is-active'" *ngIf="hasTable || hasMap">
+        <a (click)="setPosition()" [routerLink]="[AppRoutes.data.uri]" class="tab-link">
+          <svg class="tab-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 38 32" aria-hidden="true">
+            <path class="primary"
+              d="M19 0L4.5 6.4v19.4L19 32l14.5-6.4V6.4L19 0zm13.5 24.9l-13 5.7-.5.3-13.5-5.8v-18l13.5-6 13.1 5.8L19 13l.5.2v.6l13-6.1v17.2z" />
+            <path class="secondary" d="M19 30.9l.5-.2V13.2L5.9 6.9l-.4.2v.7l13 6.1v16.8z" />
+          </svg>
+          <div class="tab-text-wrapper">
+            <div>
+              <span class="tab-title" i18n="@@dataset.detail.data">Data</span>
+            </div>
+            <div>
+              <span class="tab-subtitle" i18n="@@dataset.detail.lines">{{ datasetDataNumber }} lines</span>
+            </div>
+          </div>
+        </a>
+      </li>
       <li [routerLinkActive]="'is-active'" *ngIf="datasetFormatsList">
         <a (click)="setPosition()" [routerLink]="[AppRoutes.downloads.uri]" class="tab-link">
       <svg class="tab-icon" xmlns="http://www.w3.org/2000/svg" data-name="Calque 1" viewBox="0 0 38 32" aria-hidden="true">
diff --git a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts
index 67e9466c..80972adc 100644
--- a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts
+++ b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts
@@ -9,6 +9,7 @@ import { datatsetDataRepresentationType, geosource, reusesTypes } from '../../..
 import { NavigationHistoryService } from '../../../core/services';
 import { AppRoutes } from '../../../routes';
 import { IPageHeaderInfo, Metadata, typesMetadata } from '../../../shared/models';
+import { isRentertron } from '../../../shared/variables';
 import { DatasetDetailService } from '../../services';
 
 
@@ -20,6 +21,8 @@ import { DatasetDetailService } from '../../services';
 export class DatasetDetailComponent implements OnInit, OnDestroy {
 
   AppRoutes = AppRoutes;
+  isRendertron = isRentertron;
+
   pageHeaderInfo: IPageHeaderInfo = {
     title: '',
     shareButtons: {
@@ -224,16 +227,16 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
     // If a tab (info, data...) is not specified in the url then redirect to the data tab if the dataset
     // as a table or a map or to the info tab in the failing case
     if (!this._route.snapshot.firstChild) {
-      if (this.hasTable || this.hasMap) {
+      //if (this.hasTable || this.hasMap) {
         this._router.navigate([
-          `/${AppRoutes.datasets.uri}/${this._datasetDetailService.dataset.slug}/${AppRoutes.data.uri}`,
+          `/${AppRoutes.datasets.uri}/${this._datasetDetailService.dataset.slug}/${AppRoutes.info.uri}`,
           // tslint:disable-next-line: align
         ], { queryParamsHandling: 'preserve', replaceUrl: true });
-      } else {
+      /*} else {
         this._router.navigate([
           `/${AppRoutes.datasets.uri}/${this._datasetDetailService.dataset.slug}/${AppRoutes.info.uri}`,
         ], {replaceUrl: true});
-      }
+      }*/
     } else {
       // Making that the url contains the slug and not the uuid of the dataset
       this._router.navigate([
@@ -266,7 +269,7 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
 
     // If url is null then redirect to research page
     if (url == null) {
-      url = `/${AppRoutes.research.uri}`;
+      url = `/${AppRoutes.datasets.uri}`;
     }
 
     this._router.navigateByUrl(url);
diff --git a/src/app/datasets/components/filter-list/filter-list.component.ts b/src/app/datasets/components/filter-list/filter-list.component.ts
index 518d9522..99b500dc 100644
--- a/src/app/datasets/components/filter-list/filter-list.component.ts
+++ b/src/app/datasets/components/filter-list/filter-list.component.ts
@@ -105,7 +105,7 @@ export class FilterListComponent implements OnInit, OnDestroy {
   resetActiveAggregations() {
     this._datasetResearchService.resetActiveAggregations();
     this._datasetResearchService.triggerSearchChange();
-    this._location.go(AppRoutes.research.uri, '');
+    this._location.go(AppRoutes.datasets.uri, '');
     this._navigationHistoryService.add(this._location.path());
   }
 
diff --git a/src/app/datasets/components/results/result-dataset/result-dataset.component.ts b/src/app/datasets/components/results/result-dataset/result-dataset.component.ts
index 5fa41dd5..0c174527 100644
--- a/src/app/datasets/components/results/result-dataset/result-dataset.component.ts
+++ b/src/app/datasets/components/results/result-dataset/result-dataset.component.ts
@@ -47,7 +47,7 @@ export class ResultDatasetComponent implements OnInit {
   }
 
   get datasetDetailsURI() {
-    return this.dataset.hasMap || this.dataset.hasTable ? AppRoutes.data.uri : AppRoutes.info.uri;
+    return AppRoutes.info.uri;
   }
 
 }
diff --git a/src/app/datasets/datasets-routing.module.ts b/src/app/datasets/datasets-routing.module.ts
index c296462c..849eb197 100644
--- a/src/app/datasets/datasets-routing.module.ts
+++ b/src/app/datasets/datasets-routing.module.ts
@@ -5,10 +5,10 @@ import { ResultsComponent } from './components';
 
 export const routes: Routes = [
   {
-    path: AppRoutes.research.uri,
+    path: AppRoutes.datasets.uri,
     component: ResultsComponent,
     data: {
-      title: AppRoutes.research.title,
+      title: AppRoutes.datasets.title,
     },
   },
   {
diff --git a/src/app/datasets/services/dataset-research.service.ts b/src/app/datasets/services/dataset-research.service.ts
index 474914eb..1308666b 100644
--- a/src/app/datasets/services/dataset-research.service.ts
+++ b/src/app/datasets/services/dataset-research.service.ts
@@ -479,11 +479,11 @@ export class DatasetResearchService {
     this._elasticsearchOptions.shouldAggregateResultCount = true;
     this._elasticsearchOptions.sortOptions.value = (value && true) ? 'relevance' : 'date';
     this._elasticsearchOptions.sortOptions.order = 'desc';
-    if (this._router.url.split('/').pop() !== AppRoutes.research.uri) {
+    if (this._router.url.split('/').pop() !== AppRoutes.datasets.uri) {
       if (value === '') {
-        this._router.navigate(['/', `${AppRoutes.research.uri}`]);
+        this._router.navigate(['/', `${AppRoutes.datasets.uri}`]);
       } else {
-        this._router.navigate(['/', `${AppRoutes.research.uri}`], { queryParams: { q: value } });
+        this._router.navigate(['/', `${AppRoutes.datasets.uri}`], { queryParams: { q: value } });
       }
     }
 
diff --git a/src/app/datasets/services/research-url.service.ts b/src/app/datasets/services/research-url.service.ts
index e14a2a94..a6338629 100644
--- a/src/app/datasets/services/research-url.service.ts
+++ b/src/app/datasets/services/research-url.service.ts
@@ -81,7 +81,7 @@ export class ResearchUrlService {
   setParameter(key: string, searchValue: string) {
     this._parameters[key] = searchValue;
     const params = this.generateUrlParams();
-    this._location.go(AppRoutes.research.uri, params);
+    this._location.go(AppRoutes.datasets.uri, params);
     this._navigationHistoryService.add(this._location.path());
   }
 
@@ -136,7 +136,7 @@ export class ResearchUrlService {
       }
     }
     const params = this.generateUrlParams();
-    this._location.go(AppRoutes.research.uri, params);
+    this._location.go(AppRoutes.datasets.uri, params);
     this._navigationHistoryService.add(this._location.path());
   }
 
@@ -173,7 +173,7 @@ export class ResearchUrlService {
     const value = option.order === 'desc' ? `-${option.value}` : option.value;
     this._parameters['sort'] = value;
     const params = this.generateUrlParams();
-    this._location.go(AppRoutes.research.uri, params);
+    this._location.go(AppRoutes.datasets.uri, params);
     this._navigationHistoryService.add(this._location.path());
   }
 
diff --git a/src/app/editorialisation/components/cms-posts-list/cms-posts-list.component.ts b/src/app/editorialisation/components/cms-posts-list/cms-posts-list.component.ts
index 0193237a..5859a2e0 100644
--- a/src/app/editorialisation/components/cms-posts-list/cms-posts-list.component.ts
+++ b/src/app/editorialisation/components/cms-posts-list/cms-posts-list.component.ts
@@ -40,25 +40,14 @@ export class CMSPostsListComponent implements OnInit, OnDestroy {
     const countResults = [];
     this._datasetResearchService.pageSize = 9;
 
-    this._datasetResearchService.getResults().subscribe((posts) => {
-      this.posts = [];
-      posts.forEach((result) => {
-        this.posts.push(result);
-      });
-
-      this._datasetResearchService.resultsCount.forEach((item) => {
-        console.log ('passage...');
-        countResults[item.scopeKey] = item.count || 0;
-      });
-      const length = countResults[scopesResearch.post.key];
+    this.paginator = {
+      pageIndex: this._datasetResearchService.pageIndex + 1,
+      length: 0,
+      pageSize: this._datasetResearchService.pageSize,
+      pageSizeOptions: [5, 10, 20],
+    };
 
-      this.paginator = {
-        pageIndex: this._datasetResearchService.pageIndex + 1,
-        length: length,
-        pageSize: this._datasetResearchService.pageSize,
-        pageSizeOptions: [5, 10, 20],
-      };
-    });
+    this.search();
   }
 
   // When pagination is changed by user, we update results with new pagination options
@@ -77,8 +66,6 @@ export class CMSPostsListComponent implements OnInit, OnDestroy {
         this.posts.push(result);
       });
       //const position = this._viewportScroller.getScrollPosition();
-
-
       this.countResults = [];
       this._datasetResearchService.resultsCount.forEach((item) => {
         this.countResults[item.scopeKey] = item.count || 0;
diff --git a/src/app/editorialisation/components/home/home.component.html b/src/app/editorialisation/components/home/home.component.html
index 14afb02e..db854474 100644
--- a/src/app/editorialisation/components/home/home.component.html
+++ b/src/app/editorialisation/components/home/home.component.html
@@ -17,7 +17,7 @@
     </div>
     <div class="search column is-7-desktop is-8-tablet ">
       <app-search-bar class="app-search-bar"></app-search-bar>
-      <a class="explore-link" [routerLink]="['/', AppRoutes.research.uri]" (click)="trackExploreButtonEvent()">
+      <a class="explore-link" [routerLink]="['/', AppRoutes.datasets.uri]" (click)="trackExploreButtonEvent()">
         <button class="button explore-button" i18n="@@home.explore">Explore</button>
       </a>
     </div>
diff --git a/src/app/editorialisation/components/home/home.component.ts b/src/app/editorialisation/components/home/home.component.ts
index 9d9fab40..faf0f35a 100644
--- a/src/app/editorialisation/components/home/home.component.ts
+++ b/src/app/editorialisation/components/home/home.component.ts
@@ -105,7 +105,7 @@ export class HomeComponent implements OnInit {
   goToPostsResearch() {
     this._datasetResearchService.resetResearch();
     this._datasetResearchService.scopeReasearch = scopesResearch.post;
-    this._router.navigate(['/', AppRoutes.research.uri]);
+    this._router.navigate(['/', AppRoutes.datasets.uri]);
   }
 
   trackExploreButtonEvent() {
diff --git a/src/app/editorialisation/components/site-map/site-map.component.html b/src/app/editorialisation/components/site-map/site-map.component.html
index a725a92d..f5d3e266 100644
--- a/src/app/editorialisation/components/site-map/site-map.component.html
+++ b/src/app/editorialisation/components/site-map/site-map.component.html
@@ -6,7 +6,7 @@
       <p class="pages-group-title" i18n="@@sitemap.mainPages">Main pages</p>
       <ul class="pages-list">
         <li><a class="link-1" [routerLink]="['/', AppRoutes.home.uri]" i18n="@@sitemap.home">Home</a></li>
-        <li><a class="link-1" [routerLink]="['/', AppRoutes.research.uri]" i18n="@@sitemap.research">Research</a></li>
+        <li><a class="link-1" [routerLink]="['/', AppRoutes.datasets.uri]" i18n="@@sitemap.research">Research</a></li>
         <li><a class="link-1" [routerLink]="['/', AppRoutes.partners.uri]" i18n="@@sitemap.partners">Partners</a></li>
         <li><a class="link-1" [routerLink]="['/', AppRoutes.approach.uri]" i18n="@@sitemap.approach">Approach</a></li>
         <li><a class="link-1" [routerLink]="['/', AppRoutes.documentation.uri]" i18n="@@sitemap.documentation">Documentation</a></li>
diff --git a/src/robots.txt b/src/robots.txt
index e69de29b..4835bbd0 100644
--- a/src/robots.txt
+++ b/src/robots.txt
@@ -0,0 +1,25 @@
+
+User-agent: *
+Allow: /
+Disallow: /*/donnees
+Disallow: /*/telechargements
+Disallow: /*/api
+Disallow: /*/reutilisations
+
+Disallow: /*.gif$
+Disallow: /*.jpg$
+Disallow: /*.jpeg$
+Disallow: /*.png$
+Disallow: /*.svg$
+
+Disallow: /api/analytics/
+Disallow: /api/query/map/
+
+Disallow: /*/?responsibleParty.organisationName=
+Disallow: /*/?type=
+Disallow: /*/?license=
+Disallow: /*/?link.service=
+Disallow: /*/?link.formats=
+Disallow: /*/?publicationDate=
+Disallow: /*/?updateFrequency=
+Disallow: /*/?category=
-- 
GitLab