diff --git a/backend/capellacollab/core/database/migration.py b/backend/capellacollab/core/database/migration.py index 32ba76fc4..dd22d3af7 100644 --- a/backend/capellacollab/core/database/migration.py +++ b/backend/capellacollab/core/database/migration.py @@ -396,7 +396,7 @@ def create_default_models(db: orm.Session): capella_model = toolmodels_crud.create_model( db=db, project=default_project, - post_model=toolmodels_models.PostCapellaModel( + post_model=toolmodels_models.PostToolModel( name=f"Melody Model Test {version}", description="", tool_id=capella_tool.id, @@ -434,7 +434,7 @@ def create_coffee_machine_model(db: orm.Session): capella_model = toolmodels_crud.create_model( db=db, project=coffee_machine_project, - post_model=toolmodels_models.PostCapellaModel( + post_model=toolmodels_models.PostToolModel( name="Coffee Machine", description="An open source model of a coffee machine", tool_id=capella_tool.id, diff --git a/backend/capellacollab/core/responses.py b/backend/capellacollab/core/responses.py index 1aadc8570..0765fa949 100644 --- a/backend/capellacollab/core/responses.py +++ b/backend/capellacollab/core/responses.py @@ -5,6 +5,7 @@ import os import typing as t +import fastapi import pydantic from capellacollab.core import pydantic as core_pydantic @@ -104,7 +105,43 @@ def _translate_exceptions_to_openapi_schema(excs: list[exceptions.BaseError]): ..., ), __base__=pydantic.RootModel, - ) + ), } for status_code, excs in grouped_by_status_code.items() } + + +class SVGResponse(fastapi.responses.Response): + """Custom error class for SVG responses. + + To use the class as response class, pass the following parameters + to the fastapi route definition. + + ```python + response_class=fastapi.responses.Response + responses=responses.SVGResponse.responses + ``` + + Don't use SVGResponse as response_class as this will also change the + media type for all error responses, see: + https://github.com/tiangolo/fastapi/discussions/6799 + + To return an SVG response in the route, use: + + ```python + return responses.SVGResponse( + content=b"...", + ) + ``` + """ + + media_type = "image/svg+xml" + responses: dict[int | str, dict[str, t.Any]] | None = { + 200: { + "content": { + "image/svg+xml": { + "schema": {"type": "string", "format": "binary"} + } + } + } + } diff --git a/backend/capellacollab/projects/toolmodels/crud.py b/backend/capellacollab/projects/toolmodels/crud.py index 8128b645b..b26bf79b1 100644 --- a/backend/capellacollab/projects/toolmodels/crud.py +++ b/backend/capellacollab/projects/toolmodels/crud.py @@ -78,7 +78,7 @@ def get_model_by_slugs( def create_model( db: orm.Session, project: projects_model.DatabaseProject, - post_model: models.PostCapellaModel, + post_model: models.PostToolModel, tool: tools_models.DatabaseTool, version: tools_models.DatabaseVersion | None = None, nature: tools_models.DatabaseNature | None = None, diff --git a/backend/capellacollab/projects/toolmodels/diagrams/routes.py b/backend/capellacollab/projects/toolmodels/diagrams/routes.py index 3317b8e7b..46beaf9a1 100644 --- a/backend/capellacollab/projects/toolmodels/diagrams/routes.py +++ b/backend/capellacollab/projects/toolmodels/diagrams/routes.py @@ -12,6 +12,7 @@ import capellacollab.projects.toolmodels.modelsources.git.injectables as git_injectables from capellacollab.core import logging as log +from capellacollab.core import responses from capellacollab.core.authentication import injectables as auth_injectables from capellacollab.projects.toolmodels.diagrams import models from capellacollab.projects.toolmodels.modelsources.git.handler import ( @@ -62,7 +63,9 @@ async def get_diagram_metadata( @router.get( - "/{diagram_uuid_or_filename}", response_class=fastapi.responses.Response + "/{diagram_uuid_or_filename}", + response_class=fastapi.responses.Response, + responses=responses.SVGResponse.responses, ) async def get_diagram( diagram_uuid_or_filename: str, @@ -86,7 +89,6 @@ async def get_diagram( logger.info("Failed fetching diagram", exc_info=True) raise exceptions.DiagramCacheNotConfiguredProperlyError() - return fastapi.responses.Response( + return responses.SVGResponse( content=diagram, - media_type="image/svg+xml", ) diff --git a/backend/capellacollab/projects/toolmodels/modelbadge/routes.py b/backend/capellacollab/projects/toolmodels/modelbadge/routes.py index 56c9703be..5323a9876 100644 --- a/backend/capellacollab/projects/toolmodels/modelbadge/routes.py +++ b/backend/capellacollab/projects/toolmodels/modelbadge/routes.py @@ -11,6 +11,7 @@ import capellacollab.projects.toolmodels.modelsources.git.injectables as git_injectables from capellacollab.core import logging as log +from capellacollab.core import responses from capellacollab.core.authentication import injectables as auth_injectables from capellacollab.projects.toolmodels.modelsources.git.handler import handler from capellacollab.projects.users import models as projects_users_models @@ -28,7 +29,11 @@ ) -@router.get("", response_class=fastapi.responses.Response) +@router.get( + "", + response_class=fastapi.responses.Response, + responses=responses.SVGResponse.responses, +) async def get_model_complexity_badge( git_handler: handler.GitHandler = fastapi.Depends( git_injectables.get_git_handler @@ -36,13 +41,12 @@ async def get_model_complexity_badge( logger: logging.LoggerAdapter = fastapi.Depends(log.get_request_logger), ): try: - return fastapi.responses.Response( + return responses.SVGResponse( content=( await git_handler.get_file_from_repository_or_artifacts( "model-complexity-badge.svg", "generate-model-badge" ) )[1], - media_type="image/svg+xml", ) except (aiohttp.web.HTTPException, requests.exceptions.HTTPError): logger.info("Failed fetching model complexity badge", exc_info=True) diff --git a/backend/capellacollab/projects/toolmodels/models.py b/backend/capellacollab/projects/toolmodels/models.py index 4a92a89b6..b217b35ea 100644 --- a/backend/capellacollab/projects/toolmodels/models.py +++ b/backend/capellacollab/projects/toolmodels/models.py @@ -42,13 +42,13 @@ class EditingMode(enum.Enum): GIT = "git" -class PostCapellaModel(core_pydantic.BaseModel): +class PostToolModel(core_pydantic.BaseModel): name: str description: str | None = None tool_id: int -class PatchCapellaModel(core_pydantic.BaseModel): +class PatchToolModel(core_pydantic.BaseModel): name: str | None = None description: str | None = None version_id: int | None = None @@ -122,7 +122,7 @@ class DatabaseToolModel(database.Base): ) -class CapellaModel(core_pydantic.BaseModel): +class ToolModel(core_pydantic.BaseModel): id: int slug: str name: str diff --git a/backend/capellacollab/projects/toolmodels/routes.py b/backend/capellacollab/projects/toolmodels/routes.py index 6b8716f5e..325c509ec 100644 --- a/backend/capellacollab/projects/toolmodels/routes.py +++ b/backend/capellacollab/projects/toolmodels/routes.py @@ -36,7 +36,7 @@ @router.get( - "", response_model=list[models.CapellaModel], tags=["Projects - Models"] + "", response_model=list[models.ToolModel], tags=["Projects - Models"] ) def get_models( project: projects_models.DatabaseProject = fastapi.Depends( @@ -48,7 +48,7 @@ def get_models( @router.get( "/{model_slug}", - response_model=models.CapellaModel, + response_model=models.ToolModel, tags=["Projects - Models"], ) def get_model_by_slug( @@ -61,7 +61,7 @@ def get_model_by_slug( @router.post( "", - response_model=models.CapellaModel, + response_model=models.ToolModel, dependencies=[ fastapi.Depends( auth_injectables.ProjectRoleVerification( @@ -72,7 +72,7 @@ def get_model_by_slug( tags=["Projects - Models"], ) def create_new_tool_model( - new_model: models.PostCapellaModel, + new_model: models.PostToolModel, project: projects_models.DatabaseProject = fastapi.Depends( projects_injectables.get_existing_project ), @@ -104,7 +104,7 @@ def create_new_tool_model( @router.patch( "/{model_slug}", - response_model=models.CapellaModel, + response_model=models.ToolModel, dependencies=[ fastapi.Depends( auth_injectables.ProjectRoleVerification( @@ -115,7 +115,7 @@ def create_new_tool_model( tags=["Projects - Models"], ) def patch_tool_model( - body: models.PatchCapellaModel, + body: models.PatchToolModel, project: projects_models.DatabaseProject = fastapi.Depends( projects_injectables.get_existing_project ), diff --git a/backend/capellacollab/settings/modelsources/t4c/routes.py b/backend/capellacollab/settings/modelsources/t4c/routes.py index 900485318..fa71b4e84 100644 --- a/backend/capellacollab/settings/modelsources/t4c/routes.py +++ b/backend/capellacollab/settings/modelsources/t4c/routes.py @@ -29,7 +29,7 @@ @router.get("", response_model=list[models.T4CInstance]) -def list_t4c_settings( +def get_t4c_instances( db: orm.Session = fastapi.Depends(database.get_db), ) -> abc.Sequence[models.DatabaseT4CInstance]: return crud.get_t4c_instances(db) diff --git a/backend/tests/projects/toolmodels/fixtures.py b/backend/tests/projects/toolmodels/fixtures.py index 42223f5c0..daacd2e7a 100644 --- a/backend/tests/projects/toolmodels/fixtures.py +++ b/backend/tests/projects/toolmodels/fixtures.py @@ -23,7 +23,7 @@ def fixture_capella_model( project: projects_models.DatabaseProject, capella_tool_version: tools_models.DatabaseVersion, ) -> toolmodels_models.DatabaseToolModel: - model = toolmodels_models.PostCapellaModel( + model = toolmodels_models.PostToolModel( name="test", description="test", tool_id=capella_tool_version.tool.id ) return toolmodels_crud.create_model( @@ -37,7 +37,7 @@ def fixture_jupyter_model( project: projects_models.DatabaseProject, jupyter_tool: tools_models.DatabaseTool, ) -> toolmodels_models.DatabaseToolModel: - jupyter_model = toolmodels_models.PostCapellaModel( + jupyter_model = toolmodels_models.PostToolModel( name="Jupyter test", description="", tool_id=jupyter_tool.id, diff --git a/backend/tests/projects/toolmodels/pipelines/conftest.py b/backend/tests/projects/toolmodels/pipelines/conftest.py index eca32a3d1..cfe7649c5 100644 --- a/backend/tests/projects/toolmodels/pipelines/conftest.py +++ b/backend/tests/projects/toolmodels/pipelines/conftest.py @@ -34,7 +34,7 @@ def fixture_include_commit_history( @pytest.fixture(name="pipeline") def fixture_pipeline( db: orm.Session, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, git_model: git_models.DatabaseGitModel, t4c_model: t4c_models.T4CModel, executor_name: str, diff --git a/backend/tests/projects/toolmodels/pipelines/pipeline-runs/test_pipeline_runs.py b/backend/tests/projects/toolmodels/pipelines/pipeline-runs/test_pipeline_runs.py index e630d2267..ad8f0d244 100644 --- a/backend/tests/projects/toolmodels/pipelines/pipeline-runs/test_pipeline_runs.py +++ b/backend/tests/projects/toolmodels/pipelines/pipeline-runs/test_pipeline_runs.py @@ -53,7 +53,7 @@ def fetch_logs_from_loki( def test_create_pipeline_run( db: orm.Session, project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, pipeline: pipelines_models.DatabaseBackup, ): @@ -72,7 +72,7 @@ def test_create_pipeline_run( @pytest.mark.usefixtures("project_manager") def test_create_pipeline_run_with_custom_environment( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, pipeline: pipelines_models.DatabaseBackup, ): @@ -89,7 +89,7 @@ def test_create_pipeline_run_with_custom_environment( def test_get_pipeline_runs( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, pipeline: pipelines_models.DatabaseBackup, pipeline_run: pipeline_runs_models.DatabasePipelineRun, @@ -105,7 +105,7 @@ def test_get_pipeline_runs( def test_get_pipeline_run( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, pipeline: pipelines_models.DatabaseBackup, pipeline_run: pipeline_runs_models.DatabasePipelineRun, @@ -121,7 +121,7 @@ def test_get_pipeline_run( @pytest.mark.usefixtures("patch_loki") def test_get_events( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, pipeline: pipelines_models.DatabaseBackup, pipeline_run: pipeline_runs_models.DatabasePipelineRun, @@ -136,7 +136,7 @@ def test_get_events( @pytest.mark.usefixtures("patch_loki") def def_get_logs( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, pipeline: pipelines_models.DatabaseBackup, pipeline_run: pipeline_runs_models.DatabasePipelineRun, diff --git a/backend/tests/projects/toolmodels/pipelines/test_pipelines.py b/backend/tests/projects/toolmodels/pipelines/test_pipelines.py index edfbdb8f8..92d2fffc6 100644 --- a/backend/tests/projects/toolmodels/pipelines/test_pipelines.py +++ b/backend/tests/projects/toolmodels/pipelines/test_pipelines.py @@ -54,7 +54,7 @@ def fixture_mockoperator(monkeypatch: pytest.MonkeyPatch): @pytest.mark.usefixtures("project_manager", "mockoperator", "pipeline") def test_get_all_pipelines_of_capellamodel( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, run_nightly: bool, include_commit_history: bool, @@ -73,7 +73,7 @@ def test_get_all_pipelines_of_capellamodel( ) def test_create_pipeline_of_capellamodel_git_model_does_not_exist( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, t4c_model: models_t4c_models.T4CModel, client: testclient.TestClient, ): @@ -99,7 +99,7 @@ def test_create_pipeline_of_capellamodel_git_model_does_not_exist( def test_create_pipeline( db: orm.Session, project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, t4c_model: models_t4c_models.T4CModel, git_model: git_models.GitModel, client: testclient.TestClient, @@ -129,7 +129,7 @@ def test_create_pipeline( ) def test_pipeline_creation_fails_if_t4c_server_not_available( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, t4c_model: models_t4c_models.T4CModel, git_model: git_models.GitModel, client: testclient.TestClient, @@ -174,7 +174,7 @@ def mock_add_user_to_repository( def test_delete_pipeline( db: orm.Session, project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, pipeline: pipelines_models.DatabaseBackup, client: testclient.TestClient, monkeypatch: pytest.MonkeyPatch, diff --git a/backend/tests/projects/toolmodels/test_diagrams.py b/backend/tests/projects/toolmodels/test_diagrams.py index cd9c483ee..cec25a87e 100644 --- a/backend/tests/projects/toolmodels/test_diagrams.py +++ b/backend/tests/projects/toolmodels/test_diagrams.py @@ -171,7 +171,7 @@ def fixture_mock_gitlab_diagram_cache_svg(git_type: git_models.GitType): ) def test_get_diagram_metadata_from_repository( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -218,7 +218,7 @@ def test_get_diagram_metadata_from_repository( ) def test_get_diagram_metadata_from_artifacts( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -240,7 +240,7 @@ def test_get_diagram_metadata_from_artifacts( ) def test_get_diagrams_fails_without_git_instance( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -263,7 +263,7 @@ def test_get_diagrams_fails_without_git_instance( ) def test_get_diagrams_fails_without_api_endpoint( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -315,7 +315,7 @@ def test_get_diagrams_fails_without_api_endpoint( ) def test_get_diagram_cache_without_defined_job( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -364,7 +364,7 @@ def test_get_diagram_cache_without_defined_job( ) def test_get_diagrams_failed_diagram_cache_job_found( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -422,7 +422,7 @@ def test_get_diagrams_failed_diagram_cache_job_found( @pytest.mark.usefixtures("project_user", "git_instance", "git_model") def test_get_single_diagram_from_artifacts( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -480,7 +480,7 @@ def test_get_single_diagram_from_artifacts( @pytest.mark.usefixtures("project_user", "git_instance", "git_model") def test_get_single_diagram_from_artifacts_with_file_ending( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -538,7 +538,7 @@ def test_get_single_diagram_from_artifacts_with_file_ending( @pytest.mark.usefixtures("project_user", "git_instance", "git_model") def test_get_single_diagram_from_artifacts_with_wrong_file_ending( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -593,7 +593,7 @@ def test_get_single_diagram_from_artifacts_with_wrong_file_ending( @pytest.mark.usefixtures("project_user", "git_instance", "git_model") def test_get_single_diagram_from_repository( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( diff --git a/backend/tests/projects/toolmodels/test_jupyter_fileshare.py b/backend/tests/projects/toolmodels/test_jupyter_fileshare.py index 1ff934441..e19a7c519 100644 --- a/backend/tests/projects/toolmodels/test_jupyter_fileshare.py +++ b/backend/tests/projects/toolmodels/test_jupyter_fileshare.py @@ -62,7 +62,7 @@ def test_creation_of_jupyter_fileshare( def test_deletion_of_jupyter_fileshare( client: testclient.TestClient, project: projects_models.DatabaseProject, - jupyter_model: toolmodels_models.CapellaModel, + jupyter_model: toolmodels_models.ToolModel, mockoperator: MockOperator, ): response = client.delete( diff --git a/backend/tests/projects/toolmodels/test_model_badge.py b/backend/tests/projects/toolmodels/test_model_badge.py index ed169b6e0..d30a9c62e 100644 --- a/backend/tests/projects/toolmodels/test_model_badge.py +++ b/backend/tests/projects/toolmodels/test_model_badge.py @@ -120,7 +120,7 @@ def fixture_mock_get_model_badge_from_artifacts_api( @pytest.mark.usefixtures("project_user", "git_type", "git_model") def test_model_has_no_git_instance( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -138,7 +138,7 @@ def test_model_has_no_git_instance( @pytest.mark.usefixtures("project_user", "git_instance", "git_model") def test_get_model_badge_fails_with_unsupported_git_instance( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -160,7 +160,7 @@ def test_get_model_badge_fails_with_unsupported_git_instance( ) def test_get_model_badge_fails_without_api_endpoint( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -197,7 +197,7 @@ def test_get_model_badge_fails_without_api_endpoint( ) def test_get_model_badge( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( @@ -235,7 +235,7 @@ def test_get_model_badge( ) def test_get_model_badge_from_artifacts( project: project_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, ): response = client.get( diff --git a/backend/tests/projects/toolmodels/test_toolmodels.py b/backend/tests/projects/toolmodels/test_toolmodels.py index 9290fff60..6b0850b58 100644 --- a/backend/tests/projects/toolmodels/test_toolmodels.py +++ b/backend/tests/projects/toolmodels/test_toolmodels.py @@ -18,7 +18,7 @@ def test_move_toolmodel( project: projects_models.DatabaseProject, project_manager: users_models.DatabaseUser, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, db: orm.Session, ): @@ -46,7 +46,7 @@ def test_move_toolmodel( @pytest.mark.usefixtures("project_manager") def test_move_toolmodel_non_project_member( project: projects_models.DatabaseProject, - capella_model: toolmodels_models.CapellaModel, + capella_model: toolmodels_models.ToolModel, client: testclient.TestClient, db: orm.Session, ): diff --git a/backend/tests/sessions/hooks/test_pure_variants.py b/backend/tests/sessions/hooks/test_pure_variants.py index 6101f7c9f..6f23039e6 100644 --- a/backend/tests/sessions/hooks/test_pure_variants.py +++ b/backend/tests/sessions/hooks/test_pure_variants.py @@ -43,7 +43,7 @@ def fixture_pure_variants_model( return toolmodels_crud.create_model( db, project, - post_model=toolmodels_models.PostCapellaModel( + post_model=toolmodels_models.PostToolModel( name="test", tool_id=pure_variants_tool.id ), tool=pure_variants_tool, diff --git a/frontend/src/app/general/error-handling/error-handling.interceptor.ts b/frontend/src/app/general/error-handling/error-handling.interceptor.ts index 34817c385..130d5b73b 100644 --- a/frontend/src/app/general/error-handling/error-handling.interceptor.ts +++ b/frontend/src/app/general/error-handling/error-handling.interceptor.ts @@ -15,7 +15,7 @@ import { } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { getReasonPhrase } from 'http-status-codes'; -import { Observable, tap, map, from, catchError } from 'rxjs'; +import { Observable, tap, from, catchError } from 'rxjs'; import { ToastService } from 'src/app/helpers/toast/toast.service'; import { Message } from 'src/app/openapi'; @@ -104,16 +104,6 @@ export class ErrorHandlingInterceptor implements HttpInterceptor { } }, }), - // If the body has a payload attribute, map to the attribute - // eslint-disable-next-line @typescript-eslint/no-explicit-any - map((event: HttpEvent) => { - if (event.type == HttpEventType.Response) { - if (event.body?.payload) { - event = event.clone({ body: event.body.payload }); - } - } - return event; - }), ); } @@ -167,12 +157,6 @@ export class ErrorHandlingInterceptor implements HttpInterceptor { } } -export type PayloadWrapper = { - warnings: Message[]; - errors: Message[]; - payload: unknown; -}; - interface FileReaderEventTarget extends EventTarget { result: string; } diff --git a/frontend/src/app/openapi/.openapi-generator/FILES b/frontend/src/app/openapi/.openapi-generator/FILES index 5f5c90eca..8c2c914ee 100644 --- a/frontend/src/app/openapi/.openapi-generator/FILES +++ b/frontend/src/app/openapi/.openapi-generator/FILES @@ -28,7 +28,6 @@ index.ts model/backup-pipeline-run.ts model/backup.ts model/base-user.ts -model/capella-model.ts model/cpu-resources-input.ts model/cpu-resources-output.ts model/create-backup.ts @@ -78,11 +77,11 @@ model/notice-level.ts model/notice-response.ts model/page-history-event.ts model/page-pipeline-run.ts -model/patch-capella-model.ts model/patch-git-model.ts model/patch-project-user.ts model/patch-project.ts model/patch-t4-c-instance.ts +model/patch-tool-model.ts model/patch-user-role-request.ts model/path-validation.ts model/payload-response-model-list-t4-c-repository.ts @@ -93,13 +92,13 @@ model/persistent-workspace-session-configuration-input.ts model/persistent-workspace-session-configuration-output.ts model/pipeline-run-status.ts model/pipeline-run.ts -model/post-capella-model.ts model/post-git-instance.ts model/post-git-model.ts model/post-project-request.ts model/post-project-user.ts model/post-session-request.ts model/post-token.ts +model/post-tool-model.ts model/post-user.ts model/project-status.ts model/project-type.ts @@ -145,6 +144,7 @@ model/tool-integrations-output.ts model/tool-model-provisioning-input.ts model/tool-model-provisioning-output.ts model/tool-model-restrictions.ts +model/tool-model.ts model/tool-nature.ts model/tool-session-configuration-input.ts model/tool-session-configuration-output.ts diff --git a/frontend/src/app/openapi/api/projects-models-diagrams.service.ts b/frontend/src/app/openapi/api/projects-models-diagrams.service.ts index f4ddb26e8..810b11e49 100644 --- a/frontend/src/app/openapi/api/projects-models-diagrams.service.ts +++ b/frontend/src/app/openapi/api/projects-models-diagrams.service.ts @@ -101,10 +101,10 @@ export class ProjectsModelsDiagramsService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (diagramUuidOrFilename === null || diagramUuidOrFilename === undefined) { throw new Error('Required parameter diagramUuidOrFilename was null or undefined when calling getDiagram.'); } @@ -134,6 +134,7 @@ export class ProjectsModelsDiagramsService { if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'image/svg+xml', 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); @@ -153,22 +154,11 @@ export class ProjectsModelsDiagramsService { } - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models/${this.configuration.encodeParam({name: "modelSlug", value: modelSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/diagrams/${this.configuration.encodeParam({name: "diagramUuidOrFilename", value: diagramUuidOrFilename, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - responseType: responseType_, + responseType: "blob", withCredentials: this.configuration.withCredentials, headers: localVarHeaders, observe: observe, diff --git a/frontend/src/app/openapi/api/projects-models-model-complexity-badge.service.ts b/frontend/src/app/openapi/api/projects-models-model-complexity-badge.service.ts index 568802b22..b1e1dca37 100644 --- a/frontend/src/app/openapi/api/projects-models-model-complexity-badge.service.ts +++ b/frontend/src/app/openapi/api/projects-models-model-complexity-badge.service.ts @@ -98,10 +98,10 @@ export class ProjectsModelsModelComplexityBadgeService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectSlug === null || projectSlug === undefined) { throw new Error('Required parameter projectSlug was null or undefined when calling getModelComplexityBadge.'); } @@ -128,6 +128,7 @@ export class ProjectsModelsModelComplexityBadgeService { if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'image/svg+xml', 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); @@ -147,22 +148,11 @@ export class ProjectsModelsModelComplexityBadgeService { } - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models/${this.configuration.encodeParam({name: "modelSlug", value: modelSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/badges/complexity`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - responseType: responseType_, + responseType: "blob", withCredentials: this.configuration.withCredentials, headers: localVarHeaders, observe: observe, diff --git a/frontend/src/app/openapi/api/projects-models.service.ts b/frontend/src/app/openapi/api/projects-models.service.ts index 5f679b260..e3d34cd46 100644 --- a/frontend/src/app/openapi/api/projects-models.service.ts +++ b/frontend/src/app/openapi/api/projects-models.service.ts @@ -23,8 +23,6 @@ import { Backup } from '../model/backup'; // @ts-ignore import { BackupPipelineRun } from '../model/backup-pipeline-run'; // @ts-ignore -import { CapellaModel } from '../model/capella-model'; -// @ts-ignore import { CreateBackup } from '../model/create-backup'; // @ts-ignore import { DiagramCacheMetadata } from '../model/diagram-cache-metadata'; @@ -37,20 +35,22 @@ import { HTTPValidationError } from '../model/http-validation-error'; // @ts-ignore import { PagePipelineRun } from '../model/page-pipeline-run'; // @ts-ignore -import { PatchCapellaModel } from '../model/patch-capella-model'; -// @ts-ignore import { PatchGitModel } from '../model/patch-git-model'; // @ts-ignore -import { PipelineRun } from '../model/pipeline-run'; +import { PatchToolModel } from '../model/patch-tool-model'; // @ts-ignore -import { PostCapellaModel } from '../model/post-capella-model'; +import { PipelineRun } from '../model/pipeline-run'; // @ts-ignore import { PostGitModel } from '../model/post-git-model'; // @ts-ignore +import { PostToolModel } from '../model/post-tool-model'; +// @ts-ignore import { SubmitT4CModel } from '../model/submit-t4-c-model'; // @ts-ignore import { T4CModel } from '../model/t4-c-model'; // @ts-ignore +import { ToolModel } from '../model/tool-model'; +// @ts-ignore import { ToolModelRestrictions } from '../model/tool-model-restrictions'; // @ts-ignore @@ -316,19 +316,19 @@ export class ProjectsModelsService { /** * Create New Tool Model * @param projectSlug - * @param postCapellaModel + * @param postToolModel * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public createNewToolModel(projectSlug: string, postCapellaModel: PostCapellaModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public createNewToolModel(projectSlug: string, postCapellaModel: PostCapellaModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public createNewToolModel(projectSlug: string, postCapellaModel: PostCapellaModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public createNewToolModel(projectSlug: string, postCapellaModel: PostCapellaModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + public createNewToolModel(projectSlug: string, postToolModel: PostToolModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public createNewToolModel(projectSlug: string, postToolModel: PostToolModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public createNewToolModel(projectSlug: string, postToolModel: PostToolModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public createNewToolModel(projectSlug: string, postToolModel: PostToolModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectSlug === null || projectSlug === undefined) { throw new Error('Required parameter projectSlug was null or undefined when calling createNewToolModel.'); } - if (postCapellaModel === null || postCapellaModel === undefined) { - throw new Error('Required parameter postCapellaModel was null or undefined when calling createNewToolModel.'); + if (postToolModel === null || postToolModel === undefined) { + throw new Error('Required parameter postToolModel was null or undefined when calling createNewToolModel.'); } let localVarHeaders = this.defaultHeaders; @@ -390,10 +390,10 @@ export class ProjectsModelsService { } let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - body: postCapellaModel, + body: postToolModel, responseType: responseType_, withCredentials: this.configuration.withCredentials, headers: localVarHeaders, @@ -407,19 +407,19 @@ export class ProjectsModelsService { /** * Create New Tool Model * @param projectSlug - * @param postCapellaModel + * @param postToolModel * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public createNewToolModel_1(projectSlug: string, postCapellaModel: PostCapellaModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public createNewToolModel_1(projectSlug: string, postCapellaModel: PostCapellaModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public createNewToolModel_1(projectSlug: string, postCapellaModel: PostCapellaModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public createNewToolModel_1(projectSlug: string, postCapellaModel: PostCapellaModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + public createNewToolModel_1(projectSlug: string, postToolModel: PostToolModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public createNewToolModel_1(projectSlug: string, postToolModel: PostToolModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public createNewToolModel_1(projectSlug: string, postToolModel: PostToolModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public createNewToolModel_1(projectSlug: string, postToolModel: PostToolModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectSlug === null || projectSlug === undefined) { throw new Error('Required parameter projectSlug was null or undefined when calling createNewToolModel_1.'); } - if (postCapellaModel === null || postCapellaModel === undefined) { - throw new Error('Required parameter postCapellaModel was null or undefined when calling createNewToolModel_1.'); + if (postToolModel === null || postToolModel === undefined) { + throw new Error('Required parameter postToolModel was null or undefined when calling createNewToolModel_1.'); } let localVarHeaders = this.defaultHeaders; @@ -481,10 +481,10 @@ export class ProjectsModelsService { } let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - body: postCapellaModel, + body: postToolModel, responseType: responseType_, withCredentials: this.configuration.withCredentials, headers: localVarHeaders, @@ -1221,10 +1221,10 @@ export class ProjectsModelsService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getDiagram(diagramUuidOrFilename: string, projectSlug: string, modelSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (diagramUuidOrFilename === null || diagramUuidOrFilename === undefined) { throw new Error('Required parameter diagramUuidOrFilename was null or undefined when calling getDiagram.'); } @@ -1254,6 +1254,7 @@ export class ProjectsModelsService { if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'image/svg+xml', 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); @@ -1273,22 +1274,11 @@ export class ProjectsModelsService { } - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models/${this.configuration.encodeParam({name: "modelSlug", value: modelSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/diagrams/${this.configuration.encodeParam({name: "diagramUuidOrFilename", value: diagramUuidOrFilename, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - responseType: responseType_, + responseType: "blob", withCredentials: this.configuration.withCredentials, headers: localVarHeaders, observe: observe, @@ -1641,9 +1631,9 @@ export class ProjectsModelsService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getModelBySlug(projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getModelBySlug(projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getModelBySlug(projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getModelBySlug(projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getModelBySlug(projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getModelBySlug(projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public getModelBySlug(projectSlug: string, modelSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectSlug === null || projectSlug === undefined) { throw new Error('Required parameter projectSlug was null or undefined when calling getModelBySlug.'); @@ -1702,7 +1692,7 @@ export class ProjectsModelsService { } let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models/${this.configuration.encodeParam({name: "modelSlug", value: modelSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, responseType: responseType_, @@ -1722,9 +1712,9 @@ export class ProjectsModelsService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getModelBySlug_3(projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getModelBySlug_3(projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getModelBySlug_3(projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getModelBySlug_3(projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getModelBySlug_3(projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getModelBySlug_3(projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; public getModelBySlug_3(projectSlug: string, modelSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectSlug === null || projectSlug === undefined) { throw new Error('Required parameter projectSlug was null or undefined when calling getModelBySlug_3.'); @@ -1783,7 +1773,7 @@ export class ProjectsModelsService { } let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models/${this.configuration.encodeParam({name: "modelSlug", value: modelSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, responseType: responseType_, @@ -1803,10 +1793,10 @@ export class ProjectsModelsService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getModelComplexityBadge(projectSlug: string, modelSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'image/svg+xml' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectSlug === null || projectSlug === undefined) { throw new Error('Required parameter projectSlug was null or undefined when calling getModelComplexityBadge.'); } @@ -1833,6 +1823,7 @@ export class ProjectsModelsService { if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = [ + 'image/svg+xml', 'application/json' ]; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); @@ -1852,22 +1843,11 @@ export class ProjectsModelsService { } - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models/${this.configuration.encodeParam({name: "modelSlug", value: modelSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/badges/complexity`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - responseType: responseType_, + responseType: "blob", withCredentials: this.configuration.withCredentials, headers: localVarHeaders, observe: observe, @@ -1883,9 +1863,9 @@ export class ProjectsModelsService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getModels(projectSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getModels(projectSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getModels(projectSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getModels(projectSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getModels(projectSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getModels(projectSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; public getModels(projectSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectSlug === null || projectSlug === undefined) { throw new Error('Required parameter projectSlug was null or undefined when calling getModels.'); @@ -1941,7 +1921,7 @@ export class ProjectsModelsService { } let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models`; - return this.httpClient.request>('get', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request>('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, responseType: responseType_, @@ -1960,9 +1940,9 @@ export class ProjectsModelsService { * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getModels_4(projectSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getModels_4(projectSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public getModels_4(projectSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getModels_4(projectSlug: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getModels_4(projectSlug: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getModels_4(projectSlug: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; public getModels_4(projectSlug: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectSlug === null || projectSlug === undefined) { throw new Error('Required parameter projectSlug was null or undefined when calling getModels_4.'); @@ -2018,7 +1998,7 @@ export class ProjectsModelsService { } let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models`; - return this.httpClient.request>('get', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request>('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, responseType: responseType_, @@ -2904,22 +2884,22 @@ export class ProjectsModelsService { * Patch Tool Model * @param projectSlug * @param modelSlug - * @param patchCapellaModel + * @param patchToolModel * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public patchToolModel(projectSlug: string, modelSlug: string, patchCapellaModel: PatchCapellaModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public patchToolModel(projectSlug: string, modelSlug: string, patchCapellaModel: PatchCapellaModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public patchToolModel(projectSlug: string, modelSlug: string, patchCapellaModel: PatchCapellaModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public patchToolModel(projectSlug: string, modelSlug: string, patchCapellaModel: PatchCapellaModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + public patchToolModel(projectSlug: string, modelSlug: string, patchToolModel: PatchToolModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public patchToolModel(projectSlug: string, modelSlug: string, patchToolModel: PatchToolModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public patchToolModel(projectSlug: string, modelSlug: string, patchToolModel: PatchToolModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public patchToolModel(projectSlug: string, modelSlug: string, patchToolModel: PatchToolModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectSlug === null || projectSlug === undefined) { throw new Error('Required parameter projectSlug was null or undefined when calling patchToolModel.'); } if (modelSlug === null || modelSlug === undefined) { throw new Error('Required parameter modelSlug was null or undefined when calling patchToolModel.'); } - if (patchCapellaModel === null || patchCapellaModel === undefined) { - throw new Error('Required parameter patchCapellaModel was null or undefined when calling patchToolModel.'); + if (patchToolModel === null || patchToolModel === undefined) { + throw new Error('Required parameter patchToolModel was null or undefined when calling patchToolModel.'); } let localVarHeaders = this.defaultHeaders; @@ -2981,10 +2961,10 @@ export class ProjectsModelsService { } let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models/${this.configuration.encodeParam({name: "modelSlug", value: modelSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('patch', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request('patch', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - body: patchCapellaModel, + body: patchToolModel, responseType: responseType_, withCredentials: this.configuration.withCredentials, headers: localVarHeaders, @@ -2999,22 +2979,22 @@ export class ProjectsModelsService { * Patch Tool Model * @param projectSlug * @param modelSlug - * @param patchCapellaModel + * @param patchToolModel * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public patchToolModel_5(projectSlug: string, modelSlug: string, patchCapellaModel: PatchCapellaModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public patchToolModel_5(projectSlug: string, modelSlug: string, patchCapellaModel: PatchCapellaModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public patchToolModel_5(projectSlug: string, modelSlug: string, patchCapellaModel: PatchCapellaModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public patchToolModel_5(projectSlug: string, modelSlug: string, patchCapellaModel: PatchCapellaModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + public patchToolModel_5(projectSlug: string, modelSlug: string, patchToolModel: PatchToolModel, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public patchToolModel_5(projectSlug: string, modelSlug: string, patchToolModel: PatchToolModel, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public patchToolModel_5(projectSlug: string, modelSlug: string, patchToolModel: PatchToolModel, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public patchToolModel_5(projectSlug: string, modelSlug: string, patchToolModel: PatchToolModel, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { if (projectSlug === null || projectSlug === undefined) { throw new Error('Required parameter projectSlug was null or undefined when calling patchToolModel_5.'); } if (modelSlug === null || modelSlug === undefined) { throw new Error('Required parameter modelSlug was null or undefined when calling patchToolModel_5.'); } - if (patchCapellaModel === null || patchCapellaModel === undefined) { - throw new Error('Required parameter patchCapellaModel was null or undefined when calling patchToolModel_5.'); + if (patchToolModel === null || patchToolModel === undefined) { + throw new Error('Required parameter patchToolModel was null or undefined when calling patchToolModel_5.'); } let localVarHeaders = this.defaultHeaders; @@ -3076,10 +3056,10 @@ export class ProjectsModelsService { } let localVarPath = `/api/v1/projects/${this.configuration.encodeParam({name: "projectSlug", value: projectSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/models/${this.configuration.encodeParam({name: "modelSlug", value: modelSlug, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('patch', `${this.configuration.basePath}${localVarPath}`, + return this.httpClient.request('patch', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, - body: patchCapellaModel, + body: patchToolModel, responseType: responseType_, withCredentials: this.configuration.withCredentials, headers: localVarHeaders, diff --git a/frontend/src/app/openapi/api/settings-modelsources-t4-c.service.ts b/frontend/src/app/openapi/api/settings-modelsources-t4-c.service.ts index 4b98dd42f..d0a1fc010 100644 --- a/frontend/src/app/openapi/api/settings-modelsources-t4-c.service.ts +++ b/frontend/src/app/openapi/api/settings-modelsources-t4-c.service.ts @@ -612,18 +612,14 @@ export class SettingsModelsourcesT4CService { } /** - * List T4C Repositories - * @param t4cInstanceId + * Get T4C Instances * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public listT4cRepositories(t4cInstanceId: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; - public listT4cRepositories(t4cInstanceId: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public listT4cRepositories(t4cInstanceId: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public listT4cRepositories(t4cInstanceId: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { - if (t4cInstanceId === null || t4cInstanceId === undefined) { - throw new Error('Required parameter t4cInstanceId was null or undefined when calling listT4cRepositories.'); - } + public getT4cInstances(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getT4cInstances(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getT4cInstances(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; + public getT4cInstances(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { let localVarHeaders = this.defaultHeaders; @@ -674,8 +670,8 @@ export class SettingsModelsourcesT4CService { } } - let localVarPath = `/api/v1/settings/modelsources/t4c/${this.configuration.encodeParam({name: "t4cInstanceId", value: t4cInstanceId, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: undefined})}/repositories`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + let localVarPath = `/api/v1/settings/modelsources/t4c`; + return this.httpClient.request>('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, responseType: responseType_, @@ -689,14 +685,18 @@ export class SettingsModelsourcesT4CService { } /** - * List T4C Settings + * List T4C Repositories + * @param t4cInstanceId * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public listT4cSettings(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public listT4cSettings(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public listT4cSettings(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>>; - public listT4cSettings(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + public listT4cRepositories(t4cInstanceId: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public listT4cRepositories(t4cInstanceId: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public listT4cRepositories(t4cInstanceId: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public listT4cRepositories(t4cInstanceId: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + if (t4cInstanceId === null || t4cInstanceId === undefined) { + throw new Error('Required parameter t4cInstanceId was null or undefined when calling listT4cRepositories.'); + } let localVarHeaders = this.defaultHeaders; @@ -747,8 +747,8 @@ export class SettingsModelsourcesT4CService { } } - let localVarPath = `/api/v1/settings/modelsources/t4c`; - return this.httpClient.request>('get', `${this.configuration.basePath}${localVarPath}`, + let localVarPath = `/api/v1/settings/modelsources/t4c/${this.configuration.encodeParam({name: "t4cInstanceId", value: t4cInstanceId, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: undefined})}/repositories`; + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, responseType: responseType_, diff --git a/frontend/src/app/openapi/model/models.ts b/frontend/src/app/openapi/model/models.ts index 87570ecea..63e26da0d 100644 --- a/frontend/src/app/openapi/model/models.ts +++ b/frontend/src/app/openapi/model/models.ts @@ -14,7 +14,6 @@ export * from './backup-pipeline-run'; export * from './base-user'; export * from './cpu-resources-input'; export * from './cpu-resources-output'; -export * from './capella-model'; export * from './create-backup'; export * from './create-notice-request'; export * from './create-t4-c-instance'; @@ -61,11 +60,11 @@ export * from './notice-level'; export * from './notice-response'; export * from './page-history-event'; export * from './page-pipeline-run'; -export * from './patch-capella-model'; export * from './patch-git-model'; export * from './patch-project'; export * from './patch-project-user'; export * from './patch-t4-c-instance'; +export * from './patch-tool-model'; export * from './patch-user-role-request'; export * from './path-validation'; export * from './payload-response-model-list-t4-c-repository'; @@ -76,13 +75,13 @@ export * from './persistent-workspace-session-configuration-input'; export * from './persistent-workspace-session-configuration-output'; export * from './pipeline-run'; export * from './pipeline-run-status'; -export * from './post-capella-model'; export * from './post-git-instance'; export * from './post-git-model'; export * from './post-project-request'; export * from './post-project-user'; export * from './post-session-request'; export * from './post-token'; +export * from './post-tool-model'; export * from './post-user'; export * from './project'; export * from './project-status'; @@ -126,6 +125,7 @@ export * from './tool-backup-configuration-input'; export * from './tool-backup-configuration-output'; export * from './tool-integrations-input'; export * from './tool-integrations-output'; +export * from './tool-model'; export * from './tool-model-provisioning-input'; export * from './tool-model-provisioning-output'; export * from './tool-model-restrictions'; diff --git a/frontend/src/app/openapi/model/patch-capella-model.ts b/frontend/src/app/openapi/model/patch-tool-model.ts similarity index 93% rename from frontend/src/app/openapi/model/patch-capella-model.ts rename to frontend/src/app/openapi/model/patch-tool-model.ts index 2b8a970c8..416d1e995 100644 --- a/frontend/src/app/openapi/model/patch-capella-model.ts +++ b/frontend/src/app/openapi/model/patch-tool-model.ts @@ -11,7 +11,7 @@ -export interface PatchCapellaModel { +export interface PatchToolModel { name?: string | null; description?: string | null; version_id?: number | null; diff --git a/frontend/src/app/openapi/model/post-capella-model.ts b/frontend/src/app/openapi/model/post-tool-model.ts similarity index 92% rename from frontend/src/app/openapi/model/post-capella-model.ts rename to frontend/src/app/openapi/model/post-tool-model.ts index 6b4e0ef90..03c341c4d 100644 --- a/frontend/src/app/openapi/model/post-capella-model.ts +++ b/frontend/src/app/openapi/model/post-tool-model.ts @@ -11,7 +11,7 @@ -export interface PostCapellaModel { +export interface PostToolModel { name: string; description?: string | null; tool_id: number; diff --git a/frontend/src/app/openapi/model/capella-model.ts b/frontend/src/app/openapi/model/tool-model.ts similarity index 96% rename from frontend/src/app/openapi/model/capella-model.ts rename to frontend/src/app/openapi/model/tool-model.ts index 930ad12f8..d20807d6a 100644 --- a/frontend/src/app/openapi/model/capella-model.ts +++ b/frontend/src/app/openapi/model/tool-model.ts @@ -17,7 +17,7 @@ import { Tool } from './tool'; import { ToolNature } from './tool-nature'; -export interface CapellaModel { +export interface ToolModel { id: number; slug: string; name: string; diff --git a/frontend/src/app/projects/create-project/create-project.component.spec.ts b/frontend/src/app/projects/create-project/create-project.component.spec.ts index d86223d03..43239a2a2 100644 --- a/frontend/src/app/projects/create-project/create-project.component.spec.ts +++ b/frontend/src/app/projects/create-project/create-project.component.spec.ts @@ -31,15 +31,13 @@ import { import { ToastService } from '../../helpers/toast/toast.service'; import { ProjectUserService } from '../project-detail/project-users/service/project-user.service'; import { - PatchProject, - ProjectService, - ProjectVisibility, + ProjectWrapperService, ProjectVisibilityDescriptions, } from '../service/project.service'; import { CreateProjectComponent } from './create-project.component'; import { HttpClientModule } from '@angular/common/http'; import { CookieModule } from 'ngx-cookie'; -import { Project } from 'src/app/openapi'; +import { PatchProject, Project, Visibility } from 'src/app/openapi'; const mockProjects: Project[] = [ { @@ -127,18 +125,18 @@ describe('CreateProjectComponent', () => { ); }; }, - getProjectVisibilityDescription(visibility: ProjectVisibility): string { + getProjectVisibilityDescription(visibility: Visibility): string { return ProjectVisibilityDescriptions[visibility]; }, - getAvailableVisibilities(): ProjectVisibility[] { - return Object.keys(ProjectVisibilityDescriptions) as ProjectVisibility[]; + getAvailableVisibilities(): Visibility[] { + return Object.keys(ProjectVisibilityDescriptions) as Visibility[]; }, }; beforeEach(async () => { await TestBed.configureTestingModule({ providers: [ - { provide: ProjectService, useValue: fakeProjectService }, + { provide: ProjectWrapperService, useValue: fakeProjectService }, { provide: ToastService, useValue: fakeToastService }, { provide: ProjectUserService, useValue: fakeProjectUserService }, { provide: Location, useClass: SpyLocation }, @@ -194,7 +192,6 @@ describe('CreateProjectComponent', () => { name: testProjectName, description: '', visibility: 'private', - type: 'general', }); expect(fakeToastService.showSuccess).toHaveBeenCalledTimes(1); }); @@ -213,7 +210,6 @@ describe('CreateProjectComponent', () => { name: testProjectName, description: testProjectDescription, visibility: 'private', - type: 'general', }); expect(fakeToastService.showSuccess).toHaveBeenCalledTimes(1); }); diff --git a/frontend/src/app/projects/create-project/create-project.component.ts b/frontend/src/app/projects/create-project/create-project.component.ts index 2c1c8fb09..1dba3d5ac 100644 --- a/frontend/src/app/projects/create-project/create-project.component.ts +++ b/frontend/src/app/projects/create-project/create-project.component.ts @@ -19,6 +19,7 @@ import { MatInput } from '@angular/material/input'; import { MatRadioGroup, MatRadioButton } from '@angular/material/radio'; import { MatStepper, MatStep, MatStepLabel } from '@angular/material/stepper'; import { RouterLink } from '@angular/router'; +import { Visibility } from 'src/app/openapi'; import { CreateModelComponent, CreateModelStep, @@ -27,7 +28,7 @@ import { ToastService } from '../../helpers/toast/toast.service'; import { CreateModelComponent as CreateModelComponent_1 } from '../models/create-model/create-model.component'; import { ProjectUserSettingsComponent } from '../project-detail/project-users/project-user-settings.component'; import { ProjectUserService } from '../project-detail/project-users/service/project-user.service'; -import { ProjectService, ProjectVisibility } from '../service/project.service'; +import { ProjectWrapperService } from '../service/project.service'; @Component({ selector: 'app-create-project', @@ -63,7 +64,7 @@ export class CreateProjectComponent implements OnInit, OnDestroy { public modelCreationStep: CreateModelStep = 'create-model'; constructor( - public projectService: ProjectService, + public projectService: ProjectWrapperService, public projectUserService: ProjectUserService, private toastService: ToastService, ) {} @@ -91,8 +92,7 @@ export class CreateProjectComponent implements OnInit, OnDestroy { .createProject({ name: this.form.value.name!, description: this.form.value.description!, - visibility: this.form.value.visibility! as ProjectVisibility, - type: 'general', + visibility: this.form.value.visibility! as Visibility, }) .subscribe((project) => { this.toastService.showSuccess( diff --git a/frontend/src/app/projects/models/backup-settings/job-run-overview/job-run-overview.component.ts b/frontend/src/app/projects/models/backup-settings/job-run-overview/job-run-overview.component.ts index b9aece751..759df1c0a 100644 --- a/frontend/src/app/projects/models/backup-settings/job-run-overview/job-run-overview.component.ts +++ b/frontend/src/app/projects/models/backup-settings/job-run-overview/job-run-overview.component.ts @@ -23,8 +23,8 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { combineLatest, filter } from 'rxjs'; import { PipelineRunService } from 'src/app/projects/models/backup-settings/pipeline-runs/service/pipeline-run.service'; import { PipelineService } from 'src/app/projects/models/backup-settings/service/pipeline.service'; -import { ModelService } from 'src/app/projects/models/service/model.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; import { TextLineSkeletonLoaderComponent } from '../../../../helpers/skeleton-loaders/text-line-skeleton-loader/text-line-skeleton-loader.component'; @Component({ @@ -53,8 +53,8 @@ export class JobRunOverviewComponent implements OnInit, AfterViewInit { public pipelineRunService: PipelineRunService, private router: Router, private activatedRoute: ActivatedRoute, - private projectService: ProjectService, - private modelService: ModelService, + private projectService: ProjectWrapperService, + private modelService: ModelWrapperService, private pipelineService: PipelineService, ) {} diff --git a/frontend/src/app/projects/models/backup-settings/pipeline-runs/wrapper/pipeline-run-wrapper/pipeline-run-wrapper.component.ts b/frontend/src/app/projects/models/backup-settings/pipeline-runs/wrapper/pipeline-run-wrapper/pipeline-run-wrapper.component.ts index a651beaa0..4f50eb84b 100644 --- a/frontend/src/app/projects/models/backup-settings/pipeline-runs/wrapper/pipeline-run-wrapper/pipeline-run-wrapper.component.ts +++ b/frontend/src/app/projects/models/backup-settings/pipeline-runs/wrapper/pipeline-run-wrapper/pipeline-run-wrapper.component.ts @@ -10,8 +10,8 @@ import { combineLatest, filter, map, switchMap, take, tap, timer } from 'rxjs'; import { BreadcrumbsService } from 'src/app/general/breadcrumbs/breadcrumbs.service'; import { PipelineRunService } from 'src/app/projects/models/backup-settings/pipeline-runs/service/pipeline-run.service'; import { PipelineService } from 'src/app/projects/models/backup-settings/service/pipeline.service'; -import { ModelService } from 'src/app/projects/models/service/model.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; @Component({ selector: 'app-pipeline-run-wrapper', @@ -25,8 +25,8 @@ export class PipelineRunWrapperComponent implements OnDestroy { constructor( private pipelineService: PipelineService, private pipelineRunService: PipelineRunService, - private modelService: ModelService, - private projectService: ProjectService, + private modelService: ModelWrapperService, + private projectService: ProjectWrapperService, private route: ActivatedRoute, private breadcrumbsService: BreadcrumbsService, ) { diff --git a/frontend/src/app/projects/models/backup-settings/view-logs-dialog/view-logs-dialog.component.ts b/frontend/src/app/projects/models/backup-settings/view-logs-dialog/view-logs-dialog.component.ts index 68a31195d..14219f436 100644 --- a/frontend/src/app/projects/models/backup-settings/view-logs-dialog/view-logs-dialog.component.ts +++ b/frontend/src/app/projects/models/backup-settings/view-logs-dialog/view-logs-dialog.component.ts @@ -10,8 +10,8 @@ import { combineLatest } from 'rxjs'; import { filter, switchMap, take } from 'rxjs/operators'; import { PipelineRunService } from 'src/app/projects/models/backup-settings/pipeline-runs/service/pipeline-run.service'; import { PipelineService } from 'src/app/projects/models/backup-settings/service/pipeline.service'; -import { ModelService } from 'src/app/projects/models/service/model.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; import { TextLineSkeletonLoaderComponent } from '../../../../helpers/skeleton-loaders/text-line-skeleton-loader/text-line-skeleton-loader.component'; @UntilDestroy() @@ -24,8 +24,8 @@ import { TextLineSkeletonLoaderComponent } from '../../../../helpers/skeleton-lo }) export class ViewLogsDialogComponent { constructor( - private modelService: ModelService, - private projectService: ProjectService, + private modelService: ModelWrapperService, + private projectService: ProjectWrapperService, private pipelineService: PipelineService, public pipelineRunService: PipelineRunService, ) { diff --git a/frontend/src/app/projects/models/backup-settings/wrapper/pipeline-wrapper/pipeline-wrapper.component.ts b/frontend/src/app/projects/models/backup-settings/wrapper/pipeline-wrapper/pipeline-wrapper.component.ts index e7d5c372a..d394d2e48 100644 --- a/frontend/src/app/projects/models/backup-settings/wrapper/pipeline-wrapper/pipeline-wrapper.component.ts +++ b/frontend/src/app/projects/models/backup-settings/wrapper/pipeline-wrapper/pipeline-wrapper.component.ts @@ -9,8 +9,8 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { combineLatest, filter, map, switchMap, tap } from 'rxjs'; import { BreadcrumbsService } from 'src/app/general/breadcrumbs/breadcrumbs.service'; import { PipelineService } from 'src/app/projects/models/backup-settings/service/pipeline.service'; -import { ModelService } from 'src/app/projects/models/service/model.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; @Component({ selector: 'app-pipeline-wrapper', @@ -23,8 +23,8 @@ import { ProjectService } from 'src/app/projects/service/project.service'; export class PipelineWrapperComponent implements OnInit, OnDestroy { constructor( private pipelineService: PipelineService, - private modelService: ModelService, - private projectService: ProjectService, + private modelService: ModelWrapperService, + private projectService: ProjectWrapperService, private route: ActivatedRoute, private breadcrumbsService: BreadcrumbsService, ) {} diff --git a/frontend/src/app/projects/models/choose-init/choose-init.component.ts b/frontend/src/app/projects/models/choose-init/choose-init.component.ts index 91b0d003a..857cba0ae 100644 --- a/frontend/src/app/projects/models/choose-init/choose-init.component.ts +++ b/frontend/src/app/projects/models/choose-init/choose-init.component.ts @@ -6,9 +6,9 @@ import { NgIf, AsyncPipe } from '@angular/common'; import { Component, EventEmitter, Output } from '@angular/core'; import { MatButton } from '@angular/material/button'; -import { ModelService } from 'src/app/projects/models/service/model.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; import { MatIconComponent } from '../../../helpers/mat-icon/mat-icon.component'; -import { ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; @Component({ selector: 'app-choose-init', @@ -21,7 +21,7 @@ export class ChooseInitComponent { @Output() modelInitSelection = new EventEmitter(); constructor( - public projectService: ProjectService, - public modelService: ModelService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, ) {} } diff --git a/frontend/src/app/projects/models/create-model-base/create-model-base.component.ts b/frontend/src/app/projects/models/create-model-base/create-model-base.component.ts index 0e4c6eadf..623aa3f2a 100644 --- a/frontend/src/app/projects/models/create-model-base/create-model-base.component.ts +++ b/frontend/src/app/projects/models/create-model-base/create-model-base.component.ts @@ -23,12 +23,9 @@ import { MatInput } from '@angular/material/input'; import { MatSelect } from '@angular/material/select'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { ToastService } from 'src/app/helpers/toast/toast.service'; -import { - ModelService, - NewModel, -} from 'src/app/projects/models/service/model.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; import { ToolWrapperService } from 'src/app/settings/core/tools-settings/tool.service'; -import { ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; @UntilDestroy() @Component({ @@ -71,8 +68,8 @@ export class CreateModelBaseComponent implements OnInit { }); constructor( - private modelService: ModelService, - public projectService: ProjectService, + private modelService: ModelWrapperService, + public projectService: ProjectWrapperService, public toolWrapperService: ToolWrapperService, private toastService: ToastService, ) {} @@ -90,10 +87,10 @@ export class CreateModelBaseComponent implements OnInit { if (this.form.valid && this.projectSlug) { this.modelService .createModel(this.projectSlug, { - name: this.form.value.name, + name: this.form.value.name!, description: this.form.value.description, - tool_id: this.form.value.toolID, - } as NewModel) + tool_id: this.form.value.toolID!, + }) .subscribe({ next: (model) => { this.toastService.showSuccess( diff --git a/frontend/src/app/projects/models/create-model/create-model.component.ts b/frontend/src/app/projects/models/create-model/create-model.component.ts index b85ada426..44401466a 100644 --- a/frontend/src/app/projects/models/create-model/create-model.component.ts +++ b/frontend/src/app/projects/models/create-model/create-model.component.ts @@ -16,8 +16,8 @@ import { import { MatStepper, MatStep, MatStepLabel } from '@angular/material/stepper'; import { Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import { ModelService } from 'src/app/projects/models/service/model.service'; -import { ProjectService } from '../../service/project.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from '../../service/project.service'; import { CreateModelBaseComponent } from '../create-model-base/create-model-base.component'; import { InitModelComponent } from '../init-model/init-model.component'; import { ChooseSourceComponent } from '../model-source/choose-source.component'; @@ -60,8 +60,8 @@ export class CreateModelComponent implements OnInit { constructor( private router: Router, - private projectService: ProjectService, - private modelService: ModelService, + private projectService: ProjectWrapperService, + private modelService: ModelWrapperService, ) {} ngOnInit(): void { diff --git a/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-code-block/model-diagram-code-block.component.ts b/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-code-block/model-diagram-code-block.component.ts index 6c4eb7b73..40737c130 100644 --- a/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-code-block/model-diagram-code-block.component.ts +++ b/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-code-block/model-diagram-code-block.component.ts @@ -24,11 +24,8 @@ import { MatTooltip } from '@angular/material/tooltip'; import hljs from 'highlight.js'; import { MetadataService } from 'src/app/general/metadata/metadata.service'; import { ToastService } from 'src/app/helpers/toast/toast.service'; -import { Metadata, Project } from 'src/app/openapi'; -import { - Model, - getPrimaryGitModel, -} from 'src/app/projects/models/service/model.service'; +import { Metadata, Project, ToolModel } from 'src/app/openapi'; +import { getPrimaryGitModel } from 'src/app/projects/models/service/model.service'; import { UserWrapperService } from 'src/app/services/user/user.service'; import { TokenService } from 'src/app/users/basic-auth-service/basic-auth-token.service'; @@ -69,7 +66,7 @@ export class ModelDiagramCodeBlockComponent implements OnInit, AfterViewInit { } @Input({ required: true }) - model!: Model; + model!: ToolModel; @Input({ required: true }) project!: Project; diff --git a/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-dialog.component.ts b/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-dialog.component.ts index c5adbeb2d..7e03b3cbc 100644 --- a/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-dialog.component.ts +++ b/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-dialog.component.ts @@ -31,17 +31,17 @@ import { MatInput } from '@angular/material/input'; import { MatTooltip } from '@angular/material/tooltip'; import { saveAs } from 'file-saver'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; -import { Project } from 'src/app/openapi'; +import { + DiagramCacheMetadata, + DiagramMetadata, + Project, + ProjectsModelsDiagramsService, + ToolModel, +} from 'src/app/openapi'; import { MatDialogPreviewData, ModelDiagramPreviewDialogComponent, } from 'src/app/projects/models/diagrams/model-diagram-preview-dialog/model-diagram-preview-dialog.component'; -import { - DiagramCacheMetadata, - DiagramMetadata, - ModelDiagramService, -} from 'src/app/projects/models/diagrams/service/model-diagram.service'; -import { Model } from 'src/app/projects/models/service/model.service'; import { ModelDiagramCodeBlockComponent } from './model-diagram-code-block/model-diagram-code-block.component'; @Component({ @@ -89,15 +89,15 @@ export class ModelDiagramDialogComponent implements OnInit { } constructor( - private modelDiagramService: ModelDiagramService, private dialog: MatDialog, private dialogRef: MatDialogRef, + private projectsModelsDiagramsService: ProjectsModelsDiagramsService, @Inject(MAT_DIALOG_DATA) - public data: { model: Model; project: Project }, + public data: { model: ToolModel; project: Project }, ) {} ngOnInit(): void { - this.modelDiagramService + this.projectsModelsDiagramsService .getDiagramMetadata(this.data.project.slug, this.data.model.slug) .subscribe({ next: (diagramMetadata) => { @@ -139,8 +139,8 @@ export class ModelDiagramDialogComponent implements OnInit { lazyLoadDiagram(uuid: string) { if (!this.diagrams[uuid]) { this.diagrams[uuid] = { loading: true, content: undefined }; - this.modelDiagramService - .getDiagram(this.data.project.slug, this.data.model.slug, uuid) + this.projectsModelsDiagramsService + .getDiagram(uuid, this.data.project.slug, this.data.model.slug) .subscribe({ next: (response: Blob) => { const reader = new FileReader(); @@ -186,8 +186,8 @@ export class ModelDiagramDialogComponent implements OnInit { } downloadDiagram(uuid: string) { - this.modelDiagramService - .getDiagram(this.data.project.slug, this.data.model.slug, uuid) + this.projectsModelsDiagramsService + .getDiagram(uuid, this.data.project.slug, this.data.model.slug) .subscribe((response: Blob) => { saveAs(response, `${uuid}.svg`); }); diff --git a/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-dialog.stories.ts b/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-dialog.stories.ts index 62a1c147c..2499ab0b2 100644 --- a/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-dialog.stories.ts +++ b/frontend/src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-dialog.stories.ts @@ -5,11 +5,11 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog'; import { Meta, StoryObj, moduleMetadata } from '@storybook/angular'; +import { DiagramCacheMetadata } from 'src/app/openapi'; import { dialogWrapper } from 'src/storybook/decorators'; import { base64ModelDiagram } from 'src/storybook/diagram'; import { mockModel } from 'src/storybook/model'; import { mockProject } from 'src/storybook/project'; -import { DiagramCacheMetadata } from '../service/model-diagram.service'; import { Diagrams, ModelDiagramDialogComponent, diff --git a/frontend/src/app/projects/models/diagrams/model-diagram-preview-dialog/model-diagram-preview-dialog.component.ts b/frontend/src/app/projects/models/diagrams/model-diagram-preview-dialog/model-diagram-preview-dialog.component.ts index 040de5e1a..aed0179ac 100644 --- a/frontend/src/app/projects/models/diagrams/model-diagram-preview-dialog/model-diagram-preview-dialog.component.ts +++ b/frontend/src/app/projects/models/diagrams/model-diagram-preview-dialog/model-diagram-preview-dialog.component.ts @@ -14,7 +14,7 @@ import { MatButton } from '@angular/material/button'; import { MAT_DIALOG_DATA, MatDialogClose } from '@angular/material/dialog'; import { MatDivider } from '@angular/material/divider'; import Panzoom from '@panzoom/panzoom'; -import { DiagramMetadata } from 'src/app/projects/models/diagrams/service/model-diagram.service'; +import { DiagramMetadata } from 'src/app/openapi'; @Component({ selector: 'app-model-diagram-preview-dialog', diff --git a/frontend/src/app/projects/models/diagrams/service/model-diagram.service.ts b/frontend/src/app/projects/models/diagrams/service/model-diagram.service.ts deleted file mode 100644 index df9595544..000000000 --- a/frontend/src/app/projects/models/diagrams/service/model-diagram.service.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { ModelService } from 'src/app/projects/models/service/model.service'; - -@Injectable({ - providedIn: 'root', -}) -export class ModelDiagramService { - constructor( - private http: HttpClient, - private modelService: ModelService, - ) {} - - getDiagramMetadata( - projectSlug: string, - modelSlug: string, - ): Observable { - return this.http.get( - this.modelService.backendURLFactory(projectSlug, modelSlug) + '/diagrams', - ); - } - - getDiagram( - projectSlug: string, - modelSlug: string, - diagramUUID: string, - ): Observable { - return this.http.get( - this.modelService.backendURLFactory(projectSlug, modelSlug) + - '/diagrams/' + - diagramUUID, - { responseType: 'blob' }, - ); - } -} - -export type DiagramCacheMetadata = { - diagrams: DiagramMetadata[]; - last_updated: string; -}; - -export type DiagramMetadata = { - name: string; - uuid: string; - success: boolean; -}; diff --git a/frontend/src/app/projects/models/init-model/init-model.component.ts b/frontend/src/app/projects/models/init-model/init-model.component.ts index 96efff683..1d5696de3 100644 --- a/frontend/src/app/projects/models/init-model/init-model.component.ts +++ b/frontend/src/app/projects/models/init-model/init-model.component.ts @@ -20,13 +20,16 @@ import { MatSelect } from '@angular/material/select'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { combineLatest, filter, map, switchMap, tap } from 'rxjs'; import { SKIP_ERROR_HANDLING_CONTEXT } from 'src/app/general/error-handling/error-handling.interceptor'; -import { Tool, ToolNature, ToolVersion, ToolsService } from 'src/app/openapi'; import { - Model, - ModelService, -} from 'src/app/projects/models/service/model.service'; + Tool, + ToolModel, + ToolNature, + ToolVersion, + ToolsService, +} from 'src/app/openapi'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; import { GitModelService } from '../../project-detail/model-overview/model-detail/git-model.service'; -import { ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; @UntilDestroy() @Component({ @@ -61,8 +64,8 @@ export class InitModelComponent implements OnInit { private modelSlug?: string = undefined; constructor( - public projectService: ProjectService, - public modelService: ModelService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, public gitModelService: GitModelService, private toolsService: ToolsService, ) {} @@ -89,7 +92,7 @@ export class InitModelComponent implements OnInit { this.form.controls.nature.patchValue(model.nature.id); } }), - map((model: Model) => model.tool), + map((model: ToolModel) => model.tool), switchMap((tool: Tool) => combineLatest([ this.toolsService.getToolVersions(tool.id, undefined, undefined, { diff --git a/frontend/src/app/projects/models/model-description/model-description.component.ts b/frontend/src/app/projects/models/model-description/model-description.component.ts index ebac0cb87..521638534 100644 --- a/frontend/src/app/projects/models/model-description/model-description.component.ts +++ b/frontend/src/app/projects/models/model-description/model-description.component.ts @@ -24,9 +24,9 @@ import { combineLatest, filter, switchMap, tap } from 'rxjs'; import { ConfirmationDialogComponent } from 'src/app/helpers/confirmation-dialog/confirmation-dialog.component'; import { ToastService } from 'src/app/helpers/toast/toast.service'; import { ToolNature, ToolVersion } from 'src/app/openapi'; -import { ModelService } from 'src/app/projects/models/service/model.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; import { ToolWrapperService } from 'src/app/settings/core/tools-settings/tool.service'; -import { ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; @UntilDestroy() @Component({ @@ -66,8 +66,8 @@ export class ModelDescriptionComponent implements OnInit { private modelSlug?: string = undefined; constructor( - public modelService: ModelService, - public projectService: ProjectService, + public modelService: ModelWrapperService, + public projectService: ProjectWrapperService, private toolWrapperService: ToolWrapperService, public toastService: ToastService, private router: Router, @@ -83,7 +83,7 @@ export class ModelDescriptionComponent implements OnInit { tap((model) => { this.modelSlug = model.slug; this.canDelete = !( - model.git_models.length || model.t4c_models.length + model.git_models?.length || model.t4c_models?.length ); this.form.controls.name.setAsyncValidators( diff --git a/frontend/src/app/projects/models/model-detail/model-detail.component.ts b/frontend/src/app/projects/models/model-detail/model-detail.component.ts index c839c2d31..894d99007 100644 --- a/frontend/src/app/projects/models/model-detail/model-detail.component.ts +++ b/frontend/src/app/projects/models/model-detail/model-detail.component.ts @@ -10,12 +10,12 @@ import { RouterLink } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { combineLatest, filter } from 'rxjs'; import { T4CModelService } from 'src/app/projects/models/model-source/t4c/service/t4c-model.service'; -import { ModelService } from 'src/app/projects/models/service/model.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; import { GitModelService } from 'src/app/projects/project-detail/model-overview/model-detail/git-model.service'; import { UserWrapperService } from 'src/app/services/user/user.service'; import { MatIconComponent } from '../../../helpers/mat-icon/mat-icon.component'; import { MatCardOverviewSkeletonLoaderComponent } from '../../../helpers/skeleton-loaders/mat-card-overview-skeleton-loader/mat-card-overview-skeleton-loader.component'; -import { ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; @UntilDestroy() @Component({ @@ -35,8 +35,8 @@ import { ProjectService } from '../../service/project.service'; }) export class ModelDetailComponent implements OnInit, OnDestroy { constructor( - public projectService: ProjectService, - public modelService: ModelService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, public gitModelService: GitModelService, public t4cModelService: T4CModelService, public userService: UserWrapperService, diff --git a/frontend/src/app/projects/models/model-detail/t4c-model-wrapper/t4c-model-wrapper.component.ts b/frontend/src/app/projects/models/model-detail/t4c-model-wrapper/t4c-model-wrapper.component.ts index 688d8d52a..693216a85 100644 --- a/frontend/src/app/projects/models/model-detail/t4c-model-wrapper/t4c-model-wrapper.component.ts +++ b/frontend/src/app/projects/models/model-detail/t4c-model-wrapper/t4c-model-wrapper.component.ts @@ -9,8 +9,8 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { combineLatest, filter, map } from 'rxjs'; import { BreadcrumbsService } from 'src/app/general/breadcrumbs/breadcrumbs.service'; import { T4CModelService } from 'src/app/projects/models/model-source/t4c/service/t4c-model.service'; -import { ModelService } from 'src/app/projects/models/service/model.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; @UntilDestroy() @Component({ @@ -23,8 +23,8 @@ import { ProjectService } from 'src/app/projects/service/project.service'; export class T4CModelWrapperComponent implements OnInit, OnDestroy { constructor( private route: ActivatedRoute, - public projectService: ProjectService, - public modelService: ModelService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, private t4cModelService: T4CModelService, private breadCrumbsService: BreadcrumbsService, ) {} diff --git a/frontend/src/app/projects/models/model-restrictions/model-restrictions.component.ts b/frontend/src/app/projects/models/model-restrictions/model-restrictions.component.ts index a5ca33690..25e752d0a 100644 --- a/frontend/src/app/projects/models/model-restrictions/model-restrictions.component.ts +++ b/frontend/src/app/projects/models/model-restrictions/model-restrictions.component.ts @@ -15,17 +15,15 @@ import { MatCheckbox } from '@angular/material/checkbox'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { filter } from 'rxjs'; import { ToastService } from 'src/app/helpers/toast/toast.service'; +import { ToolModel } from 'src/app/openapi'; import { ModelRestrictions, ModelRestrictionsService, areRestrictionsEqual, } from 'src/app/projects/models/model-restrictions/service/model-restrictions.service'; -import { - Model, - ModelService, -} from 'src/app/projects/models/service/model.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; import { MatCheckboxLoaderComponent } from '../../../helpers/skeleton-loaders/mat-checkbox-loader/mat-checkbox-loader.component'; -import { ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; @UntilDestroy() @Component({ @@ -46,12 +44,12 @@ import { ProjectService } from '../../service/project.service'; export class ModelRestrictionsComponent implements OnInit { loading = false; - private model?: Model; + private model?: ToolModel; private projectSlug?: string; constructor( - public projectService: ProjectService, - public modelService: ModelService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, public toastService: ToastService, private modelRestrictionService: ModelRestrictionsService, ) {} @@ -69,7 +67,9 @@ export class ModelRestrictionsComponent implements OnInit { .pipe(filter(Boolean), untilDestroyed(this)) .subscribe((model) => { this.model = model; - this.updateRestrictionsForm(model.restrictions); + if (model.restrictions) { + this.updateRestrictionsForm(model.restrictions); + } }); this.projectService.project$.subscribe( @@ -92,7 +92,10 @@ export class ModelRestrictionsComponent implements OnInit { const modelSlug = this.model.slug; const restrictions = this.mapRestrictionsFormToModelRestrictions(); - if (areRestrictionsEqual(this.model.restrictions, restrictions)) { + if ( + !this.model.restrictions || + areRestrictionsEqual(this.model.restrictions, restrictions) + ) { return; } diff --git a/frontend/src/app/projects/models/model-source/choose-source.component.ts b/frontend/src/app/projects/models/model-source/choose-source.component.ts index 381bc8349..404ace92b 100644 --- a/frontend/src/app/projects/models/model-source/choose-source.component.ts +++ b/frontend/src/app/projects/models/model-source/choose-source.component.ts @@ -8,9 +8,9 @@ import { Component, EventEmitter, Output } from '@angular/core'; import { MatAnchor } from '@angular/material/button'; import { MatDivider } from '@angular/material/divider'; import { MatIcon } from '@angular/material/icon'; -import { ModelService } from 'src/app/projects/models/service/model.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; import { UserWrapperService } from 'src/app/services/user/user.service'; -import { ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; @Component({ selector: 'app-choose-source', @@ -23,8 +23,8 @@ export class ChooseSourceComponent { @Output() modelSourceSelection = new EventEmitter(); constructor( - public projectService: ProjectService, - public modelService: ModelService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, public userService: UserWrapperService, ) {} } diff --git a/frontend/src/app/projects/models/model-source/git/manage-git-model/manage-git-model.component.ts b/frontend/src/app/projects/models/model-source/git/manage-git-model/manage-git-model.component.ts index 65c41e8cf..a6881ec2d 100644 --- a/frontend/src/app/projects/models/model-source/git/manage-git-model/manage-git-model.component.ts +++ b/frontend/src/app/projects/models/model-source/git/manage-git-model/manage-git-model.component.ts @@ -51,14 +51,14 @@ import { hasRelativePathPrefix, } from 'src/app/helpers/validators/url-validator'; import { SettingsModelsourcesGitService } from 'src/app/openapi'; -import { ModelService } from 'src/app/projects/models/service/model.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; import { CreateGitModel, GetGitModel, GitModelService, PatchGitModel, } from 'src/app/projects/project-detail/model-overview/model-detail/git-model.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; import { Credentials, GitService, @@ -118,8 +118,8 @@ export class ManageGitModelComponent implements OnInit, OnDestroy { public editing = false; constructor( - public projectService: ProjectService, - public modelService: ModelService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, private gitInstancesService: GitInstancesService, private settingsModelsourcesGitService: SettingsModelsourcesGitService, private gitService: GitService, diff --git a/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.ts b/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.ts index 36fe39891..e33bb4bd7 100644 --- a/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.ts +++ b/frontend/src/app/projects/models/model-source/t4c/create-t4c-model-new-repository/create-t4c-model-new-repository.component.ts @@ -22,11 +22,11 @@ import { ActivatedRoute, Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { combineLatest, filter, switchMap } from 'rxjs'; import { ToastService } from 'src/app/helpers/toast/toast.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; -import { T4CInstanceService } from 'src/app/services/settings/t4c-instance.service'; -import { T4CRepoService } from 'src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; +import { T4CInstanceWrapperService } from 'src/app/services/settings/t4c-instance.service'; +import { T4CRepositoryWrapperService } from 'src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service'; import { FormFieldSkeletonLoaderComponent } from '../../../../../helpers/skeleton-loaders/form-field-skeleton-loader/form-field-skeleton-loader.component'; -import { ModelService } from '../../../service/model.service'; +import { ModelWrapperService } from '../../../service/model.service'; import { T4CModelService } from '../service/t4c-model.service'; @UntilDestroy() @@ -60,11 +60,11 @@ export class CreateT4cModelNewRepositoryComponent implements OnInit { private modelSlug?: string; constructor( - public projectService: ProjectService, - public modelService: ModelService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, public t4cModelService: T4CModelService, - public t4cInstanceService: T4CInstanceService, - private t4cRepoService: T4CRepoService, + public t4cInstanceService: T4CInstanceWrapperService, + private t4cRepoService: T4CRepositoryWrapperService, private router: Router, private route: ActivatedRoute, private toastService: ToastService, diff --git a/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.component.html b/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.component.html index 5ddfafe27..6ac6053ea 100644 --- a/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.component.html +++ b/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.component.html @@ -3,109 +3,110 @@ ~ SPDX-License-Identifier: Apache-2.0 --> -
-
-
-
- - +@if ((projectService.project$ | async) && (modelService.model$ | async)) { +
+
+ +
+ @if ((t4cInstanceService.t4cInstances$ | async) === undefined) { + + } @else { + + Instance + + @for ( + instance of t4cInstanceService.t4cInstances$ | async; + track instance.id + ) { + + {{ instance.name }} + + } + + @if (form.controls.t4cInstanceId.errors) { + Please select an instance. + } + + } +
+
+ @if ((t4cInstanceService.t4cInstances$ | async) === undefined) { + + } @else { + + Repository + + @for ( + repository of t4cRepositoryService.repositories$ | async; + track repository.id + ) { + + {{ repository.name }} + + } + + @if (form.controls.t4cRepositoryId.errors) { + Please select a repository. + } + + } +
+
+ @if (loading) { + + } @else { + + T4C project name + + @if (form.controls.name.errors?.alreadyUsed) { + + This project does already exist in your model! + + } + + } - - Instance - - + @if (selectedRepository) { + + {{ selectedRepository.name }} + + } + +
+ +
+ @if (t4cModel !== undefined) { +
-
- - - - Repository - - + } + @if (loading) { + + } @else { +
-
- - - - T4C project name - - - This project does already exist in your model! - - - - - {{ selectedRepository.name }} - - -
- -
- - - -
-
+ Save reference + navigate_next + + } +
+ +
- +} diff --git a/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.component.ts b/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.component.ts index fbcbb754f..d13aba6c7 100644 --- a/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.component.ts +++ b/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.component.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { NgIf, NgFor, AsyncPipe } from '@angular/common'; +import { AsyncPipe } from '@angular/common'; import { Component, EventEmitter, @@ -41,12 +41,12 @@ import { T4CModel, T4CModelService, } from 'src/app/projects/models/model-source/t4c/service/t4c-model.service'; -import { ModelService } from 'src/app/projects/models/service/model.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; -import { T4CInstanceService } from 'src/app/services/settings/t4c-instance.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; +import { T4CInstanceWrapperService } from 'src/app/services/settings/t4c-instance.service'; import { - T4CRepoService, - T4CRepository, + ExtendedT4CRepository, + T4CRepositoryWrapperService, } from 'src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service'; import { ButtonSkeletonLoaderComponent } from '../../../../../helpers/skeleton-loaders/button-skeleton-loader/button-skeleton-loader.component'; import { FormFieldSkeletonLoaderComponent } from '../../../../../helpers/skeleton-loaders/form-field-skeleton-loader/form-field-skeleton-loader.component'; @@ -58,14 +58,12 @@ import { FormFieldSkeletonLoaderComponent } from '../../../../../helpers/skeleto styleUrls: ['./manage-t4c-model.component.css'], standalone: true, imports: [ - NgIf, FormsModule, ReactiveFormsModule, FormFieldSkeletonLoaderComponent, MatFormField, MatLabel, MatSelect, - NgFor, MatOption, MatTooltip, MatError, @@ -87,17 +85,17 @@ export class ManageT4CModelComponent implements OnInit, OnDestroy { loading = false; - t4cRepositories?: T4CRepository[]; + t4cRepositories?: ExtendedT4CRepository[]; - selectedRepository?: T4CRepository; + selectedRepository?: ExtendedT4CRepository; t4cModel?: T4CModel; constructor( - public projectService: ProjectService, - public modelService: ModelService, - public t4cInstanceService: T4CInstanceService, - public t4cRepositoryService: T4CRepoService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, + public t4cInstanceService: T4CInstanceWrapperService, + public t4cRepositoryService: T4CRepositoryWrapperService, public t4cModelService: T4CModelService, private router: Router, private route: ActivatedRoute, diff --git a/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.stories.ts b/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.stories.ts new file mode 100644 index 000000000..8e387589d --- /dev/null +++ b/frontend/src/app/projects/models/model-source/t4c/manage-t4c-model/manage-t4c-model.stories.ts @@ -0,0 +1,68 @@ +/* + * SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { Meta, moduleMetadata, StoryObj } from '@storybook/angular'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; +import { T4CInstanceWrapperService } from 'src/app/services/settings/t4c-instance.service'; +import { T4CRepositoryWrapperService } from 'src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service'; +import { mockModel, MockModelWrapperService } from 'src/storybook/model'; +import { mockProject, MockProjectWrapperService } from 'src/storybook/project'; +import { + mockExtendedT4CRepository, + mockT4CInstance, + MockT4CInstanceWrapperService, + MockT4CRepositoryWrapperService, +} from 'src/storybook/t4c'; +import { ManageT4CModelComponent } from './manage-t4c-model.component'; + +const meta: Meta = { + title: 'Model Components / Model Sources / T4C', + component: ManageT4CModelComponent, + decorators: [ + moduleMetadata({ + providers: [ + { + provide: ProjectWrapperService, + useFactory: () => + new MockProjectWrapperService(mockProject, [mockProject]), + }, + { + provide: ModelWrapperService, + useFactory: () => new MockModelWrapperService(mockModel, [mockModel]), + }, + ], + }), + ], +}; + +export default meta; +type Story = StoryObj; + +export const Loading: Story = { + args: {}, +}; + +export const General: Story = { + args: {}, + decorators: [ + moduleMetadata({ + providers: [ + { + provide: T4CInstanceWrapperService, + useFactory: () => + new MockT4CInstanceWrapperService(mockT4CInstance, [ + mockT4CInstance, + ]), + }, + { + provide: T4CRepositoryWrapperService, + useFactory: () => + new MockT4CRepositoryWrapperService([mockExtendedT4CRepository]), + }, + ], + }), + ], +}; diff --git a/frontend/src/app/projects/models/model-source/t4c/service/t4c-model.service.ts b/frontend/src/app/projects/models/model-source/t4c/service/t4c-model.service.ts index 704fc969f..44f7992f0 100644 --- a/frontend/src/app/projects/models/model-source/t4c/service/t4c-model.service.ts +++ b/frontend/src/app/projects/models/model-source/t4c/service/t4c-model.service.ts @@ -11,7 +11,7 @@ import { ValidationErrors, } from '@angular/forms'; import { BehaviorSubject, Observable, map, take, tap } from 'rxjs'; -import { T4CRepository } from 'src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service'; +import { T4CRepository } from 'src/app/openapi'; import { environment } from 'src/environments/environment'; @Injectable({ diff --git a/frontend/src/app/projects/models/model-wrapper/model-wrapper.component.ts b/frontend/src/app/projects/models/model-wrapper/model-wrapper.component.ts index 65e1112e4..57f9dfc38 100644 --- a/frontend/src/app/projects/models/model-wrapper/model-wrapper.component.ts +++ b/frontend/src/app/projects/models/model-wrapper/model-wrapper.component.ts @@ -10,8 +10,8 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { combineLatest, filter, map } from 'rxjs'; import { BreadcrumbsService } from 'src/app/general/breadcrumbs/breadcrumbs.service'; import { T4CModelService } from 'src/app/projects/models/model-source/t4c/service/t4c-model.service'; -import { ModelService } from 'src/app/projects/models/service/model.service'; -import { ProjectService } from '../../service/project.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from '../../service/project.service'; @UntilDestroy() @Component({ @@ -24,8 +24,8 @@ import { ProjectService } from '../../service/project.service'; export class ModelWrapperComponent implements OnInit, OnDestroy { constructor( private route: ActivatedRoute, - public modelService: ModelService, - private projectService: ProjectService, + public modelService: ModelWrapperService, + private projectService: ProjectWrapperService, private t4cModelService: T4CModelService, private breadcrumbService: BreadcrumbsService, ) {} diff --git a/frontend/src/app/projects/models/service/model.service.ts b/frontend/src/app/projects/models/service/model.service.ts index 87d58706d..797977b9a 100644 --- a/frontend/src/app/projects/models/service/model.service.ts +++ b/frontend/src/app/projects/models/service/model.service.ts @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { AbstractControl, @@ -12,58 +11,53 @@ import { } from '@angular/forms'; import { BehaviorSubject, forkJoin, map, Observable, take, tap } from 'rxjs'; import slugify from 'slugify'; -import { Tool, ToolNature, ToolVersion } from 'src/app/openapi'; -import { ModelRestrictions } from 'src/app/projects/models/model-restrictions/service/model-restrictions.service'; -import { T4CModel } from 'src/app/projects/models/model-source/t4c/service/t4c-model.service'; +import { + PatchToolModel, + PostToolModel, + ProjectsModelsService, + ToolModel, +} from 'src/app/openapi'; import { GetGitModel } from 'src/app/projects/project-detail/model-overview/model-detail/git-model.service'; -import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root', }) -export class ModelService { - base_url = environment.backend_url + '/projects'; - - constructor(private http: HttpClient) {} +export class ModelWrapperService { + constructor(private modelsService: ProjectsModelsService) {} - private _model = new BehaviorSubject(undefined); - private _models = new BehaviorSubject(undefined); + private _model = new BehaviorSubject(undefined); + private _models = new BehaviorSubject(undefined); public readonly model$ = this._model.asObservable(); public readonly models$ = this._models.asObservable(); - backendURLFactory(projectSlug: string, modelSlug: string) { - return `${this.base_url}/${projectSlug}/models/${modelSlug}`; - } - loadModels(projectSlug: string): void { - this.http.get(`${this.base_url}/${projectSlug}/models`).subscribe({ + this.modelsService.getModels(projectSlug).subscribe({ next: (models) => this._models.next(models), error: () => this._models.next(undefined), }); } loadModelbySlug(modelSlug: string, projectSlug: string): void { - this.http - .get(`${this.base_url}/${projectSlug}/models/${modelSlug}`) - .subscribe({ - next: (model) => this._model.next(model), - error: () => this._model.next(undefined), - }); + this.modelsService.getModelBySlug(projectSlug, modelSlug).subscribe({ + next: (model) => this._model.next(model), + error: () => this._model.next(undefined), + }); } - createModel(projectSlug: string, model: NewModel): Observable { - return this.http - .post(`${this.base_url}/${projectSlug}/models`, model) - .pipe( - tap({ - next: (model) => { - this.loadModels(projectSlug); - this._model.next(model); - }, - error: () => this._model.next(undefined), - }), - ); + createModel( + projectSlug: string, + model: PostToolModel, + ): Observable { + return this.modelsService.createNewToolModel(projectSlug, model).pipe( + tap({ + next: (model) => { + this.loadModels(projectSlug); + this._model.next(model); + }, + error: () => this._model.next(undefined), + }), + ); } setToolDetailsForModel( @@ -71,9 +65,9 @@ export class ModelService { modelSlug: string, version_id: number, nature_id: number, - ): Observable { - return this.http - .patch(`${this.base_url}/${projectSlug}/models/${modelSlug}`, { + ): Observable { + return this.modelsService + .patchToolModel(projectSlug, modelSlug, { version_id, nature_id, }) @@ -91,19 +85,16 @@ export class ModelService { private applyModelPatch( projectSlug: string, modelSlug: string, - patchData: PatchModel, - ): Observable { - return this.http.patch( - `${this.base_url}/${projectSlug}/models/${modelSlug}`, - patchData, - ); + patchData: PatchToolModel, + ): Observable { + return this.modelsService.patchToolModel(projectSlug, modelSlug, patchData); } updateModel( projectSlug: string, modelSlug: string, - patchModel: PatchModel, - ): Observable { + patchModel: PatchToolModel, + ): Observable { return this.applyModelPatch(projectSlug, modelSlug, patchModel).pipe( tap({ next: (model) => { @@ -116,15 +107,15 @@ export class ModelService { updateModels( projectSlug: string, - modelUpdates: { modelSlug: string; patchModel: PatchModel }[], - ): Observable { + modelUpdates: { modelSlug: string; patchModel: PatchToolModel }[], + ): Observable { const updateObservables = modelUpdates.map(({ modelSlug, patchModel }) => this.applyModelPatch(projectSlug, modelSlug, patchModel), ); return forkJoin(updateObservables).pipe( tap({ - next: (models: Model[]) => { + next: (models: ToolModel[]) => { this.loadModels(projectSlug); this._model.next(models[models.length - 1]); }, @@ -133,14 +124,12 @@ export class ModelService { } deleteModel(projectSlug: string, modelSlug: string): Observable { - return this.http - .delete(`${this.base_url}/${projectSlug}/models/${modelSlug}`) - .pipe( - tap(() => { - this.loadModels(projectSlug); - this._model.next(undefined); - }), - ); + return this.modelsService.deleteToolModel(projectSlug, modelSlug).pipe( + tap(() => { + this.loadModels(projectSlug); + this._model.next(undefined); + }), + ); } clearModel(): void { @@ -151,7 +140,7 @@ export class ModelService { this._models.next(undefined); } - asyncSlugValidator(ignoreModel?: Model): AsyncValidatorFn { + asyncSlugValidator(ignoreModel?: ToolModel): AsyncValidatorFn { const ignoreSlug = !!ignoreModel ? ignoreModel.slug : -1; return (control: AbstractControl): Observable => { const modelSlug = slugify(control.value, { lower: true }); @@ -167,55 +156,8 @@ export class ModelService { ); }; } - - moveModelToProject( - projectSlug: string, - modelSlug: string, - project_slug: string, - ): Observable { - return this.http - .patch(`${this.backendURLFactory(projectSlug, modelSlug)}/move`, { - project_slug, - }) - .pipe( - tap(() => { - this.loadModels(projectSlug); - this._model.next(undefined); - }), - ); - } } -export type NewModel = { - name: string; - description: string; - tool_id: number; -}; - -export type Model = { - id: number; - project_slug: string; - slug: string; - name: string; - description: string; - tool: Tool; - version?: ToolVersion; - nature?: ToolNature; - t4c_models: T4CModel[]; - git_models: GetGitModel[]; - restrictions: ModelRestrictions; - display_order: number; -}; - -export type PatchModel = { - name?: string; - description?: string; - nature_id?: number; - version_id?: number; - project_slug?: string; - display_order?: number; -}; - -export function getPrimaryGitModel(model: Model): GetGitModel | undefined { - return model.git_models.find((gitModel) => gitModel.primary); +export function getPrimaryGitModel(model: ToolModel): GetGitModel | undefined { + return model.git_models?.find((gitModel) => gitModel.primary); } diff --git a/frontend/src/app/projects/project-detail/edit-project-metadata/edit-project-metadata.component.ts b/frontend/src/app/projects/project-detail/edit-project-metadata/edit-project-metadata.component.ts index 8ef0c987d..3fb762eb2 100644 --- a/frontend/src/app/projects/project-detail/edit-project-metadata/edit-project-metadata.component.ts +++ b/frontend/src/app/projects/project-detail/edit-project-metadata/edit-project-metadata.component.ts @@ -27,9 +27,9 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { filter } from 'rxjs'; import slugify from 'slugify'; import { ToastService } from 'src/app/helpers/toast/toast.service'; -import { Project } from 'src/app/openapi'; +import { PatchProject, Project } from 'src/app/openapi'; import { ProjectUserService } from 'src/app/projects/project-detail/project-users/service/project-user.service'; -import { PatchProject, ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; @UntilDestroy() @Component({ @@ -58,7 +58,7 @@ export class EditProjectMetadataComponent implements OnInit, OnChanges { project?: Project; constructor( - public projectService: ProjectService, + public projectService: ProjectWrapperService, public projectUserService: ProjectUserService, private toastService: ToastService, private router: Router, diff --git a/frontend/src/app/projects/project-detail/model-overview/model-complexity-badge/model-complexity-badge.component.ts b/frontend/src/app/projects/project-detail/model-overview/model-complexity-badge/model-complexity-badge.component.ts index 44d229755..062b918c6 100644 --- a/frontend/src/app/projects/project-detail/model-overview/model-complexity-badge/model-complexity-badge.component.ts +++ b/frontend/src/app/projects/project-detail/model-overview/model-complexity-badge/model-complexity-badge.component.ts @@ -11,7 +11,7 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { filter, map, switchMap } from 'rxjs'; import { ModelComplexityBadgeService } from 'src/app/projects/project-detail/model-overview/model-complexity-badge/service/model-complexity-badge.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; import { environment } from 'src/environments/environment'; @Component({ selector: 'app-model-complexity-badge', @@ -37,7 +37,7 @@ export class ModelComplexityBadgeComponent implements OnChanges { constructor( private modelComplexityBadgeService: ModelComplexityBadgeService, - private projectService: ProjectService, + private projectService: ProjectWrapperService, ) {} ngOnChanges(_: SimpleChanges) { diff --git a/frontend/src/app/projects/project-detail/model-overview/model-complexity-badge/service/model-complexity-badge.service.ts b/frontend/src/app/projects/project-detail/model-overview/model-complexity-badge/service/model-complexity-badge.service.ts index 857e436f9..6ecfea3c3 100644 --- a/frontend/src/app/projects/project-detail/model-overview/model-complexity-badge/service/model-complexity-badge.service.ts +++ b/frontend/src/app/projects/project-detail/model-overview/model-complexity-badge/service/model-complexity-badge.service.ts @@ -3,30 +3,28 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { HttpClient, HttpContext } from '@angular/common/http'; +import { HttpContext } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { SKIP_ERROR_HANDLING } from 'src/app/general/error-handling/error-handling.interceptor'; -import { ModelService } from 'src/app/projects/models/service/model.service'; +import { ProjectsModelsService } from 'src/app/openapi'; @Injectable({ providedIn: 'root', }) export class ModelComplexityBadgeService { - constructor( - private http: HttpClient, - private modelService: ModelService, - ) {} + constructor(private projectModelService: ProjectsModelsService) {} getModelComplexityBadge( projectSlug: string, modelSlug: string, ): Observable { - return this.http.get( - this.modelService.backendURLFactory(projectSlug, modelSlug) + - '/badges/complexity', + return this.projectModelService.getModelComplexityBadge( + projectSlug, + modelSlug, + undefined, + undefined, { - responseType: 'blob', context: new HttpContext().set(SKIP_ERROR_HANDLING, true), }, ); diff --git a/frontend/src/app/projects/project-detail/model-overview/model-overview.component.ts b/frontend/src/app/projects/project-detail/model-overview/model-overview.component.ts index 85b6b926a..70be5c67c 100644 --- a/frontend/src/app/projects/project-detail/model-overview/model-overview.component.ts +++ b/frontend/src/app/projects/project-detail/model-overview/model-overview.component.ts @@ -18,12 +18,11 @@ import { RouterLink } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { first, filter } from 'rxjs'; -import { Project } from 'src/app/openapi'; +import { Project, ToolModel } from 'src/app/openapi'; import { ModelDiagramDialogComponent } from 'src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-dialog.component'; import { getPrimaryGitModel, - Model, - ModelService, + ModelWrapperService, } from 'src/app/projects/models/service/model.service'; import { MoveModelComponent } from 'src/app/projects/project-detail/model-overview/move-model/move-model.component'; import { ReorderModelsDialogComponent } from 'src/app/projects/project-detail/model-overview/reorder-models-dialog/reorder-models-dialog.component'; @@ -31,7 +30,7 @@ import { ProjectUserService } from 'src/app/projects/project-detail/project-user import { UserWrapperService } from 'src/app/services/user/user.service'; import { SessionService } from 'src/app/sessions/service/session.service'; import { TriggerPipelineComponent } from '../../models/backup-settings/trigger-pipeline/trigger-pipeline.component'; -import { ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; import { ModelComplexityBadgeComponent } from './model-complexity-badge/model-complexity-badge.component'; @UntilDestroy() @@ -57,14 +56,14 @@ import { ModelComplexityBadgeComponent } from './model-complexity-badge/model-co }) export class ModelOverviewComponent implements OnInit { project?: Project; - models?: Model[]; + models?: ToolModel[]; constructor( - public modelService: ModelService, + public modelService: ModelWrapperService, public sessionService: SessionService, public projectUserService: ProjectUserService, public userService: UserWrapperService, - public projectService: ProjectService, + public projectService: ProjectWrapperService, private dialog: MatDialog, ) {} @@ -85,16 +84,16 @@ export class ModelOverviewComponent implements OnInit { }); } - getPrimaryWorkingMode(model: Model): string { - if (model.t4c_models.length) { + getPrimaryWorkingMode(model: ToolModel): string { + if (model.t4c_models?.length) { return 'T4C'; - } else if (model.git_models.length) { + } else if (model.git_models?.length) { return 'Git'; } return 'Unset'; } - openPipelineDialog(model: Model): void { + openPipelineDialog(model: ToolModel): void { this.projectService.project$.pipe(first()).subscribe((project) => { this.dialog.open(TriggerPipelineComponent, { data: { projectSlug: project!.slug, modelSlug: model.slug }, @@ -102,7 +101,7 @@ export class ModelOverviewComponent implements OnInit { }); } - openDiagramsDialog(model: Model): void { + openDiagramsDialog(model: ToolModel): void { this.dialog.open(ModelDiagramDialogComponent, { maxWidth: '100vw', panelClass: [ @@ -117,12 +116,12 @@ export class ModelOverviewComponent implements OnInit { }); } - getPrimaryGitModelURL(model: Model): string { + getPrimaryGitModelURL(model: ToolModel): string { const primaryModel = getPrimaryGitModel(model); return primaryModel ? primaryModel.path : ''; } - openMoveToProjectDialog(model: Model): void { + openMoveToProjectDialog(model: ToolModel): void { this.dialog.open(MoveModelComponent, { maxWidth: '100vw', maxHeight: '200vw', @@ -130,7 +129,7 @@ export class ModelOverviewComponent implements OnInit { }); } - openReorderModelsDialog(models: Model[]): void { + openReorderModelsDialog(models: ToolModel[]): void { if (this.project) { this.dialog.open(ReorderModelsDialogComponent, { data: { projectSlug: this.project.slug, models: models }, diff --git a/frontend/src/app/projects/project-detail/model-overview/move-model/move-model.component.ts b/frontend/src/app/projects/project-detail/model-overview/move-model/move-model.component.ts index ad9537a91..a57a89a4a 100644 --- a/frontend/src/app/projects/project-detail/model-overview/move-model/move-model.component.ts +++ b/frontend/src/app/projects/project-detail/model-overview/move-model/move-model.component.ts @@ -22,12 +22,9 @@ import { MatInput } from '@angular/material/input'; import { Observable, map } from 'rxjs'; import { ConfirmationDialogComponent } from 'src/app/helpers/confirmation-dialog/confirmation-dialog.component'; import { ToastService } from 'src/app/helpers/toast/toast.service'; -import { Project } from 'src/app/openapi'; -import { - Model, - ModelService, -} from 'src/app/projects/models/service/model.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { Project, ToolModel } from 'src/app/openapi'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; @Component({ selector: 'app-move-model', @@ -52,13 +49,13 @@ export class MoveModelComponent { search = ''; filteredProjects$: Observable; constructor( - private modelService: ModelService, + private modelService: ModelWrapperService, private dialogRef: MatDialogRef, private toastService: ToastService, - public projectService: ProjectService, + public projectService: ProjectWrapperService, private dialog: MatDialog, @Inject(MAT_DIALOG_DATA) - public data: { projectSlug: string; model: Model }, + public data: { projectSlug: string; model: ToolModel }, ) { this.projectService.loadProjects('manager'); this.filteredProjects$ = projectService.projects$.pipe( diff --git a/frontend/src/app/projects/project-detail/model-overview/reorder-models-dialog/reorder-models-dialog.component.ts b/frontend/src/app/projects/project-detail/model-overview/reorder-models-dialog/reorder-models-dialog.component.ts index 0078be065..63361a24b 100644 --- a/frontend/src/app/projects/project-detail/model-overview/reorder-models-dialog/reorder-models-dialog.component.ts +++ b/frontend/src/app/projects/project-detail/model-overview/reorder-models-dialog/reorder-models-dialog.component.ts @@ -15,10 +15,8 @@ import { MatButton } from '@angular/material/button'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MatIcon } from '@angular/material/icon'; import { ToastService } from 'src/app/helpers/toast/toast.service'; -import { - Model, - ModelService, -} from 'src/app/projects/models/service/model.service'; +import { ToolModel } from 'src/app/openapi'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; @Component({ selector: 'app-reorder-models', @@ -32,18 +30,18 @@ import { }) export class ReorderModelsDialogComponent { constructor( - public modelService: ModelService, + public modelService: ModelWrapperService, private dialogRef: MatDialogRef, private toastService: ToastService, @Inject(MAT_DIALOG_DATA) - public data: { projectSlug: string; models: Model[] }, + public data: { projectSlug: string; models: ToolModel[] }, ) { this.models = [...data.models]; } - models: Model[]; + models: ToolModel[]; - drop(event: CdkDragDrop): void { + drop(event: CdkDragDrop): void { moveItemInArray(this.models, event.previousIndex, event.currentIndex); } diff --git a/frontend/src/app/projects/project-detail/project-details.component.ts b/frontend/src/app/projects/project-detail/project-details.component.ts index 4da2246f0..b81e3b412 100644 --- a/frontend/src/app/projects/project-detail/project-details.component.ts +++ b/frontend/src/app/projects/project-detail/project-details.component.ts @@ -7,7 +7,7 @@ import { NgIf } from '@angular/common'; import { Component } from '@angular/core'; import { ProjectUserService } from 'src/app/projects/project-detail/project-users/service/project-user.service'; import { CreateReadonlySessionComponent } from '../../sessions/user-sessions-wrapper/create-session/create-readonly-session/create-readonly-session.component'; -import { ProjectService } from '../service/project.service'; +import { ProjectWrapperService } from '../service/project.service'; import { ModelOverviewComponent } from './model-overview/model-overview.component'; import { ProjectMetadataComponent } from './project-metadata/project-metadata.component'; import { ProjectUserSettingsComponent } from './project-users/project-user-settings.component'; @@ -27,7 +27,7 @@ import { ProjectUserSettingsComponent } from './project-users/project-user-setti }) export class ProjectDetailsComponent { constructor( - public projectService: ProjectService, + public projectService: ProjectWrapperService, public projectUserService: ProjectUserService, ) {} } diff --git a/frontend/src/app/projects/project-detail/project-metadata/project-metadata.component.ts b/frontend/src/app/projects/project-detail/project-metadata/project-metadata.component.ts index bf0684662..7510bef5c 100644 --- a/frontend/src/app/projects/project-detail/project-metadata/project-metadata.component.ts +++ b/frontend/src/app/projects/project-detail/project-metadata/project-metadata.component.ts @@ -14,10 +14,10 @@ import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { filter } from 'rxjs'; import { ConfirmationDialogComponent } from 'src/app/helpers/confirmation-dialog/confirmation-dialog.component'; import { ToastService } from 'src/app/helpers/toast/toast.service'; -import { Project } from 'src/app/openapi'; -import { ModelService } from 'src/app/projects/models/service/model.service'; +import { PatchProject, Project } from 'src/app/openapi'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; import { ProjectUserService } from 'src/app/projects/project-detail/project-users/service/project-user.service'; -import { PatchProject, ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; @UntilDestroy() @Component({ @@ -37,8 +37,8 @@ export class ProjectMetadataComponent implements OnInit { canDelete = false; constructor( - public projectService: ProjectService, - public modelService: ModelService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, public projectUserService: ProjectUserService, private toastService: ToastService, private router: Router, diff --git a/frontend/src/app/projects/project-detail/project-users/project-audit-log/service/project-audit-log.service.ts b/frontend/src/app/projects/project-detail/project-users/project-audit-log/service/project-audit-log.service.ts index e52aea151..937b2cdfe 100644 --- a/frontend/src/app/projects/project-detail/project-users/project-audit-log/service/project-audit-log.service.ts +++ b/frontend/src/app/projects/project-detail/project-users/project-audit-log/service/project-audit-log.service.ts @@ -7,7 +7,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable, map } from 'rxjs'; import { HistoryEvent } from 'src/app/openapi'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; import { Page, PageWrapper } from 'src/app/schemes'; import { environment } from 'src/environments/environment'; @@ -27,7 +27,7 @@ export class ProjectAuditLogService { constructor( private http: HttpClient, - private projectService: ProjectService, + private projectService: ProjectWrapperService, ) { this.resetProjectAuditLogOnPipelineChange(); } diff --git a/frontend/src/app/projects/project-detail/project-users/project-user-settings.component.ts b/frontend/src/app/projects/project-detail/project-users/project-user-settings.component.ts index 89ab8a814..6284cae54 100644 --- a/frontend/src/app/projects/project-detail/project-users/project-user-settings.component.ts +++ b/frontend/src/app/projects/project-detail/project-users/project-user-settings.component.ts @@ -35,7 +35,7 @@ import { ProjectUserService, } from 'src/app/projects/project-detail/project-users/service/project-user.service'; import { UserWrapperService } from 'src/app/services/user/user.service'; -import { ProjectService } from '../../service/project.service'; +import { ProjectWrapperService } from '../../service/project.service'; @UntilDestroy() @Component({ @@ -69,7 +69,7 @@ export class ProjectUserSettingsComponent implements OnInit { public projectUserService: ProjectUserService, public userService: UserWrapperService, private toastService: ToastService, - private projectService: ProjectService, + private projectService: ProjectWrapperService, private dialog: MatDialog, private router: Router, ) {} diff --git a/frontend/src/app/projects/project-detail/project-users/service/project-user.service.ts b/frontend/src/app/projects/project-detail/project-users/service/project-user.service.ts index 54c273bf8..1bbc21635 100644 --- a/frontend/src/app/projects/project-detail/project-users/service/project-user.service.ts +++ b/frontend/src/app/projects/project-detail/project-users/service/project-user.service.ts @@ -15,7 +15,7 @@ import { tap, } from 'rxjs'; import { User } from 'src/app/openapi'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; import { environment } from 'src/environments/environment'; @Injectable({ @@ -24,7 +24,7 @@ import { environment } from 'src/environments/environment'; export class ProjectUserService { constructor( private http: HttpClient, - private projectService: ProjectService, + private projectService: ProjectWrapperService, ) { this.resetProjectUserOnProjectReset(); this.resetProjectUsersOnProjectReset(); diff --git a/frontend/src/app/projects/project-overview/project-overview.component.ts b/frontend/src/app/projects/project-overview/project-overview.component.ts index aa31c4b4d..ae506022d 100644 --- a/frontend/src/app/projects/project-overview/project-overview.component.ts +++ b/frontend/src/app/projects/project-overview/project-overview.component.ts @@ -10,7 +10,7 @@ import { MatIcon } from '@angular/material/icon'; import { RouterLink } from '@angular/router'; import { MatIconComponent } from '../../helpers/mat-icon/mat-icon.component'; import { MatCardOverviewSkeletonLoaderComponent } from '../../helpers/skeleton-loaders/mat-card-overview-skeleton-loader/mat-card-overview-skeleton-loader.component'; -import { ProjectService, UserMetadata } from '../service/project.service'; +import { ProjectWrapperService } from '../service/project.service'; @Component({ selector: 'app-project-overview', @@ -30,13 +30,9 @@ import { ProjectService, UserMetadata } from '../service/project.service'; ], }) export class ProjectOverviewComponent implements OnInit { - constructor(public projectService: ProjectService) {} + constructor(public projectService: ProjectWrapperService) {} ngOnInit() { this.projectService.loadProjects(); } - - sumUsers(user: UserMetadata): number { - return user.contributors + user.leads + user.subscribers; - } } diff --git a/frontend/src/app/projects/project-wrapper/project-wrapper.component.ts b/frontend/src/app/projects/project-wrapper/project-wrapper.component.ts index c1c3069b8..26b2c7529 100644 --- a/frontend/src/app/projects/project-wrapper/project-wrapper.component.ts +++ b/frontend/src/app/projects/project-wrapper/project-wrapper.component.ts @@ -8,8 +8,8 @@ import { ActivatedRoute, RouterOutlet } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { map } from 'rxjs'; import { BreadcrumbsService } from 'src/app/general/breadcrumbs/breadcrumbs.service'; -import { ModelService } from 'src/app/projects/models/service/model.service'; -import { ProjectService } from '../service/project.service'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from '../service/project.service'; @UntilDestroy() @Component({ @@ -22,8 +22,8 @@ import { ProjectService } from '../service/project.service'; export class ProjectWrapperComponent implements OnInit, OnDestroy { constructor( private route: ActivatedRoute, - public projectService: ProjectService, - public modelService: ModelService, + public projectService: ProjectWrapperService, + public modelService: ModelWrapperService, private breadcrumbsService: BreadcrumbsService, ) {} diff --git a/frontend/src/app/projects/service/project.service.ts b/frontend/src/app/projects/service/project.service.ts index ba1795df1..6c0cfd654 100644 --- a/frontend/src/app/projects/service/project.service.ts +++ b/frontend/src/app/projects/service/project.service.ts @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { AbstractControl, @@ -12,19 +11,21 @@ import { } from '@angular/forms'; import { BehaviorSubject, map, Observable, take, tap } from 'rxjs'; import slugify from 'slugify'; -import { Project, ProjectUserRole, ProjectsService } from 'src/app/openapi'; -import { environment } from 'src/environments/environment'; +import { + PatchProject, + PostProjectRequest, + Project, + ProjectType, + ProjectUserRole, + ProjectsService, + Visibility, +} from 'src/app/openapi'; @Injectable({ providedIn: 'root', }) -export class ProjectService { - BACKEND_URL_PREFIX = environment.backend_url + '/projects'; - - constructor( - private http: HttpClient, - private projectsService: ProjectsService, - ) {} +export class ProjectWrapperService { + constructor(private projectsService: ProjectsService) {} private _project = new BehaviorSubject(undefined); private _projects = new BehaviorSubject(undefined); @@ -45,14 +46,14 @@ export class ProjectService { } loadProjectBySlug(slug: string): void { - this.http.get(`${this.BACKEND_URL_PREFIX}/${slug}`).subscribe({ + this.projectsService.getProjectBySlug(slug).subscribe({ next: (project) => this._project.next(project), error: () => this._project.next(undefined), }); } - createProject(project: PostProject): Observable { - return this.http.post(this.BACKEND_URL_PREFIX, project).pipe( + createProject(project: PostProjectRequest): Observable { + return this.projectsService.createProject(project).pipe( tap({ next: (project) => { this.loadProjects(); @@ -67,28 +68,24 @@ export class ProjectService { project_slug: string, project: PatchProject, ): Observable { - return this.http - .patch(`${this.BACKEND_URL_PREFIX}/${project_slug}`, project) - .pipe( - tap({ - next: (project) => { - this.loadProjects(); - this._project.next(project); - }, - error: () => this._project.next(undefined), - }), - ); + return this.projectsService.updateProject(project_slug, project).pipe( + tap({ + next: (project) => { + this.loadProjects(); + this._project.next(project); + }, + error: () => this._project.next(undefined), + }), + ); } deleteProject(projectSlug: string): Observable { - return this.http - .delete(`${this.BACKEND_URL_PREFIX}/${projectSlug}`) - .pipe( - tap(() => { - this.loadProjects(); - this._project.next(undefined); - }), - ); + return this.deleteProject(projectSlug).pipe( + tap(() => { + this.loadProjects(); + this._project.next(undefined); + }), + ); } clearProject(): void { @@ -113,12 +110,12 @@ export class ProjectService { }; } - getProjectVisibilityDescription(visibility: ProjectVisibility): string { + getProjectVisibilityDescription(visibility: Visibility): string { return ProjectVisibilityDescriptions[visibility]; } - getAvailableVisibilities(): ProjectVisibility[] { - return Object.keys(ProjectVisibilityDescriptions) as ProjectVisibility[]; + getAvailableVisibilities(): Visibility[] { + return Object.keys(ProjectVisibilityDescriptions) as Visibility[]; } getProjectTypeDescription(type: ProjectType): string { @@ -130,27 +127,6 @@ export class ProjectService { } } -export type UserMetadata = { - leads: number; - contributors: number; - subscribers: number; -}; - -export type PostProject = { - name: string; - description: string; - visibility: ProjectVisibility; - type: ProjectType; -}; - -export type PatchProject = Partial & { - is_archived?: boolean; -}; - -export type ProjectVisibility = 'internal' | 'private'; - -export type ProjectType = 'general' | 'training'; - export const ProjectVisibilityDescriptions = { internal: 'Internal (viewable by all logged in users)', private: 'Private (only viewable by project members)', diff --git a/frontend/src/app/services/settings/t4c-instance.service.ts b/frontend/src/app/services/settings/t4c-instance.service.ts index bcccffdc7..0ac64f1a0 100644 --- a/frontend/src/app/services/settings/t4c-instance.service.ts +++ b/frontend/src/app/services/settings/t4c-instance.service.ts @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { AbstractControl, @@ -11,50 +10,19 @@ import { ValidationErrors, } from '@angular/forms'; import { BehaviorSubject, Observable, map, take, tap } from 'rxjs'; -import { environment } from 'src/environments/environment'; - -export type Protocol = 'tcp' | 'ssl' | 'ws' | 'wss'; - -export type BaseT4CInstance = { - version_id: number; - license: string; - host: string; - port: number; - cdo_port: number; - http_port?: number; - usage_api: string; - rest_api: string; - username: string; - password: string; - protocol: Protocol; - is_archived: boolean; -}; - -export type PatchT4CInstance = Partial; - -export type NewT4CInstance = BaseT4CInstance & { - name: string; -}; - -export type T4CInstance = NewT4CInstance & { - id: number; - version: { - id: number; - name: string; - }; -}; +import { + CreateT4CInstance, + GetSessionUsageResponse, + PatchT4CInstance, + SettingsModelsourcesT4CService, + T4CInstance, +} from 'src/app/openapi'; @Injectable({ providedIn: 'root', }) -export class T4CInstanceService { - constructor(private http: HttpClient) {} - - baseUrl = `${environment.backend_url}/settings/modelsources/t4c`; - - urlFactory(instanceId: number): string { - return `${this.baseUrl}/${instanceId}`; - } +export class T4CInstanceWrapperService { + constructor(private t4cInstanceService: SettingsModelsourcesT4CService) {} private _t4cInstances = new BehaviorSubject( undefined, @@ -73,21 +41,21 @@ export class T4CInstanceService { ); loadInstances(): void { - this.http.get(this.baseUrl).subscribe({ + this.t4cInstanceService.getT4cInstances().subscribe({ next: (instances) => this._t4cInstances.next(instances), error: () => this._t4cInstances.next(undefined), }); } loadInstance(instanceId: number): void { - this.http.get(this.urlFactory(instanceId)).subscribe({ + this.t4cInstanceService.getT4cInstance(instanceId).subscribe({ next: (instance) => this._t4cInstance.next(instance), error: () => this._t4cInstance.next(undefined), }); } - createInstance(instance: NewT4CInstance): Observable { - return this.http.post(this.baseUrl, instance).pipe( + createInstance(instance: CreateT4CInstance): Observable { + return this.t4cInstanceService.createT4cInstance(instance).pipe( tap((instance) => { this._t4cInstance.next(instance); this.loadInstances(); @@ -99,14 +67,12 @@ export class T4CInstanceService { instanceId: number, instance: PatchT4CInstance, ): Observable { - return this.http - .patch(this.urlFactory(instanceId), instance) - .pipe( - tap((instance) => { - this._t4cInstance.next(instance); - this.loadInstances(); - }), - ); + return this.t4cInstanceService.editT4cInstance(instanceId, instance).pipe( + tap((instance) => { + this._t4cInstance.next(instance); + this.loadInstances(); + }), + ); } resetT4CInstance(): void { @@ -118,10 +84,8 @@ export class T4CInstanceService { this._t4cInstances.next(undefined); } - getLicenses(instanceId: number): Observable { - return this.http.get( - `${this.urlFactory(instanceId)}/licenses`, - ); + getLicenses(instanceId: number): Observable { + return this.t4cInstanceService.fetchT4cLicenses(instanceId); } asyncNameValidator(ignoreInstance?: T4CInstance): AsyncValidatorFn { @@ -143,8 +107,3 @@ export class T4CInstanceService { }; } } - -export type SessionUsage = { - free: number; - total: number; -}; diff --git a/frontend/src/app/sessions/service/session.service.ts b/frontend/src/app/sessions/service/session.service.ts index c5181b54d..6ce920abe 100644 --- a/frontend/src/app/sessions/service/session.service.ts +++ b/frontend/src/app/sessions/service/session.service.ts @@ -13,6 +13,7 @@ import { Project, SessionProvisioningRequest, SessionsService, + SessionConnectionInformation, } from 'src/app/openapi'; import { SessionHistoryService } from 'src/app/sessions/user-sessions-wrapper/create-sessions/create-session-history/session-history.service'; import { environment } from 'src/environments/environment'; @@ -47,13 +48,6 @@ export interface PathNode { children: PathNode[] | null; } -export type SessionConnectionInformation = { - local_storage: LocalStorage; - cookies: Cookies; - t4c_token: string; - redirect_url: string; -}; - @Injectable({ providedIn: 'root', }) @@ -100,14 +94,6 @@ export class SessionService { ); } - getSessionConnectionInformation( - sessionId: string, - ): Observable { - return this.http.get( - `${this.BACKEND_URL_PREFIX}/${sessionId}/connection`, - ); - } - deleteSession(id: string): Observable { return this.http.delete(`${this.BACKEND_URL_PREFIX}/${id}`); } diff --git a/frontend/src/app/sessions/session/session-viewer.service.ts b/frontend/src/app/sessions/session/session-viewer.service.ts index 6d224a171..a3cfaf48e 100644 --- a/frontend/src/app/sessions/session/session-viewer.service.ts +++ b/frontend/src/app/sessions/session/session-viewer.service.ts @@ -6,11 +6,9 @@ import { Injectable } from '@angular/core'; import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; import { BehaviorSubject, map } from 'rxjs'; -import { Session } from 'src/app/openapi'; -import { - SessionConnectionInformation, - SessionService, -} from 'src/app/sessions/service/session.service'; +import { ToastService } from 'src/app/helpers/toast/toast.service'; +import { Session, SessionConnectionInformation } from 'src/app/openapi'; +import { SessionService } from 'src/app/sessions/service/session.service'; @Injectable({ providedIn: 'root', @@ -19,6 +17,7 @@ export class SessionViewerService { constructor( private sessionService: SessionService, private domSanitizer: DomSanitizer, + private toastService: ToastService, ) {} private _sessions = new BehaviorSubject( @@ -38,6 +37,14 @@ export class SessionViewerService { ): void { const viewerSession = session as ViewerSession; + if (!connectionInfo.redirect_url) { + this.toastService.showError( + 'Session connection information is not available yet.', + 'Try again later.', + ); + return; + } + this.sessionService.setConnectionInformation(session, connectionInfo); viewerSession.focused = false; viewerSession.safeResourceURL = diff --git a/frontend/src/app/sessions/session/session.component.ts b/frontend/src/app/sessions/session/session.component.ts index a33910b6e..63dabaa1a 100644 --- a/frontend/src/app/sessions/session/session.component.ts +++ b/frontend/src/app/sessions/session/session.component.ts @@ -14,7 +14,7 @@ import { MatTooltip } from '@angular/material/tooltip'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { filter, take } from 'rxjs'; -import { Session } from 'src/app/openapi'; +import { Session, SessionsService } from 'src/app/openapi'; import { FullscreenService } from 'src/app/sessions/service/fullscreen.service'; import { SessionService } from 'src/app/sessions/service/session.service'; import { UserSessionService } from 'src/app/sessions/service/user-session.service'; @@ -55,6 +55,7 @@ export class SessionComponent implements OnInit, OnDestroy { constructor( public userSessionService: UserSessionService, public sessionService: SessionService, + private sessionsService: SessionsService, public sessionViewerService: SessionViewerService, public fullscreenService: FullscreenService, ) { @@ -101,10 +102,13 @@ export class SessionComponent implements OnInit, OnDestroy { selectSessions() { this.checkedSessions?.forEach((session) => { - this.sessionService + this.sessionsService .getSessionConnectionInformation(session.id) .subscribe((connectionInfo) => { - this.sessionViewerService.pushSession(session, connectionInfo); + this.sessionViewerService.pushSession( + session, + connectionInfo.payload, + ); }); }); } diff --git a/frontend/src/app/sessions/user-sessions-wrapper/active-sessions/connection-dialog/connection-dialog.component.html b/frontend/src/app/sessions/user-sessions-wrapper/active-sessions/connection-dialog/connection-dialog.component.html index acbe46018..bc9a07905 100644 --- a/frontend/src/app/sessions/user-sessions-wrapper/active-sessions/connection-dialog/connection-dialog.component.html +++ b/frontend/src/app/sessions/user-sessions-wrapper/active-sessions/connection-dialog/connection-dialog.component.html @@ -18,7 +18,7 @@

Connect to Session

You can always return to this dialog by clicking on "Connect" in the "Active sessions" overview.
diff --git a/frontend/src/app/sessions/user-sessions-wrapper/active-sessions/connection-dialog/connection-dialog.component.ts b/frontend/src/app/sessions/user-sessions-wrapper/active-sessions/connection-dialog/connection-dialog.component.ts index 1f27f70e0..22f4ff8d6 100644 --- a/frontend/src/app/sessions/user-sessions-wrapper/active-sessions/connection-dialog/connection-dialog.component.ts +++ b/frontend/src/app/sessions/user-sessions-wrapper/active-sessions/connection-dialog/connection-dialog.component.ts @@ -7,10 +7,13 @@ import { Component, Inject } from '@angular/core'; import { MatButton } from '@angular/material/button'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { ToastService } from 'src/app/helpers/toast/toast.service'; -import { Session } from 'src/app/openapi'; -import { UserWrapperService } from 'src/app/services/user/user.service'; import { + Session, SessionConnectionInformation, + SessionsService, +} from 'src/app/openapi'; +import { UserWrapperService } from 'src/app/services/user/user.service'; +import { SessionService, isPersistentSession, } from 'src/app/sessions/service/session.service'; @@ -31,14 +34,15 @@ export class ConnectionDialogComponent { constructor( public userService: UserWrapperService, private sessionService: SessionService, + private sessionsService: SessionsService, @Inject(MAT_DIALOG_DATA) public session: Session, public dialogRef: MatDialogRef, private toastService: ToastService, ) { - this.sessionService + this.sessionsService .getSessionConnectionInformation(this.session.id) .subscribe((connectionInfo) => { - this.connectionInfo = connectionInfo; + this.connectionInfo = connectionInfo.payload; }); } diff --git a/frontend/src/app/sessions/user-sessions-wrapper/create-session/create-readonly-session/create-readonly-session.component.ts b/frontend/src/app/sessions/user-sessions-wrapper/create-session/create-readonly-session/create-readonly-session.component.ts index b5decd62b..8b3b8dae8 100644 --- a/frontend/src/app/sessions/user-sessions-wrapper/create-session/create-readonly-session/create-readonly-session.component.ts +++ b/frontend/src/app/sessions/user-sessions-wrapper/create-session/create-readonly-session/create-readonly-session.component.ts @@ -24,12 +24,9 @@ import { RouterLink } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { combineLatest, filter, map, Observable, take, tap } from 'rxjs'; -import { Tool, ToolVersion } from 'src/app/openapi'; -import { - Model, - ModelService, -} from 'src/app/projects/models/service/model.service'; -import { ProjectService } from 'src/app/projects/service/project.service'; +import { Tool, ToolModel, ToolVersion } from 'src/app/openapi'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; import { UserSessionService } from 'src/app/sessions/service/user-session.service'; import { ToolWrapperService, @@ -79,8 +76,8 @@ export class CreateReadonlySessionComponent implements OnInit { constructor( private toolWrapperService: ToolWrapperService, private userSessionService: UserSessionService, - private projectService: ProjectService, - private modelService: ModelService, + private projectService: ProjectWrapperService, + private modelService: ModelWrapperService, private dialog: MatDialog, private fb: FormBuilder, ) {} @@ -97,7 +94,7 @@ export class CreateReadonlySessionComponent implements OnInit { this.userSessionService.loadSessions(); } - loadToolsAndModels(): Observable<[Model[], ToolVersionWithTool[]]> { + loadToolsAndModels(): Observable<[ToolModel[], ToolVersionWithTool[]]> { return combineLatest([ this.modelService.models$.pipe(untilDestroyed(this), filter(Boolean)), this.toolWrapperService.getVersionsForTools(), @@ -109,7 +106,7 @@ export class CreateReadonlySessionComponent implements OnInit { } resolveVersionCompatibility( - models: Model[], + models: ToolModel[], allVersions: ToolVersionWithTool[], ): void { this.models = []; @@ -232,4 +229,4 @@ export class CreateReadonlySessionComponent implements OnInit { type ModelWithCompatibility = { compatibleVersions: ToolVersionWithTool[]; -} & Model; +} & ToolModel; diff --git a/frontend/src/app/sessions/user-sessions-wrapper/create-sessions/create-readonly-session/create-readonly-model-options/create-readonly-model-options.component.ts b/frontend/src/app/sessions/user-sessions-wrapper/create-sessions/create-readonly-session/create-readonly-model-options/create-readonly-model-options.component.ts index cc45e19f2..c95636a5a 100644 --- a/frontend/src/app/sessions/user-sessions-wrapper/create-sessions/create-readonly-session/create-readonly-model-options/create-readonly-model-options.component.ts +++ b/frontend/src/app/sessions/user-sessions-wrapper/create-sessions/create-readonly-session/create-readonly-model-options/create-readonly-model-options.component.ts @@ -22,8 +22,7 @@ import { MatError, MatFormField, MatLabel } from '@angular/material/form-field'; import { MatInput } from '@angular/material/input'; import { MatSlideToggle } from '@angular/material/slide-toggle'; import { filter } from 'rxjs'; -import { Tool, ToolVersion } from 'src/app/openapi'; -import { Model } from 'src/app/projects/models/service/model.service'; +import { Tool, ToolModel, ToolVersion } from 'src/app/openapi'; import { GetGitModel } from 'src/app/projects/project-detail/model-overview/model-detail/git-model.service'; import { Revisions, @@ -32,7 +31,7 @@ import { } from 'src/app/services/git/git.service'; export type ModelOptions = { - model: Model; + model: ToolModel; primaryGitModel: GetGitModel; include: boolean; revision: string; diff --git a/frontend/src/app/sessions/user-sessions-wrapper/create-sessions/create-readonly-session/create-readonly-session-dialog.component.ts b/frontend/src/app/sessions/user-sessions-wrapper/create-sessions/create-readonly-session/create-readonly-session-dialog.component.ts index 9671c7121..890e0e5cc 100644 --- a/frontend/src/app/sessions/user-sessions-wrapper/create-sessions/create-readonly-session/create-readonly-session-dialog.component.ts +++ b/frontend/src/app/sessions/user-sessions-wrapper/create-sessions/create-readonly-session/create-readonly-session-dialog.component.ts @@ -21,11 +21,8 @@ import { MatRadioButton, MatRadioGroup } from '@angular/material/radio'; import { Router } from '@angular/router'; import { UntilDestroy } from '@ngneat/until-destroy'; import { ToastService } from 'src/app/helpers/toast/toast.service'; -import { Tool, ToolVersion } from 'src/app/openapi'; -import { - getPrimaryGitModel, - Model, -} from 'src/app/projects/models/service/model.service'; +import { Tool, ToolModel, ToolVersion } from 'src/app/openapi'; +import { getPrimaryGitModel } from 'src/app/projects/models/service/model.service'; import { SessionService } from 'src/app/sessions/service/session.service'; import { CreateReadonlyModelOptionsComponent, @@ -59,7 +56,7 @@ export class CreateReadonlySessionDialogComponent implements OnInit { @Inject(MAT_DIALOG_DATA) public data: { projectSlug: string; - models: Model[]; + models: ToolModel[]; tool: Tool; toolVersion: ToolVersion; }, diff --git a/frontend/src/app/settings/modelsources/git-settings/git-settings.stories.ts b/frontend/src/app/settings/modelsources/git-settings/git-settings.stories.ts index 9e0005d67..2026e5a37 100644 --- a/frontend/src/app/settings/modelsources/git-settings/git-settings.stories.ts +++ b/frontend/src/app/settings/modelsources/git-settings/git-settings.stories.ts @@ -13,7 +13,7 @@ import { import { GitSettingsComponent } from './git-settings.component'; const meta: Meta = { - title: 'Settings Components / Modelsources / Git Instances', + title: 'Settings Components / Modelsources / Git / Instances', component: GitSettingsComponent, }; diff --git a/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.component.html b/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.component.html index 2986ff407..d324d5769 100644 --- a/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.component.html +++ b/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.component.html @@ -9,9 +9,13 @@

Add a Team4Capella instance

-
-
- + +
+ Name @@ -21,7 +25,7 @@

>An instance with the same name already exists. - + Capella version {{ version.name }} - Models are not auto-migrated on version change. - - The version is required. - + @if ( + (t4cInstanceService.t4cInstance$ | async) !== undefined && + (t4cInstanceService.t4cInstance$ | async)!.version.id !== + form.value.version_id + ) { + Models are not auto-migrated on version change. + } @else if (form.controls.version_id.errors?.required) { + The version is required. + }

- + License configuration - - The license configuration is required. - + @if (form.controls.license.errors?.required) { + The license configuration is required. + }
-
- +
+ Protocol > - + Host
-
- +
+ Port - + CDO port - + HTTP port
-
- +
+ License server API @@ -135,7 +155,7 @@

The license server API is required. - + Experimental REST API @@ -146,15 +166,15 @@

-
- +
+ Username The username is required. - + Password { - t4cInstance.password = '***********'; + .subscribe((initialT4CInstance) => { + const t4cInstance = { + ...initialT4CInstance, + password: '***********', + }; this.isArchived = t4cInstance.is_archived; this.form.patchValue(t4cInstance); this.form.controls.name.setAsyncValidators( @@ -169,7 +172,7 @@ export class EditT4CInstanceComponent implements OnInit, OnDestroy { create(): void { if (this.form.valid) { this.t4cInstanceService - .createInstance(this.form.value as NewT4CInstance) + .createInstance(this.form.value as CreateT4CInstance) .subscribe((instance) => { this.toastService.showSuccess( 'Instance created', diff --git a/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.stories.ts b/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.stories.ts new file mode 100644 index 000000000..5d127d0e1 --- /dev/null +++ b/frontend/src/app/settings/modelsources/t4c-settings/edit-t4c-instance/edit-t4c-instance.stories.ts @@ -0,0 +1,45 @@ +/* + * SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { Meta, StoryObj, moduleMetadata } from '@storybook/angular'; +import { T4CInstanceWrapperService } from 'src/app/services/settings/t4c-instance.service'; +import { + MockT4CInstanceWrapperService, + mockT4CInstance, +} from 'src/storybook/t4c'; +import { mockToolVersion } from 'src/storybook/tool'; +import { EditT4CInstanceComponent } from './edit-t4c-instance.component'; + +const meta: Meta = { + title: 'Settings Components / Modelsources / T4C / Server Instance', + component: EditT4CInstanceComponent, +}; + +export default meta; +type Story = StoryObj; + +export const AddInstance: Story = { + args: {}, +}; + +export const ModifyExistingInstance: Story = { + args: { + existing: true, + capellaVersions: [mockToolVersion], + }, + decorators: [ + moduleMetadata({ + providers: [ + { + provide: T4CInstanceWrapperService, + useFactory: () => + new MockT4CInstanceWrapperService(mockT4CInstance, [ + mockT4CInstance, + ]), + }, + ], + }), + ], +}; diff --git a/frontend/src/app/settings/modelsources/t4c-settings/licences/licences.component.ts b/frontend/src/app/settings/modelsources/t4c-settings/licences/licences.component.ts index 2acd0cb5b..67d3ca69b 100644 --- a/frontend/src/app/settings/modelsources/t4c-settings/licences/licences.component.ts +++ b/frontend/src/app/settings/modelsources/t4c-settings/licences/licences.component.ts @@ -6,11 +6,8 @@ import { NgIf } from '@angular/common'; import { HttpErrorResponse } from '@angular/common/http'; import { Component, OnInit, Input } from '@angular/core'; -import { - SessionUsage, - T4CInstance, - T4CInstanceService, -} from 'src/app/services/settings/t4c-instance.service'; +import { GetSessionUsageResponse, T4CInstance } from 'src/app/openapi'; +import { T4CInstanceWrapperService } from 'src/app/services/settings/t4c-instance.service'; @Component({ selector: 'app-licences', @@ -24,7 +21,7 @@ export class LicencesComponent implements OnInit { public errorMessage?: string; - constructor(private t4cInstanceService: T4CInstanceService) {} + constructor(private t4cInstanceService: T4CInstanceWrapperService) {} ngOnInit(): void { this.t4cInstanceService.getLicenses(this.instance.id).subscribe({ @@ -39,5 +36,5 @@ export class LicencesComponent implements OnInit { }); } - sessionUsage?: SessionUsage; + sessionUsage?: GetSessionUsageResponse; } diff --git a/frontend/src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service.ts b/frontend/src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service.ts index 809fa3f2d..f5f947c97 100644 --- a/frontend/src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service.ts +++ b/frontend/src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service.ts @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { AbstractControl, @@ -12,45 +11,36 @@ import { } from '@angular/forms'; import { BehaviorSubject, Observable, map, take, tap } from 'rxjs'; import { + CreateT4CRepository, + ResponseModel, + SettingsModelsourcesT4CService, T4CInstance, - T4CInstanceService, -} from 'src/app/services/settings/t4c-instance.service'; + T4CRepository, + T4CRepositoryStatus, +} from 'src/app/openapi'; @Injectable({ providedIn: 'root', }) -export class T4CRepoService { - constructor( - private http: HttpClient, - private t4cInstanceService: T4CInstanceService, - ) {} +export class T4CRepositoryWrapperService { + constructor(private t4cInstanceService: SettingsModelsourcesT4CService) {} private _repositories = new BehaviorSubject< - T4CServerRepository[] | undefined + ExtendedT4CRepository[] | undefined >(undefined); public readonly repositories$ = this._repositories.asObservable(); - urlFactory(instanceId: number, repositoryId: number): string { - return `${this.t4cInstanceService.urlFactory( - instanceId, - )}/repositories/${repositoryId}`; - } - loadRepositories(instanceId: number): void { - this.http - .get< - T4CServerRepository[] - >(`${this.t4cInstanceService.urlFactory(instanceId)}/repositories`) - .subscribe({ - next: (repositories) => this._repositories.next(repositories), - error: () => this._repositories.next(undefined), - }); + this.t4cInstanceService.listT4cRepositories(instanceId).subscribe({ + next: (repositories) => this._repositories.next(repositories.payload), + error: () => this._repositories.next(undefined), + }); } refreshRepositories(instanceId: number): void { const updateRepositories = this._repositories.value?.map((repository) => { - return { ...repository, status: 'LOADING' } as T4CServerRepository; + return { ...repository, status: 'LOADING' } as ExtendedT4CRepository; }); this._repositories.next(updateRepositories); this.loadRepositories(instanceId); @@ -60,25 +50,22 @@ export class T4CRepoService { instanceId: number, repository: CreateT4CRepository, ): Observable { - return this.http - .post( - `${this.t4cInstanceService.urlFactory(instanceId)}/repositories`, - repository, - ) + return this.t4cInstanceService + .createT4cRepository(instanceId, repository) .pipe(tap(() => this.loadRepositories(instanceId))); } startRepository(instanceId: number, repositoryId: number): Observable { this.publishRepositoriesWithChangedStatus(repositoryId, 'LOADING'); - return this.http - .post(`${this.urlFactory(instanceId, repositoryId)}/start`, {}) + return this.t4cInstanceService + .startT4cRepository(instanceId, repositoryId) .pipe(tap(() => this.loadRepositories(instanceId))); } stopRepository(instanceId: number, repositoryId: number): Observable { this.publishRepositoriesWithChangedStatus(repositoryId, 'LOADING'); - return this.http - .post(`${this.urlFactory(instanceId, repositoryId)}/stop`, {}) + return this.t4cInstanceService + .stopT4cRepository(instanceId, repositoryId) .pipe(tap(() => this.loadRepositories(instanceId))); } @@ -87,14 +74,17 @@ export class T4CRepoService { repositoryId: number, ): Observable { this.publishRepositoriesWithChangedStatus(repositoryId, 'LOADING'); - return this.http - .post(`${this.urlFactory(instanceId, repositoryId)}/recreate`, {}) + return this.t4cInstanceService + .recreateT4cRepository(instanceId, repositoryId) .pipe(tap(() => this.loadRepositories(instanceId))); } - deleteRepository(instanceId: number, repositoryId: number): Observable { - return this.http - .delete(`${this.urlFactory(instanceId, repositoryId)}`) + deleteRepository( + instanceId: number, + repositoryId: number, + ): Observable { + return this.t4cInstanceService + .deleteT4cRepository(instanceId, repositoryId) .pipe(tap(() => this.loadRepositories(instanceId))); } @@ -124,7 +114,7 @@ export class T4CRepoService { const updatedRepositories = currentRepositories?.map((repository) => { if (repository.id === repositoryId) { - return { ...repository, status: status } as T4CServerRepository; + return { ...repository, status: status } as ExtendedT4CRepository; } return repository; }); @@ -132,21 +122,11 @@ export class T4CRepoService { } } -export type CreateT4CRepository = { - name: string; -}; +type ExtendedT4CRepositoryStatus = T4CRepositoryStatus | 'LOADING'; -export type T4CRepository = CreateT4CRepository & { +export interface ExtendedT4CRepository { + name: string; id: number; instance: T4CInstance; -}; - -export type T4CServerRepository = T4CRepository & { - status: - | 'ONLINE' - | 'OFFLINE' - | 'INITIAL' - | 'INSTANCE_UNREACHABLE' - | 'NOT_FOUND' - | 'LOADING'; -}; + status: ExtendedT4CRepositoryStatus | null; +} diff --git a/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.component.html b/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.component.html index 119b0b824..8066ad1ed 100644 --- a/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.component.html +++ b/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.component.html @@ -75,15 +75,6 @@

Repositories

- - + +
diff --git a/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.component.ts b/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.component.ts index 82316d966..b154232dd 100644 --- a/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.component.ts +++ b/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.component.ts @@ -31,12 +31,10 @@ import { MatIcon } from '@angular/material/icon'; import { MatInput } from '@angular/material/input'; import { MatSelectionList } from '@angular/material/list'; import { MatTooltip } from '@angular/material/tooltip'; -import { T4CInstance } from 'src/app/services/settings/t4c-instance.service'; +import { CreateT4CRepository, T4CInstance } from 'src/app/openapi'; import { - CreateT4CRepository, - T4CRepoService, - T4CRepository, - T4CServerRepository, + ExtendedT4CRepository, + T4CRepositoryWrapperService, } from 'src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service'; import { T4CRepoDeletionDialogComponent } from './t4c-repo-deletion-dialog/t4c-repo-deletion-dialog.component'; @@ -68,7 +66,7 @@ export class T4CInstanceSettingsComponent implements OnChanges, OnDestroy { search = ''; constructor( - public t4cRepoService: T4CRepoService, + public t4cRepoService: T4CRepositoryWrapperService, private dialog: MatDialog, ) {} @@ -92,8 +90,8 @@ export class T4CInstanceSettingsComponent implements OnChanges, OnDestroy { }); getFilteredRepositories( - repositories: T4CServerRepository[] | undefined | null, - ): T4CServerRepository[] | undefined { + repositories: ExtendedT4CRepository[] | undefined | null, + ): ExtendedT4CRepository[] | undefined { if (repositories === undefined || repositories === null) { return undefined; } @@ -114,25 +112,25 @@ export class T4CInstanceSettingsComponent implements OnChanges, OnDestroy { } } - deleteRepository(repository: T4CRepository): void { + deleteRepository(repository: ExtendedT4CRepository): void { this.dialog.open(T4CRepoDeletionDialogComponent, { data: repository, }); } - startRepository(repository: T4CServerRepository): void { + startRepository(repository: ExtendedT4CRepository): void { this.t4cRepoService .startRepository(repository.instance.id, repository.id) .subscribe(); } - stopRepository(repository: T4CServerRepository): void { + stopRepository(repository: ExtendedT4CRepository): void { this.t4cRepoService .stopRepository(repository.instance.id, repository.id) .subscribe(); } - recreateRepository(repository: T4CServerRepository): void { + recreateRepository(repository: ExtendedT4CRepository): void { this.t4cRepoService .recreateRepository(repository.instance.id, repository.id) .subscribe(); diff --git a/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.docs.mdx b/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.docs.mdx new file mode 100644 index 000000000..e91bd8654 --- /dev/null +++ b/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.docs.mdx @@ -0,0 +1,19 @@ +{/* + SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors + SPDX-License-Identifier: Apache-2.0 +*/} + +import * as T4CInstanceSettingsComponent from './t4c-instance-settings.stories.ts' +import { Meta, Title, Story, Canvas, Unstyled } from '@storybook/blocks' + + + + + +This is an example story for the component: + +<Unstyled> + <div style={{ width: '380px' }}> + <Story of={T4CInstanceSettingsComponent.Repositories} /> + </div> +</Unstyled> diff --git a/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.stories.ts b/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.stories.ts new file mode 100644 index 000000000..2716ca885 --- /dev/null +++ b/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-instance-settings.stories.ts @@ -0,0 +1,75 @@ +/* + * SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { Meta, StoryObj, moduleMetadata } from '@storybook/angular'; +import { T4CRepositoryWrapperService } from 'src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service'; +import { + MockT4CRepositoryWrapperService, + mockT4CInstance, +} from 'src/storybook/t4c'; +import { T4CInstanceSettingsComponent } from './t4c-instance-settings.component'; + +const meta: Meta<T4CInstanceSettingsComponent> = { + title: 'Settings Components / Modelsources / T4C / Repositories', + component: T4CInstanceSettingsComponent, + parameters: { + chromatic: { viewports: [380] }, + }, +}; + +export default meta; +type Story = StoryObj<T4CInstanceSettingsComponent>; + +export const Repositories: Story = { + args: {}, + decorators: [ + moduleMetadata({ + providers: [ + { + provide: T4CRepositoryWrapperService, + useFactory: () => + new MockT4CRepositoryWrapperService([ + { + id: 1, + name: 'online-repository', + instance: mockT4CInstance, + status: 'ONLINE', + }, + { + id: 2, + name: 'offline-repository', + instance: mockT4CInstance, + status: 'OFFLINE', + }, + { + id: 3, + name: 'not-found-repository', + instance: mockT4CInstance, + status: 'NOT_FOUND', + }, + { + id: 4, + name: 'loading-repository', + instance: mockT4CInstance, + status: 'LOADING', + }, + { + id: 5, + name: 'initial-repository', + instance: mockT4CInstance, + status: 'INITIAL', + }, + { + id: 6, + name: 'unreachable-repository', + instance: mockT4CInstance, + status: 'INSTANCE_UNREACHABLE', + }, + ]), + }, + ], + }), + ], +}; diff --git a/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-repo-deletion-dialog/t4c-repo-deletion-dialog.component.ts b/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-repo-deletion-dialog/t4c-repo-deletion-dialog.component.ts index 678f25ac2..e82ece3a3 100644 --- a/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-repo-deletion-dialog/t4c-repo-deletion-dialog.component.ts +++ b/frontend/src/app/settings/modelsources/t4c-settings/t4c-instance-settings/t4c-repo-deletion-dialog/t4c-repo-deletion-dialog.component.ts @@ -20,8 +20,8 @@ import { MatFormField, MatLabel, MatError } from '@angular/material/form-field'; import { MatInput } from '@angular/material/input'; import { finalize } from 'rxjs'; import { - T4CRepoService, - T4CRepository, + ExtendedT4CRepository, + T4CRepositoryWrapperService, } from 'src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service'; @Component({ @@ -47,9 +47,9 @@ export class T4CRepoDeletionDialogComponent { ]); constructor( - private repoService: T4CRepoService, + private repoService: T4CRepositoryWrapperService, public dialogRef: MatDialogRef<T4CRepoDeletionDialogComponent>, - @Inject(MAT_DIALOG_DATA) public repo: T4CRepository, + @Inject(MAT_DIALOG_DATA) public repo: ExtendedT4CRepository, ) {} removeRepository(): void { diff --git a/frontend/src/app/settings/modelsources/t4c-settings/t4c-settings-wrapper/t4c-settings-wrapper.component.ts b/frontend/src/app/settings/modelsources/t4c-settings/t4c-settings-wrapper/t4c-settings-wrapper.component.ts index ab8a92813..94b9c221f 100644 --- a/frontend/src/app/settings/modelsources/t4c-settings/t4c-settings-wrapper/t4c-settings-wrapper.component.ts +++ b/frontend/src/app/settings/modelsources/t4c-settings/t4c-settings-wrapper/t4c-settings-wrapper.component.ts @@ -5,7 +5,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { RouterOutlet } from '@angular/router'; -import { T4CInstanceService } from 'src/app/services/settings/t4c-instance.service'; +import { T4CInstanceWrapperService } from 'src/app/services/settings/t4c-instance.service'; @Component({ selector: 'app-t4c-settings-wrapper', @@ -15,7 +15,7 @@ import { T4CInstanceService } from 'src/app/services/settings/t4c-instance.servi imports: [RouterOutlet], }) export class T4CSettingsWrapperComponent implements OnInit, OnDestroy { - constructor(public t4cInstanceService: T4CInstanceService) {} + constructor(public t4cInstanceService: T4CInstanceWrapperService) {} ngOnInit(): void { this.t4cInstanceService.loadInstances(); diff --git a/frontend/src/app/settings/modelsources/t4c-settings/t4c-settings.component.ts b/frontend/src/app/settings/modelsources/t4c-settings/t4c-settings.component.ts index 77157bc08..9124158bb 100644 --- a/frontend/src/app/settings/modelsources/t4c-settings/t4c-settings.component.ts +++ b/frontend/src/app/settings/modelsources/t4c-settings/t4c-settings.component.ts @@ -8,7 +8,7 @@ import { Component } from '@angular/core'; import { MatRipple } from '@angular/material/core'; import { MatIcon } from '@angular/material/icon'; import { RouterLink } from '@angular/router'; -import { T4CInstanceService } from 'src/app/services/settings/t4c-instance.service'; +import { T4CInstanceWrapperService } from 'src/app/services/settings/t4c-instance.service'; import { MatIconComponent } from '../../../helpers/mat-icon/mat-icon.component'; @Component({ @@ -28,5 +28,5 @@ import { MatIconComponent } from '../../../helpers/mat-icon/mat-icon.component'; ], }) export class T4CSettingsComponent { - constructor(public t4cInstanceService: T4CInstanceService) {} + constructor(public t4cInstanceService: T4CInstanceWrapperService) {} } diff --git a/frontend/src/storybook/git.ts b/frontend/src/storybook/git.ts index ed4aa3001..e7395a08b 100644 --- a/frontend/src/storybook/git.ts +++ b/frontend/src/storybook/git.ts @@ -3,10 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { GetGitModel } from 'src/app/projects/project-detail/model-overview/model-detail/git-model.service'; +import { GitModel } from 'src/app/openapi'; -export const mockPrimaryGitModel: Readonly<GetGitModel> = { +export const mockPrimaryGitModel: Readonly<GitModel> = { id: 1, + name: 'fakeGitModelName', primary: true, path: 'fakePath', revision: 'fakeRevision', diff --git a/frontend/src/storybook/model.ts b/frontend/src/storybook/model.ts index 7cd6bffc6..e77b76621 100644 --- a/frontend/src/storybook/model.ts +++ b/frontend/src/storybook/model.ts @@ -3,16 +3,17 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { Model } from 'src/app/projects/models/service/model.service'; +import { BehaviorSubject } from 'rxjs'; +import { ToolModel } from 'src/app/openapi'; +import { ModelWrapperService } from 'src/app/projects/models/service/model.service'; import { mockPrimaryGitModel } from './git'; -import { mockTool, mockToolVersion } from './tool'; +import { mockTool, mockToolNature, mockToolVersion } from './tool'; -export function createModelWithId(id: number): Model { +export function createModelWithId(id: number): ToolModel { return { id: 1, name: `fakeModelName-${id}`, slug: `fakeModelSlug-${id}`, - project_slug: 'fakeProjectSlug', description: `fakeModelDescription-${id}`, tool: mockTool, version: mockToolVersion, @@ -20,7 +21,21 @@ export function createModelWithId(id: number): Model { git_models: [mockPrimaryGitModel], restrictions: { allow_pure_variants: false }, display_order: 1, + nature: mockToolNature, }; } -export const mockModel: Readonly<Model> = createModelWithId(1); +export const mockModel: Readonly<ToolModel> = createModelWithId(1); + +export class MockModelWrapperService implements Partial<ModelWrapperService> { + private _model = new BehaviorSubject<ToolModel | undefined>(undefined); + private _models = new BehaviorSubject<ToolModel[] | undefined>(undefined); + + public readonly model$ = this._model.asObservable(); + public readonly models$ = this._models.asObservable(); + + constructor(model: ToolModel, models: ToolModel[]) { + this._model.next(model); + this._models.next(models); + } +} diff --git a/frontend/src/storybook/project.ts b/frontend/src/storybook/project.ts index 13e8e9e64..7883a4b19 100644 --- a/frontend/src/storybook/project.ts +++ b/frontend/src/storybook/project.ts @@ -3,7 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { BehaviorSubject } from 'rxjs'; import { Project } from 'src/app/openapi'; +import { ProjectWrapperService } from 'src/app/projects/service/project.service'; export const mockProject: Readonly<Project> = { name: 'mockProject', @@ -19,3 +21,18 @@ export const mockProject: Readonly<Project> = { subscribers: 1, }, }; + +export class MockProjectWrapperService + implements Partial<ProjectWrapperService> +{ + private _project = new BehaviorSubject<Project | undefined>(undefined); + private _projects = new BehaviorSubject<Project[] | undefined>(undefined); + + public readonly project$ = this._project.asObservable(); + public readonly projects$ = this._projects.asObservable(); + + constructor(project: Project, projects: Project[]) { + this._project.next(project); + this._projects.next(projects); + } +} diff --git a/frontend/src/storybook/t4c.ts b/frontend/src/storybook/t4c.ts index a630e44cf..caa65e98c 100644 --- a/frontend/src/storybook/t4c.ts +++ b/frontend/src/storybook/t4c.ts @@ -3,10 +3,96 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { + AbstractControl, + AsyncValidatorFn, + ValidationErrors, +} from '@angular/forms'; +import { BehaviorSubject, Observable, of } from 'rxjs'; +import { T4CInstance, ValidationError } from 'src/app/openapi'; import { SimpleT4CModel } from 'src/app/projects/models/model-source/t4c/service/t4c-model.service'; +import { T4CInstanceWrapperService } from 'src/app/services/settings/t4c-instance.service'; +import { + ExtendedT4CRepository, + T4CRepositoryWrapperService, +} from 'src/app/settings/modelsources/t4c-settings/service/t4c-repos/t4c-repo.service'; +import { mockToolVersion } from 'src/storybook/tool'; export const mockTeamForCapellaRepository: Readonly<SimpleT4CModel> = { project_name: 'project', repository_name: 'repository', instance_name: 'instance', }; + +export const mockT4CInstance: Readonly<T4CInstance> = { + id: 1, + name: 'test', + license: 'license', + host: 'localhost', + port: 2036, + cdo_port: 12036, + http_port: 8080, + usage_api: 'http://localhost:8086', + rest_api: 'http://localhost:8081/api/v1.0', + username: 'admin', + protocol: 'ws', + version_id: 1, + version: mockToolVersion, + is_archived: false, +}; + +export const mockExtendedT4CRepository: Readonly<ExtendedT4CRepository> = { + id: 1, + name: 'repository', + instance: mockT4CInstance, + status: 'LOADING', +}; + +export class MockT4CInstanceWrapperService + implements Partial<T4CInstanceWrapperService> +{ + private _t4cInstance = new BehaviorSubject<T4CInstance | undefined>( + undefined, + ); + public readonly t4cInstance$ = this._t4cInstance.asObservable(); + + private _t4cInstances = new BehaviorSubject<T4CInstance[] | undefined>( + undefined, + ); + public readonly t4cInstances$ = this._t4cInstances.asObservable(); + + constructor(t4cInstance: T4CInstance, t4cInstances: T4CInstance[]) { + this._t4cInstance.next(t4cInstance); + this._t4cInstances.next(t4cInstances); + } + + asyncNameValidator(_ignoreInstance?: T4CInstance): AsyncValidatorFn { + return (_control: AbstractControl): Observable<ValidationError | null> => { + return of(null); + }; + } + + resetT4CInstance(): void {} +} + +export class MockT4CRepositoryWrapperService + implements Partial<T4CRepositoryWrapperService> +{ + private _repositories = new BehaviorSubject< + ExtendedT4CRepository[] | undefined + >(undefined); + + public readonly repositories$ = this._repositories.asObservable(); + + constructor(repositories: ExtendedT4CRepository[]) { + this._repositories.next(repositories); + } + + reset() {} + + asyncNameValidator(): AsyncValidatorFn { + return (_control: AbstractControl): Observable<ValidationErrors | null> => { + return of(null); + }; + } +} diff --git a/frontend/src/storybook/tool.ts b/frontend/src/storybook/tool.ts index 2ea2b9997..e4968a491 100644 --- a/frontend/src/storybook/tool.ts +++ b/frontend/src/storybook/tool.ts @@ -3,7 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { HTTPConnectionMethodOutput, Tool, ToolVersion } from 'src/app/openapi'; +import { + HTTPConnectionMethodOutput, + Tool, + ToolNature, + ToolVersion, +} from 'src/app/openapi'; import { ToolVersionWithTool } from 'src/app/settings/core/tools-settings/tool.service'; export const mockHttpConnectionMethod: Readonly<HTTPConnectionMethodOutput> = { @@ -41,6 +46,11 @@ export const mockToolVersion: Readonly<ToolVersion> = { }, }; +export const mockToolNature: Readonly<ToolNature> = { + id: 1, + name: 'fakeNature', +}; + export const mockTool: Readonly<Tool> = { id: 1, name: 'fakeTool',