Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 1557a800 authored by Philippe Coicadan's avatar Philippe Coicadan
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
VITE_BACKEND_URL='https://your_arolios_api_server'
module.exports = {
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"env": {
"browser": true,
"es2021": true
},
"settings": {
"react": {
"version": "detect"
}
}
}
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
\ No newline at end of file
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official email address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[INSERT CONTACT METHOD].
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of
actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the
community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
# Contributing to AROLIOS
First off, thanks for taking the time to contribute!
All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions.
> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
> - Star the project
> - Tweet about it
> - Refer this project in your project's readme
> - Mention the project at local meetups and tell your friends/colleagues
## Table of Contents
- [Code of Conduct](#code-of-conduct)
- [I Have a Question](#i-have-a-question)
- [I Want To Contribute](#i-want-to-contribute)
- [Reporting Bugs](#reporting-bugs)
- [Suggesting Enhancements](#suggesting-enhancements)
- [Your First Code Contribution](#your-first-code-contribution)
- [Improving The Documentation](#improving-the-documentation)
- [Styleguides](#styleguides)
- [Commit Messages](#commit-messages)
- [Join The Project Team](#join-the-project-team)
## Code of Conduct
This project and everyone participating in it is governed by the
[AROLIOS Code of Conduct](./CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable behavior by mailing from [this LinkedIn account](https://www.linkedin.com/in/philippecoicadan).
## I Have a Question
> If you want to ask a question, we assume that you have read the available [Documentation](https://my_repository/arolios-doc).
Before you ask a question, it is best to search for existing [Issues](/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
If you then still feel the need to ask a question and need clarification, we recommend the following:
- Open an [Issue](/issues/new).
- Provide as much context as you can about what you're running into.
- Provide project and platform versions, depending on what seems relevant.
We will then take care of the issue as soon as possible.
## I Want To Contribute
> ### Legal Notice
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
### Reporting Bugs
#### Before Submitting a Bug Report
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://my_repository/arolios-doc). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](issues?q=label%3Abug).
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the community have discussed the issue.
- Collect information about the bug:
- Stack trace (Traceback)
- OS, Platform and Version (Linux, Windows, macOS, x86, ARM)
- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant.
- Possibly your input and the output
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
#### How Do I Submit a Good Bug Report?
> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by mailing from [this LinkedIn account](https://www.linkedin.com/in/philippecoicadan).
We use Gitlab issues to track bugs and errors. If you run into an issue with the project:
- Open an [Issue](/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.
Once it's filed:
- The project team will label the issue accordingly.
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).
### Suggesting Enhancements
This section guides you through submitting an enhancement suggestion for AROLIOS, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.
#### Before Submitting an Enhancement
- Make sure that you are using the latest version.
- Read the [documentation](https://my_repository/arolios-doc) carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
#### How Do I Submit a Good Enhancement Suggestion?
Enhancement suggestions are tracked as [Gitlab issues](/issues).
- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux.
- **Explain why this enhancement would be useful** to most AROLIOS users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
### Your First Code Contribution
TO BE COMPLETED
### Improving The Documentation
TO BE COMPLETED
## Styleguides
### Commit Messages
TO BE COMPLETED
## Join The Project Team
TO BE COMPLETED
## Attribution
This guide is based on the [**contributing.md**](https://contributing.md/)
The MIT License (MIT)
Copyright (C) 2024 Philippe Coicadan. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
See the [french version](./README_fr.md)
# Aperçu général
_INTRO A INSERER_
Le projet **AROLIOS** est composé actuellement de trois logiciels:
* **AROLIOS Core** est le logiciel comprenant plusieurs bibliothèques de programmes implémentant les fonctionnalités ainsi qu'un programme pour initialiser la base de données.
* **AROLIOS Server** est le logiciel agissant comme serveur Web et implémentant une interface de programmation (l'API AROLIOS) en faisant appel à AROLIOS Core
* **AROLIOS WebUI** est le logiciel interagissant avec l'utilisateur, s'exécutant dans son navigateur Web et communiquant avec un serveur implémentant l'API AROLIOS.
La suite du texte concerne **AROLIOS WebUI**
# Installation
Voir la documentation [ici](./docs/Installation_fr.md)
# Documentation
La documentation d'utilisation de **AROLIOS WebUI** se trouve [ici](./docs/UserGuide_fr.md)
La documentation sur les concepts et fonctionnalités d'**AROLIOS** se trouve [ici](https://lab.frogg.it/philcoicadan/arolios-doc/src/Presentation_fr.md)
La documentation pour utiliser l'API d'**AROLIOS** se trouve [ici](https://lab.frogg.it/philcoicadan/arolios-doc/src/API_fr.md)
# Assistance
Si vous constatez une anomalie ou si vous avez une suggestion d'amélioration, ouvrez un ticket dans ce projet. Pour toute autre demande, vous pouvez envoyer une courriel à [cette adresse](mailto:philcoicadan@arolios.org).
# Contribution
Voir le fichier CONTRIBUTING.md
# Licence
AROLIOS WebUI est publié sous licence MIT (identifiant SPDX: MIT).
Voir le fichier [LICENSE.txt](./LICENSE.md)
## Installation
Cette section s'adresse aux personnes ayant des connaissances en construction et installation de logiciels.
Pour utiliser **AROLIOS WebUI**, vous devez en premier lieu installer les prérequis puis récupérer les sources qui sont écrits en langage JavaScript.
### Prérequis
**AROLIOS WebUI** dépend du logiciel [React-Admin](http://marmelab.com/react-admin) qui sera installé avec toutes ses dépendances. Au préalable il faut installer **node.js** qui est un logiciel serveur interprétant le JavaScript et **npm** son gestionnaire de paquets.
Il y a plusieurs méthodes dépendantes de votre système d'exploitation pour installer ces deux logiciels.
Suivez les instructions que vous trouverez sur Internet, par exemple [ici](https://docs.npmjs.com)
### Construction
1. Copiez les sources téléchargés dans un nouveau répertoire.
2. Placez-vous dans ce répertoire et tapez la commande: npm install
Cette commande installe tous les paquets React-Admin nécessaires ainsi que les paquets dont ils dépendent.
3. Pour construire la version de production,
1. modifiez dans le fichier .env le paramètre VITE_BACKEND_URL pour lui indiquer l'URL du serveur qui implémente l'**API AROLIOS**. Exemple: https://my_arolios_server
2. tapez la commande: npm build
Un répertoire dist est créé avec les fichiers nécessaires à l'exécution
### Déploiement
1. Copiez le répertoire dist créé dans l'emplacement adéquat pour le serveur web (par exemple Apache) qui servira aux utilisateurs **AROLIOS WebUI**. Exemple /var/www/arolios_webui
2. Vérifiez la présence du fichier .htaccess fourni pour le serveur Apache. Si vous l'utilisez, il faut configurer Apache avec, par exemple sur Linux, les commandes suivantes:
1. sudo a2enmode rewrite
2. sudo systemctl apache2 restart
3. Configurez votre serveur web (Apache par exemple) pour servir **AROLIOS WebUI**. Par exemple avec Apache sur Linux:
1. Placez vous dans le repertoire /etc/apache2/sites-available
2. Copiez le fichier 000-default.conf (par exemple arolios.conf)
3. Dans cette copie, renseignez les paramètres ServerName (l'URL pour adresser **AROLIOS WebUI**, par exemple www.my-arolios.com) et DocumentRoot (l'emplacement du fichier index.html, par exemple /var/www/arolios_webui)
4. Passez la commande: sudo a2ensite /etc/apache/sites-available/arolios.conf
5. Redémarrez le serveur Apache: sudo systemctl restart apache2
4. Si le serveur de l'API AROLIOS que vous avez renseigné dans le paramètre VITE_BACKEND_URL est lancé ainsi que votre serveur web servant **AROLIOS WebUI** (Apache par exemple), vous pouvez démarrer **AROLIOS WebUI** depuis votre navigateur web en l'adressant avec l'URL renseigné dans la configuration de votre serveur Web ( par exemple www.my-arolios.com)
En cas de difficulté, référez-vous à la documentation de votre serveur web ou aux articles disponibles sur Internet pour y déployer une application React.
# TO BE COMPLETED
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<!--link rel="manifest" href="./manifest.json" / -->
<!--link rel="shortcut icon" href="./favicon.ico" / -->
<title>AROLIOS WebUI</title>
<style>
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
.loader-container {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: #fafafa;
}
/* CSS Spinner from https://projects.lukehaas.me/css-loaders/ */
.loader,
.loader:before,
.loader:after {
border-radius: 50%;
}
.loader {
color: #283593;
font-size: 11px;
text-indent: -99999em;
margin: 55px auto;
position: relative;
width: 10em;
height: 10em;
box-shadow: inset 0 0 0 1em;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
}
.loader:before,
.loader:after {
position: absolute;
content: '';
}
.loader:before {
width: 5.2em;
height: 10.2em;
background: #fafafa;
border-radius: 10.2em 0 0 10.2em;
top: -0.1em;
left: -0.1em;
-webkit-transform-origin: 5.2em 5.1em;
transform-origin: 5.2em 5.1em;
-webkit-animation: load2 2s infinite ease 1.5s;
animation: load2 2s infinite ease 1.5s;
}
.loader:after {
width: 5.2em;
height: 10.2em;
background: #fafafa;
border-radius: 0 10.2em 10.2em 0;
top: -0.1em;
left: 5.1em;
-webkit-transform-origin: 0px 5.1em;
transform-origin: 0px 5.1em;
-webkit-animation: load2 2s infinite ease;
animation: load2 2s infinite ease;
}
@-webkit-keyframes load2 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes load2 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
</style>
<!--link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap"
rel="stylesheet"
/ -->
</head>
<body>
<noscript> You need to enable JavaScript to run this app. </noscript>
<div id="root">
<div class="loader-container">
<div class="loader">Loading...</div>
</div>
</div>
</body>
<script type="module" src="/src/index.tsx"></script>
</html>
{
"name": "arolios-webui",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview",
"type-check": "tsc --noEmit",
"lint": "eslint --fix --ext .js,.jsx,.ts,.tsx ./src",
"format": "prettier --write ./src"
},
"dependencies": {
"ra-input-rich-text": "^4.16.17",
"ra-language-french": "^4.16.17",
"react": "^18.2.0",
"react-admin": "^4.16.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^18.16.1",
"@types/react": "^18.0.22",
"@types/react-dom": "^18.0.7",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"@vitejs/plugin-react": "^4.0.1",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^2.8.8",
"typescript": "^5.1.6",
"vite": "^4.3.9"
},
"author": "Philippe Coicadan",
"license": "MIT"
}
module.exports = {}
\ No newline at end of file
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
import * as React from "react";
import { Authenticated, Admin, CustomRoutes, Resource, Error} from 'react-admin';
import { Route } from 'react-router';
import CustomDataProvider from './utils/dataProvider';
import authProvider from './utils/authProvider';
import i18nProvider from './utils/i18nProvider';
import {backEndURL, idFromURL} from './utils/utils';
import CustomDashboard from './pages/dashboard';
import CustomLayout from './pages/layout';
import DomainList from './resources/domains';
import {UserList, UserCreate, UserEdit } from './resources/users';
import {AppList, AppCreate, AppEdit, AppConfigLoad, AppUserList, AppDomainList, AppUserCreate, AppDomainCreate} from './resources/apps';
import { ClassList } from './resources/classes';
import { AssociationList } from './resources/associations';
import { SettingsEdit, PasswordCreate } from './resources/settings';
import AppsIcon from '@mui/icons-material/Apps'
import PeopleIcon from '@mui/icons-material/People';
import { ClassInstanceList, AssociationInstanceList
, ClassInstanceCreate
, AssocInstanceCreate
, ClassInstanceEdit
, AssocInstanceEdit
, ClassInstanceShow
, AssocInstanceShow
, InstanceAssocList
} from './resources/instances';
import {TrashList} from './resources/trash';
import { EnumerationValuesList} from './resources/enumerations';
import { LanguageList} from './resources/languages';
import Help from './pages/help';
import About from './pages/about';
import ImportData from './pages/import';
import ExportData from './pages/export';
import LoadModel from './pages/loadmodel';
import LoadTranslations from './pages/loadtranslations';
const fetchDomains = (token, lang) => {
const req = backEndURL() + '/domains?lang=' + lang;
const request = new Request(req, {
method: 'GET',
headers: new Headers({ 'Content-Type': 'application/json' , 'Authorization':`Bearer ${token}`}),
});
return fetch(request, { credentials: 'include'})
.then(response => {
if (response.status < 200 || response.status >= 300) {
throw new Error(response.statusText);
}
return response.json();
})
.then( (json ) => {
if (json["total"] === 1) {
sessionStorage.setItem ('arolios_model_default_domain', JSON.stringify({name: json["elements"][0]['name'], _tname: json["elements"][0]['_tname']}));
} else {
sessionStorage.removeItem ('arolios_model_default_domain');
};
return Promise.resolve ( json["elements"])
})
}
const fetchClasses = (token, lang)=> {
const req = backEndURL() + '/classes?lang=' + lang;
const request = new Request(req, {
method: 'GET',
headers: new Headers({ 'Content-Type': 'application/json' , 'Authorization':`Bearer ${token}`}),
});
return fetch(request, { credentials: 'include'})
.then(response => {
if (response.status < 200 || response.status >= 300) {
throw new Error(response.statusText);
}
return response.json();
})
.then( ( json) => {
return Promise.resolve ( json["elements"].map(record => ( {id:idFromURL(record.url), ...record})))
})
}
const fetchAssociations = (token, lang)=> {
const req = backEndURL() + '/associations?lang=' + lang;
const request = new Request(req, {
method: 'GET',
headers: new Headers({ 'Content-Type': 'application/json' , 'Authorization':`Bearer ${token}`}),
});
return fetch(request, { credentials: 'include'})
.then(response => {
if (response.status < 200 || response.status >= 300) {
throw new Error(response.statusText);
}
return response.json();
})
.then( (json) => {
return Promise.resolve ( json["elements"].map(record => ( {id:idFromURL(record.url), ...record})))
})
}
const fetchEnumerations = (token, lang)=> {
const req = backEndURL() + '/enumerations?lang=' + lang;
const request = new Request(req, {
method: 'GET',
headers: new Headers({ 'Content-Type': 'application/json' , 'Authorization':`Bearer ${token}`}),
});
return fetch(request, { credentials: 'include'})
.then(response => {
if (response.status < 200 || response.status >= 300) {
throw new Error(response.statusText);
}
return response.json();
})
.then( (json) => {
return Promise.resolve ( json["elements"].map(record => ( {id:idFromURL(record.url), ...record})))
})
}
const fetchModelInfo = () => {
const auth = sessionStorage.getItem('arolios_auth');
if (auth) {
const { token } = JSON.parse(sessionStorage.getItem('arolios_auth'));
const lang = localStorage.getItem('arolios_model_language') ||
sessionStorage.getItem('arolios_model_default_language');
return fetchDomains (token, lang).then ( ( domains) => {
return fetchClasses (token, lang).then ( ( classes) => {
return fetchAssociations (token, lang).then ( (associations) => {
return fetchEnumerations (token, lang).then ( ( enumerations) => {
return Promise.resolve ( { domains, classes, associations, enumerations}) ;
})
})
})
}
)
.catch(() => {
throw new Error('Network error')
});
} else {
return Promise.reject() ;
}
}
const dynamicResourcesAndRoutes = (permissions) => {
return fetchModelInfo().then ( ( {domains, classes, associations, enumerations}) => {
return (
<>
<Resource name='settings' edit={SettingsEdit} />
<Resource name='password' create={PasswordCreate} />
<Resource name='domains' list={DomainList} />
{ authProvider.canEdit(permissions.role) ?
<Resource name='trash' list={TrashList}/>
: null
}
<Resource name='languages' list={LanguageList} />
{ (permissions.role === "admin" && permissions.isDefaultApp ) ?
<>
<Resource name='apps' list={AppList} create={AppCreate} edit={AppEdit} icon={AppsIcon} recordRepresentation="name"/>
<Resource name='users' list={UserList} create={UserCreate} edit={UserEdit} icon={PeopleIcon} recordRepresentation="identifier"/>
<Resource name='appusers' list={AppUserList} create={AppUserCreate}/>
<Resource name='appdomains' list={AppDomainList} create={AppDomainCreate}/>
<Resource name='models' create={LoadModel} />
<Resource name='translations' create={LoadTranslations} />
</>
: null
}
{ domains.map ( resource => {
return (<Resource name={`${resource.name}/classes`} key={resource.name} list={ClassList} /> )
})}
{ domains.map ( resource => (
<Resource name={`${resource.name}/associations`} key={resource.name} list={AssociationList} />
))}
{classes.map(resource => {
return ( resource._is_abstract ?
<Resource name={resource.id} key={resource.id} list={ClassInstanceList} show={ClassInstanceShow} edit={authProvider.canEdit(permissions.role) ? ClassInstanceEdit : null} /> :
<Resource name={resource.id} key={resource.id} list={ClassInstanceList} show={ClassInstanceShow} edit={authProvider.canEdit(permissions.role) ? ClassInstanceEdit : null} create={authProvider.canEdit(permissions.role) ? ClassInstanceCreate : null}/>
) } )}
{associations.map(resource => {
return( <Resource name={resource.id} key={resource.id} list={AssociationInstanceList} show={AssocInstanceShow} edit={authProvider.canEdit(permissions.role) ? AssocInstanceEdit : null} create={authProvider.canEdit(permissions.role) ? AssocInstanceCreate : null}/>
) } )}
{enumerations.map(resource => {
return( <Resource name={resource.id} key={resource.id} list={EnumerationValuesList} recordRepresentation="name" />
) } )}
<CustomRoutes>
<Route path='/about' element={<About />} />
<Route path='/help' element={<Authenticated><Help /></Authenticated>} />
{ authProvider.canEdit(permissions.role) ?
<Route path='/instances/import' element={<Authenticated><ImportData /></Authenticated>} />
: null
}
<Route path='/instances/export' element={<Authenticated><ExportData /></Authenticated>} />
{ permissions.role === "admin" ?
<Route path='/apps/:instId/config' element={<Authenticated><AppConfigLoad /></Authenticated>} />
: null
}
{classes.map(resource => {
return ( <Route path={`/${resource.id}/:instId/association_ends/:propId`} key={resource.id} element={<Authenticated><InstanceAssocList/></Authenticated>} />)
} )}
{authProvider.canEdit(permissions.role) ?
classes.map(resource => {
return ( <Route path={`/${resource.id}/select`} key={resource.id} element={<Authenticated><AssocInstanceEdit/></Authenticated>} />)
} )
: null
}
</CustomRoutes>
</>
)
}
)
}
export const App = () =>
{
return (
<Admin disableTelemetry dataProvider={CustomDataProvider} i18nProvider={i18nProvider} authProvider={authProvider} requireAuth layout={CustomLayout}
dashboard={CustomDashboard}
title="AROLIOS App" >
{dynamicResourcesAndRoutes }
</Admin>
)
}
;
import React from "react";
import ReactDOM from "react-dom/client";
import { App } from "./App";
import { AssociationMemberEndProvider, ClassifierProvider} from './utils/contexts';
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<ClassifierProvider>
<AssociationMemberEndProvider>
<App />
</AssociationMemberEndProvider>
</ClassifierProvider>
</React.StrictMode>
);
import {useTranslate} from "react-admin";
import {
Box,
} from '@mui/material';
const LicenseText = () => {
return (
<Box sx={{ border: '1px solid black'}}>
<p>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.</p>
</Box>
)
}
const About = () => {
const translate = useTranslate();
return (
<div>
<p>AROLIOS WebUI &nbsp;{translate('arolios.WebUI_purpose')}.</p>
<p>AROLIOS &nbsp;{translate('arolios.trademark_registered')}.</p>
<p>AROLIOS WebUI &nbsp; &copy; 2024 Philippe Coicadan. {translate('arolios.all_rights_reserved')}.</p>
<p>AROLIOS WebUI &nbsp;{translate('arolios.license_intro')}</p>
<LicenseText/>
<p>{translate('arolios.source_link')}&nbsp; http://my_ repository/arolios-webui</p>
</div>
)
}
export default About;
\ No newline at end of file
import { useCreatePath} from 'react-admin';
import {useNavigate } from 'react-router-dom';
import { useContext } from "react";
import { ClassifierContext} from '../../utils/contexts'
const CustomDashboard = () => {
const createPath = useCreatePath();
const navigate = useNavigate();
const {mapDomainNameResource} = useContext(ClassifierContext);
const def_dom = sessionStorage.getItem('arolios_model_default_domain') ;
if ( def_dom ) {
const { name, _tname} = JSON.parse(sessionStorage.getItem('arolios_model_default_domain'));
mapDomainNameResource (name, _tname);
return navigate(createPath( { resource: `${name}/classes`, type: 'list'}));
} else {
return navigate(createPath( { resource: 'domains', type: 'list' }));
}
}
export default CustomDashboard;
\ No newline at end of file
import {FileInput, FileField , useNotify, useRedirect, useCreatePath} from 'react-admin';
import { SimpleForm, useTranslate, required} from 'react-admin';
import { backEndURL } from '../../utils/utils';
// from downloadCSV
const downloadJSON = (content, filename) => {
const fakeLink = document.createElement('a');
fakeLink.style.display = 'none';
document.body.appendChild(fakeLink);
const blob = new Blob([content], { type: 'application/json;charset=utf-8' });
// @ts-ignore
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
// Manage IE11+ & Edge
// @ts-ignore
window.navigator.msSaveOrOpenBlob(blob, `${filename}.json`);
} else {
fakeLink.setAttribute('href', URL.createObjectURL(blob));
fakeLink.setAttribute('download', `${filename}.json`);
fakeLink.click();
}
};
const ExportData = () => {
const translate = useTranslate();
const notify = useNotify();
const redirect = useRedirect();
const createPath = useCreatePath();
const postData = (data) => {
const { token } = JSON.parse(sessionStorage.getItem('arolios_auth'));
const formData = new FormData();
formData.append ('file', data.query.rawFile, `${data.query.title}`);
if (data.params != null) {
formData.append ('file', data.params.rawFile, `${data.params.title}`);
}
const request = new Request(backEndURL() + '/instances', {
method: 'POST',
body: formData,
headers: new Headers({ 'Authorization':`Bearer ${token}` }),
});
return fetch(request, { credentials: 'include'})
.then(response => {
if (response.status < 200 || response.status >= 300) {
throw new Error(response.statusText);
}
return response.json();
} )
.then ( json => {
notify ('arolios.export_success', {type: 'success', messageArgs: { title: `${data.query.title}`}});
downloadJSON (JSON.stringify(json["elements"]), "export");
redirect (createPath( { resource: 'domains', type: 'list' }));
return Promise.resolve();
})
.catch(() => {
throw new Error('Network error')
});
}
return (
<div>
<h1>{translate('arolios.data_export')}</h1>
<SimpleForm onSubmit={postData}>
<FileInput source="query" label="arolios.export_query">
<FileField source="src" title="title" validate={required}/>
</FileInput>
<FileInput source="params" label="arolios.export_params">
<FileField source="src" title="title"/>
</FileInput>
</SimpleForm>
</div>
)
}
export default ExportData;
\ No newline at end of file
import {useLocaleState} from "react-admin";
const HelpEn = () => {
return (
<div>
<h1>Help in construction</h1>
</div>
)
}
const HelpFr = () => {
return (
<div>
<h1>Aide en construction</h1>
</div>
)
}
const Help = () => {
const [locale] =useLocaleState();
if (locale === 'fr') {
return ( <HelpFr/> );
} else if (locale === 'en') {
return ( <HelpEn/> );
}
}
export default Help;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment