diff --git a/docs/assets/media/how-to/study-create-button.png b/docs/assets/media/how-to/study-create-button.png new file mode 100644 index 0000000000..fb149407cc Binary files /dev/null and b/docs/assets/media/how-to/study-create-button.png differ diff --git a/docs/assets/media/how-to/study-create-form.png b/docs/assets/media/how-to/study-create-form.png new file mode 100644 index 0000000000..725cb504d6 Binary files /dev/null and b/docs/assets/media/how-to/study-create-form.png differ diff --git a/docs/assets/media/how-to/study-create-other-options.png b/docs/assets/media/how-to/study-create-other-options.png new file mode 100644 index 0000000000..1d0db58c26 Binary files /dev/null and b/docs/assets/media/how-to/study-create-other-options.png differ diff --git a/docs/assets/media/how-to/study-creation-edit-properties.png b/docs/assets/media/how-to/study-creation-edit-properties.png new file mode 100644 index 0000000000..80b4a3e4d0 Binary files /dev/null and b/docs/assets/media/how-to/study-creation-edit-properties.png differ diff --git a/docs/assets/media/how-to/study-creation-move-to-subfolder.png b/docs/assets/media/how-to/study-creation-move-to-subfolder.png new file mode 100644 index 0000000000..db5f64e66e Binary files /dev/null and b/docs/assets/media/how-to/study-creation-move-to-subfolder.png differ diff --git a/docs/how-to/studies-create.md b/docs/how-to/studies-create.md new file mode 100644 index 0000000000..8123872433 --- /dev/null +++ b/docs/how-to/studies-create.md @@ -0,0 +1,160 @@ +--- +title: How to Create a New Study? +author: Laurent LAPORTE +date: 2024-07-03 +tags: + + - tutorial + - guide + - create + - version + - new + - study management + - workspace +--- + +# How to Create a New Study? + +Creating a new study in Antares Web is a straightforward process designed to facilitate users in setting up their energy +system simulations. +This guide will walk you through the steps to create a new study, from initial setup to finalization. + +## Open the "Create Study" dialog + +Navigate to the "Studies" pages to display the list of studies. +Click on the "Create" button to open the "Create Study" dialog box. + +![List of studies](../assets/media/how-to/study-create-button.png) + +## Fill in Study Properties + +In the "Create Study" dialog, you will be prompted to enter details about your study, such as: + +- **Study Name**: Give your study a unique and descriptive name. +- **Version**: Select the version you wish to use, by default, the latest version is selected. +- **Permission**: + - **Public Mode**: Select this option if you want to share your study with other users (it is recommended to + select "READ" permission). + - **Group**: Choose the groups you want to share your study with. +- **Metadata**: + - **Tag**: Add tags to your study to help categorize and organize it (enter each tag, and presse Ctrl+Enter to add + it). + +![Create Study Form](../assets/media/how-to/study-create-form.png) + +Validate the form by clicking the "Save" button. + +Your study is automatically saved in the `default` folder, which is the default folder of managed studies. + +## Customize Study Properties + +After creating your study, you can customize it further by moving it in a subfolder, changing its permission, or adding +metadata. + +Select the `default` folder to display the list of studies in this folder. +Click on the "More options" button of your study to access the "Properties" and "Move" options. + +![Other Options Menu](../assets/media/how-to/study-create-other-options.png) + +### Move Study in a Subfolder + +To move your study in a subfolder, click on the "Move" option. +The "Move Study" dialog opens, allowing you to select the destination folder. + +Enter the name of the subfolder and validate by clicking the "Save" button. + +![Move Study Dialog](../assets/media/how-to/study-creation-move-to-subfolder.png) + +If the subfolder does not exist, it will be created automatically. + +### Edit the Study Properties + +To edit the study properties, click on the "Properties" option. +The "Edit Study" dialog opens, allowing you to modify the study name, permission, and metadata: + +- **Study Name**: Give your study a unique and descriptive name. +- **Permission**: + - **Public Mode**: Select this option if you want to share your study with other users (it is recommended to + select "READ" permission). + - **Group**: Choose the groups you want to share your study with. +- **Metadata**: + - **Tag**: Add tags to your study to help categorize and organize it (enter each tag, and presse Ctrl+Enter to add + it). + +![Edit Study Dialog](../assets/media/how-to/study-creation-edit-properties.png) + +Validate the form by clicking the "Save" button. + +> **NOTE:** It is not possible to modify the version of a study after its creation, +> but you can still upgrade the version of the study. +> Refer to the [How to Upgrade a Study?](studies-upgrade.md) section for more information. + +## Creating a Study Using the API Endpoint + +The following Python script demonstrates how to create a study using the API endpoint `POST /v1/studies`: + +You need to provide the following parameters: + +- `name`: name of the study +- `version`: version of the study +- `groups`: list of groups to which the study will be assigned (optional) + +Make sure you have the correct API URL and a valid authentication token. + +```python +import httpx # or requests + +URL = "https://antares-web/api" +TOKEN = "" + +study = { + "name": "My New Study", + "version": 860, + "groups": "group1, group2" +} + +with httpx.Client(verify=False, headers={"Authorization ": f"Bearer {TOKEN}"}) as client: + res = client.post(f"{URL}/v1/studies", params=study) + +res.raise_for_status() +study_id = res.json() +``` + +The script above creates a new study named `My New Study` with version `860` and assigns it to the groups `group1` +and `group2`. + +Here is a breakdown of what each part of the code does: + +1. `import httpx`: This line imports the `httpx` library, which is used for making HTTP requests in Python. + Alternatively, the `requests` library can be used instead of `httpx` for the same purpose. + +2. `URL = "https://antares-web/api"`: This line sets the URL to which the POST request will be made. + You need to provide the right URL according to your own Antares Web server. + +3. `TOKEN = ""`: This line sets the authentication token that will be used in the request. + You should replace `` with your actual authentication token. + +4. The `study = {...}` block defines the properties of the study to be created. + +5. The `with httpx.Client(verify=False, headers=...) as client:` block creates an HTTP client. + The `verify=False` argument is used to disable SSL certificate verification. + The `headers={"Authorization ": f"Bearer {TOKEN}"}` argument sets authentication token. + +6. The `res = client.post(f"{URL}/v1/studies", params=study)` line sends a POST request to create the study. + The `params=study` argument sends the study properties as JSON data in the request body. + +7. `res.raise_for_status()` checks if the response from the server indicates an error. + If an error is detected, it raises an exception. + +8. `study_id = res.json()` parses the response from the server, assuming it is in JSON format, + and assigns it to the variable `study_id`. + +See also: + +- ["User account & api tokens"](../user-guide/1-interface.md#user-account-and-api-tokens) in the user guide. + +## See also + +- [How to Upgrade a Study?](studies-upgrade.md) -- Upgrade a study to a recent version +- [How to Import a Compressed Study?](studies-import.md) - Import a study from a compressed file +- How to Run a study simulation? - Run a simulation on a study diff --git a/docs/how-to/studies-import.md b/docs/how-to/studies-import.md index 4434131437..153b139fdc 100644 --- a/docs/how-to/studies-import.md +++ b/docs/how-to/studies-import.md @@ -4,9 +4,14 @@ author: Laurent LAPORTE date: 2023-10-25 tags: - - import - - zip - - 7z + - tutorial + - guide + - import + - zip + - 7z + - compressed + - study management + - workspace --- @@ -56,10 +61,20 @@ The import dialog box will appear. Click the "Browse" button to select the compr You can also drag and drop the compressed file into the dialog box. -Once imported, you can see the study in the list of studies. Select the "default" workspace to view the imported study. You can also search for the study by name using the search input. +Once imported, you can see the study in the list of studies. Select the "default" workspace to view the imported study. +You can also search for the study by name using the search input. ![studies-import-studies-list.png](../assets/media/how-to/studies-import-studies-list.png) +> **NOTE:** The properties of the imported study can be modified by clicking on the "More options" button and +> selecting "Properties". You can change the study name, permission, and metadata. +> Refer to the [Customize Study Properties](studies-create.md#customize-study-properties) paragraph +> for more information. + +> **NOTE:** It is not possible to modify the version of a study after its import, +> but you can still upgrade the version of the study. +> Refer to the [How to Upgrade a Study?](studies-upgrade.md) section for more information. + ## Importing a Study Using the API Endpoint The following Python script demonstrates how to import a study using the API endpoint `POST /v1/studies/_import`: @@ -78,21 +93,20 @@ URL = "https://antares-web/api" TOKEN = "" with open("perso/new_study.zip", mode="rb") as fd: - with httpx.Client(verify=False) as client: + with httpx.Client(verify=False, headers={"Authorization ": f"Bearer {TOKEN}"}) as client: res = client.post( f"{URL}/v1/studies/_import", - headers={"Authorization": f"Bearer {TOKEN}"}, files={"study": fd}, params={"groups": "foo,bar"}, ) res.raise_for_status() -study_uuid = res.json() +study_id = res.json() ``` The script above imports the compressed file `perso/new_study.zip` and assigns the study to the groups `foo` and `bar`. -Here's a breakdown of what each part of the code does: +Here is a breakdown of what each part of the code does: 1. `import httpx`: This line imports the `httpx` library, which is used for making HTTP requests in Python. Alternatively, the `requests` library can be used instead of `httpx` for the same purpose. @@ -105,19 +119,26 @@ Here's a breakdown of what each part of the code does: 4. The `with open("perso/new_study.zip", mode="rb") as fd:` block opens the specified compressed file in binary mode. -5. The `with httpx.Client(verify=False) as client:` block creates an HTTP client. +5. The `with httpx.Client(verify=False, headers=...) as client:` block creates an HTTP client. The `verify=False` argument is used to disable SSL certificate verification. + The `headers={"Authorization ": f"Bearer {TOKEN}"}` argument sets authentication token. 6. `res = client.post(...)` makes a POST request to the specified URL with the provided parameters. It sends the file contents, sets the headers with the authentication token, and adds query parameters. 7. `res.raise_for_status()` checks if the response from the server indicates an error. If an error is detected, it raises an exception. - You may have the HTTP error 415 if the file is not a valid ZIP of 7z file. + You may have the HTTP error 415 if the file is not a valid ZIP of 7z file. -8. `study_uuid = res.json()` parses the response from the server, assuming it is in JSON format, - and assigns it to the variable `study_uuid`. +8. `study_id = res.json()` parses the response from the server, assuming it is in JSON format, + and assigns it to the variable `study_id`. See also: - ["User account & api tokens"](../user-guide/1-interface.md#user-account-and-api-tokens) in the user guide. + +## See also + +- [How to Create a New Study?](studies-create.md) -- Create a new study in Antares Web +- [How to Upgrade a Study?](studies-upgrade.md) -- Upgrade a study to a recent version +- How to Run a study simulation? - Run a simulation on a study diff --git a/docs/how-to/studies-upgrade.md b/docs/how-to/studies-upgrade.md index fe48723539..f92a1855ff 100644 --- a/docs/how-to/studies-upgrade.md +++ b/docs/how-to/studies-upgrade.md @@ -2,10 +2,15 @@ title: How to Upgrade a Study? author: Laurent LAPORTE date: 2023-03-10 +revision: 2024-07-03 tags: -- upgrade -- version + - tutorial + - guide + - upgrade + - version + - study management + - raw --- @@ -31,6 +36,10 @@ hesitate to contact our support team for assistance. ## Upgrading +> **WARNING:** Upgrading a study is only possible if the study is a **raw study** without any variants, +> as it is not possible to update its descendants. Also, upgrading a variant study is not possible. +> If you have a variant study, you must first create a new raw study and then upgrade it. + To upgrade your study to the latest version of Antares Web and Antares Simulator, you can follow these steps: On the main page of the study, you can find the version number at the top of the menu bar: @@ -58,5 +67,6 @@ Once the upgrade is complete, you can open your study and perform the manual upg ## See also -- Create a new study in the latest version -- Run a study in the latest version +- [How to Create a New Study?](studies-create.md) -- Create a new study in Antares Web +- [How to Import a Compressed Study?](studies-import.md) - Import a study from a compressed file +- How to Run a study simulation? - Run a simulation on a study diff --git a/docs/index.md b/docs/index.md index de7365f71b..4e1a2f818f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,29 +4,32 @@ ![TypeScript](https://img.shields.io/badge/TypeScript-00599c?style=for-the-badge&logo=TypeScript&logoColor=61DAFB) ![React](https://img.shields.io/badge/React-00599c?style=for-the-badge&logo=react&logoColor=61DAFB) +![](assets/antares.png "Antares Web Logo") +> Web API and UI for [Antares Simulator][antares-simulator-website] -![antares logo](assets/antares.png) -> Web API and UI for [Antares Simulator][antareswebsite] - -This package works along with RTE's adequacy software [Antares Simulator][antareswebsite] that is also [hosted on github][antares-github] - -Please see the [Antares Web Documentation][readthedocs] for an introductory tutorial, -and a full user guide. Visit the [Antares-Simulator Documentation][readthedocs-antares] for more insights on ANTARES. +Please see the [Antares Web Documentation][antares-web-readthedocs] for an introductory tutorial, +and a full user guide. Visit the [Antares-Simulator Documentation][antares-simulator-readthedocs] for more insights on +ANTARES. ## Introduction -`antares-web` is a server api interfacing Antares Simulator solver and studies management. It provides a web application to manage studies -adding more features to simple edition. +Welcome to `antares-web`, a comprehensive web application designed to interface with RTE’s adequacy software, +the [Antares Simulator][antares-simulator-website], also [hosted on GitHub][antares-simulator-github]. +The Antares Simulator is an open-source power system simulator for anyone valuing the quantification of adequacy or the +economic performance of interconnected energy systems over short or distant time horizons. +It enables detailed modeling of energy consumption, generation, and transportation, performing probabilistic simulations +across numerous year-long scenarios, each consisting of 8760 hourly time-frames. + +`antares-web` serves as a server API interfacing with Antares Simulator studies, providing a web application to manage +studies while adding features for enhanced edition capabilities. -This brings: +This integration brings: -> - **application interoperability** : assign unique id to studies, expose operation endpoint api -> -> - **optimized storage**: extract matrices data and share them between studies, archive mode -> -> - **variant management**: add a new editing description language and generation tool -> -> - **user accounts** : add user management and permission system +- **Application Interoperability**: Assign unique IDs to studies and expose operations through an endpoint API, + facilitating integration with other applications and services. +- **Optimized Storage**: Extract matrices data and share them between studies, supporting archive mode. +- **Variant Management**: Introduce a new editing description language and generation tool. +- **User Accounts**: Implement user management and permission systems. ## Documentation @@ -34,18 +37,24 @@ This brings: - [Using the application](./user-guide/0-introduction.md) - [Contributing to the application code](./architecture/0-introduction.md) - `Antares-Web` is currently under development. Feel free to submit any issue. +[ci_result]: https://github.com/AntaresSimulatorTeam/AntaREST/actions/workflows/main.yml/badge.svg + +[ci_result_link]: https://github.com/AntaresSimulatorTeam/AntaREST/actions/workflows/main.yml -[ci_result]: https://github.com/AntaresSimulatorTeam/AntaREST/workflows/main/badge.svg -[ci_result_link]: https://github.com/AntaresSimulatorTeam/AntaREST/actions?query=workflow%3Amain [coverage_result]: https://sonarcloud.io/api/project_badges/measure?project=AntaresSimulatorTeam_api-iso-antares&metric=coverage + [coverage_result_link]: https://sonarcloud.io/dashboard?id=AntaresSimulatorTeam_api-iso-antares + [license_badge]: https://img.shields.io/github/license/AntaresSimulatorTeam/AntaREST + [license_link]: https://www.apache.org/licenses/LICENSE-2.0 -[antares-github]: https://github.com/AntaresSimulatorTeam/Antares_Simulator -[readthedocs]: https://antares-web.readthedocs.io/ -[readthedocs-antares]: https://antares-simulator.readthedocs.io/ -[antareswebsite]: https://antares-simulator.org +[antares-web-readthedocs]: https://antares-web.readthedocs.io/ + +[antares-simulator-readthedocs]: https://antares-simulator.readthedocs.io/ + +[antares-simulator-website]: https://antares-simulator.org + +[antares-simulator-github]: https://github.com/AntaresSimulatorTeam/Antares_Simulator diff --git a/docs/user-guide/0-introduction.md b/docs/user-guide/0-introduction.md index dc60974c2f..de2bd50eb7 100644 --- a/docs/user-guide/0-introduction.md +++ b/docs/user-guide/0-introduction.md @@ -14,27 +14,35 @@ tags: # Introduction -![](../assets/antares.png) +![](../assets/antares.png "Antares Web Logo") -This package works along with RTE's adequacy software [Antares Simulator](https://antares-simulator.org) -that is also [hosted on github][antares-github] +Welcome to `antares-web`, a comprehensive web application designed to interface with RTE’s adequacy software, +the [Antares Simulator][antares-simulator-website], also [hosted on GitHub][antares-simulator-github]. +The Antares Simulator is an open-source power system simulator for anyone valuing the quantification of adequacy or the +economic performance of interconnected energy systems over short or distant time horizons. +It enables detailed modeling of energy consumption, generation, and transportation, performing probabilistic simulations +across numerous year-long scenarios, each consisting of 8760 hourly time-frames. -`antares-web` is a server api interfacing Antares Simulator studies. It provides a web application to manage studies -adding more features to simple edition. +`antares-web` serves as a server API interfacing with Antares Simulator studies, providing a web application to manage +studies while adding features for enhanced edition capabilities. -This brings: +This integration brings: -> - **application interoperability** : assign unique id to studies, expose operation endpoint api -> -> - **optimized storage**: extract matrices data and share them between studies, archive mode -> -> - **variant management**: add a new editing description language and generation tool -> -> - **user accounts** : add user management and permission system +- **Application Interoperability**: Assign unique IDs to studies and expose operations through an endpoint API, + facilitating integration with other applications and services. +- **Optimized Storage**: Extract matrices data and share them between studies, supporting archive mode. +- **Variant Management**: Introduce a new editing description language and generation tool. +- **User Accounts**: Implement user management and permission systems. -## Variant manager +## Variant Manager -`antares-web` brings an edition event store that provides a way to edit a study while keeping track of changes. -It eases the creation of "variants" of a study and allow an explicit diff change between studies. +`antares-web` introduces an edition event store that tracks changes, simplifying the creation of study "variants" and +allowing for explicit diff change comparisons between studies. -You can read more information in [using the variant manager here](./3-variant_manager.md) +Explore the suite of features `antares-web` offers to enhance the Antares Simulator, improving study management, +interoperability, and user collaboration. + + +[antares-simulator-website]: https://antares-simulator.org + +[antares-simulator-github]: https://github.com/AntaresSimulatorTeam/Antares_Simulator diff --git a/docs/user-guide/1-interface.md b/docs/user-guide/1-interface.md index ab7954d693..38d1088a0c 100644 --- a/docs/user-guide/1-interface.md +++ b/docs/user-guide/1-interface.md @@ -24,39 +24,43 @@ tags: - [Strict folder filtering](#strict-folder-filtering) - [Zipped output retrieval](#launch-dialog) +The application is split into 3 main menus: Studies, Jobs, and Data. +API documentation, external reference links, and user account details are also available. -The application is split in 3 main menus : Studies, Jobs and Data. -API documentation, external reference links and user account details is also available. - - - "Studies" is the main section and redirects to the study listing where we can browse studies and work -on them. - - "Jobs" is a monitoring section which display currently running or latest execution jobs - - "Data" is a section where we can manage matrix data that can be then used in the [variant manager](#variant-management) +- "Studies" is the main section and redirects to the study listing where we can browse studies and work on them. +- "Jobs" is a monitoring section that displays currently running or latest execution jobs. +- "Data" is a section where we can manage matrix data that can then be used in + the [variant manager](#variant-management). ![](../assets/media/img/userguide_mainmenu.png) ## Study listing The study listing view is the main view, which provides : + - the listing of existing studies - filters/sorting/tree view - creation/import tool Studies are linked to a "workspace" which refers to a storage disk. The workspace "default" (orange colored) is -the internal storage where "managed" studies live. These studies files aren't meant to be accessible directly (via disk mount for instance). -The other workspaces are studies that are found on mounted workspace and their unique ID can change if the studies are moved. +the internal storage where "managed" studies live. These studies files aren't meant to be accessible directly (via disk +mount for instance). +The other workspaces are studies that are found on mounted workspace and their unique ID can change if the studies are +moved. + +Copied studies are always copied within the managed workspace. These managed studies though not directly accessible +offers additional features: -Copied studies are always copied within the managed workspace. These managed studies though not directly accessible offers additional features: - a permanent ID - archiving - variant creation - faster operations - storage improvements - ![](../assets/media/img/userguide_studylisting.png) Some actions are available from this view: + - launching the study simulation - exporting the study - deleting the study @@ -67,13 +71,12 @@ Some actions are available from this view: When launching a study, a dialog will open with some choices. - ![](../assets/media/img/userguide_launch_dialog.png) - ### Launch batch mode -To launch multiple studies at once, we can click on the checkbox icon to enable selection mode. In this mode, we can click +To launch multiple studies at once, we can click on the checkbox icon to enable selection mode. In this mode, we can +click on study cards to select / unselect them. Then clicking on the launch button will open the launch dialog. @@ -81,17 +84,18 @@ the launch dialog. ### Strict folder filtering -The folder icon next to the breadcrumb path allow to filter (when activated) the studies to only the direct descendant of the selected folder. +The folder icon next to the breadcrumb path allow to filter (when activated) the studies to only the direct descendant +of the selected folder. ![](../assets/media/img/userguide_strict_folder_filter.png) - For more operation over a study, we can click on a study "explore" button and go to the dedicated study view. The url of dedicated study view can be bookmarked for sharing or quick access. ## Study view The study view is composed of 2 or 3 main menus depending on the managed status of the study. + - ["Information"](#overview) view is an overview of the study - ["Detailed view"](#detailed-view) is a raw view of the study contents - ["Variant"](#variant-management) view is where we can manage the variant of a study if it is managed @@ -99,6 +103,7 @@ The study view is composed of 2 or 3 main menus depending on the managed status ### Overview The overview provides access to : + - basic metadata - name and permission edition (a study can be public or associated with groups with specific permissions) - simulation execution monitoring @@ -110,6 +115,7 @@ The overview provides access to : The variant command tab is only available for managed variant studies. It shows an edition view where we can: + - edit the command list composing the variant - monitor or verify the result of the generation process @@ -117,11 +123,10 @@ It shows an edition view where we can: ### Detailed view -The detailed view is a tree representation of a study files. +The detailed view is a tree representation of a study files. It can be browsed and node can be viewed and edited. :warning: The view can take some time to load the first time. - Example of the detailed view of a configuration node (ini files): ![](../assets/media/img/userguide_treeview_json.png) @@ -130,11 +135,10 @@ Example of the detailed view of a matrix node (txt data files): ![](../assets/media/img/userguide_treeview_matrix.png) - ## Data management The data view display dataset which are list of matrices. -These matrices can then be used as argument in [variant manager commands](./3-variant_manager.md#base-commands). +These matrices can then be used as argument in [variant manager commands](./3-variant_manager.md#command-list). ![](../assets/media/img/userguide_dataset_listing.png) @@ -149,12 +153,15 @@ These token can be used in scripts that will use the [API](#api-documentation). ![](../assets/media/img/userguide_token_listing.png) -We can choose to assign specific permission to the token and can choose if the scripts using the token will impersonate our user or not. +We can choose to assign specific permission to the token and can choose if the scripts using the token will impersonate +our user or not. If we choose the later, studies created using the token will be owned by a new user that will have the token's name. ![](../assets/media/img/userguide_token_creation.png) -We have to save the token (as it is generated once and not saved). It will then be used as an authentication token in HTTP Basic Auth, eg.: +We have to save the token (as it is generated once and not saved). It will then be used as an authentication token in +HTTP Basic Auth, eg.: + ``` curl -H 'Authorization: Bearer ' https://antares-web/api/studies ``` diff --git a/docs/user-guide/3-variant_manager.md b/docs/user-guide/3-variant_manager.md index 7e4b7fd690..8b8ceb4ed7 100644 --- a/docs/user-guide/3-variant_manager.md +++ b/docs/user-guide/3-variant_manager.md @@ -402,7 +402,7 @@ Coming soon ### Composite commands -Comming soon +Coming soon ## CLI Tool diff --git a/mkdocs.yml b/mkdocs.yml index 6a0c971cb6..5a28ea96df 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -58,6 +58,7 @@ nav: - 'Main Topics': 'user-guide/study/06-table-mode.md' - 'Variant manager': 'user-guide/3-variant_manager.md' - 'How to': + - 'Create a study': 'how-to/studies-create.md' - 'Import a study': 'how-to/studies-import.md' - 'Upgrade a study': 'how-to/studies-upgrade.md' - 'Build': diff --git a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/index.tsx b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/index.tsx index d6f987753a..97637987d3 100644 --- a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/index.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/index.tsx @@ -20,6 +20,7 @@ import { addClusterCapacity, capacityAggregationFn, getClustersWithCapacityTotals, + toCapacityString, } from "../common/clustersUtils"; import { TRow } from "../../../../../../common/GroupedDataTable/types"; import BooleanCell from "../../../../../../common/GroupedDataTable/cellRenderers/BooleanCell"; @@ -80,29 +81,26 @@ function Renewables() { columnHelper.accessor("nominalCapacity", { header: "Nominal Capacity (MW)", size: 220, - Cell: ({ cell }) => Math.floor(cell.getValue()), - }), - columnHelper.accessor("installedCapacity", { - header: "Enabled / Installed (MW)", - size: 220, - aggregationFn: capacityAggregationFn(), - AggregatedCell: ({ cell }) => ( - - {cell.getValue() ?? ""} - - ), - Cell: ({ row }) => ( - <> - {Math.floor(row.original.enabledCapacity)} /{" "} - {Math.floor(row.original.installedCapacity)} - - ), - Footer: () => ( - - {totalEnabledCapacity} / {totalInstalledCapacity} - - ), + Cell: ({ cell }) => cell.getValue().toFixed(1), }), + columnHelper.accessor( + (row) => toCapacityString(row.enabledCapacity, row.installedCapacity), + { + header: "Enabled / Installed (MW)", + size: 220, + aggregationFn: capacityAggregationFn(), + AggregatedCell: ({ cell }) => ( + + {cell.getValue()} + + ), + Footer: () => ( + + {toCapacityString(totalEnabledCapacity, totalInstalledCapacity)} + + ), + }, + ), ]; }, [totals]); diff --git a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/index.tsx b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/index.tsx index 69193af96d..6c19931d74 100644 --- a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/index.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/index.tsx @@ -69,13 +69,13 @@ function Storages() { aggregationFn: "sum", AggregatedCell: ({ cell }) => ( - {Math.floor(cell.getValue())} + {Math.round(cell.getValue())} ), - Cell: ({ cell }) => Math.floor(cell.getValue()), + Cell: ({ cell }) => Math.round(cell.getValue()), Footer: () => ( - {Math.floor(totalInjectionNominalCapacity)} + {Math.round(totalInjectionNominalCapacity)} ), }), @@ -96,13 +96,13 @@ function Storages() { aggregationFn: "sum", AggregatedCell: ({ cell }) => ( - {Math.floor(cell.getValue())} + {Math.round(cell.getValue())} ), - Cell: ({ cell }) => Math.floor(cell.getValue()), + Cell: ({ cell }) => Math.round(cell.getValue()), Footer: () => ( - {Math.floor(totalWithdrawalNominalCapacity)} + {Math.round(totalWithdrawalNominalCapacity)} ), }), @@ -123,12 +123,12 @@ function Storages() { columnHelper.accessor("efficiency", { header: t("study.modelization.storages.efficiency"), size: 50, - Cell: ({ cell }) => `${Math.floor(cell.getValue() * 100)}`, + Cell: ({ cell }) => `${Math.round(cell.getValue() * 100)}`, }), columnHelper.accessor("initialLevel", { header: t("study.modelization.storages.initialLevel"), size: 50, - Cell: ({ cell }) => `${Math.floor(cell.getValue() * 100)}`, + Cell: ({ cell }) => `${Math.round(cell.getValue() * 100)}`, }), columnHelper.accessor("initialLevelOptim", { header: t("study.modelization.storages.initialLevelOptim"), diff --git a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Thermal/index.tsx b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Thermal/index.tsx index 0b36a6903a..3a7cfd6801 100644 --- a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Thermal/index.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Thermal/index.tsx @@ -20,6 +20,7 @@ import { addClusterCapacity, capacityAggregationFn, getClustersWithCapacityTotals, + toCapacityString, } from "../common/clustersUtils"; import { TRow } from "../../../../../../common/GroupedDataTable/types"; import BooleanCell from "../../../../../../common/GroupedDataTable/cellRenderers/BooleanCell"; @@ -84,27 +85,24 @@ function Thermal() { size: 220, Cell: ({ cell }) => cell.getValue().toFixed(1), }), - columnHelper.accessor("installedCapacity", { - header: "Enabled / Installed (MW)", - size: 220, - aggregationFn: capacityAggregationFn(), - AggregatedCell: ({ cell }) => ( - - {cell.getValue() ?? ""} - - ), - Cell: ({ row }) => ( - <> - {Math.floor(row.original.enabledCapacity)} /{" "} - {Math.floor(row.original.installedCapacity)} - - ), - Footer: () => ( - - {totalEnabledCapacity} / {totalInstalledCapacity} - - ), - }), + columnHelper.accessor( + (row) => toCapacityString(row.enabledCapacity, row.installedCapacity), + { + header: "Enabled / Installed (MW)", + size: 220, + aggregationFn: capacityAggregationFn(), + AggregatedCell: ({ cell }) => ( + + {cell.getValue()} + + ), + Footer: () => ( + + {toCapacityString(totalEnabledCapacity, totalInstalledCapacity)} + + ), + }, + ), columnHelper.accessor("marketBidCost", { header: "Market Bid (€/MWh)", size: 50, diff --git a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/common/clustersUtils.ts b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/common/clustersUtils.ts index a035dfa07f..3d5c80dd30 100644 --- a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/common/clustersUtils.ts +++ b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/common/clustersUtils.ts @@ -2,6 +2,13 @@ import { MRT_AggregationFn } from "material-react-table"; import { ThermalClusterWithCapacity } from "../Thermal/utils"; import { RenewableClusterWithCapacity } from "../Renewables/utils"; +export function toCapacityString( + enabledCapacity: number, + installedCapacity: number, +) { + return `${Math.round(enabledCapacity)} / ${Math.round(installedCapacity)}`; +} + /** * Custom aggregation function summing the values of each row, * to display enabled and installed capacity in the same cell. This function is @@ -29,9 +36,7 @@ export const capacityAggregationFn = < { enabledCapacitySum: 0, installedCapacitySum: 0 }, ); - return `${Math.floor(enabledCapacitySum)} / ${Math.floor( - installedCapacitySum, - )}`; + return toCapacityString(enabledCapacitySum, installedCapacitySum); }; };