adminforth 1.0.31 β 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dataConnectors/postgres.ts +9 -6
- package/dist/dataConnectors/postgres.js +9 -6
- package/dist/index.js +9 -0
- package/dist/spa/spa/src/App.vue +0 -4
- package/dist/spa/spa/src/components/Dropdown.vue +0 -1
- package/dist/spa/spa/src/views/ListView.vue +0 -4
- package/index.ts +8 -0
- package/package.json +1 -1
- package/spa/src/App.vue +0 -4
- package/spa/src/components/Dropdown.vue +0 -1
- package/spa/src/views/ListView.vue +0 -4
|
@@ -147,7 +147,7 @@ class PostgresConnector {
|
|
|
147
147
|
|
|
148
148
|
async getRecordByPrimaryKey(resource, key) {
|
|
149
149
|
const tableName = resource.table;
|
|
150
|
-
const columns = resource.dataSourceColumns.map((col) => col.name).join(', ');
|
|
150
|
+
const columns = resource.dataSourceColumns.map((col) => `"${col.name}"`).join(', ');
|
|
151
151
|
const stmt = await this.db.query(`SELECT ${columns} FROM ${tableName} WHERE ${this.getPrimaryKey(resource)} = $1`, [key]);
|
|
152
152
|
const row = stmt.rows[0];
|
|
153
153
|
if (!row) {
|
|
@@ -177,7 +177,7 @@ class PostgresConnector {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
async getData({ resource, limit, offset, sort, filters }) {
|
|
180
|
-
const columns = resource.dataSourceColumns.filter(c=> !c.virtual).map((col) => col.name).join(', ');
|
|
180
|
+
const columns = resource.dataSourceColumns.filter(c=> !c.virtual).map((col) => `"${col.name}"`).join(', ');
|
|
181
181
|
const tableName = resource.table;
|
|
182
182
|
|
|
183
183
|
for (const filter of filters) {
|
|
@@ -199,7 +199,7 @@ class PostgresConnector {
|
|
|
199
199
|
} else {
|
|
200
200
|
totalCounter += 1;
|
|
201
201
|
}
|
|
202
|
-
return
|
|
202
|
+
return `"${field}" ${operator} ${placeholder}`
|
|
203
203
|
}).join(' AND ')}` : '';
|
|
204
204
|
|
|
205
205
|
const filterValues = [];
|
|
@@ -267,17 +267,20 @@ class PostgresConnector {
|
|
|
267
267
|
return record[colName];
|
|
268
268
|
}
|
|
269
269
|
});
|
|
270
|
+
for (let i = 0; i < columns.length; i++) {
|
|
271
|
+
columns[i] = `"${columns[i]}"`;
|
|
272
|
+
}
|
|
270
273
|
await this.db.query(`INSERT INTO ${tableName} (${columns.join(', ')}) VALUES (${placeholders})`, values);
|
|
271
274
|
}
|
|
272
275
|
|
|
273
276
|
async updateRecord({ resource, recordId, record, newValues }) {
|
|
274
277
|
const values = [...Object.values(newValues), recordId];
|
|
275
|
-
const columnsWithPlaceholders = Object.keys(newValues).map((col, i) =>
|
|
276
|
-
await this.db.query(`UPDATE ${resource.table} SET ${columnsWithPlaceholders} WHERE ${this.getPrimaryKey(resource)} = $${values.length}`, values);
|
|
278
|
+
const columnsWithPlaceholders = Object.keys(newValues).map((col, i) => `"${col}" = $${i + 1}`).join(', ');
|
|
279
|
+
await this.db.query(`UPDATE ${resource.table} SET ${columnsWithPlaceholders} WHERE "${this.getPrimaryKey(resource)}" = $${values.length}`, values);
|
|
277
280
|
}
|
|
278
281
|
|
|
279
282
|
async deleteRecord({ resource, recordId }) {
|
|
280
|
-
await this.db.query(`DELETE FROM ${resource.table} WHERE ${this.getPrimaryKey(resource)} = $1`, [recordId]);
|
|
283
|
+
await this.db.query(`DELETE FROM ${resource.table} WHERE "${this.getPrimaryKey(resource)}" = $1`, [recordId]);
|
|
281
284
|
}
|
|
282
285
|
|
|
283
286
|
async close() {
|
|
@@ -148,7 +148,7 @@ class PostgresConnector {
|
|
|
148
148
|
getRecordByPrimaryKey(resource, key) {
|
|
149
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
150
|
const tableName = resource.table;
|
|
151
|
-
const columns = resource.dataSourceColumns.map((col) => col.name).join(', ');
|
|
151
|
+
const columns = resource.dataSourceColumns.map((col) => `"${col.name}"`).join(', ');
|
|
152
152
|
const stmt = yield this.db.query(`SELECT ${columns} FROM ${tableName} WHERE ${this.getPrimaryKey(resource)} = $1`, [key]);
|
|
153
153
|
const row = stmt.rows[0];
|
|
154
154
|
if (!row) {
|
|
@@ -180,7 +180,7 @@ class PostgresConnector {
|
|
|
180
180
|
}
|
|
181
181
|
getData(_a) {
|
|
182
182
|
return __awaiter(this, arguments, void 0, function* ({ resource, limit, offset, sort, filters }) {
|
|
183
|
-
const columns = resource.dataSourceColumns.filter(c => !c.virtual).map((col) => col.name).join(', ');
|
|
183
|
+
const columns = resource.dataSourceColumns.filter(c => !c.virtual).map((col) => `"${col.name}"`).join(', ');
|
|
184
184
|
const tableName = resource.table;
|
|
185
185
|
for (const filter of filters) {
|
|
186
186
|
if (!this.OperatorsMap[filter.operator]) {
|
|
@@ -202,7 +202,7 @@ class PostgresConnector {
|
|
|
202
202
|
else {
|
|
203
203
|
totalCounter += 1;
|
|
204
204
|
}
|
|
205
|
-
return
|
|
205
|
+
return `"${field}" ${operator} ${placeholder}`;
|
|
206
206
|
}).join(' AND ')}` : '';
|
|
207
207
|
const filterValues = [];
|
|
208
208
|
filters.length ? filters.forEach((f) => {
|
|
@@ -272,19 +272,22 @@ class PostgresConnector {
|
|
|
272
272
|
return record[colName];
|
|
273
273
|
}
|
|
274
274
|
});
|
|
275
|
+
for (let i = 0; i < columns.length; i++) {
|
|
276
|
+
columns[i] = `"${columns[i]}"`;
|
|
277
|
+
}
|
|
275
278
|
yield this.db.query(`INSERT INTO ${tableName} (${columns.join(', ')}) VALUES (${placeholders})`, values);
|
|
276
279
|
});
|
|
277
280
|
}
|
|
278
281
|
updateRecord(_a) {
|
|
279
282
|
return __awaiter(this, arguments, void 0, function* ({ resource, recordId, record, newValues }) {
|
|
280
283
|
const values = [...Object.values(newValues), recordId];
|
|
281
|
-
const columnsWithPlaceholders = Object.keys(newValues).map((col, i) =>
|
|
282
|
-
yield this.db.query(`UPDATE ${resource.table} SET ${columnsWithPlaceholders} WHERE ${this.getPrimaryKey(resource)} = $${values.length}`, values);
|
|
284
|
+
const columnsWithPlaceholders = Object.keys(newValues).map((col, i) => `"${col}" = $${i + 1}`).join(', ');
|
|
285
|
+
yield this.db.query(`UPDATE ${resource.table} SET ${columnsWithPlaceholders} WHERE "${this.getPrimaryKey(resource)}" = $${values.length}`, values);
|
|
283
286
|
});
|
|
284
287
|
}
|
|
285
288
|
deleteRecord(_a) {
|
|
286
289
|
return __awaiter(this, arguments, void 0, function* ({ resource, recordId }) {
|
|
287
|
-
yield this.db.query(`DELETE FROM ${resource.table} WHERE ${this.getPrimaryKey(resource)} = $1`, [recordId]);
|
|
290
|
+
yield this.db.query(`DELETE FROM ${resource.table} WHERE "${this.getPrimaryKey(resource)}" = $1`, [recordId]);
|
|
288
291
|
});
|
|
289
292
|
}
|
|
290
293
|
close() {
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,14 @@ import { guessLabelFromName } from './modules/utils.js';
|
|
|
22
22
|
import ExpressServer from './servers/express.js';
|
|
23
23
|
import { v1 as uuid } from 'uuid';
|
|
24
24
|
import fs from 'fs';
|
|
25
|
+
let package_json;
|
|
26
|
+
if (fs.existsSync('../package.json')) {
|
|
27
|
+
// in prod we are in dist folder
|
|
28
|
+
package_json = JSON.parse(fs.readFileSync('../package.json', 'utf8'));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
package_json = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
|
32
|
+
}
|
|
25
33
|
import { AdminForthFilterOperators, AdminForthTypes } from './types.js';
|
|
26
34
|
const AVAILABLE_SHOW_IN = ['list', 'edit', 'create', 'filter', 'show'];
|
|
27
35
|
const DEFAULT_ALLOWED_ACTIONS = { create: true, edit: true, show: true, delete: true };
|
|
@@ -409,6 +417,7 @@ class AdminForth {
|
|
|
409
417
|
usernameField: this.config.auth.usernameField,
|
|
410
418
|
},
|
|
411
419
|
adminUser,
|
|
420
|
+
version: package_json.version,
|
|
412
421
|
};
|
|
413
422
|
}),
|
|
414
423
|
});
|
package/dist/spa/spa/src/App.vue
CHANGED
|
@@ -141,10 +141,6 @@ const routerIsReady = ref(false);
|
|
|
141
141
|
|
|
142
142
|
const loggedIn = computed(() => route.name !== 'login' && routerIsReady.value);
|
|
143
143
|
|
|
144
|
-
watch(loggedIn, (value) => {
|
|
145
|
-
console.log('π»π»π» loggedIn', value);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
144
|
const theme = ref('light');
|
|
149
145
|
|
|
150
146
|
function toggleTheme() {
|
|
@@ -76,7 +76,6 @@ const showDropdown = ref(false);
|
|
|
76
76
|
const selectedItems = ref([]);
|
|
77
77
|
|
|
78
78
|
function updateFromProps() {
|
|
79
|
-
console.log('β‘ updateFromProps', props.modelValue)
|
|
80
79
|
if (props.modelValue !== undefined) {
|
|
81
80
|
if (props.single) {
|
|
82
81
|
selectedItems.value = [props.options.find(item => item.value === props.modelValue)];
|
|
@@ -357,10 +357,6 @@ const totalRows = ref(0);
|
|
|
357
357
|
const allCheckedActions = ref([]);
|
|
358
358
|
const allowedActions = ref({});
|
|
359
359
|
|
|
360
|
-
onMounted(() => {
|
|
361
|
-
console.log('LISTVIEW mountedββββββπ»π»π»');
|
|
362
|
-
});
|
|
363
|
-
|
|
364
360
|
const DEFAULT_PAGE_SIZE = 10;
|
|
365
361
|
|
|
366
362
|
const columnsListed = computed(() => coreStore.resourceColumns?.filter(c => c.showIn.includes('list')));
|
package/index.ts
CHANGED
|
@@ -9,6 +9,13 @@ import ExpressServer from './servers/express.js';
|
|
|
9
9
|
import {v1 as uuid} from 'uuid';
|
|
10
10
|
import fs from 'fs';
|
|
11
11
|
|
|
12
|
+
let package_json;
|
|
13
|
+
if (fs.existsSync('../package.json')) {
|
|
14
|
+
// in prod we are in dist folder
|
|
15
|
+
package_json = JSON.parse(fs.readFileSync('../package.json', 'utf8'));
|
|
16
|
+
} else {
|
|
17
|
+
package_json = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
|
18
|
+
}
|
|
12
19
|
|
|
13
20
|
import { AdminForthFilterOperators, AdminForthTypes, AdminForthTypesValues } from './types.js';
|
|
14
21
|
|
|
@@ -568,6 +575,7 @@ class AdminForth {
|
|
|
568
575
|
usernameField: this.config.auth.usernameField,
|
|
569
576
|
},
|
|
570
577
|
adminUser,
|
|
578
|
+
version: package_json.version,
|
|
571
579
|
};
|
|
572
580
|
},
|
|
573
581
|
});
|
package/package.json
CHANGED
package/spa/src/App.vue
CHANGED
|
@@ -141,10 +141,6 @@ const routerIsReady = ref(false);
|
|
|
141
141
|
|
|
142
142
|
const loggedIn = computed(() => route.name !== 'login' && routerIsReady.value);
|
|
143
143
|
|
|
144
|
-
watch(loggedIn, (value) => {
|
|
145
|
-
console.log('π»π»π» loggedIn', value);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
144
|
const theme = ref('light');
|
|
149
145
|
|
|
150
146
|
function toggleTheme() {
|
|
@@ -76,7 +76,6 @@ const showDropdown = ref(false);
|
|
|
76
76
|
const selectedItems = ref([]);
|
|
77
77
|
|
|
78
78
|
function updateFromProps() {
|
|
79
|
-
console.log('β‘ updateFromProps', props.modelValue)
|
|
80
79
|
if (props.modelValue !== undefined) {
|
|
81
80
|
if (props.single) {
|
|
82
81
|
selectedItems.value = [props.options.find(item => item.value === props.modelValue)];
|
|
@@ -357,10 +357,6 @@ const totalRows = ref(0);
|
|
|
357
357
|
const allCheckedActions = ref([]);
|
|
358
358
|
const allowedActions = ref({});
|
|
359
359
|
|
|
360
|
-
onMounted(() => {
|
|
361
|
-
console.log('LISTVIEW mountedββββββπ»π»π»');
|
|
362
|
-
});
|
|
363
|
-
|
|
364
360
|
const DEFAULT_PAGE_SIZE = 10;
|
|
365
361
|
|
|
366
362
|
const columnsListed = computed(() => coreStore.resourceColumns?.filter(c => c.showIn.includes('list')));
|