Skip to content

Commit

Permalink
fix: api uuid save zero
Browse files Browse the repository at this point in the history
  • Loading branch information
scarqin committed Jul 15, 2022
1 parent 4c8761b commit 25c7cc0
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/workbench/browser/src/app/pages/api/api.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
</ng-template>
<span
class="flex items-center justify-center mx-1 icon"
i18n-title
title="Enviroment Quick Look"
i18n-nzTooltipTitle
nz-tooltip nzTooltipTitle="Enviroment Quick Look"
nz-popover
[nzPopoverContent]="envParams"
nzPopoverPlacement="bottomRight"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnChanges, OnInit, Input, SimpleChanges } from '@angular/core';
import { ApiTestService } from 'eo/workbench/browser/src/app/pages/api/test/api-test.service';
import { eoFormatRequestData, formatUri } from 'eo/workbench/browser/src/app/shared/services/api-test/api-test.utils';
import { formatUri } from 'eo/workbench/browser/src/app/shared/services/api-test/api-test.utils';
import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/remote/remote.service';
import { StorageService } from 'eo/workbench/browser/src/app/shared/services/storage/storage.service';
import { copyText } from 'eo/workbench/browser/src/app/utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export class ApiEditComponent implements OnInit, OnDestroy {
//Add From Test|Copy Api
window.sessionStorage.removeItem('apiDataWillbeSave');
Object.assign(this.apiData, JSON.parse(tmpApiData));
console.log(this.apiData)
this.validateForm.patchValue(this.apiData);
} else {
//Add directly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { takeUntil, debounceTime } from 'rxjs/operators';
import { StorageService } from 'eo/workbench/browser/src/app/shared/services/storage/storage.service';
import { ActivatedRoute } from '@angular/router';
import { tree2obj } from 'eo/workbench/browser/src/app/utils/tree/tree.utils';
import { eoFormatRequestData, formatUri } from 'eo/workbench/browser/src/app/shared/services/api-test/api-test.utils';
import { formatUri } from 'eo/workbench/browser/src/app/shared/services/api-test/api-test.utils';
import { ApiTestService } from 'eo/workbench/browser/src/app/pages/api/test/api-test.service';
import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/remote/remote.service';
import { NzMessageService } from 'ng-zorro-antd/message';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class ApiTestService {
};
let result = {
...inData.testData,
responseHeaders: inData.history.response.headers,
responseHeaders: inData.history.response.headers||[],
responseBodyType: 'json',
responseBodyJsonType: 'object',
responseBody: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
(nzClick)="nzClick($event)" [nzTreeTemplate]="nzTreeTemplate"></nz-tree>
<ng-template #nzTreeTemplate let-node>
<ng-template [ngIf]="!node.isLeaf">
<span class="text-xs">{{ node.title }}</span>
<span class="text-sm">{{ node.title }}</span>
</ng-template>
<ng-template [ngIf]="node.isLeaf">
<div (click)="insertCode(node)">
<span class="text-sm text-blue-400">{{ node.title }}</span>
<span class="text-xs text-blue-400">{{ node.title }}</span>
<ng-container *ngIf="node.origin.note">
<span [nzTooltipTitle]="titleTemplate" [nzTooltipPlacement]="['topLeft', 'leftTop']" class="text-blue-400"
nzTooltipColor="black" (click)="insertCode(node)" nz-tooltip>
nzTooltipColor="black" nz-tooltip>
[?]
</span>
<ng-template #titleTemplate let-thing>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class ApiScriptComponent implements OnInit {
}

insertCode = (event) => {
console.log('isertCode',event)
const { value } = event.origin;
this.eoEditor.handleInsert(value);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
import { Component, OnInit } from '@angular/core';
import { ApiTestService } from 'eo/workbench/browser/src/app/pages/api/test/api-test.service';
import { it_IT } from 'ng-zorro-antd/i18n';
import { StorageRes, StorageResStatus } from '../../../shared/services/storage/index.model';
import { Environment, StorageRes, StorageResStatus } from '../../../shared/services/storage/index.model';
import { StorageService } from '../../services/storage';

@Component({
selector: 'env-list',
template: ` <div style="width:300px">
<span class="text-gray-400" *ngIf="envParams.length">Environment variable</span>
<!-- <span class="my-2">{{ item.name }}</span> -->
<div *ngFor="let it of envParams" class="flex items-center justify-between h-8">
<span class="px-1 w-1/3 text-gray-500 text-ellipsis overflow-hidden" [title]="it.name">{{ it.name }}</span>
<span class="px-1 w-2/3 text-gray-500 text-ellipsis overflow-hidden" [title]="it.value">{{ it.value }}</span>
</div>
<span class="text-gray-400" *ngIf="gloablParams.length">Global variable</span>
<span class="text-gray-400" i18n>Global variable</span>
<div *ngFor="let it of gloablParams" class="flex items-center justify-between h-8">
<span class="px-1 w-1/3 text-gray-500 text-ellipsis overflow-hidden" [title]="it.name">{{ it.name }}</span>
<span class="px-1 w-2/3 text-gray-500 text-ellipsis overflow-hidden" [title]="it.value">{{ it.value }}</span>
</div>
<p *ngIf="!gloablParams.length" class="text-gray-500" i18n>No Global variables</p>
<div class="py-2.5" *ngIf="env.uuid">
<span class="text-gray-400" i18n>Environment Host</span>
<div>
<p class="text-gray-500 text-ellipsis overflow-hidden" class="h-8">{{ env.hostUri }}</p>
</div>
<span class="text-gray-400" *ngIf="env.parameters?.length" i18n>Environment variable</span>
<div *ngFor="let it of env.parameters" class="flex items-center justify-between h-8">
<span class="px-1 w-1/3 text-gray-500 text-ellipsis overflow-hidden" [title]="it.name">{{ it.name }}</span>
<span class="px-1 w-2/3 text-gray-500 text-ellipsis overflow-hidden" [title]="it.value">{{ it.value }}</span>
</div>
</div>
</div>`,
styleUrls: [],
})
export class EnvListComponent implements OnInit {
envParams: any = [];
env: Environment | any = {};
gloablParams: any = [];
constructor(private storage: StorageService, private apiTest: ApiTestService) {}
async ngOnInit() {
this.gloablParams = this.getGlobalParams();
const uuid = Number(localStorage.getItem('env:selected')) || null;
if (uuid == null) {
this.envParams = [];
return;
}
const envList = (await this.getAllEnv()) as [];
const [env]: any[] = envList.filter((it: any) => it.uuid === uuid);
this.envParams = env.parameters;
const envList: any = await this.getAllEnv();
this.env = envList.find((it: any) => it.uuid === uuid);
}
getAllEnv(uuid?: number) {
const projectID = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const eoFormatRequestData = (
};
const result: TestLocalNodeData = {
lang: opts.lang,
globals:opts.globals,
URL: formatUri(data.uri, data.restParams),
method: data.method,
methodType: METHOD.indexOf(data.method).toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class IndexedDBStorage extends Dexie implements StorageInterface {
if (!item.createdAt) {
item.createdAt = new Date();
}
delete item.uuid;
item.updatedAt = item.createdAt;
const result = table.add(item);
return new Observable((obs) => {
Expand Down
2 changes: 2 additions & 0 deletions src/workbench/browser/src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { ApiScriptComponent } from './components/api-script/api-script.component
import { EouiModule } from 'eo/workbench/browser/src/app/eoui/eoui.module';
import { NzTreeModule } from 'ng-zorro-antd/tree';
import { EnvListComponent } from 'eo/workbench/browser/src/app/shared/components/env-list/env-list.component';
import { NzEmptyModule } from 'ng-zorro-antd/empty';

const COMPONENTS = [
ToolbarComponent,
Expand All @@ -52,6 +53,7 @@ const COMPONENTS = [
NzSpinModule,
NzCardModule,
NzNotificationModule,
NzEmptyModule,
NzMessageModule,
NzDescriptionsModule,
EoIconparkIconModule,
Expand Down
1 change: 0 additions & 1 deletion src/workbench/browser/src/app/utils/tree/tree.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export const tree2obj = (list: any[] = [], opts: TreeToObjOpts = {}, initObj = {
tree2obj(curr[childKey], opts, (prev[curr[key]] = {}));
}
} catch (error) {
console.error(error);
console.log('error==>', `prev: ${prev} == curr: ${curr} == key: ${key}`);
}
return prev;
Expand Down
13 changes: 13 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"rewrites": [
{
"source": "/:path((?!en/).*)",
"destination": "/en/:path*"
},
{
"source": "/:path((?!zh/).*)",
"destination": "/zh/:path*"
}
]
}

0 comments on commit 25c7cc0

Please sign in to comment.