Skip to content

Commit acd2fb9

Browse files
committed
fix: Use table to display stats
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent da362f0 commit acd2fb9

File tree

2 files changed

+47
-34
lines changed

2 files changed

+47
-34
lines changed

lib/Settings/AdminSettings.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use OCA\ContextChat\Db\QueueContentItemMapper;
1010
use OCA\ContextChat\Service\ActionService;
1111
use OCA\ContextChat\Service\LangRopeService;
12+
use OCA\ContextChat\Service\ProviderConfigService;
1213
use OCA\ContextChat\Service\QueueService;
1314
use OCA\ContextChat\Service\StorageService;
1415
use OCP\AppFramework\Http\TemplateResponse;
@@ -52,12 +53,6 @@ public function getForm(): TemplateResponse {
5253
$this->logger->error($e->getMessage(), ['exception' => $e]);
5354
$stats['eligible_files_count'] = 0;
5455
}
55-
try {
56-
$stats['queued_files_count'] = $this->queueService->count();
57-
} catch (Exception $e) {
58-
$this->logger->error($e->getMessage(), ['exception' => $e]);
59-
$stats['queued_files_count'] = 0;
60-
}
6156
$stats['indexed_files_count'] = Util::numericToNumber($this->appConfig->getAppValueString('indexed_files_count', '0'));
6257
try {
6358
$stats['queued_actions_count'] = $this->actionService->count();
@@ -71,11 +66,18 @@ public function getForm(): TemplateResponse {
7166
} catch (\RuntimeException $e) {
7267
$stats['backend_available'] = false;
7368
}
69+
try {
70+
$queued_files_count = $this->queueService->count();
71+
} catch (Exception $e) {
72+
$this->logger->error($e->getMessage(), ['exception' => $e]);
73+
$queued_files_count = 0;
74+
}
7475
try {
7576
$stats['queued_documents_counts'] = $this->contentQueue->count();
77+
$stats['queued_documents_counts'][ProviderConfigService::getDefaultProviderKey()] = $queued_files_count;
7678
} catch (Exception $e) {
7779
$this->logger->error($e->getMessage(), ['exception' => $e]);
78-
$stats['queued_documents_counts'] = 0;
80+
$stats['queued_documents_counts'] = [];
7981
}
8082

8183
$this->initialState->provideInitialState('stats', $stats);

src/components/ViewAdmin.vue

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,30 @@ SPDX-License-Identifier: AGPL-3.0-or-later
2121
<NcNoteCard v-if="stats.initial_indexing_complete && stats.eligible_files_count > stats.vectordb_document_counts['files__default'] * 1.2" type="warning">
2222
{{ t('context_chat', 'Less files were indexed than expected. Only {percent}% files out of {eligibleCount} are in the VectorDB.', {percent: Math.round((stats.vectordb_document_counts['files__default'] / stats.eligible_files_count) * 100), eligibleCount: stats.eligible_files_count}) }}
2323
</NcNoteCard>
24-
25-
<ul>
26-
<li>
27-
{{ t('context_chat', 'Eligible files for indexing: {count}', {count: stats.eligible_files_count}) }}
28-
</li>
29-
<li>
30-
{{ t('context_chat', 'Queued files for indexing: {count}', {count: stats.queued_files_count}) }}
31-
</li>
32-
<li v-for="(count, providerId) in stats.queued_documents_counts" :key="providerId">
33-
{{ t('context_chat', 'Queued documents from provider {providerId} for indexing: {count}', {count, providerId}) }}
34-
</li>
35-
<template v-if="stats.vectordb_document_counts">
36-
<li v-for="(count, providerId) in stats.vectordb_document_counts" :key="providerId">
37-
{{ t('context_chat', 'Documents in VectorDB from provider {providerId}: {count}', {count, providerId}) }}
38-
</li>
39-
</template>
40-
<li>
41-
{{ t('context_chat', 'Queued content update actions: {count}', {count: stats.queued_actions_count}) }}
42-
</li>
43-
</ul>
24+
<p>{{ t('context_chat', 'Eligible files for indexing: {count}', {count: stats.eligible_files_count}) }}</p>
25+
<table>
26+
<thead>
27+
<tr>
28+
<th>{{ t('context_chat', 'Content provider') }}</th>
29+
<th>{{ t('context_chat', 'Queued documents') }}</th>
30+
<th>{{ t('context_chat', 'Documents in vector database') }}</th>
31+
</tr>
32+
</thead>
33+
<tr v-for="(count, providerId) in stats.queued_documents_counts" :key="providerId">
34+
<td>{{ providerId }}</td>
35+
<td>{{ count }}</td>
36+
<td v-if="stats.vectordb_document_counts">
37+
{{ stats.vectordb_document_counts[providerId] }}
38+
<template v-if="providerId === 'files__default'">
39+
{{ t('context_chat', '(out of {count} sent)', {count: stats.indexed_files_count}) }}
40+
</template>
41+
</td>
42+
<td v-else>
43+
{{ t('context_chat', 'Not available') }}
44+
</td>
45+
</tr>
46+
</table>
47+
<p>{{ t('context_chat', 'Queued content update actions: {count}', {count: stats.queued_actions_count}) }}</p>
4448
<p><a href="https://docs.nextcloud.com/server/latest/admin_manual/ai/app_context_chat.html">{{ t('context_chat', 'Official documentation') }}</a></p>
4549
</NcSettingsSection>
4650
</div>
@@ -104,14 +108,21 @@ figure[class^='icon-'] {
104108
position: relative;
105109
}
106110
107-
#context_chat .loading,
108-
#context_chat .success {
109-
position: fixed;
110-
top: 70px;
111-
right: 20px;
111+
#context_chat table {
112+
border-collapse: collapse;
113+
width: 100%;
114+
border: 1px solid #ccc; /* Adds a border around the table */
115+
}
116+
117+
#context_chat th,
118+
#context_chat td {
119+
border: 1px solid #ccc; /* Adds borders to table cells */
120+
padding: 8px; /* Adds padding inside the cells */
121+
text-align: left; /* Aligns text to the left */
112122
}
113123
114-
#context_chat a:link, #context_chat a:visited, #context_chat a:hover {
115-
text-decoration: underline;
124+
#context_chat th {
125+
background-color: #f4f4f4; /* Adds a background color to the table headers */
116126
}
127+
117128
</style>

0 commit comments

Comments
 (0)