Skip to content

Commit

Permalink
fix: some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Aug 3, 2022
1 parent 3ca968c commit f89e4ef
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
treeNodes: GroupTreeItem[] | NzTreeNode[] | any;
fixedTreeNode: GroupTreeItem[] | NzTreeNode[] = [
{
title: $localize `:@@API Index:Index`,
title: $localize`:@@API Index:Index`,
key: 'overview',
weight: 0,
parentID: '0',
Expand Down Expand Up @@ -86,6 +86,7 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
this.treeNodes = [];
listToTree(this.treeItems, this.treeNodes, '0');
setTimeout(() => {
console.log('this.treeNodes', this.treeNodes);
this.expandGroup();
}, 0);
}
Expand Down Expand Up @@ -273,7 +274,11 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
* @param node NzTreeNode
*/
deleteGroup(node: NzTreeNode) {
this.groupModal($localize`Delete Group`, { group: this.nodeToGroup(node), treeItems: this.treeItems, action: 'delete' });
this.groupModal($localize`Delete Group`, {
group: this.nodeToGroup(node),
treeItems: this.treeItems,
action: 'delete',
});
}

/**
Expand Down Expand Up @@ -325,35 +330,53 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
if (dragNode.isLeaf) {
groupApiData.api.push({ uuid: item.key, weight: index, groupID: '0' });
} else {
groupApiData.group.push({ uuid: item.key.replace('group-', ''), weight: index, parentID: '0' });
groupApiData.group.push({ uuid: item.key, weight: index, parentID: '0' });
}
});
}
this.updateoperateApiEvent(groupApiData);
}

replaceGroupKey(key: string) {
return Number(key.replace('group-', ''));
}
/**
* Update tree items after drag.
*
* @param data GroupApiDataModel
*/
updateoperateApiEvent(data: GroupApiDataModel) {
if (data.group.length > 0) {
console.log('data.group', data.group);
this.storage.run(
'groupBulkUpdate',
[
data.group.map((val) => {
return { ...val, uuid: val.uuid.replace('group-', ''), parentID: val.parentID.replace('group-', '') };
}),
data.group.map((val) => ({
...val,
uuid: this.replaceGroupKey(val.uuid),
parentID: this.replaceGroupKey(val.parentID),
})),
],
(result: StorageRes) => {
this.buildGroupTreeData();
}
);
}
if (data.api.length > 0) {
this.storage.run('apiDataBulkUpdate', [data.api], (result: StorageRes) => {
this.buildGroupTreeData();
});
console.log('data.api', data.api);
this.storage.run(
'apiDataBulkUpdate',
[
data.api.map((n) => ({
...n,
uuid: this.replaceGroupKey(n.uuid),
groupID: this.replaceGroupKey(n.groupID),
})),
],
(result: StorageRes) => {
this.buildGroupTreeData();
}
);
}
}
private watchRouterChange() {
Expand Down
41 changes: 10 additions & 31 deletions src/workbench/browser/src/app/pages/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
</a>
</div>
<div class="flex items-center">
<span
class="flex items-center justify-center mx-1 icon"
i18n-title
title="Open Settings"
(click)="handleShowModal()"
>
<span class="flex items-center justify-center mx-1 icon" i18n-title title="Open Settings"
(click)="handleShowModal()">
<eo-iconpark-icon name="setting-two"></eo-iconpark-icon>
</span>
<!-- <span
Expand All @@ -26,40 +22,23 @@
<eo-iconpark-icon name="help"> </eo-iconpark-icon>
</span>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<ul nz-menu>
<a href="https://docs.eoapi.io" target="_blank" nz-menu-item i18n>Document</a>
<a href="https://developer.eoapi.io" target="_blank" nz-menu-item i18n>Developer Support</a>
<li nz-menu-divider></li>
<a href="https://github.com/eolinker/eoapi/issues" target="_blank" nz-menu-item i18n>Report Issue</a>
</ul>
</nz-dropdown-menu>
<div *ngIf="!OS_TYPE.includes('mac') && isElectron">
<span
nz-tooltip
i18n-nzTooltipTitle
nzTooltipTitle="Minimize"
nzTooltipPlacement="left"
class="iconfont icon-jianhao mr10 fs24 cp"
(click)="minimize()"
>
<span nz-tooltip i18n-nzTooltipTitle nzTooltipTitle="Minimize" nzTooltipPlacement="left"
class="iconfont icon-jianhao mr10 fs24 cp" (click)="minimize()">
</span>
<span
nz-tooltip
i18n-nzTooltipTitle
[nzTooltipTitle]="isMaximized ? 'Restore' : 'Maximize'"
nzTooltipPlacement="left"
class="iconfont icon-{{ isMaximized ? 'copy' : 'duoxuanweixuanzhong' }} mr10 fs24 cp"
(click)="toggleMaximize()"
>
<span nz-tooltip i18n-nzTooltipTitle [nzTooltipTitle]="isMaximized ? 'Restore' : 'Maximize'"
nzTooltipPlacement="left" class="iconfont icon-{{ isMaximized ? 'copy' : 'duoxuanweixuanzhong' }} mr10 fs24 cp"
(click)="toggleMaximize()">
</span>
<span
nz-tooltip
i18n-nzTooltipTitle
nzTooltipTitle="Close"
nzTooltipPlacement="left"
class="iconfont icon-guanbi pr15 fs24 cp"
(click)="close()"
>
<span nz-tooltip i18n-nzTooltipTitle nzTooltipTitle="Close" nzTooltipPlacement="left"
class="iconfont icon-guanbi pr15 fs24 cp" (click)="close()">
</span>
</div>
<div *ngIf="!isElectron">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { Component, OnInit, QueryList, TemplateRef, ViewChild, ViewChildren } from '@angular/core';
import { ElectronService } from '../../core/services';
import { ModuleInfo } from 'eo/platform/node/extension-manager';
import { MessageService } from '../../shared/services/message';
import { NzConfigService } from 'ng-zorro-antd/core/config';
import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/remote/remote.service';
import { ResourceInfo } from '../../shared/models/client.model';
import { NzDropdownMenuComponent } from 'ng-zorro-antd/dropdown';
@Component({
selector: 'eo-navbar',
templateUrl: './navbar.component.html',
Expand All @@ -16,6 +17,8 @@ export class NavbarComponent implements OnInit {
isSettingVisible = false;
messageTop;
@ViewChild('notificationTemplate', { static: true })
@ViewChildren(NzDropdownMenuComponent)
dropdownMenuList: QueryList<NzDropdownMenuComponent>;
notificationTemplate!: TemplateRef<{}>;
get dataSourceType() {
return this.remoteService.dataSourceType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Dexie, { Table } from 'dexie';
import { getSettings } from 'eo/workbench/browser/src/app/core/services/settings/settings.service';
import { messageService } from 'eo/workbench/browser/src/app/shared/services/message/message.service';
import { DataSourceType } from 'eo/workbench/browser/src/app/shared/services/storage/storage.service';
import { uniqueSlash } from 'eo/workbench/browser/src/app/utils/api';
import { tree2obj } from 'eo/workbench/browser/src/app/utils/tree/tree.utils';
import { Observable } from 'rxjs';
import {
Expand Down Expand Up @@ -34,7 +35,7 @@ const getApiUrl = (apiData: ApiData) => {
? window.eo?.getModuleSettings?.('eoapi-common.remoteServer.url') + '/mock/eo-1/'
: window.eo?.getMockUrl?.();

const url = new URL(`${mockUrl}/${apiData.uri}`.replace(/(?<!:)\/{2,}/g, '/'), 'https://github.com/');
const url = new URL(uniqueSlash(`${mockUrl}/${apiData.uri}`), 'https://github.com/');
// if (apiData) {
// url.searchParams.set('mockID', apiData.uuid + '');
// }
Expand Down Expand Up @@ -228,12 +229,7 @@ export class IndexedDBStorage extends Dexie implements StorageInterface {
});
// @ts-ignore
table
.bulkPut(
newItems.map((n: any) => ({
...n,
groupID: ~~n.groupID.replace('group-', ''),
}))
)
.bulkPut(newItems)
.then((result) => {
obs.next(this.resProxy({ number: result, items: newItems }));
obs.complete();
Expand Down

0 comments on commit f89e4ef

Please sign in to comment.