Skip to content

Commit

Permalink
feat: Support Git paths in diagram cache code snippet
Browse files Browse the repository at this point in the history
The commits identifies the primary Git model of a model and
adds the information to the code snippet of the diagram cache.

In addition, there were some minor/internal changes:

- The code snippet code was moved to a new component `ModelDiagramCacheBlockComponent`.
- Syntax highlighting was added in the frontend.
- A duplication of the code snippet declaration was removed.
- Margins and paddings were updated, responsive design was added.
- The colors of the code snippet were inverted (white text on dark background)
- Information about token revocation was added to the dialog.
  • Loading branch information
MoritzWeber0 committed Dec 14, 2023
1 parent 13f5add commit 4d390cf
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 258 deletions.
23 changes: 17 additions & 6 deletions backend/capellacollab/core/metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors
# SPDX-License-Identifier: Apache-2.0

import typing as t

import fastapi
import pydantic

Expand All @@ -18,9 +20,15 @@ class Metadata(pydantic.BaseModel):
authentication_provider: str | None
environment: str | None

host: str | None
port: str | None
protocol: str | None


router = fastapi.APIRouter()
cfg: dict[str, str | None] = config["general"].get("metadata", {})

general_cfg: dict[str, t.Any] = config["general"]
metadata_cfg: dict[str, str | None] = general_cfg.get("metadata", {})


@router.get(
Expand All @@ -30,9 +38,12 @@ class Metadata(pydantic.BaseModel):
def get_metadata():
return Metadata(
version=capellacollab.__version__,
privacy_policy_url=cfg.get("privacyPolicyURL"),
imprint_url=cfg.get("imprintURL"),
provider=cfg.get("provider"),
authentication_provider=cfg.get("authenticationProvider"),
environment=cfg.get("environment"),
privacy_policy_url=metadata_cfg.get("privacyPolicyURL"),
imprint_url=metadata_cfg.get("imprintURL"),
provider=metadata_cfg.get("provider"),
authentication_provider=metadata_cfg.get("authenticationProvider"),
environment=metadata_cfg.get("environment"),
host=general_cfg.get("host"),
port=str(general_cfg.get("port")),
protocol=general_cfg.get("scheme"),
)
2 changes: 1 addition & 1 deletion backend/config/config_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ k8s:

general:
host: localhost
port: 4200
port: 8000
scheme: http
wildcardHost: False

Expand Down
7 changes: 6 additions & 1 deletion frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ module.exports = {
parser: "@angular-eslint/template-parser",
rules: {
"tailwindcss/classnames-order": "off",
"tailwindcss/no-custom-classname": "error",
"tailwindcss/no-custom-classname": [
"error",
{
whitelist: ["language-python"],
},
],
"tailwindcss/enforces-negative-arbitrary-values": "error",
"tailwindcss/enforces-shorthand": "error",
"tailwindcss/no-contradicting-classname": "error",
Expand Down
3 changes: 2 additions & 1 deletion frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"styles": [
"src/custom-theme.scss",
"src/styles.css",
"node_modules/ngx-toastr/toastr.css"
"node_modules/ngx-toastr/toastr.css",
"node_modules/highlight.js/styles/atom-one-dark.css"
],
"optimization": {
"fonts": false
Expand Down
144 changes: 9 additions & 135 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/semver": "^7.5.6",
"buffer": "^6.0.3",
"file-saver": "^2.0.5",
"highlight.js": "^11.9.0",
"http-status-codes": "^2.3.0",
"ngx-cookie": "^6.0.1",
"ngx-skeleton-loader": "^8.1.0",
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CookieModule } from 'ngx-cookie';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { ToastrModule } from 'ngx-toastr';
import {
HighlightPipeTransform,
ModelDiagramCodeBlockComponent,
} from 'src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-code-block/model-diagram-code-block.component';
import { BasicAuthTokenComponent } from 'src/app/users/basic-auth-token/basic-auth-token.component';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
Expand Down Expand Up @@ -182,6 +186,7 @@ import { UsersProfileComponent } from './users/users-profile/users-profile.compo
FormFieldSkeletonLoaderComponent,
GitSettingsComponent,
HeaderComponent,
HighlightPipeTransform,
InitModelComponent,
InputDialogComponent,
JobRunOverviewComponent,
Expand All @@ -198,6 +203,7 @@ import { UsersProfileComponent } from './users/users-profile/users-profile.compo
ModelComplexityBadgeComponent,
ModelDescriptionComponent,
ModelDetailComponent,
ModelDiagramCodeBlockComponent,
ModelDiagramDialogComponent,
ModelDiagramPreviewDialogComponent,
ModelOverviewComponent,
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/app/general/metadata/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,8 @@ export interface BackendMetadata {
provider: string;
authentication_provider: string;
environment: string;

host: string;
port: string;
protocol: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
~ SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors
~ SPDX-License-Identifier: Apache-2.0
-->

<mat-expansion-panel color="bg-slate-400">
<mat-expansion-panel-header>
<mat-panel-title>
Learn how to use the diagram cache with capellambse!
</mat-panel-title>
</mat-expansion-panel-header>
<div class="mt-2">
You can also access the diagrams via our Python library
<i>capellambse</i>. Follow the installation instructions on
<a
target="_blank"
rel="noopener"
class="text-url"
href="https://github.com/DSD-DBS/py-capellambse#installation"
>Github<span class="align-middle"
><mat-icon class="scale-75">open_in_new</mat-icon></span
>
</a>
and then use the code snippet. To authenticate, you have to insert a
personal access token. The token has the same scope as your user. Be careful
with it. You can revoke the token in the settings.
</div>
<pre
class="my-2 overflow-x-scroll whitespace-pre rounded-md border shadow"
><code class="language-python" [innerHTML]="this.codeBlockContent | hightlight:'python'"></code></pre>
<div class="flex flex-wrap gap-2">
<button
class="mt-auto self-end"
[cdkCopyToClipboard]="this.codeBlockContent"
matTooltip="Copy codeblock to clipboard"
color="bg-transparent"
mat-raised-button
>
<mat-icon>content_copy</mat-icon>
</button>
<button
class="mt-auto self-end text-white"
(click)="insertToken()"
[disabled]="passwordValue"
matTooltip="Insert new personal access token for your user"
color="primary"
mat-raised-button
>
Insert token
</button>
</div>
</mat-expansion-panel>
Loading

0 comments on commit 4d390cf

Please sign in to comment.