mirror of
https://github.com/nikdoof/pocket-id.git
synced 2025-12-24 23:09:22 +00:00
feat: add audit log with email notification (#26)
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
import type {
|
||||
AllApplicationConfiguration,
|
||||
ApplicationConfigurationRawResponse
|
||||
AllAppConfig,
|
||||
AppConfigRawResponse
|
||||
} from '$lib/types/application-configuration';
|
||||
import APIService from './api-service';
|
||||
|
||||
export default class ApplicationConfigurationService extends APIService {
|
||||
export default class AppConfigService extends APIService {
|
||||
async list(showAll = false) {
|
||||
let url = '/application-configuration';
|
||||
if (showAll) {
|
||||
url += '/all';
|
||||
}
|
||||
|
||||
const { data } = await this.api.get<ApplicationConfigurationRawResponse>(url);
|
||||
const { data } = await this.api.get<AppConfigRawResponse>(url);
|
||||
|
||||
const applicationConfiguration: Partial<AllApplicationConfiguration> = {};
|
||||
const appConfig: Partial<AllAppConfig> = {};
|
||||
data.forEach(({ key, value }) => {
|
||||
(applicationConfiguration as any)[key] = value;
|
||||
(appConfig as any)[key] = value;
|
||||
});
|
||||
|
||||
return applicationConfiguration as AllApplicationConfiguration;
|
||||
return appConfig as AllAppConfig;
|
||||
}
|
||||
|
||||
async update(applicationConfiguration: AllApplicationConfiguration) {
|
||||
const res = await this.api.put('/application-configuration', applicationConfiguration);
|
||||
return res.data as AllApplicationConfiguration;
|
||||
async update(appConfig: AllAppConfig) {
|
||||
const res = await this.api.put('/application-configuration', appConfig);
|
||||
return res.data as AllAppConfig;
|
||||
}
|
||||
|
||||
async updateFavicon(favicon: File) {
|
||||
20
frontend/src/lib/services/audit-log-service.ts
Normal file
20
frontend/src/lib/services/audit-log-service.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { AuditLog } from '$lib/types/audit-log.type';
|
||||
import type { Paginated, PaginationRequest } from '$lib/types/pagination.type';
|
||||
import APIService from './api-service';
|
||||
|
||||
class AuditLogService extends APIService {
|
||||
async list(pagination?: PaginationRequest) {
|
||||
const page = pagination?.page || 1;
|
||||
const limit = pagination?.limit || 10;
|
||||
|
||||
const res = await this.api.get('/audit-logs', {
|
||||
params: {
|
||||
page,
|
||||
limit
|
||||
}
|
||||
});
|
||||
return res.data as Paginated<AuditLog>;
|
||||
}
|
||||
}
|
||||
|
||||
export default AuditLogService;
|
||||
Reference in New Issue
Block a user