Skip to content

Commit

Permalink
Dummy commit for UI warning
Browse files Browse the repository at this point in the history
Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
  • Loading branch information
SagarGi committed Jun 4, 2024
1 parent 206f942 commit b3d6c6f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
27 changes: 19 additions & 8 deletions lib/Service/OpenProjectAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\PreConditionNotMetException;
use OCP\Security\ISecureRandom;
use OCP\Server;
use phpDocumentor\Reflection\Types\This;
use Psr\Log\LoggerInterface;
use Safe\Exceptions\JsonException;
use OCA\AdminAudit\AuditLogger;
Expand Down Expand Up @@ -1090,23 +1092,32 @@ class_exists('\OCA\GroupFolders\Folder\FolderManager') &&
}

/**
* @param $string $auditLogMessage
* @param $boolean $isRunningFullReset
* @param $auditLogMessage
* @return void
*/
public function logToAudit($auditLogMessage, $isRunningFullReset = false): void {
$isProjectFolderSetupDone = $this->config->getAppValue(Application::APP_ID, 'fresh_project_folder_setup', '0') === '1';
$isAdminConfigOk = self::isAdminConfigOk($this->config);
if($this->appManager->isInstalled('admin_audit')) {
if(($isAdminConfigOk && $isProjectFolderSetupDone === false) || $isRunningFullReset) {
public function logToAudit($auditLogMessage): void {
if($this->isAdminAuditConfigSetCorrectly()) {
$this->auditLogger = new AuditLogger($this->logFactory, $this->config);

Check failure on line 1100 in lib/Service/OpenProjectAPIService.php

View workflow job for this annotation

GitHub Actions / builds / unit tests and linting (stable26, 8.2)

UndefinedClass

lib/Service/OpenProjectAPIService.php:1100:30: UndefinedClass: Class, interface or enum named OCA\AdminAudit\AuditLogger does not exist (see https://psalm.dev/019)

Check failure on line 1100 in lib/Service/OpenProjectAPIService.php

View workflow job for this annotation

GitHub Actions / builds / unit tests and linting (stable27, 8)

UndefinedClass

lib/Service/OpenProjectAPIService.php:1100:30: UndefinedClass: Class, interface or enum named OCA\AdminAudit\AuditLogger does not exist (see https://psalm.dev/019)

Check failure on line 1100 in lib/Service/OpenProjectAPIService.php

View workflow job for this annotation

GitHub Actions / builds / unit tests and linting (stable27, 8.1)

UndefinedClass

lib/Service/OpenProjectAPIService.php:1100:30: UndefinedClass: Class, interface or enum named OCA\AdminAudit\AuditLogger does not exist (see https://psalm.dev/019)
$this->auditLogger->info($auditLogMessage,
['app' => 'admin_audit']
);
}
}
}

public function isAdminAuditConfigSetCorrectly(): bool {
$logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN);
$configAuditFile = $this->config->getSystemValue('logfile_audit', ILogger::WARN);
$logCondition = $this->config->getSystemValue('log.condition', []);
// All the above config should be satisfied in order for admin audit log for the integration application
// if any of the config is failed to be set then we are not able to send the admin audit logging in the audit.log file
return (
$this->appManager->isInstalled('admin_audit') &&
$configAuditFile === $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log' &&
(isset($logCondition["apps"]) && in_array('admin_audit', $logCondition["apps"])) &&
$logLevel === 1
);
}

public function isTermsOfServiceAppEnabled(): bool {
return (
class_exists('\OCA\TermsOfService\Db\Entities\Signatory') &&
Expand Down
4 changes: 3 additions & 1 deletion lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function getForm(): TemplateResponse {
}
$projectFolderStatusInformation = $this->openProjectAPIService->getProjectFolderSetupInformation();
$isAllTermsOfServiceSignedForUserOpenProject = $this->openProjectAPIService->isAllTermsOfServiceSignedForUserOpenProject();
$isAdminAuditConfigCorrectForIntegrationApp = $this->openProjectAPIService->isAdminAuditConfigSetCorrectly();
$adminConfig = [
'openproject_client_id' => $clientID,
'openproject_client_secret' => $clientSecret,
Expand All @@ -68,7 +69,8 @@ public function getForm(): TemplateResponse {
'app_password_set' => $this->openProjectAPIService->hasAppPassword(),
'project_folder_info' => $projectFolderStatusInformation,
'fresh_project_folder_setup' => $this->config->getAppValue(Application::APP_ID, 'fresh_project_folder_setup', '0') === '1',
'all_terms_of_services_signed' => $isAllTermsOfServiceSignedForUserOpenProject
'all_terms_of_services_signed' => $isAllTermsOfServiceSignedForUserOpenProject,
'is_admin_audit_config_correct' => $isAdminAuditConfigCorrectForIntegrationApp
];

$adminConfigStatus = OpenProjectAPIService::isAdminConfigOk($this->config);
Expand Down
6 changes: 5 additions & 1 deletion src/components/AdminSettings.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div id="openproject_prefs" class="section">
<TermsOfServiceUnsigned :is-all-terms-of-service-signed-for-user-open-project="isAllTermsOfServiceSignedForUserOpenProject" />
<SettingsTitle is-setting="admin" />
<SettingsTitle is-setting="admin" :is-audit-logging-warning="!isThereAuditLogWarning"/>
<div class="openproject-server-host">
<FormHeading index="1"
:title="t('integration_openproject', 'OpenProject server')"
Expand Down Expand Up @@ -507,6 +507,9 @@ export default {
isProjectFolderSetupCompleted() {
return this.isProjectFolderSetupFormInEdit ? false : this.opUserAppPassword
},
isThereAuditLogWarning() {
return this.state.is_admin_audit_config_correct
},
adminFileStorageHref() {
let hostPart = ''
const urlPart = '%sadmin/settings/storages'
Expand Down Expand Up @@ -565,6 +568,7 @@ export default {
methods: {
init() {
if (this.state) {
console.log(this.state)
if (this.state.all_terms_of_services_signed === false) {
this.isAllTermsOfServiceSignedForUserOpenProject = false
}
Expand Down
16 changes: 16 additions & 0 deletions src/components/settings/SettingsTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<span>{{ title }}</span>
</h2>
<p class="settings--documentation-info" v-html="sanitizedHintText" /> <!-- eslint-disable-line vue/no-v-html -->
<div v-if="isAuditLoggingWarning" class="settings--warning">
<p class="settings--documentation-info">There are some warnings regarding your setup</p>
<li>Hello</li>
</div>
</div>
</template>

Expand All @@ -23,6 +27,10 @@ export default {
type: String,
required: true,
},
isAuditLoggingWarning: {
type: String,
required: false,
},
},
computed: {
title() {
Expand Down Expand Up @@ -71,6 +79,14 @@ export default {
&--documentation-info {
font-size: 1rem;
}
&--warning {
padding-top: 10px;
li{
padding-top: 10px;
color: var(--color-warning);
padding-left: 20px;
}
}
}
.settings .link {
Expand Down

0 comments on commit b3d6c6f

Please sign in to comment.