|
1 |
| -import { sleep } from "/app/utils/time.utils.js"; |
2 |
| -import { BaseApiService } from "/app/common/shared/services/base-api-service.js"; |
| 1 | +import { BaseCrudService } from '/app/common/shared/services/base-crud-service.js'; |
3 | 2 |
|
4 |
| -class DashboardService extends BaseApiService { |
| 3 | +class DashboardService extends BaseCrudService { |
5 | 4 | constructor() {
|
6 |
| - super(); |
| 5 | + super({ basePath: "/system/admin/_schema" }); |
7 | 6 | }
|
8 | 7 |
|
9 | 8 | async getDashboardInfo() {
|
10 |
| - // FIXME: For now we use mock data |
11 |
| - |
12 |
| - await sleep(5000); |
13 |
| - |
14 |
| - const quota = { |
15 |
| - TEST: Math.floor(Math.random() * 100), |
16 |
| - Items1: Math.floor(Math.random() * 100), |
17 |
| - Items2: Math.floor(Math.random() * 100), |
18 |
| - Items3: Math.floor(Math.random() * 100), |
19 |
| - Items4: Math.floor(Math.random() * 100), |
20 |
| - Items5: Math.floor(Math.random() * 100), |
21 |
| - Items6: Math.floor(Math.random() * 100) |
22 |
| - }; |
| 9 | + |
| 10 | + this._basePath = '/system/admin/_schema'; |
| 11 | + let recordCount = await this.count(); |
| 12 | + let collections = await this.getAll(); |
| 13 | + let quota = {}; |
| 14 | + for await (const item of collections) { |
| 15 | + let collName = item.CollectionName; |
| 16 | + this._basePath = '/api/CRUD/' + collName; |
| 17 | + let collCount = await this.count(); |
| 18 | + quota[collName] = collCount; |
| 19 | + } |
| 20 | + |
23 | 21 | return {
|
24 | 22 | recordQuotas: quota,
|
25 |
| - entitiesNum: Object.keys(quota).length, |
26 |
| - lastWeekCallsNum: Math.floor(Math.random() * 500) |
| 23 | + entitiesNum: recordCount |
27 | 24 | };
|
28 | 25 | }
|
29 | 26 | }
|
|
0 commit comments