-
+
{{ origin.title }}
+
+
+
+ -
+ {{ item.title }}
+
+
+
+
-
-
-
- -
- {{ item.title }}
-
-
-
-
diff --git a/src/browser/src/app/pages/workspace/project/api/components/group/api-group-tree.component.ts b/src/browser/src/app/pages/workspace/project/api/components/group/api-group-tree.component.ts
index 5cb96853..7551a238 100644
--- a/src/browser/src/app/pages/workspace/project/api/components/group/api-group-tree.component.ts
+++ b/src/browser/src/app/pages/workspace/project/api/components/group/api-group-tree.component.ts
@@ -2,6 +2,7 @@ import { Component, Inject, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { EoNgFeedbackMessageService } from 'eo-ng-feedback';
import { action, autorun, reaction, toJS } from 'mobx';
+import { NzContextMenuService, NzDropdownMenuComponent } from 'ng-zorro-antd/dropdown';
import { NzTreeComponent, NzFormatEmitEvent, NzTreeNodeOptions, NzTreeNode, NzFormatBeforeDropEvent } from 'ng-zorro-antd/tree';
import { PageUniqueName } from 'pc/browser/src/app/pages/workspace/project/api/api-tab.service';
import { ApiGroupService } from 'pc/browser/src/app/pages/workspace/project/api/components/group/api-group.service';
@@ -93,11 +94,14 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
private feedback: EoNgFeedbackMessageService,
private router: Router,
private route: ActivatedRoute,
+ private nzContextMenuService: NzContextMenuService,
@Inject(BASIC_TABS_INFO) public tabsConfig: TabsConfig
) {
this.operateByModule = this.getGroupOperate();
}
-
+ contextMenu($event: MouseEvent, menu: NzDropdownMenuComponent): void {
+ this.nzContextMenuService.create($event, menu);
+ }
searchFunc = (node: NzTreeNodeOptions) => {
const { title } = node;
const uri = node.relationInfo?.uri;
diff --git a/src/browser/src/app/pages/workspace/project/api/group-edit/group.component.html b/src/browser/src/app/pages/workspace/project/api/group-edit/group.component.html
index 133f52e8..61c05425 100644
--- a/src/browser/src/app/pages/workspace/project/api/group-edit/group.component.html
+++ b/src/browser/src/app/pages/workspace/project/api/group-edit/group.component.html
@@ -20,6 +20,9 @@
+
diff --git a/src/browser/src/app/pages/workspace/project/api/group-edit/group.component.ts b/src/browser/src/app/pages/workspace/project/api/group-edit/group.component.ts
index cc437a92..0abf02c5 100644
--- a/src/browser/src/app/pages/workspace/project/api/group-edit/group.component.ts
+++ b/src/browser/src/app/pages/workspace/project/api/group-edit/group.component.ts
@@ -4,6 +4,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { EoNgFeedbackMessageService } from 'eo-ng-feedback';
import { EditTabViewComponent } from 'pc/browser/src/app/components/eo-ui/tab/tab.model';
import { AuthorizationExtensionFormComponent } from 'pc/browser/src/app/pages/workspace/project/api/components/authorization-extension-form/authorization-extension-form.component';
+import { ApiGroupService } from 'pc/browser/src/app/pages/workspace/project/api/components/group/api-group.service';
import { AuthTypeValue } from 'pc/browser/src/app/pages/workspace/project/api/constants/auth.model';
import { ApiService } from 'pc/browser/src/app/services/storage/api.service';
import { Group } from 'pc/browser/src/app/services/storage/db/models';
@@ -39,6 +40,7 @@ export class GroupComponent implements OnDestroy, EditTabViewComponent {
private effect: ApiEffectService,
public globalStore: StoreService,
private fb: FormBuilder,
+ public group: ApiGroupService,
private feedback: EoNgFeedbackMessageService,
private route: ActivatedRoute,
private router: Router,
diff --git a/src/browser/src/app/pages/workspace/project/api/http/mock/api-mock.service.ts b/src/browser/src/app/pages/workspace/project/api/http/mock/api-mock.service.ts
index 4a4ea55a..574a595f 100644
--- a/src/browser/src/app/pages/workspace/project/api/http/mock/api-mock.service.ts
+++ b/src/browser/src/app/pages/workspace/project/api/http/mock/api-mock.service.ts
@@ -7,6 +7,7 @@ import { ApiTestUtilService } from 'pc/browser/src/app/pages/workspace/project/a
import { ProjectApiService } from 'pc/browser/src/app/pages/workspace/project/api/service/project-api.service';
import { ApiEffectService } from 'pc/browser/src/app/pages/workspace/project/api/store/api-effect.service';
import { syncUrlAndQuery } from 'pc/browser/src/app/pages/workspace/project/api/utils/api.utils';
+import { ModalService } from 'pc/browser/src/app/services/modal.service';
import { ApiService } from 'pc/browser/src/app/services/storage/api.service';
import { MockCreateWay } from 'pc/browser/src/app/services/storage/db/models';
import { ApiData } from 'pc/browser/src/app/services/storage/db/models/apiData';
@@ -27,6 +28,7 @@ export class ApiMockService {
private message: EoNgFeedbackMessageService,
private apiEffect: ApiEffectService,
private projectApi: ProjectApiService,
+ private modalService: ModalService,
@Inject(BASIC_TABS_INFO) public tabsConfig: TabsConfig
) {
this.mockOperateUrl = this.tabsConfig.pathByName[PageUniqueName.HttpMock];
@@ -130,13 +132,19 @@ export class ApiMockService {
});
}
async toDelete(id: number) {
- const data = await this.deleteMock(id);
- if (!data) {
- this.message.error($localize`Failed to delete`);
- return;
- }
- this.message.success($localize`Successfully deleted`);
- this.apiEffect.deleteMockDetail();
+ const modelRef = this.modalService.confirm({
+ nzTitle: $localize`Deletion Confirmation?`,
+ nzContent: $localize``,
+ nzOnOk: async () => {
+ const data = await this.deleteMock(id);
+ if (!data) {
+ this.message.error($localize`Failed to delete`);
+ return;
+ }
+ this.message.success($localize`Successfully deleted`);
+ this.apiEffect.deleteMockDetail();
+ }
+ });
}
async copy(mock_id: string) {
const [res] = await this.api.api_mockDetail({ id: mock_id });
diff --git a/src/browser/src/app/pages/workspace/project/api/http/test/api-test-ui.component.ts b/src/browser/src/app/pages/workspace/project/api/http/test/api-test-ui.component.ts
index 6f447c21..21ffc229 100644
--- a/src/browser/src/app/pages/workspace/project/api/http/test/api-test-ui.component.ts
+++ b/src/browser/src/app/pages/workspace/project/api/http/test/api-test-ui.component.ts
@@ -1,6 +1,5 @@
import {
Component,
- OnInit,
OnDestroy,
ChangeDetectorRef,
Input,
@@ -9,13 +8,13 @@ import {
ViewChild,
ElementRef,
AfterViewInit,
- HostListener,
OnChanges,
Inject,
TemplateRef
} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
+import { EoNgFeedbackMessageService } from 'eo-ng-feedback';
import { isEmpty, isEqual } from 'lodash-es';
import { autorun, reaction } from 'mobx';
import { NzResizeEvent } from 'ng-zorro-antd/resizable';
@@ -51,14 +50,7 @@ import { interval, Subscription, Subject } from 'rxjs';
import { takeUntil, distinctUntilChanged, takeWhile } from 'rxjs/operators';
import { enumsToArr, JSONParse } from '../../../../../../shared/utils/index.utils';
-import {
- ApiBodyType,
- ApiParamsType,
- BASIC_TABS_INFO,
- BodyContentType as ContentTypeEnum,
- RequestMethod,
- TabsConfig
-} from '../../constants/api.model';
+import { ApiBodyType, ApiParamsType, BASIC_TABS_INFO, RequestMethod, TabsConfig } from '../../constants/api.model';
import { ApiParamsNumPipe } from '../../pipe/api-param-num.pipe';
import { ApiTestUtilService } from '../../service/api-test-util.service';
import { TestServerService } from '../../service/test-server/test-server.service';
@@ -144,6 +136,7 @@ export class ApiTestUiComponent implements AfterViewInit, OnDestroy, OnChanges {
private project: ProjectApiService,
private elementRef: ElementRef,
private apiEdit: ApiEditUtilService,
+ private feedback: EoNgFeedbackMessageService,
private trace: TraceService,
@Inject(BASIC_TABS_INFO) public tabsConfig: TabsConfig
) {
@@ -275,12 +268,24 @@ export class ApiTestUiComponent implements AfterViewInit, OnDestroy, OnChanges {
private fixedHeaderAndContentType() {
const bodyType = this.model.request?.apiAttrInfo?.contentType;
if (bodyType !== ApiBodyType.Binary) {
+ //* User customer headers first
+ const userCustomerHeader = this.model.request.requestParams.headerParams.find(
+ //@ts-ignore
+ val => val.name.toLowerCase() === 'content-type' && !val.disableEdit
+ );
+ if (userCustomerHeader) {
+ const contentType = this.getContentTypeByBodyType();
+ this.model.userSelectedContentType = contentType as ContentType;
+ return;
+ }
+
+ //* app set header default
const contentType = this.getContentTypeByBodyType();
this.model.request.requestParams.headerParams = this.apiTestUtil.addOrReplaceContentType(
contentType,
this.model.request.requestParams.headerParams
);
- this.model.userSelectedContentType ??= contentType as ContentType;
+ this.model.userSelectedContentType = contentType as ContentType;
return;
}
@@ -294,6 +299,7 @@ export class ApiTestUiComponent implements AfterViewInit, OnDestroy, OnChanges {
}
changeBodyType($event) {
StorageUtil.set('api_test_body_type', $event);
+ this.fixedHeaderAndContentType();
}
handleBottomTabSelect(tab) {
if (tab.index === 2) {
@@ -474,9 +480,14 @@ export class ApiTestUiComponent implements AfterViewInit, OnDestroy, OnChanges {
this.validateForm = this.fb.group(controls);
this.validateForm.valueChanges.pipe(takeUntil(this.destroy$)).subscribe(x => {
- //Watch uri changes
+ //Import curl when uri match
if (x?.uri?.trim().startsWith('curl')) {
- this.model = this.apiTestUtil.getTestDataFromCurl(x.uri, this.model);
+ const [result, err] = this.apiTestUtil.getTestDataFromCurl(x.uri, this.model);
+ if (err) {
+ this.feedback.error($localize`Curl text error: ${err}`);
+ return;
+ }
+ this.model = result;
this.validateForm.patchValue({
uri: this.model.request.uri,
method: this.model.request.apiAttrInfo?.requestMethod
diff --git a/src/browser/src/app/pages/workspace/project/api/http/test/api-test.component.html b/src/browser/src/app/pages/workspace/project/api/http/test/api-test.component.html
index 6265307d..e8497379 100644
--- a/src/browser/src/app/pages/workspace/project/api/http/test/api-test.component.html
+++ b/src/browser/src/app/pages/workspace/project/api/http/test/api-test.component.html
@@ -1,8 +1,8 @@