From 2bbb383267d902b8f55e77c35d103c8a83441004 Mon Sep 17 00:00:00 2001
From: "guilhem.carron" <gcarron@grandlyon.com>
Date: Mon, 27 Sep 2021 14:38:28 +0200
Subject: [PATCH] Fix remote backoffice names + edit remote image links in
 welcome mail

---
 manifest.webapp                                   |  8 ++++----
 src/components/Tutorial/TutorialWelcome.tsx       | 12 +++++++++++-
 src/notifications/welcome.hbs                     | 12 ++++++------
 src/services/environement.service.ts              |  2 +-
 src/targets/services/monthlyReportNotification.ts |  4 ++--
 5 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/manifest.webapp b/manifest.webapp
index f774c8825..c644824d1 100644
--- a/manifest.webapp
+++ b/manifest.webapp
@@ -57,7 +57,7 @@
         "backoffice-rec": {
           "description": "Requis pour la récupération et l’envoi de statistiques d’utilisation anonymisées."
         },
-        "backoffice-prod": {
+        "backoffice": {
           "description": "Requis pour la récupération et l’envoi de statistiques d’utilisation anonymisées."
         }
       }
@@ -111,7 +111,7 @@
         "backoffice-rec": {
           "description": "Required for gathering and sending anonymous usage statistics."
         },
-        "backoffice-prod": {
+        "backoffice": {
           "description": "Required for gathering and sending anonymous usage statistics."
         }
       }
@@ -190,11 +190,11 @@
       "verbs": ["ALL"]
     },
     "backoffice-rec": {
-      "type": "org.ecolyo.backoffice-rec",
+      "type": "org.ecolyo.backoffice.rec",
       "verbs": ["ALL"]
     },
     "backoffice-prod": {
-      "type": "org.ecolyo.backoffice-prod",
+      "type": "org.ecolyo.backoffice",
       "verbs": ["ALL"]
     }
   }
diff --git a/src/components/Tutorial/TutorialWelcome.tsx b/src/components/Tutorial/TutorialWelcome.tsx
index ae84424a3..4e93d407a 100644
--- a/src/components/Tutorial/TutorialWelcome.tsx
+++ b/src/components/Tutorial/TutorialWelcome.tsx
@@ -20,6 +20,7 @@ import RigthArrowIcon from 'assets/icons/visu/tuto/arrowRight.svg'
 import Illu1 from 'assets/icons/visu/tuto/tuto1.svg'
 import Illu2 from 'assets/icons/visu/tuto/tuto2.svg'
 import Illu3 from 'assets/icons/visu/tuto/tuto3.svg'
+import EnvironementService from 'services/environement.service'
 interface TutorialWelcomeProps {
   open: boolean
 }
@@ -39,11 +40,20 @@ const TutorialWelcome: React.FC<TutorialWelcomeProps> = ({
     if (instanceSettings.public_name !== '') {
       username = instanceSettings.public_name
     }
-
+    const environementService = new EnvironementService()
     const template = welcomeTemplate({
       title: 'Bienvenue sur Ecolyo !',
       username: username,
       clientUrl: client.options.uri,
+      cloudImageUrl:
+        environementService.getPublicURL() + '/assets/godCloud.svg',
+      ecolyoPhoneImageUrl:
+        environementService.getPublicURL() + '/assets/ecolyoPhone.svg',
+      androidImageUrl:
+        environementService.getPublicURL() + '/assets/android.png',
+      menuImageUrl: environementService.getPublicURL() + '/assets/menu.svg',
+      appleImageUrl: environementService.getPublicURL() + '/assets/apple.svg',
+      shareImageUrl: environementService.getPublicURL() + '/assets/share.svg',
     })
 
     const mailData = {
diff --git a/src/notifications/welcome.hbs b/src/notifications/welcome.hbs
index 75c9dfae9..deeb85660 100644
--- a/src/notifications/welcome.hbs
+++ b/src/notifications/welcome.hbs
@@ -17,7 +17,7 @@
 
       </mj-column>
       <mj-column vertical-align="middle">
-        <mj-image src="https://ecolyo-agent.self-data.alpha.grandlyon.com/assets/godCloud.svg" width="130px" align="center"></mj-image>
+        <mj-image src={{cloudImageUrl}} width="130px" align="center"></mj-image>
       </mj-column>
     </mj-section>
 
@@ -26,7 +26,7 @@
         <mj-text color="white" font-weight="900" font-size="24px" align="center">
           Vous pouvez dès maintenant ajouter Ecolyo sur votre téléphone !
         </mj-text>
-        <mj-image src="https://ecolyo-agent.self-data.alpha.grandlyon.com/assets/ecolyoPhone.svg" width="92px" align="center"></mj-image>
+        <mj-image src={{ecolyoPhoneImageUrl}} width="92px" align="center"></mj-image>
         <mj-text color="white" font-weight="600" font-size="18px">
           Comment faire ?
         </mj-text>
@@ -36,7 +36,7 @@
 
         <mj-hero background-color="#1B1C22" padding-top="15px">
           <mj-text color="#F1C017" font-weight="600" font-size="18px">
-            <img style="vertical-align: middle; margin-right: 12px" src="https://ecolyo-agent.self-data.alpha.grandlyon.com/assets/android.png" />
+            <img style="vertical-align: middle; margin-right: 12px" src={{androidImageUrl}} />
             Ecolyo pour Android
           </mj-text>
         </mj-hero>
@@ -44,7 +44,7 @@
         <mj-hero background-color="#1B1C22" padding-top="15px">
           <mj-text color="white" font-weight="600" font-size="18px">
             1 - Appuyez sur les trois petits points du menu en haut à droite
-            <img style="vertical-align: middle; margin-left: 12px" src="https://ecolyo-agent.self-data.alpha.grandlyon.com/assets/menu.svg" />
+            <img style="vertical-align: middle; margin-left: 12px" src={{menuImageUrl}} />
           </mj-text>
         </mj-hero>
         <mj-text color="white" font-weight="600" font-size="18px">
@@ -56,7 +56,7 @@
 
         <mj-hero background-color="#1B1C22" padding-top="15px">
           <mj-text color="#F1C017" font-weight="600" font-size="18px">
-            <img style="vertical-align: middle; margin-right: 12px" src="https://ecolyo-agent.self-data.alpha.grandlyon.com/assets/apple.png" />
+            <img style="vertical-align: middle; margin-right: 12px" src={{appleImageUrl}} />
             Ecolyo pour Iphone
           </mj-text>
         </mj-hero>
@@ -64,7 +64,7 @@
         <mj-hero background-color="#1B1C22" padding-top="15px" >
           <mj-text color="white" font-weight="600" font-size="18px" vertical-align="middle">
             1 - Cliquez sur partager (carré avec flèche pointant vers le haut)
-            <img style="margin-left: 12px; height: 24px; width: 14px" src="https://ecolyo-agent.self-data.alpha.grandlyon.com/assets/share.svg"  />
+            <img style="margin-left: 12px; height: 24px; width: 14px" src={{shareImageUrl}}  />
           </mj-text>
         </mj-hero>
         <mj-text color="white" font-weight="600" font-size="18px">
diff --git a/src/services/environement.service.ts b/src/services/environement.service.ts
index 16df3f8b9..ada633c3a 100644
--- a/src/services/environement.service.ts
+++ b/src/services/environement.service.ts
@@ -13,7 +13,7 @@ export default class EnvironementService {
     if (this.getEnvironement() === 'production') {
       return 'https://ecolyo-agent.grandlyon.com'
     } else {
-      return 'https://ecolyo-agent.self-data.alpha.grandlyon.com'
+      return 'https://ecolyo-agent-rec.grandlyon.com'
     }
   }
 }
diff --git a/src/targets/services/monthlyReportNotification.ts b/src/targets/services/monthlyReportNotification.ts
index 1bf2976fc..deb83f0bd 100644
--- a/src/targets/services/monthlyReportNotification.ts
+++ b/src/targets/services/monthlyReportNotification.ts
@@ -154,8 +154,8 @@ const getMonthlyReport = async (
       .fetchJSON(
         'GET',
         environementService.isProduction()
-          ? `/remote/org.ecolyo.backoffice-prod?year=${year}&month=${month}`
-          : `https://ecolyo-agent.self-data.alpha.grandlyon.com/api/common/monthlyReport/${year}/${month}`
+          ? `/remote/org.ecolyo.backoffice?year=${year}&month=${month}`
+          : `/remote/org.ecolyo.backoffice.rec?year=${year}&month=${month}`
       )
     return result
   } catch (error) {
-- 
GitLab