Skip to content

Commit

Permalink
Update - Mise à jour de l'app pour fonctionner en local avec un envir…
Browse files Browse the repository at this point in the history
…onnement docker
  • Loading branch information
noelmugnier committed Nov 19, 2020
1 parent a9c8e8a commit 2b41a16
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
await authInstance.login();
}
const progress = await fetch('https://content.sheaft.com/progress/departments.json');
const progress = await fetch(config.content + '/progress/departments.json');
var data = await progress.json();
allDepartmentsProgress.set(data);
Expand Down
3 changes: 2 additions & 1 deletion src/components/nav/Nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import SellingPointRoutes from "./../../routes/selling-points/routes.js";
import DeliveryRoutes from "./../../routes/deliveries/routes.js";
import QuickOrderRoutes from "./../../routes/quick-orders/routes.js";
import { config } from "../../configs/config";
const authInstance = GetAuthInstance();
const routerInstance = GetRouterInstance();
Expand Down Expand Up @@ -323,7 +324,7 @@
{$authUserAccount.profile.given_name ? $authUserAccount.profile.given_name : $authUserAccount.profile.name}
</span>
<div
style="background-image: url('{$authUserAccount.profile.picture ? $authUserAccount.profile.picture : "https://content.sheaft.com/pictures/users/profile.svg"}');"
style="background-image: url('{$authUserAccount.profile.picture ? $authUserAccount.profile.picture : config.content + "/pictures/users/profile.svg"}');"
class="rounded-full bg-white user-photo ml-2 w-5 h-5 lg:w-8 lg:h-8" />
</button>
{:else}
Expand Down
1 change: 1 addition & 0 deletions src/configs/config.local.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const config = {
front: "http://localhost:4200",
api: "http://localhost:5002",
signalr: "http://localhost:5009",
content: "http://localhost:10000/devstoreaccount1",
auth: {
url: "http://localhost:5000",
settings: {
Expand Down
1 change: 1 addition & 0 deletions src/configs/config.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const config = {
front: "https://app.sheaft.com",
api: "https://api.sheaft.com",
signalr: "https://signalr.sheaft.com",
content: "https://content.sheaft.com",
auth: {
url: "https://auth.sheaft.com",
settings: {
Expand Down
1 change: 1 addition & 0 deletions src/configs/config.remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const config = {
front: "http://localhost:4200",
api: "https://sheaft-api-rd.azurewebsites.net",
signalr: "https://sheaft-signalr-rd.azurewebsites.net",
content: "https://rd.content.sheaft.com",
auth: {
url: "https://sheaft-identity-rd.azurewebsites.net",
settings: {
Expand Down
1 change: 1 addition & 0 deletions src/configs/config.staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const config = {
front: "https://dev.app.sheaft.com",
api: "https://sheaft-api-rd.azurewebsites.net",
signalr: "https://sheaft-signalr-rd.azurewebsites.net",
content: "https://rd.content.sheaft.com",
auth: {
url: "https://sheaft-identity-rd.azurewebsites.net",
settings: {
Expand Down
3 changes: 2 additions & 1 deletion src/routes/account/Profile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import EditConsumer from "./EditConsumer.svelte";
import EditProducer from "./EditProducer.svelte";
import EditStore from "./EditStore.svelte";
import { config } from "../../configs/config";
const errorsHandler = new SheaftErrors();
const authInstance = GetAuthInstance();
Expand Down Expand Up @@ -65,7 +66,7 @@
$authUserAccount.profile &&
$authUserAccount.profile.picture
? $authUserAccount.profile.picture
: "https://content.sheaft.com/pictures/users/profile.svg";
: config.content + "/pictures/users/profile.svg";
</script>

<svelte:head>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/account/UpdateImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import ActionConfirm from "./../../components/modal/ActionConfirm.svelte";
import GetGraphQLInstance from "./../../services/SheaftGraphQL.js";
import SheaftErrors from "./../../services/SheaftErrors";
import { config } from "../../configs/config";
const errorsHandler = new SheaftErrors();
export let id, mutation, close, onClose, initialSrc = "https://content.sheaft.com/pictures/users/profile.svg";
export let id, mutation, close, onClose, initialSrc = config.content + "/pictures/users/profile.svg";
var graphQLInstance = GetGraphQLInstance();
let src = initialSrc;
Expand Down
3 changes: 2 additions & 1 deletion src/routes/leaderboard/Leaderboard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
USER_POINTS_PER_COUNTRY,
USER_POSITION_IN_COUNTRY
} from "./queries.js";
import { config } from "../../configs/config";
export let params;
Expand Down Expand Up @@ -77,7 +78,7 @@
const getUserPicture = (user) => {
if (user.picture) return user.picture;
return "https://content.sheaft.com/pictures/users/profile.svg";
return config.content + "/pictures/users/profile.svg";
}
const getUserName = (user) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/products/ImportProducts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<ul class="list-decimal">
<li>
Téléchargez le modèle de catalogue
<a href="https://content.sheaft.com/resources/excel/sheaft_catalogue_produits.xlsx"> en cliquant ici</a>.
<a href="{config.content + '/resources/excel/sheaft_catalogue_produits.xlsx'}"> en cliquant ici</a>.
</li>
<li>
Complétez le fichier Excel téléchargé en veillant à bien respecter les colonnes.
Expand Down
3 changes: 2 additions & 1 deletion src/routes/products/ProductForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import UnitKind from "../../enums/UnitKind";
import ConditioningKind from "../../enums/ConditioningKind";
import GetAuthInstance from "../../services/SheaftAuth";
import { config } from "../../configs/config";
export let submit, product, isLoading;
Expand Down Expand Up @@ -302,7 +303,7 @@
classNames="ml-1"
isChecked={isBio}
onChange={() => toggleBio()}>
<img src="https://content.sheaft.com/pictures/tags/icons/bio.png" alt="Produit bio" class="w-8" />
<img src="{config.content + '/pictures/tags/icons/bio.png'}" alt="Produit bio" class="w-8" />
</Toggle>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/products/ProductRatings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { GET_PRODUCT_RATINGS } from "./queries.js";
import SheaftErrors from "../../services/SheaftErrors";
import ErrorCard from "./../../components/ErrorCard.svelte";
import { config } from "../../configs/config";
export let params = {};
Expand Down Expand Up @@ -78,7 +79,7 @@
<img
class="absolute top-0 left-0 w-full h-full bg-cover
object-fit object-cover"
src={rating.user.picture ? rating.user.picture : "https://content.sheaft.com/pictures/users/profile.svg"}
src={rating.user.picture ? rating.user.picture : config.content + "/pictures/users/profile.svg"}
alt={rating.user.name} />
<div
class="absolute top-0 left-0 w-full h-full rounded-full
Expand Down
3 changes: 2 additions & 1 deletion src/routes/register/RegisterConsumer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import ErrorCard from "../../components/ErrorCard.svelte";
import { form, bindClass } from '../../../vendors/svelte-forms/src/index';
import ErrorContainer from "./../../components/ErrorContainer.svelte";
import { config } from "../../configs/config";
const authInstance = GetAuthInstance();
const routerInstance = GetRouterInstance();
Expand Down Expand Up @@ -220,7 +221,7 @@
checked={acceptMangoCgv}
onClick={() => (acceptMangoCgv = !acceptMangoCgv)} />
Je reconnais avoir lu et compris
<a href="https://content.sheaft.com/resources/legals/Mangopay_Terms-FR.pdf" target="_blank">
<a href="{config.content + '/resources/legals/Mangopay_Terms-FR.pdf'}" target="_blank">
les conditions générales d'utilisation de MangoPay,
</a>
notre tiers de paiement, et je les accepte
Expand Down
3 changes: 2 additions & 1 deletion src/routes/register/owner/FormProductionSite.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Loader from "./../../../components/Loader.svelte";
import Icon from "svelte-awesome";
import { faInfoCircle } from "@fortawesome/free-solid-svg-icons";
import { config } from "../../../configs/config";
export let company, stepper = 4, isStore, submit = () => {};
Expand Down Expand Up @@ -111,7 +112,7 @@
checked={acceptMangoCgv}
onClick={() => (acceptMangoCgv = !acceptMangoCgv)} />
Je reconnais avoir lu et compris
<a href="https://content.sheaft.com/resources/legals/Mangopay_Terms-FR.pdf" target="_blank">
<a href="{config.content + '/resources/legals/Mangopay_Terms-FR.pdf'}" target="_blank">
les conditions générales d'utilisation de services de paiement de MangoPay,
</a>
notre tiers de paiement, et je les accepte
Expand Down
2 changes: 1 addition & 1 deletion src/routes/search-producers/ProducerCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<div class="bg-white rounded-lg p-0 pl-3 lg:p-4 w-full">
<div style="width: 20px; right: 15px;" class="absolute">
{#if producer.tags && producer.tags.find(c => c.name == 'bio') != null}
<img src="https://content.sheaft.com/pictures/tags/icons/bio.png" alt="Bio" class="mb-3" />
<img src="{config.content + '/pictures/tags/icons/bio.png'}" alt="Bio" class="mb-3" />
{/if}
</div>
<div class="pr-8">
Expand Down
3 changes: 2 additions & 1 deletion src/routes/search-producers/ProducerDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import RatingStars from "./../../components/rating/RatingStars.svelte";
import AgreementRoutes from "../agreements/routes";
import GetNotificationsInstance from "./../../services/SheaftNotifications.js";
import { config } from "../../configs/config";
const graphQLInstance = GetGraphQLInstance();
const routerInstance = GetRouterInstance();
Expand Down Expand Up @@ -230,7 +231,7 @@
<p class="text-xl lg:text-3xl font-semibold">{producer.name}</p>
{#if producer.tags && producer.tags && producer.tags.length > 0 && producer.tags.find((t) => t.name === "Bio")}
<div class="text-center ml-3">
<img src="https://content.sheaft.com/pictures/tags/icons/bio.png" alt="Bio" class="m-auto mb-1" style="max-width: 30px;" />
<img src="{config.content + '/pictures/tags/icons/bio.png'}" alt="Bio" class="m-auto mb-1" style="max-width: 30px;" />
</div>
{/if}
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/search-products/ProductCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { cartItems, selectedItem } from "./../../stores/app.js";
import { GetDistanceInfos } from "./../../helpers/distances.js";
import { formatMoney, formatConditioningDisplay } from "./../../helpers/app";
import { config } from "../../configs/config";
const routerInstance = GetRouterInstance();
export let product, hoveredProduct = null;
Expand Down Expand Up @@ -132,7 +133,7 @@
<div class="bg-white rounded-lg p-0 pl-3 lg:p-4 w-full">
<div style="width: 30px; right: 15px;" class="absolute">
{#if product.tags.map(t => t.name).includes('bio')}
<img src="https://content.sheaft.com/pictures/tags/icons/bio.png" alt="Bio" class="mb-1" />
<img src="{config.content + '/pictures/tags/icons/bio.png'}" alt="Bio" class="mb-1" />
{/if}
{#if product.isReturnable}
<img src="./img/returnable.svg" alt="Consigné" class="mb-1" style="transform: scale(0.7);" />
Expand Down
7 changes: 4 additions & 3 deletions src/routes/search-products/ProductDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import ErrorCard from "./../../components/ErrorCard.svelte";
import { groupBy, encodeQuerySearchUrl, formatConditioningDisplay } from "./../../helpers/app";
import orderBy from "lodash/orderBy";
import { config } from "../../configs/config";
const errorsHandler = new SheaftErrors();
const routerInstance = GetRouterInstance();
Expand Down Expand Up @@ -129,7 +130,7 @@
const getUserPicture = picture => {
if (picture) return picture;
return "https://content.sheaft.com/pictures/users/profile.svg";
return config.content + '/pictures/users/profile.svg';
};
const focus = node => {
Expand Down Expand Up @@ -223,7 +224,7 @@
</div>
{/if}
<div
style="background-position: center; background-image: url({product.picture ? product.picture : 'https://content.sheaft.com/pictures/tags/images/default.jpg'}); background-size: cover;"
style="background-position: center; background-image: url({product.picture ? product.picture : config.content + '/pictures/tags/images/default.jpg'}); background-size: cover;"
class:opacity-50={product.picture.includes("pictures/tags/images/")}
class="w-full shadow-md h-40 lg:h-64" />
<!-- <button class="flex items-center justify-center w-12 h-12 bg-white rounded-full shadow absolute cursor-pointer text-accent" style="right: 40px; bottom: -25px;">
Expand All @@ -237,7 +238,7 @@
{#if product.tags && product.tags.length > 0 && product.tags.find(t => t.name.toLowerCase() === 'bio' && t.kind == TagKind.Label.Value)}
<div class="text-center ml-3">
<img
src="https://content.sheaft.com/pictures/tags/icons/bio.png"
src="{config.content + '/pictures/tags/icons/bio.png'}"
alt="Bio"
class="m-auto mb-1"
style="max-width: 30px;" />
Expand Down
3 changes: 2 additions & 1 deletion src/routes/search-stores/StoreCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { faMapMarkerAlt } from "@fortawesome/free-solid-svg-icons";
import { selectedItem } from "./../../stores/app.js";
import { GetDistanceInfos } from "./../../helpers/distances";
import { config } from "../../configs/config";
export let store, hoveredStore = null, businessLocation = null;
Expand Down Expand Up @@ -94,7 +95,7 @@
<div class="bg-white rounded-lg p-0 pl-3 lg:p-4 w-full">
<div style="width: 20px; right: 15px;" class="absolute">
{#if store.tags && store.tags.find(c => c.name == 'bio') != null}
<img src="https://content.sheaft.com/pictures/tags/icons/bio.png" alt="Bio" class="mb-3" />
<img src="{config.content + '/pictures/tags/icons/bio.png'}" alt="Bio" class="mb-3" />
{/if}
</div>
<div class="pr-8">
Expand Down
3 changes: 2 additions & 1 deletion src/routes/search-stores/StoreDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { groupBy, timeSpanToFrenchHour } from "./../../helpers/app";
import AgreementRoutes from "../agreements/routes";
import GetNotificationsInstance from "./../../services/SheaftNotifications.js";
import { config } from "../../configs/config.js";
const graphQLInstance = GetGraphQLInstance();
const routerInstance = GetRouterInstance();
Expand Down Expand Up @@ -176,7 +177,7 @@
{#if store.tags && store.tags.length > 0 && store.tags.find(t => t.name === 'Bio')}
<div class="text-center ml-3">
<img
src="https://content.sheaft.com/pictures/tags/icons/bio.png"
src="{config.content + '/pictures/tags/icons/bio.png'}"
alt="Bio"
class="m-auto mb-1"
style="max-width: 30px;" />
Expand Down
22 changes: 13 additions & 9 deletions src/services/SheaftAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ class SheaftAuth {
var content = await result.json();
if (content.data.me && content.data.me.id) {
this.setAuthStatus(user, true, true, true, true);
} else if (content.errors && content.errors.length > 0) {
throw content.errors;
} else if (content.errors && content.errors.length > 0) {
console.error('An error occurred while retrieving user infos', content.errors);
this.refreshPageAsUnauthorized(user);
} else {
this.setAuthStatus(user, true, true, false, true);
}
Expand All @@ -77,11 +78,15 @@ class SheaftAuth {
return await this.login();
}

this.setAuthStatus(user, false, false, false, true);
if(location.hash != '/'){
location.hash = "/";
location.reload();
}
this.refreshPageAsUnauthorized(user);
}
}

refreshPageAsUnauthorized(user){
this.setAuthStatus(user, false, false, false, true);
if(location.hash.indexOf('/callback') > -1){
location.hash = "/";
location.reload();
}
}

Expand Down Expand Up @@ -150,6 +155,7 @@ class SheaftAuth {
try {
return await this.userManager.signinCallback();
} catch (exc) {
await this.userManager.removeUser();
location.hash = "";
location.reload();
}
Expand All @@ -159,8 +165,6 @@ class SheaftAuth {
try {
return await this.userManager.signinSilentCallback();
} catch (exc) {
location.hash = "";
location.reload();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/stores/auth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { writable } from "svelte/store";
import { config } from "./../configs/config";

export const authUserAccount = writable({ profile: { role: "ANONYMOUS", picture:"https://content.sheaft.com/pictures/users/profile.svg" } });
export const authUserAccount = writable({ profile: { role: "ANONYMOUS", picture: config.content + '/pictures/users/profile.svg' } });
export const authInitialized = writable(false);
export const authRegistered = writable(false);
export const authAuthenticated = writable(false);
Expand Down

0 comments on commit 2b41a16

Please sign in to comment.