Replace moment with dayjs

This commit is contained in:
Adina Țeudan 2022-03-22 00:33:56 +02:00
parent 5201cdb836
commit 13ae57e5cf
33 changed files with 136 additions and 134 deletions

View File

@ -41,7 +41,7 @@
<div class="cell">
<div class="small-label">
{{ download.creationDate | date: 'd MMM. yyyy, hh:mm a' }}
{{ download.creationDate | date: 'd MMM yyyy, hh:mm a' }}
</div>
</div>

View File

@ -1,5 +0,0 @@
import { LanguageService } from './language.service';
export function languageInitializer(languageService: LanguageService) {
return () => languageService.chooseAndSetInitialLanguage();
}

View File

@ -2,12 +2,28 @@ import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { UserPreferenceService } from '@services/user-preference.service';
import { firstValueFrom } from 'rxjs';
import 'dayjs/locale/en';
import 'dayjs/locale/de';
import dayjs, { Dayjs } from 'dayjs';
import { DateAdapter } from '@angular/material/core';
import arraySupport from 'dayjs/plugin/arraySupport';
import localeData from 'dayjs/plugin/localeData';
import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';
dayjs.extend(arraySupport);
dayjs.extend(localeData);
@Injectable({
providedIn: 'root',
})
export class LanguageService {
constructor(private readonly _translateService: TranslateService, private readonly _userPreferenceService: UserPreferenceService) {
constructor(
private readonly _translateService: TranslateService,
private readonly _userPreferenceService: UserPreferenceService,
private readonly _dateAdapter: DateAdapter<Dayjs>,
) {
registerLocaleData(localeDe);
_translateService.addLangs(['en', 'de']);
_translateService.setDefaultLang('en');
}
@ -16,11 +32,17 @@ export class LanguageService {
return this._translateService.currentLang;
}
async setLanguage(locale: string): Promise<void> {
dayjs.locale(locale);
this._dateAdapter.setLocale(locale);
await firstValueFrom(this._translateService.use(locale));
}
languageAvailable(language: string): boolean {
return this._translateService.getLangs().includes(language);
}
chooseAndSetInitialLanguage() {
async chooseAndSetInitialLanguage(): Promise<void> {
let defaultLang = 'en';
const userPreferenceLang = this._userPreferenceService.getLanguage();
if (this.languageAvailable(userPreferenceLang)) {
@ -28,12 +50,12 @@ export class LanguageService {
}
document.documentElement.lang = defaultLang;
this._translateService.setDefaultLang(defaultLang);
firstValueFrom(this._translateService.use(defaultLang)).then();
await this.setLanguage(defaultLang);
}
async changeLanguage(language: string) {
await this._userPreferenceService.saveLanguage(language);
document.documentElement.lang = language;
await firstValueFrom(this._translateService.use(language));
await this.setLanguage(language);
}
}

View File

@ -1,8 +1,6 @@
import { Component, Inject, Injector } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import * as moment from 'moment';
import { Moment } from 'moment';
import { applyIntervalConstraints } from '@utils/date-inputs-utils';
import { downloadTypesTranslations } from '../../../../translations/download-types-translations';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
@ -12,6 +10,7 @@ import { DossierTemplate, DownloadFileType, IDossierTemplate } from '@red/domain
import { HttpStatusCode } from '@angular/common/http';
import { DictionaryService } from '@shared/services/dictionary.service';
import { firstValueFrom } from 'rxjs';
import dayjs, { Dayjs } from 'dayjs';
@Component({
templateUrl: './add-edit-dossier-template-dialog.component.html',
@ -26,10 +25,10 @@ export class AddEditDossierTemplateDialogComponent extends BaseDialogComponent {
label: downloadTypesTranslations[type],
}));
readonly dossierTemplate: DossierTemplate;
private _previousValidFrom: Moment;
private _previousValidTo: Moment;
private _lastValidFrom: Moment;
private _lastValidTo: Moment;
private _previousValidFrom: Dayjs;
private _previousValidTo: Dayjs;
private _lastValidFrom: Dayjs;
private _lastValidTo: Dayjs;
constructor(
private readonly _toaster: Toaster,
@ -56,10 +55,10 @@ export class AddEditDossierTemplateDialogComponent extends BaseDialogComponent {
});
this.addSubscription = this.form.controls['validFrom'].valueChanges.subscribe(value => {
this._lastValidFrom = value ? value : this._lastValidFrom;
this._lastValidFrom = value || this._lastValidFrom;
});
this.addSubscription = this.form.controls['validTo'].valueChanges.subscribe(value => {
this._lastValidFrom = value ? value : this._lastValidFrom;
this._lastValidTo = value || this._lastValidTo;
});
}
@ -99,11 +98,11 @@ export class AddEditDossierTemplateDialogComponent extends BaseDialogComponent {
name: [this.dossierTemplate?.name, Validators.required],
description: [this.dossierTemplate?.description],
validFrom: [
this.dossierTemplate?.validFrom ? moment(this.dossierTemplate?.validFrom) : null,
this.dossierTemplate?.validFrom ? dayjs(this.dossierTemplate?.validFrom) : null,
this._requiredIfValidator(() => this.hasValidFrom),
],
validTo: [
this.dossierTemplate?.validTo ? moment(this.dossierTemplate?.validTo) : null,
this.dossierTemplate?.validTo ? dayjs(this.dossierTemplate?.validTo) : null,
this._requiredIfValidator(() => this.hasValidTo),
],
downloadFileTypes: [this.dossierTemplate?.downloadFileTypes || ['PREVIEW', 'REDACTED']],

View File

@ -103,7 +103,7 @@
</div>
<div class="small-label cell">
{{ log.recordDate | date: 'd MMM. yyyy, hh:mm a' }}
{{ log.recordDate | date: 'd MMM yyyy, hh:mm a' }}
</div>
<div class="user-column cell">

View File

@ -1,6 +1,5 @@
import { Component, forwardRef, Injector, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Moment } from 'moment';
import { applyIntervalConstraints } from '@utils/date-inputs-utils';
import { DefaultListingServices, ListingComponent, LoadingService, TableColumnConfig } from '@iqser/common-ui';
import { auditCategoriesTranslations } from '../../translations/audit-categories-translations';
@ -9,6 +8,7 @@ import { UserService } from '@services/user.service';
import { Audit, IAudit, IAuditResponse, IAuditSearchRequest } from '@red/domain';
import { AuditService } from '../../services/audit.service';
import { firstValueFrom } from 'rxjs';
import { Dayjs } from 'dayjs';
const PAGE_SIZE = 50;
@ -34,8 +34,8 @@ export class AuditScreenComponent extends ListingComponent<Audit> implements OnD
{ label: _('audit-screen.table-col-names.category') },
];
readonly tableHeaderLabel = _('audit-screen.table-header.title');
private _previousFrom: Moment;
private _previousTo: Moment;
private _previousFrom: Dayjs;
private _previousTo: Dayjs;
constructor(
private readonly _userService: UserService,

View File

@ -20,25 +20,25 @@
<div class="cell">
<div class="small-label">
{{ dossierTemplate.dateAdded | date: 'd MMM. yyyy' }}
{{ dossierTemplate.dateAdded | date: 'd MMM yyyy' }}
</div>
</div>
<div class="cell">
<div class="small-label">
{{ dossierTemplate.dateModified | date: 'd MMM. yyyy' }}
{{ dossierTemplate.dateModified | date: 'd MMM yyyy' }}
</div>
</div>
<div class="cell">
<div class="small-label">
{{ dossierTemplate.validFrom | date: 'd MMM. yyyy' }}
{{ dossierTemplate.validFrom | date: 'd MMM yyyy' }}
</div>
</div>
<div class="cell">
<div class="small-label">
{{ dossierTemplate.validTo | date: 'd MMM. yyyy' }}
{{ dossierTemplate.validTo | date: 'd MMM yyyy' }}
</div>
</div>

View File

@ -23,12 +23,12 @@
<div *ngIf="dossierTemplate.validTo && dossierTemplate.validFrom">
<mat-icon svgIcon="red:calendar"></mat-icon>
{{ 'dossier-template-info-screen.valid-from' | translate: { date: dossierTemplate.validFrom | date: 'd MMM. yyyy' } }}
{{ 'dossier-template-info-screen.valid-from' | translate: { date: dossierTemplate.validFrom | date: 'd MMM yyyy' } }}
</div>
<div>
<mat-icon svgIcon="red:calendar"></mat-icon>
{{ 'dossier-template-info-screen.created-on' | translate: { date: dossierTemplate.dateAdded | date: 'd MMM. yyyy' } }}
{{ 'dossier-template-info-screen.created-on' | translate: { date: dossierTemplate.dateAdded | date: 'd MMM yyyy' } }}
</div>
<div>
@ -38,12 +38,12 @@
<div *ngIf="dossierTemplate.validTo && dossierTemplate.validFrom">
<mat-icon svgIcon="red:calendar"></mat-icon>
{{ 'dossier-template-info-screen.valid-to' | translate: { date: dossierTemplate.validTo | date: 'd MMM. yyyy' } }}
{{ 'dossier-template-info-screen.valid-to' | translate: { date: dossierTemplate.validTo | date: 'd MMM yyyy' } }}
</div>
<div *ngIf="dossierTemplate.dateModified">
<mat-icon svgIcon="red:calendar"></mat-icon>
{{ 'dossier-template-info-screen.modified-on' | translate: { date: dossierTemplate.dateModified | date: 'd MMM. yyyy' } }}
{{ 'dossier-template-info-screen.modified-on' | translate: { date: dossierTemplate.dateModified | date: 'd MMM yyyy' } }}
</div>
</div>

View File

@ -1,6 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { ConfigService } from '@services/config.service';
import * as moment from 'moment';
import { TranslateService } from '@ngx-translate/core';
import { ButtonConfig, IconButtonTypes, LoadingService } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@ -10,6 +9,7 @@ import { LicenseReportService } from '../../services/licence-report.service';
import { ILicenseReport } from '@red/domain';
import { Color, ScaleType } from '@swimlane/ngx-charts';
import { firstValueFrom } from 'rxjs';
import dayjs from 'dayjs';
@Component({
selector: 'redaction-license-information-screen',
@ -63,8 +63,8 @@ export class LicenseInformationScreenComponent implements OnInit {
async ngOnInit() {
this.totalLicensedNumberOfPages = this.configService.values.LICENSE_PAGE_COUNT || 0;
const startDate = moment(this.configService.values.LICENSE_START, 'DD-MM-YYYY');
const endDate = moment(this.configService.values.LICENSE_END, 'DD-MM-YYYY');
const startDate = dayjs(this.configService.values.LICENSE_START, 'DD-MM-YYYY');
const endDate = dayjs(this.configService.values.LICENSE_END, 'DD-MM-YYYY');
await this._setMonthlyStats(startDate, endDate);
@ -77,7 +77,7 @@ export class LicenseInformationScreenComponent implements OnInit {
firstValueFrom(this._licenseReportService.licenseReport({})),
];
if (endDate.isBefore(moment())) {
if (endDate.isBefore(dayjs())) {
const unlicensedConfig = {
startDate: endDate.toDate(),
};
@ -111,20 +111,19 @@ export class LicenseInformationScreenComponent implements OnInit {
window.location.href = `mailto:${this.configService.values.LICENSE_EMAIL}?subject=${subject}&body=${body}`;
}
private async _setMonthlyStats(startDate: moment.Moment, endDate: moment.Moment) {
private async _setMonthlyStats(startDate: dayjs.Dayjs, endDate: dayjs.Dayjs) {
const [startMonth, startYear] = [startDate.month(), startDate.year()];
const [endMonth, endYear] = [endDate.month(), endDate.year()];
moment.locale(this._translateService.currentLang);
let m = startMonth;
let y = startYear;
let m: number = startMonth;
let y: number = startYear;
const totalLicensedSeries = [];
const cumulativePagesSeries = [];
const promises = [];
while (m <= endMonth && y <= endYear) {
totalLicensedSeries.push({
name: `${moment.localeData().monthsShort(moment([y, m]))} ${y}`,
name: `${dayjs.monthsShort()[m]} ${y}`,
value: this.totalLicensedNumberOfPages,
});
@ -138,8 +137,8 @@ export class LicenseInformationScreenComponent implements OnInit {
promises.push(
firstValueFrom(
this._licenseReportService.licenseReport({
startDate: moment(`01-${m + 1}-${y}`, 'DD-MM-YYYY').toDate(),
endDate: moment(`01-${nm + 1}-${ny}`, 'DD-MM-YYYY').toDate(),
startDate: dayjs(`01-${m + 1}-${y}`, 'DD-M-YYYY').toDate(),
endDate: dayjs(`01-${nm + 1}-${ny}`, 'DD-M-YYYY').toDate(),
}),
),
);
@ -157,11 +156,11 @@ export class LicenseInformationScreenComponent implements OnInit {
for (const report of reports) {
cumulativePages += report.numberOfAnalyzedPages;
this.barChart.push({
name: `${moment.localeData().monthsShort(moment([y, m]))} ${y}`,
name: `${dayjs.monthsShort()[m]} ${y}`,
value: report.numberOfAnalyzedPages,
});
cumulativePagesSeries.push({
name: `${moment.localeData().monthsShort(moment([y, m]))} ${y}`,
name: `${dayjs.monthsShort()[m]} ${y}`,
value: cumulativePages,
});
m++;

View File

@ -2,7 +2,7 @@
<redaction-dossier-name-column [dossierStats]="stats$ | async" [dossier]="dossier"></redaction-dossier-name-column>
</div>
<div class="cell small-label">{{ dossier.archivedTime | date: 'd MMM. yyyy' }}</div>
<div class="cell small-label">{{ dossier.archivedTime | date: 'd MMM yyyy' }}</div>
<div class="cell user-column">
<redaction-initials-avatar [user]="dossier.ownerId" [withName]="true"></redaction-initials-avatar>

View File

@ -21,12 +21,12 @@
<span>{{ 'dossier-overview.dossier-details.stats.analysed-pages' | translate: { count: stats.numberOfPages | number } }}</span>
</div>
<div *ngIf="dossier.date | date: 'd MMM. yyyy' as date">
<div *ngIf="dossier.date | date: 'd MMM yyyy' as date">
<mat-icon svgIcon="red:calendar"></mat-icon>
<span>{{ 'dossier-overview.dossier-details.stats.created-on' | translate: { date: date } }}</span>
</div>
<div *ngIf="dossier.dueDate | date: 'd MMM. yyyy' as dueDate">
<div *ngIf="dossier.dueDate | date: 'd MMM yyyy' as dueDate">
<mat-icon svgIcon="red:lightning"></mat-icon>
<span>{{ 'dossier-overview.dossier-details.stats.due-date' | translate: { date: dueDate } }}</span>
</div>
@ -62,7 +62,7 @@
<div (click)="openEditDossierDialog('dossierAttributes')" *ngFor="let attr of dossierAttributes" class="link-property">
<mat-icon svgIcon="red:attribute"></mat-icon>
<span *ngIf="!attr.value"> {{ attr.label + ': -' }}</span>
<span *ngIf="attr.value && attr.type === 'DATE'"> {{ attr.label + ': ' + (attr.value | date: 'd MMM. yyyy') }}</span>
<span *ngIf="attr.value && attr.type === 'DATE'"> {{ attr.label + ': ' + (attr.value | date: 'd MMM yyyy') }}</span>
<span *ngIf="attr.value && attr.type === 'IMAGE'">
{{ attr.label + ': ' + ('dossier-overview.dossier-details.attributes.image-uploaded' | translate) }}</span
>

View File

@ -20,10 +20,10 @@ import { UserService } from '@services/user.service';
import { DossiersDialogService } from '../dossier/services/dossiers-dialog.service';
import { annotationFilterChecker, RedactionFilterSorter } from '../../utils';
import { workloadTranslations } from '../dossier/translations/workload-translations';
import * as moment from 'moment';
import { ConfigService as AppConfigService } from '@services/config.service';
import { BehaviorSubject, Observable } from 'rxjs';
import { BulkActionsService } from './services/bulk-actions.service';
import dayjs from 'dayjs';
@Injectable()
export class ConfigService {
@ -177,7 +177,7 @@ export class ConfigService {
entities.forEach(file => {
allDistinctPeople.add(file.assignee);
allDistinctWorkflowFileStatuses.add(file.workflowStatus);
allDistinctAddedDates.add(moment(file.added).format('DD/MM/YYYY'));
allDistinctAddedDates.add(dayjs(file.added).format('DD/MM/YYYY'));
if (file.analysisRequired) {
allDistinctNeedsWork.add('analysis');
@ -329,9 +329,9 @@ export class ConfigService {
}
_recentlyModifiedChecker = (file: File) =>
moment(file.lastUpdated)
dayjs(file.lastUpdated)
.add(this._appConfigService.values.RECENT_PERIOD_IN_HOURS as number, 'hours')
.isAfter(moment());
.isAfter(dayjs());
_assignedToMeChecker = (file: File) => file.assignee === this._userService.currentUser.id;

View File

@ -16,12 +16,12 @@
<div class="iqser-input-group required w-400">
<mat-form-field floatLabel="always">
<mat-label>{{ 'add-dossier-dialog.form.template' | translate }}</mat-label>
<mat-label>{{ 'add-dossier-dialog.form.template.label' | translate }}</mat-label>
<mat-select
(valueChange)="dossierTemplateChanged($event)"
[placeholder]="'add-dossier-dialog.form.template.placeholder' | translate"
formControlName="dossierTemplateId"
id="dossierTemplateSelect"
style="width: 100%"
>
<mat-option
*ngFor="let dossierTemplate of dossierTemplates"

View File

@ -2,7 +2,6 @@ import { Component, Injector } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
import { DownloadFileType, IDossierRequest, IDossierTemplate, IReportTemplate } from '@red/domain';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import * as moment from 'moment';
import { downloadTypesTranslations } from '../../../../translations/download-types-translations';
import { BaseDialogComponent, IconButtonTypes, SaveOptions } from '@iqser/common-ui';
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
@ -10,6 +9,7 @@ import { DossierTemplatesService } from '@services/entity-services/dossier-templ
import { ReportTemplateService } from '@services/report-template.service';
import { firstValueFrom } from 'rxjs';
import { DOSSIER_TEMPLATE_ID } from '@utils/constants';
import dayjs from 'dayjs';
@Component({
templateUrl: './add-dossier-dialog.component.html',
@ -118,8 +118,8 @@ export class AddDossierDialogComponent extends BaseDialogComponent {
private _getDossierTemplates() {
this.dossierTemplates = this._dossierTemplatesService.all
.filter(r => {
const notYetValid = !!r.validFrom && moment(r.validFrom).isAfter(moment());
const notValidAnymore = !!r.validTo && moment(r.validTo).add(1, 'd').isBefore(moment());
const notYetValid = !!r.validFrom && dayjs(r.validFrom).isAfter(dayjs());
const notValidAnymore = !!r.validTo && dayjs(r.validTo).add(1, 'd').isBefore(dayjs());
return !(notYetValid || notValidAnymore) && r.isActive;
})
.sort((t1, t2) => t1.name.toLowerCase().localeCompare(t2.name.toLowerCase()));

View File

@ -4,10 +4,10 @@ import { Dossier, DossierAttributeConfigType, DossierAttributeConfigTypes, Dossi
import { PermissionsService } from '@services/permissions.service';
import { CircleButtonTypes, IconButtonTypes, LoadingService, Toaster } from '@iqser/common-ui';
import { FormBuilder, FormGroup } from '@angular/forms';
import * as moment from 'moment';
import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { firstValueFrom } from 'rxjs';
import dayjs from 'dayjs';
@Component({
selector: 'redaction-edit-dossier-attributes',
@ -38,7 +38,7 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
get changed() {
for (const attr of this.attributes) {
if (this.isSpecificType(attr, this.dossierAttributeConfigTypes.DATE) && attr.value) {
if (!moment(attr.value).isSame(moment(this.currentAttrValue(attr)))) {
if (!dayjs(attr.value).isSame(dayjs(this.currentAttrValue(attr)), 'day')) {
return true;
}
} else if (this._parseAttrValue(attr.value) !== this._parseAttrValue(this.currentAttrValue(attr))) {
@ -69,7 +69,7 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
dossierAttributeConfigId: attr.id,
value:
this.isSpecificType(attr, DossierAttributeConfigTypes.DATE) && !!this.currentAttrValue(attr)
? moment(this.currentAttrValue(attr)).format('YYYY-MM-DD')
? dayjs(this.currentAttrValue(attr)).format('YYYY-MM-DD')
: this.currentAttrValue(attr),
}));
try {

View File

@ -14,7 +14,7 @@
<div class="iqser-input-group required w-400">
<mat-form-field floatLabel="always">
<mat-label>{{ 'edit-dossier-dialog.general-info.form.template' | translate }}</mat-label>
<mat-select formControlName="dossierTemplateId" style="width: 100%">
<mat-select formControlName="dossierTemplateId">
<mat-option
*ngFor="let dossierTemplate of dossierTemplates"
[matTooltip]="dossierTemplate.description ? dossierTemplate.description : dossierTemplate.name"

View File

@ -1,6 +1,5 @@
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import * as moment from 'moment';
import { Dossier, IDossierRequest, IDossierTemplate } from '@red/domain';
import { EditDossierSaveResult, EditDossierSectionInterface } from '../edit-dossier-section.interface';
import { DossiersDialogService } from '../../../services/dossiers-dialog.service';
@ -19,6 +18,7 @@ import { DossiersService } from '@services/dossiers/dossiers.service';
import { TrashService } from '@services/entity-services/trash.service';
import { ArchivedDossiersService } from '@services/dossiers/archived-dossiers.service';
import { DossierStatesMapService } from '@services/entity-services/dossier-states-map.service';
import dayjs from 'dayjs';
import { FeaturesService } from '@services/features.service';
@Component({
@ -62,7 +62,7 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
if (this.hasDueDate !== !!this.dossier.dueDate) {
return true;
}
if (this.hasDueDate && !moment(this.dossier.dueDate).isSame(moment(this.form.get(key).value))) {
if (this.hasDueDate && !dayjs(this.dossier.dueDate).isSame(dayjs(this.form.get(key).value), 'day')) {
return true;
}
} else if (this.dossier[key] !== this.form.get(key).value) {
@ -204,8 +204,8 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
if (this.dossier?.dossierTemplateId === r.dossierTemplateId) {
return true;
}
const notYetValid = !!r.validFrom && moment(r.validFrom).isAfter(moment());
const notValidAnymore = !!r.validTo && moment(r.validTo).add(1, 'd').isBefore(moment());
const notYetValid = !!r.validFrom && dayjs(r.validFrom).isAfter(dayjs());
const notValidAnymore = !!r.validTo && dayjs(r.validTo).add(1, 'd').isBefore(dayjs());
return !(notYetValid || notValidAnymore) && r.isActive;
});
}

View File

@ -1,3 +1,3 @@
<div [class.error]="isError" class="small-label">
{{ date | date: 'd MMM. yyyy' }}
{{ date | date: 'd MMM yyyy' }}
</div>

View File

@ -11,7 +11,6 @@ import {
ViewModes,
} from '@red/domain';
import { AnnotationWrapper } from '../../../models/file/annotation.wrapper';
import * as moment from 'moment';
import { BehaviorSubject, firstValueFrom, iif, Observable, Subject } from 'rxjs';
import { RedactionLogEntry } from '../../../models/file/redaction-log.entry';
import { Injectable } from '@angular/core';
@ -28,6 +27,7 @@ import { TextHighlightService } from '../../dossier/services/text-highlight.serv
import { ViewModeService } from './view-mode.service';
import { Core } from '@pdftron/webviewer';
import { Router } from '@angular/router';
import dayjs from 'dayjs';
import Annotation = Core.Annotations.Annotation;
const DELTA_VIEW_TIME = 10 * 60 * 1000; // 10 minutes;
@ -254,7 +254,7 @@ export class FileDataService {
} {
if (file.numberOfAnalyses > 1) {
const viableChanges = redactionLogEntry.changes.filter(c => c.analysisNumber > 1);
viableChanges.sort((a, b) => moment(a.dateTime).valueOf() - moment(b.dateTime).valueOf());
viableChanges.sort((a, b) => dayjs(a.dateTime).valueOf() - dayjs(b.dateTime).valueOf());
const lastChange = viableChanges.length >= 1 ? viableChanges[viableChanges.length - 1] : undefined;
const page = redactionLogEntry.positions?.[0].page;
@ -263,13 +263,13 @@ export class FileDataService {
// page has been seen -> let's see if it's a change
if (viewedPage) {
const viewTime = moment(viewedPage.viewedTime).valueOf() - DELTA_VIEW_TIME;
const viewTime = dayjs(viewedPage.viewedTime).valueOf() - DELTA_VIEW_TIME;
// these are all unseen changes
const relevantChanges = viableChanges.filter(change => moment(change.dateTime).valueOf() > viewTime);
const relevantChanges = viableChanges.filter(change => dayjs(change.dateTime).valueOf() > viewTime);
// at least one unseen change
if (relevantChanges.length > 0) {
// at least 1 relevant change
viewedPage.showAsUnseen = moment(viewedPage.viewedTime).valueOf() < moment(lastChange.dateTime).valueOf();
viewedPage.showAsUnseen = dayjs(viewedPage.viewedTime).valueOf() < dayjs(lastChange.dateTime).valueOf();
this.hasChangeLog$.next(true);
return {
changeLogType: relevantChanges[relevantChanges.length - 1].type,

View File

@ -17,6 +17,7 @@ import { MatSelectModule } from '@angular/material/select';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatChipsModule } from '@angular/material/chips';
import { MatDayjsDateModule } from '@tabuckner/material-dayjs-adapter';
const matImports = [
MatDialogModule,
@ -37,6 +38,7 @@ const matImports = [
MatProgressBarModule,
MatAutocompleteModule,
MatChipsModule,
MatDayjsDateModule,
];
@NgModule({

View File

@ -1,8 +1,8 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Dossier, DossierStats } from '@red/domain';
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
import * as moment from 'moment';
import { List } from '@iqser/common-ui';
import dayjs from 'dayjs';
const DUE_DATE_WARN_DAYS = 14;
@ -36,7 +36,7 @@ export class DossierNameColumnComponent {
}
private get _dueDateDaysDiff(): number {
return moment(this.dossier.dueDate).diff(moment().startOf('day'), 'days');
return dayjs(this.dossier.dueDate).diff(dayjs().startOf('day'), 'days');
}
getDossierTemplateNameFor(dossierTemplateId: string): string {

View File

@ -17,12 +17,12 @@
</g>
</svg>
<div [style]="'height: ' + size + 'px; width: ' + size + 'px; padding: ' + strokeWidth + 'px;'" class="text-container">
<div [style]="'height: ' + size + 'px; width: ' + size + 'px; padding: ' + (strokeWidth + 5) + 'px;'" class="text-container">
<div class="heading-xl">{{ displayedDataTotal }}</div>
<div class="mt-5">{{ subtitle }}</div>
</div>
<div class="breakdown-container" [iqserHelpMode]="helpModeKey">
<div [iqserHelpMode]="helpModeKey" class="breakdown-container">
<div
(click)="val.key && selectValue(val.key)"
*ngFor="let val of config"

View File

@ -1,24 +1,8 @@
import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core';
import * as moment from 'moment';
import { TranslateService } from '@ngx-translate/core';
import { DatePipe as BaseDatePipe } from '@angular/common';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { getLeftDateTime } from '@iqser/common-ui';
const MONTH_NAMES: Record<number, string> = {
0: _('months.jan'),
1: _('months.feb'),
2: _('months.mar'),
3: _('months.apr'),
4: _('months.may'),
5: _('months.jun'),
6: _('months.jul'),
7: _('months.aug'),
8: _('months.sep'),
9: _('months.oct'),
10: _('months.nov'),
11: _('months.dec'),
};
import dayjs from 'dayjs';
@Pipe({
name: 'date',
@ -42,7 +26,7 @@ export class DatePipe extends BaseDatePipe implements PipeTransform {
return this._getExactDate(value);
}
}
return super.transform(value, format, timezone, locale);
return super.transform(value, format, timezone, locale || this._translateService.currentLang);
}
private _getTimeFromNow(value: string) {
@ -71,12 +55,12 @@ export class DatePipe extends BaseDatePipe implements PipeTransform {
}
private _getSophisticatedDate(item: string) {
const date = moment(item);
const date = dayjs(item);
const day = date.date();
const month = date.month();
const year = date.year();
const now = moment(Date.now());
const now = dayjs(Date.now());
const yesterday = now.clone().subtract(1, 'days').startOf('day');
const thisDay = now.date();
const thisMonth = now.month();
@ -84,10 +68,10 @@ export class DatePipe extends BaseDatePipe implements PipeTransform {
const isTodayFormat = date.isSame(new Date(), 'day');
if (isTodayFormat) {
return moment(date, ['h:mm A']).format('HH:mm');
return dayjs(date, ['h:mm A']).format('HH:mm');
}
const isYesterdayFormat = date.isSame(yesterday, 'd');
const isYesterdayFormat = date.isSame(yesterday, 'day');
if (isYesterdayFormat) {
return this._translateService.instant('yesterday');
}
@ -96,13 +80,13 @@ export class DatePipe extends BaseDatePipe implements PipeTransform {
year === thisYear &&
((month === thisMonth && day !== thisDay && day !== thisDay - 1) || (month !== thisMonth && month >= thisMonth - 2));
if (isShortMonthFormat) {
const translatedMonth = this._translateService.instant(MONTH_NAMES[month]);
const translatedMonth = dayjs.monthsShort()[month];
return `${day} ${translatedMonth}`;
}
const isShortMonthYearFormat = (year === thisYear && month <= thisMonth - 3) || year === thisYear - 1;
if (isShortMonthYearFormat) {
const translatedMonth = this._translateService.instant(MONTH_NAMES[month]);
const translatedMonth = dayjs.monthsShort()[month];
return `${translatedMonth} ${year}`;
}
@ -110,9 +94,9 @@ export class DatePipe extends BaseDatePipe implements PipeTransform {
}
private _getExactDate(item: string) {
const date = moment(item);
const date = dayjs(item);
const day = date.date();
const month = this._translateService.instant(MONTH_NAMES[date.month()]);
const month = dayjs.monthsShort()[date.month()];
const year = date.year();
const hour = date.hour().toString(10).padStart(2, '0');
const minute = date.minute().toString(10).padStart(2, '0');

View File

@ -12,8 +12,6 @@ import { AnnotationIconComponent } from './components/annotation-icon/annotation
import { SimpleDoughnutChartComponent } from './components/simple-doughnut-chart/simple-doughnut-chart.component';
import { DictionaryAnnotationIconComponent } from './components/dictionary-annotation-icon/dictionary-annotation-icon.component';
import { CommonUiModule } from '@iqser/common-ui';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';
import { MomentDateAdapter } from '@angular/material-moment-adapter';
import { SelectComponent } from './components/select/select.component';
import { NavigateLastDossiersScreenDirective } from './directives/navigate-last-dossiers-screen.directive';
import { DictionaryManagerComponent } from './components/dictionary-manager/dictionary-manager.component';
@ -31,6 +29,7 @@ import { DossierStateComponent } from '@shared/components/dossier-state/dossier-
import { FileStatsComponent } from './components/file-stats/file-stats.component';
import { FileNameColumnComponent } from '@shared/components/file-name-column/file-name-column.component';
import { DossierNameColumnComponent } from '@shared/components/dossier-name-column/dossier-name-column.component';
import { MAT_DATE_FORMATS } from '@angular/material/core';
const buttons = [FileDownloadBtnComponent, UserButtonComponent];
@ -64,7 +63,6 @@ const modules = [MatConfigModule, ScrollingModule, IconsModule, FormsModule, Rea
imports: [CommonModule, ...modules, MonacoEditorModule],
exports: [...modules, ...components, ...utils],
providers: [
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
{
provide: MAT_DATE_FORMATS,
useValue: {

View File

@ -1,6 +1,5 @@
import { Injectable, Injector } from '@angular/core';
import { GenericService, List, mapEach, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
import * as moment from 'moment';
import { TranslateService } from '@ngx-translate/core';
import { EMPTY, iif, Observable } from 'rxjs';
import { INotification, Notification, NotificationTypes } from '@red/domain';
@ -10,6 +9,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { ActiveDossiersService } from './dossiers/active-dossiers.service';
import { UserService } from '@services/user.service';
import { FilesMapService } from '@services/entity-services/files-map.service';
import dayjs from 'dayjs';
@Injectable({
providedIn: 'root',
@ -60,8 +60,7 @@ export class NotificationsService extends GenericService<Notification> {
}
private _getTime(date: string): string {
moment.locale(this._translateService.currentLang);
return moment(date).format('hh:mm A');
return dayjs(date).format('hh:mm A');
}
private _translate(notification: INotification, translation: string): string {

View File

@ -36,7 +36,7 @@ export function configurationInitializer(
title.setTitle('RedactManager');
return of({});
}),
tap(() => languageService.chooseAndSetInitialLanguage()),
switchMap(() => languageService.chooseAndSetInitialLanguage()),
tap(() => userService.initialize()),
take(1),
),

View File

@ -1,10 +1,10 @@
import { FormGroup } from '@angular/forms';
import { Moment } from 'moment';
import { Dayjs } from 'dayjs';
export function applyIntervalConstraints(
value,
previousFrom: Moment,
previousTo: Moment,
previousFrom: Dayjs,
previousTo: Dayjs,
form: FormGroup,
fromKey: string,
toKey: string,

View File

@ -1,7 +1,7 @@
{
"ADMIN_CONTACT_NAME": null,
"ADMIN_CONTACT_URL": null,
"API_URL": "https://dev-04.iqser.cloud/redaction-gateway-v1",
"API_URL": "https://dev-08.iqser.cloud/redaction-gateway-v1",
"APP_NAME": "RedactManager",
"AUTO_READ_TIME": 3,
"BACKEND_APP_VERSION": "4.4.40",
@ -10,14 +10,14 @@
"FRONTEND_APP_VERSION": "1.1",
"LICENSE_CUSTOMER": "Development License",
"LICENSE_EMAIL": "todo-license@email.com",
"LICENSE_END": "31-12-2021",
"LICENSE_PAGE_COUNT": 1000000,
"LICENSE_END": "31-12-2022",
"LICENSE_PAGE_COUNT": 1000,
"LICENSE_START": "01-01-2021",
"MAX_FILE_SIZE_MB": 100,
"MAX_RETRIES_ON_SERVER_ERROR": 3,
"OAUTH_CLIENT_ID": "redaction",
"OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://dev-04.iqser.cloud/auth/realms/redaction",
"OAUTH_URL": "https://dev-08.iqser.cloud/auth/realms/redaction",
"RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural",
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview"

View File

@ -27,7 +27,10 @@
"label": "Dossier-Name",
"placeholder": "Geben Sie einen Namen ein."
},
"template": "Dossier-Vorlage",
"template": {
"label": "Dossier-Vorlage",
"placeholder": ""
},
"watermark": "Geschwärzte Dokumente mit Wasserzeichen versehen",
"watermark-preview": "Vorschau Dokumente mit Wasserzeichen versehen"
},

View File

@ -27,7 +27,10 @@
"label": "Dossier Name",
"placeholder": "Enter Name"
},
"template": "Dossier Template",
"template": {
"label": "Dossier Template",
"placeholder": "Choose Dossier Template"
},
"watermark": "Watermark application on redacted documents",
"watermark-preview": "Watermark application on preview documents"
},

View File

@ -1,5 +1,5 @@
import { getLeftDateTime } from '@iqser/common-ui';
import * as moment from 'moment';
import * as dayjs from 'dayjs';
export abstract class TrashItem {
abstract readonly type: 'dossier' | 'file';
@ -38,6 +38,6 @@ export abstract class TrashItem {
}
get #restoreDate(): string {
return moment(this.softDeletedTime).add(this._retentionHours, 'hours').toISOString();
return dayjs(this.softDeletedTime).add(this._retentionHours, 'hours').toISOString();
}
}

View File

@ -28,10 +28,11 @@
"@angular/cdk": "13.2.6",
"@angular/common": "13.2.6",
"@angular/compiler": "13.2.6",
"@tabuckner/material-dayjs-adapter": "2.0.0",
"dayjs": "^1.11.0",
"@angular/core": "13.2.6",
"@angular/forms": "13.2.6",
"@angular/material": "13.2.6",
"@angular/material-moment-adapter": "^13.2.0",
"@angular/platform-browser": "13.2.6",
"@angular/platform-browser-dynamic": "13.2.6",
"@angular/router": "13.2.6",
@ -49,7 +50,6 @@
"keycloak-js": "^16.1.1",
"lodash-es": "^4.17.21",
"messageformat": "^2.3.0",
"moment": "^2.29.1",
"monaco-editor": "^0.33.0",
"ngx-color-picker": "^12.0.1",
"ngx-logger": "^5.0.9",

View File

@ -257,13 +257,6 @@
resolved "https://registry.yarnpkg.com/@angular/language-service/-/language-service-13.2.6.tgz#ee417af8a814b531be54e82e73254c3f18793a3a"
integrity sha512-nhF8GvEyUKIaDFTIQ4RSPQwRng7XjEWQl2zz0B8ShvQsgF/zMLo7mAci9MXxkYBIejU1I07w32r2J90rkjsARA==
"@angular/material-moment-adapter@^13.2.0":
version "13.2.6"
resolved "https://registry.yarnpkg.com/@angular/material-moment-adapter/-/material-moment-adapter-13.2.6.tgz#62461ae77ac3bcc61aec068151e726f8e4d4ce21"
integrity sha512-mlp+890uL8nr/ufiAw9axEkr4z5Xv4rvyq1bBDUBjrLhODS4gOyo3XC5vO57Ycf4zhSpHPjmDAU/BTFtmNLw4A==
dependencies:
tslib "^2.3.0"
"@angular/material@13.2.6":
version "13.2.6"
resolved "https://registry.yarnpkg.com/@angular/material/-/material-13.2.6.tgz#615ad63453cd4122ab1775b077e8122c932cab06"
@ -2149,6 +2142,11 @@
d3-transition "^2.0.0"
tslib "^2.0.0"
"@tabuckner/material-dayjs-adapter@2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@tabuckner/material-dayjs-adapter/-/material-dayjs-adapter-2.0.0.tgz#e79207232363fca391820c7992f7ed97576d7199"
integrity sha512-U2h76Gid/9sWXo+CxxQFnkMpOxfGiSH2xnHDHUmI9ZHZjTzOQ3/T7bZl9jIh43eBEwM3E4mba5W8NYvKExtzaA==
"@tootallnate/once@1":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
@ -4649,6 +4647,11 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"
dayjs@^1.11.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.0.tgz#009bf7ef2e2ea2d5db2e6583d2d39a4b5061e805"
integrity sha512-JLC809s6Y948/FuCZPm5IX8rRhQwOiyMb2TfVVQEixG7P8Lm/gt5S7yoQZmC8x1UehI9Pb7sksEt4xx14m+7Ug==
debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@ -8807,11 +8810,6 @@ mkdirp@^1.0.3, mkdirp@^1.0.4:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
moment@^2.29.1:
version "2.29.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
monaco-editor@^0.33.0:
version "0.33.0"
resolved "https://registry.yarnpkg.com/monaco-editor/-/monaco-editor-0.33.0.tgz#842e244f3750a2482f8a29c676b5684e75ff34af"