-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue(#654): Incluso la visualizzazione degli headers e del payload n…
…el dettaglio del messaggi (#656) Co-authored-by: Alfonso Tatarelli <a.tatarelli@gmail.com>
- Loading branch information
1 parent
55b9cec
commit cdbd1d4
Showing
14 changed files
with
249 additions
and
4 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
wars/web-console/src/main/angular/console/npm-shrinkwrap.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lar/console/src/app/elements/item-view/views/key-value-view/key-value-view.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...onsole/src/main/angular/console/src/app/elements/payload-view/payload-view.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div *ngIf="!attribute">{{ 'Nessun dato da visualizzare' }}</div> | ||
<div class="border p-2" style="height: 240px;overflow: auto;" *ngIf="attribute"> | ||
<!-- <div>{{ type }}</div> --> | ||
<pre *ngIf="type === MimeEnum.JSON">{{ payload | json }}</pre> | ||
<pre *ngIf="type === MimeEnum.XML">{{ payload | xml }}</pre> | ||
</div> | ||
<div class="float-right" *ngIf="showCopy"> | ||
<button mat-icon-button type="button" (click)="copyPayload()" [matTooltip]="'Copia negli appunti'"><mat-icon>content_copy</mat-icon></button> | ||
</div> |
Empty file.
63 changes: 63 additions & 0 deletions
63
...-console/src/main/angular/console/src/app/elements/payload-view/payload-view.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
|
||
enum MimeEnum { | ||
JSON = 'application/json', | ||
XML = 'text/xml', | ||
} | ||
|
||
@Component({ | ||
selector: 'link-payload-view', | ||
templateUrl: './payload-view.component.html', | ||
styleUrls: ['./payload-view.component.scss'] | ||
}) | ||
export class PayloadViewComponent implements OnInit { | ||
|
||
@Input() data: any = null; | ||
@Input() attribute: string = ''; | ||
@Input() showCopy: boolean = true; | ||
|
||
@Output() copied: EventEmitter<boolean> = new EventEmitter(); | ||
|
||
payload = null; | ||
payloadString = null; | ||
type= null; | ||
header = null; | ||
|
||
_arrXML = ['API_PAGOPA', 'API_MAGGIOLI']; | ||
|
||
readonly MimeEnum = MimeEnum; | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
if (this.data[this.attribute]) { | ||
this.header = this.data[this.attribute].headers; | ||
const _contentTypeRichiesta = this.header.find((item: any) => (item.nome.toLowerCase() === 'content-type')); | ||
if (_contentTypeRichiesta) { | ||
this.type = _contentTypeRichiesta.valore.split(';')[0] || null; | ||
} | ||
if (!this.type) { | ||
this.type = this._arrXML.includes(this.data.componente) ? MimeEnum.XML : MimeEnum.JSON; | ||
} | ||
this.payload = this._decodeB64ToJson(this.data[this.attribute].payload); | ||
} | ||
} | ||
|
||
protected _decodeB64ToJson(_base: string): any { | ||
const _jsonDecode = decodeURIComponent(atob(_base).split('').map(function(c) { | ||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); | ||
}).join('')); | ||
this.payloadString = _jsonDecode; | ||
if (this.type === MimeEnum.JSON) { | ||
return JSON.parse(_jsonDecode); | ||
} else { | ||
return _jsonDecode; | ||
} | ||
} | ||
|
||
copyPayload() { | ||
window.navigator['clipboard'].writeText(this.payloadString) | ||
.then( r => this.copied.emit(true) ) | ||
.catch( e => { this.copied.emit(false); console.log(e) }); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...eb-console/src/main/angular/console/src/app/elements/table-view/table-view.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div *ngIf="attributes.length === 0">{{ 'Nessun dato da visualizzare' }}</div> | ||
<table class="table table-bordered table-sm" *ngIf="attributes.length > 0"> | ||
<thead> | ||
<tr> | ||
<th class="{{ item.col }}" scope="col" *ngFor="let item of attributes">{{ item.label }}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let elem of data"> | ||
<td class="text-break text-wrap" *ngFor="let item of attributes">{{ elem[item.attribute] }}</td> | ||
</tr> | ||
</tbody> | ||
</table> |
Empty file.
16 changes: 16 additions & 0 deletions
16
.../web-console/src/main/angular/console/src/app/elements/table-view/table-view.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'link-table-view', | ||
templateUrl: './table-view.component.html', | ||
styleUrls: ['./table-view.component.scss'] | ||
}) | ||
export class TableViewComponent implements OnInit { | ||
|
||
@Input() data: any[] = null; | ||
@Input() attributes: any[] = []; | ||
|
||
constructor() { } | ||
|
||
ngOnInit() {} | ||
} |
12 changes: 12 additions & 0 deletions
12
wars/web-console/src/main/angular/console/src/app/pipes/xml.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Pipe, PipeTransform } from "@angular/core"; | ||
|
||
import * as vkbeautify from 'vkbeautify'; | ||
|
||
@Pipe({ | ||
name: 'xml' | ||
}) | ||
export class XmlPipe implements PipeTransform { | ||
transform(value: string): string { | ||
return vkbeautify.xml(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters