Skip to content

Commit

Permalink
fix: reflesh tab no reflesh data
Browse files Browse the repository at this point in the history
  • Loading branch information
scarqin committed Jan 18, 2022
1 parent 86dc5f7 commit 27eff5e
Show file tree
Hide file tree
Showing 48 changed files with 326 additions and 478 deletions.
2 changes: 1 addition & 1 deletion app/request/libs/apiUtil.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @name 返回通用方法
* @author 广州银云信息科技有限公司
* @author EOAPI
*/
let _LIB_WORKER_THREAD = require('./exec_worker_thread');
let CryptoJS = require('crypto-js');
Expand Down
2 changes: 1 addition & 1 deletion app/request/libs/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @name 通用方法
* @author 广州银云信息科技有限公司
* @author EOAPI
*/
'use strict';
let _LibsDataConstructor = new (require('./data_constructor').core)();
Expand Down
2 changes: 1 addition & 1 deletion app/request/libs/data_constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';
/**
* @name 信息构造器类
* @author 广州银云信息科技有限公司
* @author EOAPI
*/
class main {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion app/request/libs/http.package.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
setDefaultRequestHeader(inputHeaderObj = {}, inputOptions = {}) {
let TMP_DEAFULT_HEADER_OBJ = {
"User-Agent": "Eolink",
"User-Agent": "Eoapi",
"Accept":"*/*"
};
if (inputOptions.sendNocacheToken) {
Expand Down
2 changes: 1 addition & 1 deletion app/request/libs/vm2/lib/contextify.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ BufferMock.allocUnsafeSlow = function allocUnsafeSlow(size) {
};
/**
* start
* @author 广州银云信息科技有限公司
* @author EOAPI
* @desc Buffer默认取原始的Buffer,不做安全过滤,不能随意更改,会导致脚本步骤crypto执行错误
*/
const LocalBuffer = global.Buffer = Contextify.readonly(host.Buffer, BufferMock);
Expand Down
326 changes: 0 additions & 326 deletions build/SetupScripts/nim/license.txt

This file was deleted.

7 changes: 7 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import { EnvState } from './shared/store/env.state';

// NG1 Upgrade
import { UpgradeModule } from '@angular/upgrade/static';

//Storage Module
import { StorageSetting } from './modules/storage/storage.config';
import { demoApi } from './storageSetting.model';

import { NzModalModule } from 'ng-zorro-antd/modal';

Expand All @@ -36,6 +39,10 @@ const storageSetting: StorageSetting = {
name: 'project',
items: [{ uuid: 1, name: 'Default' }],
},
{
name: 'apiData',
items: demoApi,
},
],
};

Expand Down
14 changes: 6 additions & 8 deletions src/app/eoui/editor/eo-editor/eo-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,12 @@ export class EoEditorComponent implements AfterViewInit, OnChanges {
}
case 'newTab':
{
if (this.code) {
const tmpNewWin = window.open();
const value = session.getValue();
const code = this.formatCode(value, this.editorType);
tmpNewWin.document.open();
tmpNewWin.document.write(code);
tmpNewWin.document.close();
}
const tmpNewWin = window.open();
const value = session.getValue();
const code = this.formatCode(value, this.editorType);
tmpNewWin.document.open();
tmpNewWin.document.write(code);
tmpNewWin.document.close();
}
break;
case 'download':
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/api/api.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<eo-env></eo-env>
</div>
</div>
<div class="flex-1 overflow-auto content-box {{ this.id ? 'has_tab_page' : '' }}">
<div class="content_container {{ this.id ? 'has_tab_page' : '' }}">
<nz-tabset class="inside_page_tab" *ngIf="this.id" nzLinkRouter>
<nz-tab>
<a *nzTabLink nz-tab-link [routerLink]="['detail']" queryParamsHandling="merge"> 文档 </a>
Expand Down
11 changes: 8 additions & 3 deletions src/app/pages/api/api.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ nz-tree {
background-color: #f0f0f0;
padding: 5px 10px 0 15px;
display: flex;
margin-bottom: -1px;
align-items: center;
justify-content: space-between;
.ant-tabs-top {
Expand Down Expand Up @@ -106,11 +107,15 @@ nz-tree {
height: 36px;
}
}
.inside_page_tab {
.ant-tabs-nav {
padding-left: 20px;
.content_container {
border-top: 1px solid var(--BORDER);
.inside_page_tab {
.ant-tabs-nav {
padding-left: 20px;
}
}
}

eo-api {
router-outlet + * {
display: block;
Expand Down
50 changes: 26 additions & 24 deletions src/app/pages/api/api.component.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
import { ActivatedRoute } from '@angular/router';

import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd/tree';
import { Message, MessageService } from '../../shared/services/message';
import { ApiTabComponent } from './tab/api-tab.component';

import { GroupService } from '../../shared/services/group/group.service';
import { NzModalService } from 'ng-zorro-antd/modal';
import { ApiDataService } from '../../shared/services/api-data/api-data.service';
import { listToTree } from '../../utils/tree';

import { GroupApiDataModel, GroupTreeItem } from '../../shared/models';
import { ApiData } from '../../shared/services/api-data/api-data.model';
import { listToTree } from '../../utils/tree';

import { of, Subject } from 'rxjs';
import { filter, switchMap, takeUntil } from 'rxjs/operators';
import { Group } from '../../shared/services/group/group.model';

import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({
selector: 'eo-api',
templateUrl: './api.component.html',
Expand Down Expand Up @@ -79,6 +78,9 @@ export class ApiComponent implements OnInit, OnDestroy {
this.groupByID = {};
this.apiDataItems = {};
this.treeItems = [];
this.getGroups();
}
getGroups() {
this.groupService.loadAllByProjectID(this.projectID).subscribe((items: Array<Group>) => {
items.forEach((item) => {
delete item.updatedAt;
Expand All @@ -91,21 +93,25 @@ export class ApiComponent implements OnInit, OnDestroy {
isLeaf: false,
});
});
this.apiDataService.loadAllByProjectID(this.projectID).subscribe((items: Array<ApiData>) => {
items.forEach((item) => {
delete item.updatedAt;
this.apiDataItems[item.uuid] = item;
this.treeItems.push({
title: item.name,
key: item.uuid,
weight: item.weight || 0,
parentID: item.groupID || 0,
method: item.method,
isLeaf: true,
});
this.getApis();
});
}
getApis() {
this.apiDataService.loadAllByProjectID(this.projectID).subscribe((items: Array<ApiData>) => {
items.forEach((item) => {
delete item.updatedAt;
this.apiDataItems[item.uuid] = item;
this.treeItems.push({
title: item.name,
key: item.uuid,
weight: item.weight || 0,
parentID: item.groupID || 0,
method: item.method,
isLeaf: true,
});
this.generateGroupTreeData();
});
this.generateGroupTreeData();
this.apiTabComponent.initTab();
});
}
/**
Expand Down Expand Up @@ -203,9 +209,9 @@ export class ApiComponent implements OnInit, OnDestroy {
* Generate group tree nodes.
*/
generateGroupTreeData(): void {
this.apiTabComponent.initTab();
this.treeItems.sort((a, b) => a.weight - b.weight);
this.treeNodes = [];
console.log('generateGroupTreeData=>',this.treeItems)
listToTree(this.treeItems, this.treeNodes, 0);
}

Expand Down Expand Up @@ -317,21 +323,17 @@ export class ApiComponent implements OnInit, OnDestroy {
this.getChildrenFromTree(this.treeItems, data, group.uuid);
if (data.group.length > 0 && data.api.length > 0) {
this.groupService.bulkRemove(data.group).subscribe((result) => {
console.log(result);
this.apiDataService.bulkRemove(data.api).subscribe((result) => {
console.log(result);
this.buildGroupTreeData();
this.messageService.send({ type: 'apiBatchDelete', data: { uuids: data.api } });
});
});
} else if (data.group.length > 0) {
this.groupService.bulkRemove(data.group).subscribe((result) => {
console.log(result);
this.buildGroupTreeData();
});
} else if (data.api.length > 0) {
this.apiDataService.bulkRemove(data.api).subscribe((result) => {
console.log(result);
this.buildGroupTreeData();
this.messageService.send({ type: 'apiBatchDelete', data: { uuids: data.api } });
});
Expand Down
1 change: 1 addition & 0 deletions src/app/pages/api/demo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion src/app/pages/api/detail/api-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div *ngIf="apiInfo.requestBody && apiInfo.requestBody.length">
<div class="api_line">
Body 请求参数<nz-tag class="ml10" nzColor="default">{{ CONST.BODY_TYPE[apiInfo.requestBodyType] }}</nz-tag>
<nz-tag nzColor="default">最外层结构为:{{ CONST.JSON_ROOT_TYPE[apiInfo.requestBodyJsonType] }}</nz-tag>
<nz-tag *ngIf="apiInfo.requestBodyType==='json'" nzColor="default">最外层结构为:{{ CONST.JSON_ROOT_TYPE[apiInfo.requestBodyJsonType] }}</nz-tag>
</div>
<eo-api-detail-body
[bodyType]="apiInfo.requestBodyType"
Expand Down
4 changes: 1 addition & 3 deletions src/app/pages/api/detail/api-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { ApiData } from '../../../shared/services/api-data/api-data.model';
import { ApiBodyType, JsonRootType } from '../../../shared/services/api-data/api-body-type';
import { ApiBodyType, JsonRootType } from '../../../shared/services/api-data/api-data.model';

import { ApiDataService } from '../../../shared/services/api-data/api-data.service';
import { treeToListHasLevel } from '../../../utils/tree';
Expand Down Expand Up @@ -30,7 +30,6 @@ export class ApiDetailComponent implements OnInit {
JSON_ROOT_TYPE: reverseObj(JsonRootType)
};
constructor(private apiService: ApiDataService, private route: ActivatedRoute) {
console.log(this.CONST.BODY_TYPE);
}
ngOnInit(): void {
this.route.queryParams.subscribe((params) => {
Expand All @@ -49,7 +48,6 @@ export class ApiDetailComponent implements OnInit {
}
});
this.apiInfo = result;
console.log(this.apiInfo);
});
}
}
2 changes: 1 addition & 1 deletion src/app/pages/api/detail/body/api-detail-body.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

import { Subject } from 'rxjs';
import { ApiEditBody } from '../../../../shared/services/api-data/api-edit-params.model';
import { ApiBodyType, JsonRootType } from '../../../../shared/services/api-data/api-body-type';
import { ApiBodyType, JsonRootType } from '../../../../shared/services/api-data/api-data.model';
import { ApiDetailService } from '../api-detail.service';
@Component({
selector: 'eo-api-detail-body',
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/api/edit/api-edit.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="p15">
<form nz-form [nzLayout]="'vertical'" [formGroup]="validateForm">
<button type="button" class="eo_theme_btn_success" (click)="saveApi()">保存</button>
<button type="button" nz-button nztype="primary" class="eo_theme_btn_success" (click)="saveApi()">保存</button>
<nz-divider></nz-divider>
<nz-form-label nzFor="uri">API Path</nz-form-label>
<nz-input-group nzCompact>
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/api/edit/api-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class ApiEditComponent implements OnInit, OnDestroy {
const treeItems: any = [
{
title: '根目录',
//actually is 0,but 0 will hidden,so use -1 replace 0
//!actually is 0,but 0 will hidden in nz component,so use -1 replace 0
key: '-1',
weight: 0,
parentID: '0',
Expand Down
2 changes: 2 additions & 0 deletions src/app/pages/api/edit/api-edit.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzTabsModule } from 'ng-zorro-antd/tabs';
import { NzRadioModule } from 'ng-zorro-antd/radio';
import { NzDividerModule } from 'ng-zorro-antd/divider';
import { NzAffixModule } from 'ng-zorro-antd/affix';

import { ApiEditComponent } from './api-edit.component';
import { ApiEditHeaderComponent } from './header/api-edit-header.component';
Expand All @@ -42,6 +43,7 @@ const NZ_COMPONETS = [
NzTabsModule,
NzRadioModule,
NzDividerModule,
NzAffixModule
];
const COMPONENTS = [
ApiEditComponent,
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/api/edit/body/api-edit-body.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ApiParamsTypeJsonOrXml,
} from '../../../../shared/services/api-data/api-edit-params.model';
import { ApiEditBody } from '../../../../shared/services/api-data/api-edit-params.model';
import { ApiBodyType, JsonRootType } from '../../../../shared/services/api-data/api-body-type';
import { ApiBodyType, JsonRootType } from '../../../../shared/services/api-data/api-data.model';
import { ApiEditService } from '../api-edit.service';
@Component({
selector: 'eo-api-edit-body',
Expand Down
11 changes: 3 additions & 8 deletions src/app/pages/api/group/tree/api-group-tree.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,11 @@
<i nz-icon nzType="caret-down" nzTheme="outline"></i>
</button>
</nz-button-group>
<!-- <button nz-button nzType="primary" nz-dropdown [nzDropdownMenu]="menu">
<i nz-icon nzType="plus"></i>
API
<i nz-icon nzType="down"></i>
</button> -->
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu>
<li nz-menu-item (click)="onClick({ event: $event, eventName: 'newApi' })">新建API</li>
<li nz-menu-item (click)="onClick({ event: $event, eventName: 'newApiTest' })">新建测试</li>
<li nz-menu-item (click)="newGroup()">新建分组</li>
<li nz-menu-item (click)="onClick({ event: $event, eventName: 'newApi' })"><a>新建API</a></li>
<li nz-menu-item (click)="onClick({ event: $event, eventName: 'newApiTest' })"><a>新建测试</a></li>
<li nz-menu-item (click)="newGroup()"><a>新建分组</a></li>
</ul>
</nz-dropdown-menu>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/app/pages/api/tab/api-tab.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<nz-tabset
[(nzSelectedIndex)]="selectedIndex"
nzType="editable-card"
Expand All @@ -9,7 +10,7 @@
*ngFor="let tab of tabs; let i = index"
nzClosable
[nzTitle]="titleTemplate"
(nzSelect)="tabSelect(tab)"
(nzSelect)="tabSelect({index:i,tab:tab})"
>
<ng-template #titleTemplate>
<span class="mr5 method_text_{{tab.method}}" *ngIf="tab.method">{{ tab.method | uppercase }}</span>
Expand All @@ -29,4 +30,4 @@
<li nz-menu-item>关闭右侧标签页</li>
</ul>
</nz-dropdown-menu>
</ng-template>
</ng-template>
10 changes: 9 additions & 1 deletion src/app/pages/api/tab/api-tab.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
eo-api-tab {
.ant-tabs-card.ant-tabs-top > .ant-tabs-nav .ant-tabs-tab {
border-radius: 6px 6px 0 0;
border: 1px solid var(--BORDER);
border-width: 1px;
border-bottom: 1px solid var(--BORDER);
}
.ant-tabs-card.ant-tabs-top > .ant-tabs-nav .ant-tabs-tab-active {
border-color: rgba($color: #000000, $alpha: 0.15);
border-bottom-color: var(--MAIN_BG);
}
.ant-tabs > .ant-tabs-nav .ant-tabs-nav-add {
border: 0 none;
}
.ant-tabs-tab {
&.ant-tabs-tab-active {
Expand Down
Loading

0 comments on commit 27eff5e

Please sign in to comment.