Revert "Move settings to public/svgld-settings.js"
This reverts commit 2cf56632155f5378c8819991b1b42ab135cbe384.
This commit is contained in:
parent
fff0645045
commit
d368641200
12 changed files with 27 additions and 26 deletions
3
.env.development
Normal file
3
.env.development
Normal file
|
@ -0,0 +1,3 @@
|
|||
VITE_API_FETCH_URL=http://localhost:5000
|
||||
VITE_API_SET_CONTAINER_LIST_URL=http://localhost:5000/SetContainerList
|
||||
VITE_API_GET_FEEDBACK_URL=http://localhost:5000/GetFeedback
|
3
.env.production
Normal file
3
.env.production
Normal file
|
@ -0,0 +1,3 @@
|
|||
VITE_API_FETCH_URL=https://localhost/SmartMenuiserieTemplate/Service.svc/GetSVGLayoutConfiguration
|
||||
VITE_API_SET_CONTAINER_LIST_URL=https://localhost/SmartMenuiserieTemplate/Service.svc/SetContainerList
|
||||
VITE_API_GET_FEEDBACK_URL=https://localhost/SmartMenuiserieTemplate/Service.svc/GetFeedback
|
3
.env.test
Normal file
3
.env.test
Normal file
|
@ -0,0 +1,3 @@
|
|||
VITE_API_FETCH_URL=http://localhost:5000
|
||||
VITE_API_SET_CONTAINER_LIST_URL=http://localhost:5000/SetContainerList
|
||||
VITE_API_GET_FEEDBACK_URL=http://localhost:5000/GetFeedback
|
|
@ -26,18 +26,18 @@ Il y deux manières de récupérer les builds du projets:
|
|||
|
||||
Customiser le build du projet permet de modifier les urls de l'API et de personnaliser des fonctionnalités.
|
||||
|
||||
## Configurer l'API
|
||||
## Configurer les options de build
|
||||
|
||||
Il y a deux fichiers principaux à configurer :
|
||||
- `src/assets/svgld-settings.js`: pour configurer les URLs d'API
|
||||
- `.env.production.local`: pour configurer les URLs d'API
|
||||
- `src/utils/default.ts`: pour configurer les fonctionnalités
|
||||
|
||||
Modifiez `public/svgld-settings.js`
|
||||
Copiez `.env.production` vers `.env.production.local` et modifiez-le comme bon vous semble :
|
||||
|
||||
```js
|
||||
export const API_FETCH_URL = 'http://localhost:5000';
|
||||
export const API_SET_CONTAINER_LIST_URL = 'http://localhost:5000/SetContainerList';
|
||||
export const API_GET_FEEDBACK_URL = 'http://localhost:5000/GetFeedback';
|
||||
```
|
||||
VITE_API_FETCH_URL=https://localhost/SmartMenuiserieTemplate/Service.svc/GetSVGLayoutConfiguration
|
||||
VITE_API_SET_CONTAINER_LIST_URL=https://localhost/SmartMenuiserieTemplate/Service.svc/SetContainerList
|
||||
VITE_API_GET_FEEDBACK_URL=https://localhost/SmartMenuiserieTemplate/Service.svc/GetFeedback
|
||||
```
|
||||
|
||||
Vous pouvez modifiez `src/utils/default.ts` mais ne le committez pas.
|
||||
|
@ -92,7 +92,7 @@ Cliquez sur le menu hamburger et cliquez sur **Download Artifacts** :
|
|||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/svgld-settings.js"></script>
|
||||
<script type="module" src="./src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
4
public/svgld-settings.d.ts
vendored
4
public/svgld-settings.d.ts
vendored
|
@ -1,4 +0,0 @@
|
|||
|
||||
export declare const API_FETCH_URL: string;
|
||||
export declare const API_SET_CONTAINER_LIST_URL: string;
|
||||
export declare const API_GET_FEEDBACK_URL: string;
|
|
@ -1,3 +0,0 @@
|
|||
export const API_FETCH_URL = 'http://localhost:5000';
|
||||
export const API_SET_CONTAINER_LIST_URL = 'http://localhost:5000/SetContainerList';
|
||||
export const API_GET_FEEDBACK_URL = 'http://localhost:5000/GetFeedback';
|
|
@ -1,6 +1,5 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { API_FETCH_URL } from '../../../public/svgld-settings';
|
||||
import { AddMethod } from '../../Enums/AddMethod';
|
||||
import { Orientation } from '../../Enums/Orientation';
|
||||
import { Position } from '../../Enums/Position';
|
||||
|
@ -21,9 +20,9 @@ const CHARP_WEB_API_RESOURCE_URL = 'SVGLD';
|
|||
const CSHARP_WEB_API_URL = CSHARP_WEB_API_BASE_URL + CHARP_WEB_API_RESOURCE_URL + '/';
|
||||
|
||||
// TODO: Migrate this test to SVGLDWebAPI rather than using test-server/
|
||||
describe.concurrent('Test server test', async() => {
|
||||
describe.concurrent('Test server test', () => {
|
||||
it('Load environment', () => {
|
||||
const url = API_FETCH_URL;
|
||||
const url = import.meta.env.VITE_API_FETCH_URL;
|
||||
expect(url).toBe('http://localhost:5000');
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { API_FETCH_URL, API_SET_CONTAINER_LIST_URL } from '../../../public/svgld-settings';
|
||||
import { IConfiguration } from '../../Interfaces/IConfiguration';
|
||||
import { ISetContainerListRequest } from '../../Interfaces/ISetContainerListRequest';
|
||||
import { ISetContainerListResponse } from '../../Interfaces/ISetContainerListResponse';
|
||||
|
@ -9,7 +8,7 @@ import { GetCircularReplacerToDotnet } from '../../utils/saveload';
|
|||
* @returns {Configation} The model of the configuration for the application
|
||||
*/
|
||||
export async function FetchConfiguration(): Promise<IConfiguration> {
|
||||
const url = API_FETCH_URL;
|
||||
const url = import.meta.env.VITE_API_FETCH_URL;
|
||||
// The test library cannot use the Fetch API
|
||||
// @ts-expect-error
|
||||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
||||
|
@ -35,7 +34,7 @@ export async function FetchConfiguration(): Promise<IConfiguration> {
|
|||
}
|
||||
|
||||
export async function SetContainerList(request: ISetContainerListRequest): Promise<ISetContainerListResponse> {
|
||||
const url = API_SET_CONTAINER_LIST_URL;
|
||||
const url = import.meta.env.VITE_API_SET_CONTAINER_LIST_URL;
|
||||
const dataParsed = JSON.stringify(request, GetCircularReplacerToDotnet());
|
||||
// The test library cannot use the Fetch API
|
||||
// @ts-expect-error
|
||||
|
|
|
@ -4,7 +4,6 @@ import { IGetFeedbackRequest } from '../../Interfaces/IGetFeedbackRequest';
|
|||
import { IGetFeedbackResponse } from '../../Interfaces/IGetFeedbackResponse';
|
||||
import { IMessage } from '../../Interfaces/IMessage';
|
||||
import { GetCircularReplacerToDotnet } from '../../utils/saveload';
|
||||
import { API_GET_FEEDBACK_URL } from '../../../public/svgld-settings';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
||||
const myWorker = window.Worker && new Worker('workers/message_worker.js');
|
||||
|
@ -16,7 +15,7 @@ export function UseWorker(
|
|||
// use webworker for the stringify to avoid freezing
|
||||
myWorker.postMessage({
|
||||
state,
|
||||
url: API_GET_FEEDBACK_URL
|
||||
url: import.meta.env.VITE_API_GET_FEEDBACK_URL
|
||||
});
|
||||
|
||||
return () => {
|
||||
|
@ -38,7 +37,7 @@ export function UseAsync(
|
|||
ApplicationState: state
|
||||
};
|
||||
const dataParsed = JSON.stringify(request, GetCircularReplacerToDotnet());
|
||||
fetch(API_GET_FEEDBACK_URL, {
|
||||
fetch(import.meta.env.VITE_API_GET_FEEDBACK_URL, {
|
||||
method: 'POST',
|
||||
headers: new Headers({
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
|
|
3
src/vite-env.d.ts
vendored
3
src/vite-env.d.ts
vendored
|
@ -1,6 +1,9 @@
|
|||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_API_FETCH_URL: string
|
||||
readonly VITE_API_SET_CONTAINER_LIST_URL: string
|
||||
readonly VITE_API_GET_FEEDBACK_URL: string
|
||||
// more env variables...
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": ["src", "public/svgld-settings.d.ts", "public/svgld-settings.ts"],
|
||||
"include": ["src"],
|
||||
"exclude": ["test-server"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue