Merge branch 'master' into dev

This commit is contained in:
Dan Percic 2023-03-10 17:43:55 +02:00
commit 2db9fe67f4
8 changed files with 60 additions and 29 deletions

View File

@ -75,23 +75,23 @@
<div class="row">
<div
*ngIf="licenseService.totalInfo.startDate | date : 'longDate' as startDate"
*ngIf="licenseService.annualInfo.startDate | date : 'longDate' as startDate"
[innerHTML]="'license-info-screen.total-analyzed' | translate : { date: startDate }"
></div>
<div>{{ licenseService.totalInfo.numberOfAnalyzedPages }}</div>
<div>{{ licenseService.annualInfo.numberOfAnalyzedPages }}</div>
</div>
<div class="row">
<div translate="license-info-screen.current-analyzed"></div>
<div>
{{ licenseService.currentInfo.numberOfAnalyzedPages }}
{{ licenseService.analyzedPagesInCurrentLicensingPeriod }}
({{ analysisPercentageOfLicense$ | async | number : '1.0-2' }}%)
</div>
</div>
<div *ngIf="!!licenseService.unlicensedInfo" class="row">
<div *ngIf="!!licenseService.unlicensedPages" class="row">
<div translate="license-info-screen.unlicensed-analyzed"></div>
<div>{{ licenseService.unlicensedInfo.numberOfAnalyzedPages }}</div>
<div>{{ licenseService.unlicensedPages }}</div>
</div>
</div>

View File

@ -50,7 +50,7 @@ export class LicenseScreenComponent {
getAnalysisPercentageOfLicense() {
const totalLicensedNumberOfPages = this.licenseService.totalLicensedNumberOfPages;
const numberOfAnalyzedPages = this.licenseService.currentInfo.numberOfAnalyzedPages;
const numberOfAnalyzedPages = this.licenseService.analyzedPagesInCurrentLicensingPeriod;
return totalLicensedNumberOfPages > 0 ? (numberOfAnalyzedPages / totalLicensedNumberOfPages) * 100 : 100;
}

View File

@ -51,20 +51,16 @@ export class LicenseService extends GenericService<ILicenseReport> {
activeLicenseId: string;
totalLicensedNumberOfPages = 0;
currentInfo: ILicenseReport = {};
totalInfo: ILicenseReport = {};
unlicensedInfo: ILicenseReport = {};
annualInfo: ILicenseReport = {};
unlicensedPages = 0;
analyzedPagesInCurrentLicensingPeriod = 0;
protected readonly _defaultModelPath = 'report';
readonly #licenseData$ = new BehaviorSubject<ILicenses | undefined>(undefined);
readonly #selectedLicense$ = new BehaviorSubject<ILicense | undefined>(undefined);
constructor(private readonly _logger: NGXLogger) {
super();
this.selectedLicense$ = this.#selectedLicense$.pipe(
filter(license => !!license),
tap(license => {
this.totalLicensedNumberOfPages = this.getTotalLicensedNumberOfPages(license);
}),
);
this.selectedLicense$ = this.#selectedLicense$.pipe(filter(license => !!license));
this.licenseData$ = this.#licenseData$.pipe(
filter(licenses => !!licenses),
tap(data => (this.activeLicenseId = data.activeLicense)),
@ -95,6 +91,8 @@ export class LicenseService extends GenericService<ILicenseReport> {
}
async loadLicenseData(license: ILicense = this.selectedLicense) {
this.totalLicensedNumberOfPages = this.getTotalLicensedNumberOfPages(license);
const startDate = dayjs(license.validFrom);
const endDate = dayjs(license.validUntil);
@ -102,16 +100,23 @@ export class LicenseService extends GenericService<ILicenseReport> {
startDate: startDate.toDate(),
endDate: endDate.toDate(),
};
const reports: Promise<ILicenseReport>[] = [this.getReport(currentConfig), this.getReport({})];
if (endDate.isBefore(dayjs())) {
const unlicensedConfig = {
startDate: endDate.toDate(),
};
reports.push(this.getReport(unlicensedConfig));
const thisYearConfig = {
startDate: `${startDate.year()}-01-01T00:00:00.000Z`,
endDate: `${startDate.year()}-12-31T00:00:00.000Z`,
};
const configs = [currentConfig, thisYearConfig];
const reports = configs.map(config => this.getReport(config));
[this.currentInfo, this.annualInfo] = await Promise.all(reports);
if (this.currentInfo.numberOfAnalyzedPages > this.totalLicensedNumberOfPages) {
this.unlicensedPages = this.currentInfo.numberOfAnalyzedPages - this.totalLicensedNumberOfPages;
this.analyzedPagesInCurrentLicensingPeriod = this.totalLicensedNumberOfPages;
} else {
this.unlicensedPages = 0;
this.analyzedPagesInCurrentLicensingPeriod = this.currentInfo.numberOfAnalyzedPages;
}
[this.currentInfo, this.totalInfo, this.unlicensedInfo] = await Promise.all(reports);
}
getTotalLicensedNumberOfPages(license: ILicense) {

View File

@ -13,6 +13,10 @@ import dayjs from 'dayjs';
const INCLUDE_SEEN = false;
const AVAILABLE_NOTIFICATIONS_DAYS = 30;
const AVAILABLE_OLD_NOTIFICATIONS_MINUTES = 60;
const NOTIFICATIONS_THRESHOLD = 1000;
@Injectable({
providedIn: 'root',
})
@ -81,14 +85,30 @@ export class NotificationsService extends EntitiesService<INotification, Notific
}
const creationDate = dayjs(n.creationDate);
if (todayDate.diff(creationDate, 'day') <= this.#config.AVAILABLE_NOTIFICATIONS_DAYS) {
if (todayDate.diff(creationDate, 'day') <= (this.#config.AVAILABLE_NOTIFICATIONS_DAYS ?? AVAILABLE_NOTIFICATIONS_DAYS)) {
return true;
}
return todayDate.diff(readDate, 'minute') <= this.#config.AVAILABLE_OLD_NOTIFICATIONS_MINUTES;
console.log('------------------------------------------------------------------------------');
console.log('id: ', n.id);
console.log('today date: ', todayDate);
console.log('read date: ', readDate);
console.log('diff in minutes: ', todayDate.diff(readDate, 'minute'));
console.log(
'should be shown: ',
todayDate.diff(readDate, 'minute') <=
(this.#config.AVAILABLE_OLD_NOTIFICATIONS_MINUTES ?? AVAILABLE_OLD_NOTIFICATIONS_MINUTES),
);
console.log('CONFIG AVAILABLE_OLD_NOTIFICATIONS_MINUTES: ', this.#config.AVAILABLE_OLD_NOTIFICATIONS_MINUTES);
console.log('DEFAULT AVAILABLE_OLD_NOTIFICATIONS_MINUTES: ', AVAILABLE_OLD_NOTIFICATIONS_MINUTES);
return (
todayDate.diff(readDate, 'minute') <=
(this.#config.AVAILABLE_OLD_NOTIFICATIONS_MINUTES ?? AVAILABLE_OLD_NOTIFICATIONS_MINUTES)
);
});
return notifications.slice(0, this.#config.NOTIFICATIONS_THRESHOLD);
return notifications.slice(0, this.#config.NOTIFICATIONS_THRESHOLD ?? NOTIFICATIONS_THRESHOLD);
}
#loadNotificationsIfChanged(): Observable<Notification[]> {

View File

@ -18,6 +18,9 @@ RECENT_PERIOD_IN_HOURS="${RECENT_PERIOD_IN_HOURS:-24}"
SELECTION_MODE="${SELECTION_MODE:-structural}"
MANUAL_BASE_URL="${MANUAL_BASE_URL:-https://docs.redactmanager.com/preview}"
ANNOTATIONS_THRESHOLD="${ANNOTATIONS_THRESHOLD:-1000}"
AVAILABLE_NOTIFICATIONS_DAYS="${AVAILABLE_NOTIFICATIONS_DAYS:-30}"
AVAILABLE_OLD_NOTIFICATIONS_MINUTES="${AVAILABLE_OLD_NOTIFICATIONS_MINUTES:-60}"
NOTIFICATIONS_THRESHOLD="${NOTIFICATIONS_THRESHOLD:-1000}"
BASE_TRANSLATIONS_DIRECTORY="${BASE_TRANSLATIONS_DIRECTORY:-/assets/i18n/redact/}"
THEME="${THEME:-theme-template}"
@ -42,7 +45,10 @@ echo '{
"MANUAL_BASE_URL":"'"$MANUAL_BASE_URL"'",
"BASE_TRANSLATIONS_DIRECTORY":"'"$BASE_TRANSLATIONS_DIRECTORY"'",
"THEME":"'"$THEME"'",
"ANNOTATIONS_THRESHOLD":"'"$ANNOTATIONS_THRESHOLD"'"
"ANNOTATIONS_THRESHOLD":"'"$ANNOTATIONS_THRESHOLD"'",
"AVAILABLE_NOTIFICATIONS_DAYS":"'"$AVAILABLE_NOTIFICATIONS_DAYS"'",
"AVAILABLE_OLD_NOTIFICATIONS_MINUTES":"'"$AVAILABLE_OLD_NOTIFICATIONS_MINUTES"'",
"NOTIFICATIONS_THRESHOLD":"'"$NOTIFICATIONS_THRESHOLD"'"
}' > /usr/share/nginx/html/ui/assets/config/config.json
echo 'Env variables: '

View File

@ -2,7 +2,7 @@ import { List } from '@iqser/common-ui';
export interface ILicenseReportRequest {
dossierIds?: List;
endDate?: Date;
endDate?: Date | string;
requestId?: string;
startDate?: Date;
startDate?: Date | string;
}

View File

@ -1,6 +1,6 @@
{
"name": "redaction",
"version": "3.977.0",
"version": "3.983.0",
"private": true,
"license": "MIT",
"scripts": {

Binary file not shown.