Skip to content

Commit

Permalink
fix: eo-editor view not reflesh
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Jul 15, 2022
1 parent 23c74b1 commit 2805ce5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
width: 100%;
display: flex;
align-items: center;
padding-left: 10px;
nz-select {
width: 90px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export class EoEditorComponent implements AfterViewInit, OnInit, OnChanges {
this.codeChange.emit(this.code);
}, 0);
}
rerenderAce() {
this.aceRef.directiveRef.ace().renderer.updateFull(true);
}
formatCode(code, type) {
if (type === 'json') {
return beautifier.js(code, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</form>
<div class="scroll_container">
<!-- Request Info -->
<nz-tabset [nzTabBarStyle]="{ 'padding-left': '10px' }" [nzAnimated]="false" [nzSelectedIndex]="1">
<nz-tabset [nzTabBarStyle]="{ 'padding-left': '10px' }" [nzAnimated]="false" [(nzSelectedIndex)]="nzSelectedIndex">
<!-- Request Headers -->
<nz-tab [nzTitle]="headerTitleTmp" [nzForceRender]="true">
<ng-template #headerTitleTmp>
Expand Down Expand Up @@ -68,25 +68,27 @@
<nz-tab [nzTitle]="restTitleTmp" [nzForceRender]="true">
<ng-template #restTitleTmp>
<span i18n>REST</span>
<span class="eo-tab-icon ml-[4px]" *ngIf="bindGetApiParamNum(apiData.restParams)">{{
<span class="eo-tab-icon ml-[4px] " *ngIf="bindGetApiParamNum(apiData.restParams)">{{
apiData.restParams | apiParamsNum
}}</span>
</ng-template>
<eo-api-test-rest class="eo_theme_iblock bbd" [model]="apiData.restParams"></eo-api-test-rest>
</nz-tab>
<nz-tab [nzTitle]="preScriptTitleTmp" [nzForceRender]="true">
<ng-template #preScriptTitleTmp>
Pre-request Script
<span i18n>Pre-request Script</span>
<span class="iconfont icon-circle eo-tab-theme-icon" *ngIf="beforeScript?.trim()"></span>
</ng-template>
<eo-api-script [(code)]="beforeScript" [treeData]="BEFORE_DATA" [completions]="beforeScriptCompletions"
class="eo_theme_iblock bbd"></eo-api-script>
<eo-api-script *ngIf="nzSelectedIndex === 4" [(code)]="beforeScript" [treeData]="BEFORE_DATA"
[completions]="beforeScriptCompletions" class="eo_theme_iblock bbd"></eo-api-script>
</nz-tab>
<nz-tab [nzTitle]="suffixScriptTitleTmp" [nzForceRender]="true">
<ng-template #suffixScriptTitleTmp>
After-response Script
<span i18n>After-response Script</span>
<span class="iconfont icon-circle eo-tab-theme-icon" *ngIf="afterScript?.trim()"></span>
</ng-template>
<eo-api-script [(code)]="afterScript" [treeData]="AFTER_DATA" [completions]="afterScriptCompletions"
class="eo_theme_iblock bbd"></eo-api-script>
<eo-api-script *ngIf="nzSelectedIndex === 5" [(code)]="afterScript" [treeData]="AFTER_DATA"
[completions]="afterScriptCompletions" class="eo_theme_iblock bbd"></eo-api-script>
</nz-tab>
</nz-tabset>
<!-- Response -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class ApiTestComponent implements OnInit, OnDestroy {
afterScriptCompletions = afterScriptCompletions;
beforeScript = '';
afterScript = '';
nzSelectedIndex = 1;
status: 'start' | 'testing' | 'tested' = 'start';
waitSeconds = 0;
tabIndexRes = 0;
Expand Down Expand Up @@ -106,8 +107,7 @@ export class ApiTestComponent implements OnInit, OnDestroy {
console.log('restoreHistory', result);
//restore request
this.apiData = result.testData;
this.beforeScript = result.response?.beforeScript;
this.afterScript = result.response?.afterScript;
this.setScriptsByHistory(result.response);
this.changeUri();
//restore response
this.tabIndexRes = 0;
Expand All @@ -121,6 +121,10 @@ export class ApiTestComponent implements OnInit, OnDestroy {
}
});
}
setScriptsByHistory(response) {
this.beforeScript = response?.beforeScript || '';
this.afterScript = response?.afterScript || '';
}
loadTestHistory(id) {
if (!id) {
this.beforeScript = '';
Expand Down Expand Up @@ -278,6 +282,7 @@ export class ApiTestComponent implements OnInit, OnDestroy {
const tabData = this.apiTab.tabCache[this.apiTab.tabID];
this.apiData = tabData.apiData;
this.testResult = tabData.testResult;
this.setScriptsByHistory(tabData.testResult);
return;
}
if (!id) {
Expand Down

0 comments on commit 2805ce5

Please sign in to comment.