add logging views

This commit is contained in:
einhornimmond 2024-05-10 14:19:43 +02:00
parent 04696c46d4
commit 83361ea17d
3 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import { AbstractLoggingView } from '@logging/AbstractLogging.view'
import { Account } from '@/apis/humhub/model/Account'
export class AccountLoggingView extends AbstractLoggingView {
public constructor(private self: Account) {
super()
}
public toJSON(): Account {
return {
username: this.self.username.substring(0, 3) + '...',
email: this.self.email.substring(0, 3) + '...',
language: this.self.language,
status: this.self.status,
}
}
}

View File

@ -0,0 +1,23 @@
import { AbstractLoggingView } from '@logging/AbstractLogging.view'
import { PostUser } from '@/apis/humhub/model/PostUser'
import { AccountLoggingView } from './AccountLogging.view'
import { ProfileLoggingView } from './ProfileLogging.view'
export class PostUserLoggingView extends AbstractLoggingView {
public constructor(private self: PostUser) {
super()
}
public toJSON(): PostUser {
return {
account: new AccountLoggingView(this.self.account).toJSON(),
profile: new ProfileLoggingView(this.self.profile).toJSON(),
password: {
newPassword: '',
mustChangePassword: false,
},
}
}
}

View File

@ -0,0 +1,20 @@
import { AbstractLoggingView } from '@logging/AbstractLogging.view'
import { Profile } from '@/apis/humhub/model/Profile'
export class ProfileLoggingView extends AbstractLoggingView {
public constructor(private self: Profile) {
super()
}
public toJSON(): Profile {
const gradidoAddressParts = this.self.gradido_address.split('/')
return {
firstname: this.self.firstname.substring(0, 3) + '...',
lastname: this.self.lastname.substring(0, 3) + '...',
// eslint-disable-next-line camelcase
gradido_address:
gradidoAddressParts[0] + '/' + gradidoAddressParts[1].substring(0, 3) + '...',
}
}
}