diff --git a/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.ts b/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.ts index 479d2010ae..a85ec745d0 100644 --- a/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.ts +++ b/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.ts @@ -4,7 +4,7 @@ import { BaseViewModel } from 'src/app/site/base/base-view-model'; import { ExportServiceModule } from '../export-service.module'; import { FileExportService } from '../file-export.service'; import { - CsvColumnsDefinition, + BackendCsvColumnsDefinition, DEFAULT_COLUMN_SEPARATOR, DEFAULT_ENCODING, DEFAULT_LINE_SEPARATOR, @@ -30,7 +30,7 @@ export class CsvExportForBackendService { */ public export( models: T[], - columns: CsvColumnsDefinition, + columns: BackendCsvColumnsDefinition, filename: string, { lineSeparator = DEFAULT_LINE_SEPARATOR, @@ -54,7 +54,7 @@ export class CsvExportForBackendService { const header = columns.map(column => { let label = ``; if (isPropertyDefinition(column)) { - label = column.label ? column.label : (column.property as string); + label = column.property as string; } else if (isMapDefinition(column)) { label = column.label; } diff --git a/client/src/app/gateways/export/csv-export.service/csv-export-utils.ts b/client/src/app/gateways/export/csv-export.service/csv-export-utils.ts index 8048796dca..fee0e09cae 100644 --- a/client/src/app/gateways/export/csv-export.service/csv-export-utils.ts +++ b/client/src/app/gateways/export/csv-export.service/csv-export-utils.ts @@ -1,3 +1,11 @@ +/** + * Defines a csv column with a property of the model and an optional label. If this is not given, the + * translated and capitalized property name is used. + */ +export interface BackendCsvColumnDefinitionProperty { + property: keyof T; +} + /** * Defines a csv column with a property of the model and an optional label. If this is not given, the * translated and capitalized property name is used. @@ -44,6 +52,12 @@ export function isMapDefinition(obj: any): obj is CsvColumnDefinitionMap { */ export type CsvColumnsDefinition = (CsvColumnDefinitionProperty | CsvColumnDefinitionMap)[]; +/** + * The definition of columns in the export. Either use a property for every model or do a custom mapping to + * a string to be put into the csv. + */ +export type BackendCsvColumnsDefinition = (BackendCsvColumnDefinitionProperty | CsvColumnDefinitionMap)[]; + export const ISO_8859_15_ENCODING = `iso-8859-15`; export const DEFAULT_LINE_SEPARATOR = `\r\n`; export const DEFAULT_COLUMN_SEPARATOR = `,`; diff --git a/client/src/app/gateways/repositories/users/user-action.ts b/client/src/app/gateways/repositories/users/user-action.ts index 556516417e..750f45c89a 100644 --- a/client/src/app/gateways/repositories/users/user-action.ts +++ b/client/src/app/gateways/repositories/users/user-action.ts @@ -14,4 +14,6 @@ export class UserAction { public static readonly FORGET_PASSWORD_CONFIRM = `user.forget_password_confirm`; public static readonly ASSIGN_MEETINGS = `user.assign_meetings`; public static readonly MERGE_TOGETHER = `user.merge_together`; + public static readonly ACCOUNT_JSON_UPLOAD = `account.json_upload`; + public static readonly ACCOUNT_IMPORT = `account.import`; } diff --git a/client/src/app/gateways/repositories/users/user-repository.service.ts b/client/src/app/gateways/repositories/users/user-repository.service.ts index fa5014b82c..748a7e1132 100644 --- a/client/src/app/gateways/repositories/users/user-repository.service.ts +++ b/client/src/app/gateways/repositories/users/user-repository.service.ts @@ -5,6 +5,7 @@ import { BaseRepository } from 'src/app/gateways/repositories/base-repository'; import { UserAction } from 'src/app/gateways/repositories/users/user-action'; import { ActiveMeetingIdService } from 'src/app/site/pages/meetings/services/active-meeting-id.service'; import { ViewMeetingUser } from 'src/app/site/pages/meetings/view-models/view-meeting-user'; +import { BackendImportRawPreview } from 'src/app/ui/modules/import-list/definitions/backend-import-preview'; import { Id } from '../../../domain/definitions/key-types'; import { Displayable } from '../../../domain/interfaces/displayable'; @@ -497,6 +498,14 @@ export class UserRepositoryService extends BaseRepository { return this.createAction(UserAction.SET_PRESENT, payload); } + public accountJsonUpload(payload: { [key: string]: any }): Action { + return this.createAction(UserAction.ACCOUNT_JSON_UPLOAD, payload); + } + + public accountImport(payload: { id: number; import: boolean }[]): Action { + return this.createAction(UserAction.ACCOUNT_IMPORT, payload); + } + private sanitizePayload(payload: any): any { const temp = { ...payload }; for (const key of Object.keys(temp).filter(field => !this.isFieldAllowedToBeEmpty(field))) { diff --git a/client/src/app/site/base/base-import.service/base-backend-import.service.ts b/client/src/app/site/base/base-import.service/base-backend-import.service.ts index ca892b8a00..3f78c7ee20 100644 --- a/client/src/app/site/base/base-import.service/base-backend-import.service.ts +++ b/client/src/app/site/base/base-import.service/base-backend-import.service.ts @@ -282,15 +282,24 @@ export abstract class BaseBackendImportService implements BackendImportService { isBackendImportRawPreview(result) ) as BackendImportRawPreview[]; this.processRawPreviews(updatedPreviews); - if (this.previewHasRowErrors) { + const statesSet = new Set(updatedPreviews.map(preview => preview.state)); + if (statesSet.has(BackendImportState.Error)) { this._currentImportPhaseSubject.next(BackendImportPhase.ERROR); + } else if (statesSet.has(BackendImportState.Warning)) { + this.processRawPreviews( + updatedPreviews + .filter(preview => preview.state === BackendImportState.Warning) + .map(preview => ({ + ...preview, + rows: preview.rows.filter(row => row.messages && row.messages.length) + })) + ); + this._currentImportPhaseSubject.next(BackendImportPhase.FINISHED_WITH_WARNING); } else { - this._currentImportPhaseSubject.next(BackendImportPhase.TRY_AGAIN); + this._currentImportPhaseSubject.next(BackendImportPhase.FINISHED); + this._csvLines = []; + return true; } - } else { - this._currentImportPhaseSubject.next(BackendImportPhase.FINISHED); - this._csvLines = []; - return true; } return false; } diff --git a/client/src/app/site/base/base-via-backend-import-list.component.ts b/client/src/app/site/base/base-via-backend-import-list.component.ts index b9ba3eb7f0..b11d1c39f4 100644 --- a/client/src/app/site/base/base-via-backend-import-list.component.ts +++ b/client/src/app/site/base/base-via-backend-import-list.component.ts @@ -29,7 +29,7 @@ export abstract class BaseViaBackendImportListComponent extends BaseComponent im * True if the import is in a state in which an import can be conducted */ public get canImport(): boolean { - return this._state === BackendImportPhase.AWAITING_CONFIRM || this.tryAgain; + return this._state === BackendImportPhase.AWAITING_CONFIRM; } /** @@ -42,8 +42,8 @@ export abstract class BaseViaBackendImportListComponent extends BaseComponent im /** * True if, after an attempted import failed, the view is waiting for the user to confirm the import on the new preview. */ - public get tryAgain(): boolean { - return this._state === BackendImportPhase.TRY_AGAIN; + public get finishedWithWarnings(): boolean { + return this._state === BackendImportPhase.FINISHED_WITH_WARNING; } /** diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/components/topic-import/topic-import.component.html b/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/components/topic-import/topic-import.component.html index 5e9b79a31b..a2093e0426 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/components/topic-import/topic-import.component.html +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/components/topic-import/topic-import.component.html @@ -6,10 +6,16 @@

{{ 'Import topics' | translate }}