mirror of
https://github.com/bitwarden/browser
synced 2024-12-27 10:23:48 +01:00
Export Organization events (#375)
* Export Organization events * Lint fixes
This commit is contained in:
parent
306aef73d4
commit
92dbf24ab8
@ -1,5 +1,8 @@
|
||||
import { EventView } from '../models/view/eventView';
|
||||
|
||||
export abstract class ExportService {
|
||||
getExport: (format?: 'csv' | 'json' | 'encrypted_json') => Promise<string>;
|
||||
getOrganizationExport: (organizationId: string, format?: 'csv' | 'json' | 'encrypted_json') => Promise<string>;
|
||||
getEventExport: (events: EventView[]) => Promise<string>;
|
||||
getFileName: (prefix?: string, extension?: string) => string;
|
||||
}
|
||||
|
26
src/models/export/event.ts
Normal file
26
src/models/export/event.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { EventType } from '../../enums/eventType';
|
||||
import { EventView } from '../view/eventView';
|
||||
|
||||
export class Event {
|
||||
message: string;
|
||||
appIcon: string;
|
||||
appName: string;
|
||||
userId: string;
|
||||
userName: string;
|
||||
userEmail: string;
|
||||
date: string;
|
||||
ip: string;
|
||||
type: string;
|
||||
|
||||
constructor(event: EventView) {
|
||||
this.message = event.humanReadableMessage;
|
||||
this.appIcon = event.appIcon;
|
||||
this.appName = event.appName;
|
||||
this.userId = event.userId;
|
||||
this.userName = event.userName;
|
||||
this.userEmail = event.userEmail;
|
||||
this.date = event.date;
|
||||
this.ip = event.ip;
|
||||
this.type = EventType[event.type];
|
||||
}
|
||||
}
|
27
src/models/view/eventView.ts
Normal file
27
src/models/view/eventView.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { EventType } from '../../enums/eventType';
|
||||
|
||||
export class EventView {
|
||||
message: string;
|
||||
humanReadableMessage: string;
|
||||
appIcon: string;
|
||||
appName: string;
|
||||
userId: string;
|
||||
userName: string;
|
||||
userEmail: string;
|
||||
date: string;
|
||||
ip: string;
|
||||
type: EventType;
|
||||
|
||||
constructor(data: Required<EventView>) {
|
||||
this.message = data.message;
|
||||
this.humanReadableMessage = data.humanReadableMessage;
|
||||
this.appIcon = data.appIcon;
|
||||
this.appName = data.appName;
|
||||
this.userId = data.userId;
|
||||
this.userName = data.userName;
|
||||
this.userEmail = data.userEmail;
|
||||
this.date = data.date;
|
||||
this.ip = data.ip;
|
||||
this.type = data.type;
|
||||
}
|
||||
}
|
@ -22,7 +22,9 @@ import { CollectionDetailsResponse } from '../models/response/collectionResponse
|
||||
|
||||
import { CipherWithIds as CipherExport } from '../models/export/cipherWithIds';
|
||||
import { CollectionWithId as CollectionExport } from '../models/export/collectionWithId';
|
||||
import { Event } from '../models/export/event';
|
||||
import { FolderWithId as FolderExport } from '../models/export/folderWithId';
|
||||
import { EventView } from '../models/view/eventView';
|
||||
|
||||
import { Utils } from '../misc/utils';
|
||||
|
||||
@ -47,6 +49,10 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
async getEventExport(events: EventView[]): Promise<string> {
|
||||
return papa.unparse(events.map(e => new Event(e)));
|
||||
}
|
||||
|
||||
getFileName(prefix: string = null, extension: string = 'csv'): string {
|
||||
const now = new Date();
|
||||
const dateString =
|
||||
|
Loading…
Reference in New Issue
Block a user