chore: apply prettier on all files (#8)
* chore: apply prettier on all files
* chore: add prettier npm script
* Update .prettierrc
Co-authored-by: Axel Cocat <ax.cocat@gmail.com>
* Update .prettierignore
Co-authored-by: Axel Cocat <ax.cocat@gmail.com>
* Update .prettierignore
Co-authored-by: Axel Cocat <ax.cocat@gmail.com>
* Update .prettierignore
Co-authored-by: Axel Cocat <ax.cocat@gmail.com>
* chore: apply prettier with new conf
* Revert "chore: apply prettier with new conf"
This reverts commit db2a04c03f.
* chore: apply prettier correctly
* chore: update .prettierignore
* chore: restore viewer.min.js minification
* chore: apply again prettier
Co-authored-by: Stefano Borzi <stefano.borzi@fedex.com>
Co-authored-by: Axel Cocat <ax.cocat@gmail.com>
This commit is contained in:
parent
fe21209817
commit
8331e4dd73
15 changed files with 504 additions and 228 deletions
|
|
@ -38,22 +38,22 @@ export class DataTablesSsp {
|
|||
private start: number;
|
||||
private length: number;
|
||||
private _order: {
|
||||
column: number,
|
||||
dir: string,
|
||||
column: number;
|
||||
dir: string;
|
||||
}[];
|
||||
private columns: {
|
||||
data: number,
|
||||
name: string,
|
||||
searchable: boolean,
|
||||
orderable: boolean,
|
||||
data: number;
|
||||
name: string;
|
||||
searchable: boolean;
|
||||
orderable: boolean;
|
||||
search: {
|
||||
value: string,
|
||||
regex: boolean,
|
||||
}
|
||||
value: string;
|
||||
regex: boolean;
|
||||
};
|
||||
}[];
|
||||
private search: {
|
||||
value: string,
|
||||
regex: boolean,
|
||||
value: string;
|
||||
regex: boolean;
|
||||
};
|
||||
|
||||
private wheres: string[] = [];
|
||||
|
|
@ -69,18 +69,18 @@ export class DataTablesSsp {
|
|||
this.start = parseInt(query.start as string, 10);
|
||||
this.length = parseInt(query.length as string, 10);
|
||||
this.draw = parseInt(query.draw as string, 10);
|
||||
this._order = (query.order as { column: string, dir: string }[])
|
||||
.map(order => { return { column: parseInt(order.column, 10), dir: order.dir, }; });
|
||||
this.columns = (query.columns as { data: string, name: string, searchable: string, orderable: string, search: any }[])
|
||||
.map(column => {
|
||||
return {
|
||||
data: parseInt(column.data, 10),
|
||||
name: column.name,
|
||||
searchable: column.searchable === "true",
|
||||
orderable: column.orderable === "true",
|
||||
search: { value: column.search.value, regex: column.search.regex === "true" },
|
||||
};
|
||||
});
|
||||
this._order = (query.order as { column: string; dir: string }[]).map((order) => {
|
||||
return { column: parseInt(order.column, 10), dir: order.dir };
|
||||
});
|
||||
this.columns = (query.columns as { data: string; name: string; searchable: string; orderable: string; search: any }[]).map((column) => {
|
||||
return {
|
||||
data: parseInt(column.data, 10),
|
||||
name: column.name,
|
||||
searchable: column.searchable === "true",
|
||||
orderable: column.orderable === "true",
|
||||
search: { value: column.search.value, regex: column.search.regex === "true" },
|
||||
};
|
||||
});
|
||||
this.search = {
|
||||
value: (query.search as any).value as string,
|
||||
regex: (query.search as any).regex === "true",
|
||||
|
|
@ -93,7 +93,7 @@ export class DataTablesSsp {
|
|||
}
|
||||
|
||||
private colSettingsToStr(colSettings: IColumnSettings) {
|
||||
const db = colSettings.database ? ("`" + colSettings.database + "`.") : "";
|
||||
const db = colSettings.database ? "`" + colSettings.database + "`." : "";
|
||||
return `${db}\`${colSettings.table || this.table}\`.\`${colSettings.name}\``;
|
||||
}
|
||||
|
||||
|
|
@ -153,19 +153,16 @@ export class DataTablesSsp {
|
|||
this.filterBindings.push(`%${this.search.value}%`);
|
||||
}
|
||||
if (filterWheres.length > 0) {
|
||||
this.filterWhereSql = "(" + filterWheres.map(w => `(${w})`).join(" OR ") + ")";
|
||||
this.filterWhereSql = "(" + filterWheres.map((w) => `(${w})`).join(" OR ") + ")";
|
||||
}
|
||||
}
|
||||
|
||||
this.customWhereSql = this.wheres.map(w => `(${w})`).join(" AND ");
|
||||
this.customWhereSql = this.wheres.map((w) => `(${w})`).join(" AND ");
|
||||
return this;
|
||||
}
|
||||
|
||||
public sql(): string {
|
||||
const columns = [
|
||||
...this.columnSettings.map(c => this.colSettingsToStr(c)),
|
||||
...this.extraDataColumns,
|
||||
];
|
||||
const columns = [...this.columnSettings.map((c) => this.colSettingsToStr(c)), ...this.extraDataColumns];
|
||||
return `
|
||||
SELECT ${columns.join(", ")}
|
||||
FROM ${this.table}
|
||||
|
|
@ -199,10 +196,7 @@ export class DataTablesSsp {
|
|||
}
|
||||
|
||||
public async run(queryTimeout: number = 10_000): Promise<IResult> {
|
||||
this.limit()
|
||||
.order()
|
||||
.join()
|
||||
.filter();
|
||||
this.limit().order().join().filter();
|
||||
|
||||
const bindings = [...this.filterBindings, ...this.customBindings];
|
||||
|
||||
|
|
@ -226,7 +220,7 @@ export class DataTablesSsp {
|
|||
values: bindings,
|
||||
timeout: queryTimeout,
|
||||
});
|
||||
rows = (rows as any[][]).map(row => {
|
||||
rows = (rows as any[][]).map((row) => {
|
||||
for (let i = 0; i < this.columnSettings.length; ++i) {
|
||||
const col = this.columnSettings[i];
|
||||
if (col.formatter !== undefined) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue