mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-06 20:03:05 +08:00
- 实现基于原生 DOM 事件的零渲染列宽拖拽,彻底解决卡顿与误触排序问题 - 查询编辑器集成 DataGrid,支持 SQL 结果直接编辑与事务提交 - 侧边栏新增上下文感知的 "新建查询" 快捷入口 - 优化 TabManager 渲染逻辑与全局布局,消除不必要的滚动条
137 lines
3.6 KiB
TypeScript
Executable File
137 lines
3.6 KiB
TypeScript
Executable File
export namespace connection {
|
|
|
|
export class UpdateRow {
|
|
keys: Record<string, any>;
|
|
values: Record<string, any>;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new UpdateRow(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.keys = source["keys"];
|
|
this.values = source["values"];
|
|
}
|
|
}
|
|
export class ChangeSet {
|
|
inserts: any[];
|
|
updates: UpdateRow[];
|
|
deletes: any[];
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ChangeSet(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.inserts = source["inserts"];
|
|
this.updates = this.convertValues(source["updates"], UpdateRow);
|
|
this.deletes = source["deletes"];
|
|
}
|
|
|
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
if (!a) {
|
|
return a;
|
|
}
|
|
if (a.slice && a.map) {
|
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
|
} else if ("object" === typeof a) {
|
|
if (asMap) {
|
|
for (const key of Object.keys(a)) {
|
|
a[key] = new classs(a[key]);
|
|
}
|
|
return a;
|
|
}
|
|
return new classs(a);
|
|
}
|
|
return a;
|
|
}
|
|
}
|
|
export class SSHConfig {
|
|
host: string;
|
|
port: number;
|
|
user: string;
|
|
password: string;
|
|
keyPath: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SSHConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.host = source["host"];
|
|
this.port = source["port"];
|
|
this.user = source["user"];
|
|
this.password = source["password"];
|
|
this.keyPath = source["keyPath"];
|
|
}
|
|
}
|
|
export class ConnectionConfig {
|
|
type: string;
|
|
host: string;
|
|
port: number;
|
|
user: string;
|
|
password: string;
|
|
database: string;
|
|
useSSH: boolean;
|
|
ssh: SSHConfig;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ConnectionConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.type = source["type"];
|
|
this.host = source["host"];
|
|
this.port = source["port"];
|
|
this.user = source["user"];
|
|
this.password = source["password"];
|
|
this.database = source["database"];
|
|
this.useSSH = source["useSSH"];
|
|
this.ssh = this.convertValues(source["ssh"], SSHConfig);
|
|
}
|
|
|
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
if (!a) {
|
|
return a;
|
|
}
|
|
if (a.slice && a.map) {
|
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
|
} else if ("object" === typeof a) {
|
|
if (asMap) {
|
|
for (const key of Object.keys(a)) {
|
|
a[key] = new classs(a[key]);
|
|
}
|
|
return a;
|
|
}
|
|
return new classs(a);
|
|
}
|
|
return a;
|
|
}
|
|
}
|
|
export class QueryResult {
|
|
success: boolean;
|
|
message: string;
|
|
data: any;
|
|
fields?: string[];
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new QueryResult(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.success = source["success"];
|
|
this.message = source["message"];
|
|
this.data = source["data"];
|
|
this.fields = source["fields"];
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|