Skip to content

Commit

Permalink
fix: response of test result should auto format
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Aug 5, 2022
1 parent 655d18a commit fa0d6a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import { Component, Input, OnInit, OnChanges } from '@angular/core';
import { Component, Input, OnInit, OnChanges, ViewChild } from '@angular/core';
import { getBlobUrl } from 'eo/workbench/browser/src/app/utils';
import { ApiTestHistoryResponse } from '../../../../shared/services/storage/index.model';
import { ApiTestService } from '../api-test.service';
import { EoMonacoEditorComponent } from 'eo/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component';

@Component({
selector: 'eo-api-test-result-response',
templateUrl: './api-test-result-response.component.html',
styleUrls: ['./api-test-result-response.component.scss'],
})
export class ApiTestResultResponseComponent implements OnInit, OnChanges {
@Input() model: any | ApiTestHistoryResponse;
@ViewChild(EoMonacoEditorComponent, { static: false }) eoEditor?: EoMonacoEditorComponent;
codeStatus: { status: string; cap: number; class: string };
size: string;
blobUrl='';
blobUrl = '';
responseIsImg = false;
constructor(private apiTest: ApiTestService) {}
ngOnChanges(changes) {
if (changes.model&&this.model) {
if (changes.model && this.model) {
this.codeStatus = this.apiTest.getHTTPStatus(this.model.statusCode);
this.eoEditor?.formatCode();
}
}
ngOnInit(): void {}
downloadResponseText() {
this.blobUrl=getBlobUrl(this.model.body, this.model.contentType);
this.blobUrl = getBlobUrl(this.model.body, this.model.contentType);
const blobFileName = decodeURI(this.model.blobFileName);
const tmpAElem = document.createElement('a');
if ('download' in tmpAElem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges
};
formatCode() {
return new Promise<string>((resolve) => {
setTimeout(async () => {
requestAnimationFrame(async () => {
this.codeEdtor.updateOptions({ readOnly: false });
await this.codeEdtor?.getAction('editor.action.formatDocument').run();
this.codeEdtor.updateOptions({ readOnly: this.config.readOnly });
Expand Down

0 comments on commit fa0d6a0

Please sign in to comment.