From 5a211b4cf373f40bb67d362131ba4fb43392a3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E9=B9=B0?= <17kungfuboy@gmail.com> Date: Wed, 13 Jul 2022 16:11:25 +0800 Subject: [PATCH] feat: show env params --- .../src/app/pages/api/api.component.html | 12 +- .../src/app/pages/api/api.component.scss | 13 +++ .../src/app/pages/api/api.component.ts | 12 ++ .../app/pages/navbar/navbar.component.html | 43 +++++-- .../components/env-list/env-list.component.ts | 41 +++++++ .../shared/components/env/env.component.html | 33 ++++-- .../browser/src/app/shared/shared.module.ts | 3 +- src/workbench/browser/src/index.html | 107 +++++++++--------- 8 files changed, 184 insertions(+), 80 deletions(-) create mode 100644 src/workbench/browser/src/app/shared/components/env-list/env-list.component.ts diff --git a/src/workbench/browser/src/app/pages/api/api.component.html b/src/workbench/browser/src/app/pages/api/api.component.html index 8f452e9b..9c7f63ae 100644 --- a/src/workbench/browser/src/app/pages/api/api.component.html +++ b/src/workbench/browser/src/app/pages/api/api.component.html @@ -52,8 +52,18 @@ - Manage Environment + Manage Environment + + +
diff --git a/src/workbench/browser/src/app/pages/api/api.component.scss b/src/workbench/browser/src/app/pages/api/api.component.scss index 1c4dab65..0e4b5439 100644 --- a/src/workbench/browser/src/app/pages/api/api.component.scss +++ b/src/workbench/browser/src/app/pages/api/api.component.scss @@ -93,3 +93,16 @@ nz-divider { color: #00785a; } +.icon { + -webkit-app-region: no-drag; + width: 30px; + height: 30px; + font-size: 1.5em; + color: rgba(0,0,0,0.5); + cursor: pointer; + border-radius: 3px; + transition: all .4s ease; + &:hover { + background-color: rgba(0,0,0,0.05); + } +} diff --git a/src/workbench/browser/src/app/pages/api/api.component.ts b/src/workbench/browser/src/app/pages/api/api.component.ts index 595cb1fc..26e04ee9 100644 --- a/src/workbench/browser/src/app/pages/api/api.component.ts +++ b/src/workbench/browser/src/app/pages/api/api.component.ts @@ -7,7 +7,10 @@ import { Message, MessageService } from '../../shared/services/message'; import { ApiService } from './api.service'; import { StorageService } from '../../shared/services/storage'; import { Change } from '../../shared/store/env.state'; +import { NzModalRef } from 'ng-zorro-antd/modal'; +import { ModalService } from '../../shared/services/modal.service'; import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/remote/remote.service'; +import { EnvListComponent } from 'eo/workbench/browser/src/app/shared/components/env-list/env-list.component'; @Component({ selector: 'eo-api', @@ -47,6 +50,7 @@ export class ApiComponent implements OnInit, OnDestroy { private messageService: MessageService, private storage: StorageService, private remoteService: RemoteService, + private modalService: ModalService, private store: Store ) {} @@ -165,5 +169,13 @@ export class ApiComponent implements OnInit, OnDestroy { }); } + handleShowEnv() { + const modal: NzModalRef = this.modalService.create({ + nzTitle: 'Environment', + nzContent: EnvListComponent, + nzClosable: true, + nzFooter: null, + }); + } handleEnvSelectStatus(event: boolean) {} } diff --git a/src/workbench/browser/src/app/pages/navbar/navbar.component.html b/src/workbench/browser/src/app/pages/navbar/navbar.component.html index 6faafc2c..b98fff4e 100644 --- a/src/workbench/browser/src/app/pages/navbar/navbar.component.html +++ b/src/workbench/browser/src/app/pages/navbar/navbar.component.html @@ -6,20 +6,24 @@
- + - - - + +
    @@ -29,15 +33,32 @@
- + - + (click)="toggleMaximize()" + > - +
diff --git a/src/workbench/browser/src/app/shared/components/env-list/env-list.component.ts b/src/workbench/browser/src/app/shared/components/env-list/env-list.component.ts new file mode 100644 index 00000000..f93672ce --- /dev/null +++ b/src/workbench/browser/src/app/shared/components/env-list/env-list.component.ts @@ -0,0 +1,41 @@ +import { Component, OnInit } from '@angular/core'; +import { it_IT } from 'ng-zorro-antd/i18n'; +import { StorageRes, StorageResStatus } from '../../../shared/services/storage/index.model'; +import { StorageService } from '../../services/storage'; + +@Component({ + selector: '', + template: ` Environment variable + +
+ {{ it.name }} + {{ it.description }} +
`, + styleUrls: [], +}) +export class EnvListComponent implements OnInit { + envParams: any = []; + constructor(private storage: StorageService) {} + async ngOnInit() { + 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); + console.log(env, envList); + this.envParams = env.parameters.filter((it: any) => it.name && it.value); + } + getAllEnv(uuid?: number) { + const projectID = 1; + return new Promise((resolve) => { + this.storage.run('environmentLoadAllByProjectID', [projectID], async (result: StorageRes) => { + if (result.status === StorageResStatus.success) { + return resolve(result.data || []); + } + return resolve([]); + }); + }); + } +} diff --git a/src/workbench/browser/src/app/shared/components/env/env.component.html b/src/workbench/browser/src/app/shared/components/env/env.component.html index 383e6509..ab69c5ad 100644 --- a/src/workbench/browser/src/app/shared/components/env/env.component.html +++ b/src/workbench/browser/src/app/shared/components/env/env.component.html @@ -1,18 +1,25 @@
Environment -
- - +
+
{{ item.name }} - - - + +
@@ -33,11 +40,13 @@

Environment variable:can be referenced by using {{ varName }} in Document or Test

- + - - + diff --git a/src/workbench/browser/src/app/shared/shared.module.ts b/src/workbench/browser/src/app/shared/shared.module.ts index 49c4e267..7ca3f25f 100644 --- a/src/workbench/browser/src/app/shared/shared.module.ts +++ b/src/workbench/browser/src/app/shared/shared.module.ts @@ -25,6 +25,7 @@ import { EoIconparkIconModule } from 'eo/workbench/browser/src/app/eoui/iconpark import { ApiScriptComponent } from './components/api-script/api-script.component'; import { EouiModule } from 'eo/workbench/browser/src/app/eoui/eoui.module'; import { NzTreeViewModule } from 'ng-zorro-antd/tree-view'; +import { EnvListComponent } from 'eo/workbench/browser/src/app/shared/components/env-list/env-list.component'; const COMPONENTS = [ ToolbarComponent, @@ -54,7 +55,7 @@ const COMPONENTS = [ EouiModule, NzTreeViewModule, ], - declarations: [WebviewDirective, ...COMPONENTS, ApiParamsNumPipe, PageBlankComponent], + declarations: [WebviewDirective, ...COMPONENTS, ApiParamsNumPipe, PageBlankComponent, EnvListComponent], providers: [ModalService], exports: [WebviewDirective, ...COMPONENTS, ApiParamsNumPipe, EoIconparkIconModule], }) diff --git a/src/workbench/browser/src/index.html b/src/workbench/browser/src/index.html index 5841bbc0..fdfa9c90 100644 --- a/src/workbench/browser/src/index.html +++ b/src/workbench/browser/src/index.html @@ -1,62 +1,59 @@ + + + Eoapi + + + + + + + - - - Eoapi - - - - - - - - - - -
- -
- - - - - - + + +
+ +
+ + + + + + +
-
- -
- - + .loading_container { + position: absolute; + top: 40%; + left: 50%; + transform: translateX(-50%); + } + .loading_container img { + width: 200px; + } +