Skip to content

Commit

Permalink
fix: resetForm
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed Sep 13, 2022
1 parent 396db18 commit 566cd14
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/workbench/browser/src/app/pages/api/api-tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ export class ApiTabService {
this.componentRef.initialModel = currentTab?.baseContent?.[contentID] || null;
this.componentRef.init();
}

updateTab(currentTab, inData) {
const model = inData.model;
console.log('=< model', model);
const contentID = currentTab.module;

//Set tabItem
Expand All @@ -166,7 +168,6 @@ export class ApiTabService {
replaceTab.extends.method = model.method;
if (currentTab.module === 'test') {
if (currentTab.pathname === '/home/api/ws/test') {
console.log('model', model);
replaceTab.extends.method = model.request.protocol?.toUpperCase();
} else {
replaceTab.extends.method = model.request.method;
Expand Down Expand Up @@ -244,6 +245,7 @@ export class ApiTabService {
* @param inData.url get component fit tab data
*/
afterContentChanged(inData: { when: 'init' | 'editing' | 'saved' | 'afterTested'; url: string; model: any }) {
console.log('model =>', inData.model);
if (!this.apiTabComponent) {
console.warn(`EO_WARNING:apiTabComponent hasn't init yet!`);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ApiTabStorageService {
}
addTab(tabItem) {
if (this.tabsByID.has(tabItem.uuid)) {
throw new Error(`EO_ERROR:can't add same id tab`);
throw new Error(`EO_ERROR: can't add same id tab`);
}
this.tabOrder.push(tabItem.uuid);
this.tabsByID.set(tabItem.uuid, tabItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class WebsocketComponent implements OnInit, OnDestroy {
async init() {
if (!this.model || isEmptyObj(this.model)) {
this.model = this.resetModel();
this.resetForm();
const id = this.route.snapshot.queryParams.uuid;
if (id && id.includes('history_')) {
const historyData: unknown = await this.testService.getHistory(Number(id.replace('history_', '')));
Expand Down Expand Up @@ -132,6 +133,7 @@ export class WebsocketComponent implements OnInit, OnDestroy {
}
this.modelChange.emit(this.model);
}

async handleConnect(bool = 'disconnect') {
const isOK = this.checkForm();
if (!isOK) {
Expand Down Expand Up @@ -271,7 +273,6 @@ export class WebsocketComponent implements OnInit, OnDestroy {
}
checkTabCanLeave = () => {
if (this.wsStatus === 'disconnect') {
// this.resetForm();
return true;
}
return new Promise((resolve) => {
Expand All @@ -285,7 +286,6 @@ export class WebsocketComponent implements OnInit, OnDestroy {
type: 'primary',
onClick: () => {
modal.destroy();
// this.resetForm();
// * disconnect ws connect
this.handleConnect('disconnect');
resolve(true);
Expand Down

0 comments on commit 566cd14

Please sign in to comment.