Skip to content

Commit

Permalink
feat(ui): ui can show fqn payload
Browse files Browse the repository at this point in the history
  • Loading branch information
timonback committed Oct 13, 2023
1 parent 052b7ee commit e5204f1
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ button {
font-weight: normal;
}

.header-name {
background-color: #e0e0e0;
border-radius: 4px;
padding: 6px;
font-weight: normal;
}

.button-container {
height: 50px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,19 @@ <h4>Message</h4>
</mat-tab>
<mat-tab label="Schema">
<h4>
{{ schemaName }}
<span class="payload-name">
<a [href]="operation.message.payload.anchorUrl">{{
operation.message.payload.name
}}</a>
</span>
Schema:
<a [href]="operation.message.payload.anchorUrl">{{
operation.message.payload.name
}}</a>
</h4>
<app-schema *ngIf="schema" [schema]="schema"></app-schema>
</mat-tab>
<mat-tab label="Headers">
<h4>
{{ headersSchemaName }}
<span class="header-name">
<a [href]="operation.message.headers.anchorUrl">{{
operation.message.headers.name
}}</a>
</span>
Schema:
<a [href]="operation.message.headers.anchorUrl">{{
operation.message.headers.name
}}</a>
</h4>
<app-schema *ngIf="headers" [schema]="headers"></app-schema>
<div class="flex-column">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: Apache-2.0 */
import { Component, OnInit, Input } from "@angular/core";
import { Component, Input, OnInit } from "@angular/core";
import { AsyncApiService } from "src/app/shared/asyncapi.service";
import { Example } from "src/app/shared/models/example.model";
import { Schema } from "src/app/shared/models/schema.model";
Expand All @@ -19,12 +19,12 @@ export class ChannelMainComponent implements OnInit {
@Input() operation: Operation;

schema: Schema;
schemaName: string;
schemaIdentifier: string;
defaultExample: Example;
defaultExampleType: string;
exampleTextAreaLineCount: number;
headers: Schema;
headersSchemaName: string;
headersSchemaIdentifier: string;
headersExample: Example;
headersTextAreaLineCount: number;
protocolName: string;
Expand All @@ -40,19 +40,19 @@ export class ChannelMainComponent implements OnInit {
ngOnInit(): void {
this.asyncApiService.getAsyncApi().subscribe((asyncapi) => {
const schemas: Map<string, Schema> = asyncapi.components.schemas;
this.schemaName = this.operation.message.payload.name.slice(
this.schemaIdentifier = this.operation.message.payload.name.slice(
this.operation.message.payload.name.lastIndexOf("/") + 1
);
this.schema = schemas.get(this.schemaName);
this.schema = schemas.get(this.schemaIdentifier);

this.defaultExample = this.schema.example;
this.exampleTextAreaLineCount = this.defaultExample?.lineCount || 0;
this.defaultExampleType = this.operation.message.name;

this.headersSchemaName = this.operation.message.headers.name.slice(
this.headersSchemaIdentifier = this.operation.message.headers.name.slice(
this.operation.message.headers.name.lastIndexOf("/") + 1
);
this.headers = schemas.get(this.headersSchemaName);
this.headers = schemas.get(this.headersSchemaIdentifier);
this.headersExample = this.headers.example;
this.headersTextAreaLineCount = this.headersExample?.lineCount || 0;
this.messageBindingExampleTextAreaLineCount =
Expand Down
2 changes: 1 addition & 1 deletion springwolf-ui/src/app/channels/channels.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h1>Channels</h1>
></i>
</div>
<h3>{{ channel.name }}</h3>
<div class="payload-name">{{ channel.operation.message.title }}</div>
<span class="payload-name">{{ channel.operation.message.title }}</span>
</mat-panel-title>
</mat-expansion-panel-header>
<app-channel-main
Expand Down
4 changes: 2 additions & 2 deletions springwolf-ui/src/app/schemas/schema/schema.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
>
<span class="type" *ngIf="property.value.items.anchorUrl">
<a [href]="property.value.items.anchorUrl"
>{{ property.value.items.refName }}[]</a
>{{ property.value.items.refTitle }}[]</a
>
</span>
</ng-container>
<span class="type" *ngIf="property.value.type != 'array'">{{
property.value.type
}}</span>
<span class="type" *ngIf="property.value.refName">
<a [href]="property.value.anchorUrl">{{ property.value.refName }}</a>
<a [href]="property.value.anchorUrl">{{ property.value.refTitle }}</a>
</span>
<span class="format" *ngIf="property.value.format"
>({{ property.value.format }})</span
Expand Down
7 changes: 7 additions & 0 deletions springwolf-ui/src/app/schemas/schemas.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
h3 {
margin: 0;
}

.schema-name {
background-color: #e0e0e0;
border-radius: 4px;
padding: 6px;
font-weight: normal;
}
7 changes: 5 additions & 2 deletions springwolf-ui/src/app/schemas/schemas.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ <h1>Schemas</h1>
>
<mat-expansion-panel-header>
<mat-panel-title>
<h3>{{ schema.value.schemaName }}</h3>
<h3>{{ schema.value.title }}</h3>
</mat-panel-title>
<mat-panel-description>
{{ schema.value.description }}
</mat-panel-description>
</mat-expansion-panel-header>
<app-schema [schema]="schema?.value"></app-schema>
<h4>
Title: <span class="schema-name">{{ schema.value.name }}</span>
</h4>
<app-schema [schema]="schema.value"></app-schema>
</mat-expansion-panel>
</mat-accordion>
6 changes: 5 additions & 1 deletion springwolf-ui/src/app/shared/asyncapi-mapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ export class AsyncApiMapperService {
description: v.description,
payload: {
name: v.payload.$ref,
title: v.payload.$ref?.split(".")?.pop(),
anchorUrl:
AsyncApiMapperService.BASE_URL + v.payload.$ref?.split("/")?.pop(),
},
headers: {
name: v.headers.$ref,
title: v.headers.$ref?.split("/")?.pop(),
anchorUrl:
AsyncApiMapperService.BASE_URL + v.headers.$ref?.split("/")?.pop(),
},
Expand Down Expand Up @@ -268,9 +270,11 @@ export class AsyncApiMapperService {
const example =
schema.example !== undefined ? new Example(schema.example) : undefined;
return {
schemaName: schemaName.split(".")?.pop(),
name: schemaName,
title: schemaName.split(".")?.pop(),
description: schema.description,
refName: schema.$ref,
refTitle: schema.$ref?.split("/")?.pop(),
anchorIdentifier: "#" + schemaName,
anchorUrl: anchorUrl,
type: schema.type,
Expand Down
2 changes: 2 additions & 0 deletions springwolf-ui/src/app/shared/models/channel.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ export interface Message {
description?: string;
payload: {
name: string;
title: string;
anchorUrl: string;
};
headers: {
name: string;
title: string;
anchorUrl: string;
};
bindings?: Map<string, MessageBinding>;
Expand Down
4 changes: 3 additions & 1 deletion springwolf-ui/src/app/shared/models/schema.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
import { Example } from "./example.model";

export interface Schema {
schemaName: string;
name?: string;
title: string;
description?: string;

refName?: string;
refTitle?: string;
anchorIdentifier?: string;
anchorUrl?: string;

Expand Down

0 comments on commit e5204f1

Please sign in to comment.