Skip to content

Commit

Permalink
fix: swtich data source tips
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Aug 1, 2022
1 parent f67f8b5 commit 2b13dc6
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<nz-form-item>
<nz-form-label i18n nzFor="currentEditMock.response">Response</nz-form-label>
<nz-form-control>
<eo-monaco-editor [(code)]="responseStr" (codeChange)="rawDataChange()"
<eo-monaco-editor [(code)]="responseStr" (codeChange)="rawDataChange()" [maxLine]="20"
[disabled]="currentEditMock.createWay === 'system'"
[eventList]="['type', 'format', 'copy', 'search', 'replace']"></eo-monaco-editor>
</nz-form-control>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges
return;
}
try {
this.$$code = JSON.stringify(val);
this.$$code = typeof val === 'string' ? val : JSON.stringify(val);
} catch {
this.$$code = String(val);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class AboutComponent implements OnInit {
}

getSystemInfo() {
const systemInfo = this.electron.ipcRenderer.sendSync('get-system-info');
return systemInfo;
const systemInfo = this.electron.ipcRenderer?.sendSync('get-system-info');
return systemInfo || {};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { NzMessageService } from 'ng-zorro-antd/message';
formControlName="eoapi-common.dataStorage"
i18n-nzPlaceHolder="@@DataSource"
nzPlaceHolder="Data Storage"
(ngModelChange)="handleSelectDataStorage($event)"
>
<nz-option nzValue="http" i18n-nzLabel="@@Remote Server" nzLabel="Remote Server"></nz-option>
<nz-option nzValue="local" i18n-nzLabel nzLabel="Localhost"></nz-option>
Expand Down Expand Up @@ -92,6 +93,15 @@ export class DataStorageComponent implements OnInit, OnChanges {
}
}

handleSelectDataStorage(val) {
if (!this.electronService.isElectron && val === 'http') {
this.validateForm.controls['eoapi-common.dataStorage'].setValue('local');
return this.message.error(
$localize`Only the client can connect to the remote server. You need to download the client first.`
);
}
}

/**
* 测试远程服务器地址是否可用
*/
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { FormGroup } from '@angular/forms';
import { SelectionModel } from '@angular/cdk/collections';
import { FlatTreeControl } from '@angular/cdk/tree';
import { NzTreeFlatDataSource, NzTreeFlattener } from 'ng-zorro-antd/tree-view';
import { eoapiSettings } from './eoapi-settings/';
import { Message, MessageService } from '../../../shared/services/message';
import { Subject, takeUntil, debounceTime } from 'rxjs';
import { Subject, takeUntil } from 'rxjs';
import { NzMessageService } from 'ng-zorro-antd/message';
import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/remote/remote.service';
import { SettingService } from 'eo/workbench/browser/src/app/core/services/settings/settings.service';
import { Router } from '@angular/router';
import { debounce } from 'eo/workbench/browser/src/app/utils';

interface TreeNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } fr
import { Injectable } from '@angular/core';
import { SettingService } from 'eo/workbench/browser/src/app/core/services/settings/settings.service';
import { filter, map, Observable } from 'rxjs';
import { uniqueSlash } from '../../../../../utils/api';
const protocolReg = new RegExp('^(http|https)://');

// implements StorageInterface
Expand All @@ -10,7 +11,7 @@ export class BaseUrlInterceptor extends SettingService implements HttpIntercepto
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const { url = '', token = '' } = this.getConfiguration('eoapi-common.remoteServer') || {};
req = req.clone({
url: protocolReg.test(req.url) ? req.url : url + req.url,
url: uniqueSlash(protocolReg.test(req.url) ? req.url : url + req.url),
headers: req.headers.append('x-api-key', token),
});

Expand Down
5 changes: 4 additions & 1 deletion src/workbench/browser/src/app/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
* @param url
* @returns
*/
export const getRest: (url: string) => string[] = (url) => [...url.replace(/{{(.*?)}}/g, '').matchAll(/{(.*?)}/g)].map((val) => val[1]);
export const getRest: (url: string) => string[] = (url) =>
[...url.replace(/{{(.*?)}}/g, '').matchAll(/{(.*?)}/g)].map((val) => val[1]);

export const uniqueSlash = (path: string) => path.replace(/(?<!:)\/{2,}/g, '/');

0 comments on commit 2b13dc6

Please sign in to comment.