Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
['name' => 'provider#getProviders', 'url' => '/providers', 'verb' => 'GET'],
['name' => 'provider#getDefaultProviderKey', 'url' => '/default-provider-key', 'verb' => 'GET'],
['name' => 'provider#getMetadataFor', 'url' => '/sources-metadata', 'verb' => 'POST'],
['name' => 'log#getNextcloudLogs', 'url' => '/download-logs-nextcloud', 'verb' => 'GET'],
],
];
50 changes: 50 additions & 0 deletions lib/Controller/LogController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\ContextChat\Controller;

use OCA\ContextChat\Logger;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;

use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TextPlainResponse;
use OCP\AppFramework\Http\ZipResponse;
use OCP\IRequest;

class LogController extends Controller {
public function __construct(
string $appName,
IRequest $request,
private Logger $logger,
) {
parent::__construct($appName, $request);
}
/**
* Downloads log file
*
* @return Response
*/
#[NoCSRFRequired]
public function getNextcloudLogs(): Response {
$logFilepath = $this->logger->getLogFilepath();
$response = new ZipResponse($this->request, 'nextcloud-logs');
$filePath = $logFilepath;
$counter = 1;
while ($remoteFile = fopen($filePath, 'r')) {
$size = filesize($filePath);
$time = filemtime($filePath); // Needed otherwise tar complains that time is in the future
$response->addResource($remoteFile, basename($filePath), $size, $time);
$filePath = $logFilepath . '.' . $counter++;
}
if ($counter == 1) {
return new TextPlainResponse('No log file found', Http::STATUS_NOT_FOUND);
}
return $response;
}
}
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"dependencies": {
"@nextcloud/initial-state": "^2.2.0",
"@nextcloud/router": "^3.0.1",
"@nextcloud/vue": "8.x",
"humanize-duration": "^3.32.1",
"vue": "^2.7.12"
Expand Down
33 changes: 28 additions & 5 deletions src/components/ViewAdmin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,43 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<p>&nbsp;</p>
<p>{{ t('context_chat', 'Eligible files for indexing: {count}', {count: stats.eligible_files_count}) }}</p>
<p>{{ t('context_chat', 'Queued content update actions: {count}', {count: stats.queued_actions_count}) }}</p>
<p><a href="https://docs.nextcloud.com/server/latest/admin_manual/ai/app_context_chat.html">{{ t('context_chat', 'Official documentation') }}</a></p>
</NcSettingsSection>
<NcSettingsSection :name="t('context_chat', 'Context Chat Logs')">
<div class="horizontal-flex">
<NcButton :href="downloadURLNextcloudLogs">
{{ t('context_chat', 'Download the PHP App logs') }}
</NcButton>
<NcButton :href="downloadURLDockerLogs">
{{ t('context_chat', 'Download the Ex-App Backend logs') }}
</NcButton>
</div>
<p>&nbsp;</p>
<p>
<a href="https://docs.nextcloud.com/server/latest/admin_manual/ai/app_context_chat.html">{{
t('context_chat', 'Official documentation')
}}</a>
</p>
</NcSettingsSection>
</div>
</template>

<script>
import { NcNoteCard, NcSettingsSection } from '@nextcloud/vue'
import { NcNoteCard, NcSettingsSection, NcButton } from '@nextcloud/vue'
import { loadState } from '@nextcloud/initial-state'
import humanizeDuration from 'humanize-duration'
import { generateUrl } from '@nextcloud/router'

const MAX_RELATIVE_DATE = 1000 * 60 * 60 * 24 * 7 // one week

export default {
name: 'ViewAdmin',
components: { NcSettingsSection, NcNoteCard },
components: { NcSettingsSection, NcNoteCard, NcButton },

data() {
return {
stats: {},
stats: {},
downloadURLNextcloudLogs: generateUrl('/apps/context_chat/download-logs-nextcloud'),
downloadURLDockerLogs: generateUrl('/apps/app_api/proxy/context_chat_backend/downloadLogs'),
}
},

Expand Down Expand Up @@ -126,7 +144,12 @@ figure[class^='icon-'] {
background-color: var(--color-background-dark);
}

#context_chat a:link, #context_chat a:visited, #context_chat a:hover {
#context_chat p a:link, #context_chat p a:visited, #context_chat p a:hover {
text-decoration: underline;
}

.horizontal-flex {
display: flex;
gap: 10px;
}
</style>
Loading