add licence report service

This commit is contained in:
Dan Percic 2021-10-14 13:26:03 +03:00
parent 65b2f25844
commit 09cf5b795a
4 changed files with 33 additions and 9 deletions

View File

@ -42,6 +42,7 @@ import { TrashScreenComponent } from './screens/trash/trash-screen.component';
import { AuditService } from './services/audit.service';
import { DigitalSignatureService } from './services/digital-signature.service';
import { BaseAdminScreenComponent } from './base-admin-screen/base-admin-screen.component';
import { LicenseReportService } from './services/licence-report.service';
const dialogs = [
AddEditDossierTemplateDialogComponent,
@ -92,7 +93,7 @@ const components = [
@NgModule({
declarations: [...components],
providers: [AdminDialogService, AuditService, DigitalSignatureService],
providers: [AdminDialogService, AuditService, DigitalSignatureService, LicenseReportService],
imports: [CommonModule, SharedModule, AdminRoutingModule, NgxChartsModule, ColorPickerModule, MonacoEditorModule],
})
export class AdminModule {}

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { LicenseReport, LicenseReportControllerService } from '@redaction/red-ui-http';
import { LicenseReport } from '@redaction/red-ui-http';
import { ConfigService } from '@services/config.service';
import * as moment from 'moment';
import { TranslateService } from '@ngx-translate/core';
@ -7,6 +7,7 @@ import { ButtonConfig, IconButtonTypes, LoadingService } from '@iqser/common-ui'
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@services/user.service';
import { RouterHistoryService } from '@services/router-history.service';
import { LicenseReportService } from '../../services/licence-report.service';
@Component({
selector: 'redaction-license-information-screen',
@ -47,7 +48,7 @@ export class LicenseInformationScreenComponent implements OnInit {
private readonly _loadingService: LoadingService,
readonly routerHistoryService: RouterHistoryService,
private readonly _translateService: TranslateService,
private readonly _licenseReportController: LicenseReportControllerService,
private readonly _licenseReportService: LicenseReportService,
) {
_loadingService.start();
}
@ -68,15 +69,15 @@ export class LicenseInformationScreenComponent implements OnInit {
endDate: endDate.toDate(),
};
const promises = [
this._licenseReportController.licenseReport(currentConfig).toPromise(),
this._licenseReportController.licenseReport({}).toPromise(),
this._licenseReportService.licenseReport(currentConfig).toPromise(),
this._licenseReportService.licenseReport({}).toPromise(),
];
if (endDate.isBefore(moment())) {
const unlicensedConfig = {
startDate: endDate.toDate(),
};
promises.push(this._licenseReportController.licenseReport(unlicensedConfig).toPromise());
promises.push(this._licenseReportService.licenseReport(unlicensedConfig).toPromise());
}
Promise.all(promises).then(reports => {
@ -131,7 +132,7 @@ export class LicenseInformationScreenComponent implements OnInit {
}
promises.push(
this._licenseReportController
this._licenseReportService
.licenseReport({
startDate: moment(`01-${m + 1}-${y}`, 'DD-MM-YYYY').toDate(),
endDate: moment(`01-${nm + 1}-${ny}`, 'DD-MM-YYYY').toDate(),

View File

@ -0,0 +1,24 @@
import { Injectable, Injector } from '@angular/core';
import { GenericService, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
import { LicenseReport, LicenseReportRequest } from '@redaction/red-ui-http';
@Injectable()
export class LicenseReportService extends GenericService<LicenseReport> {
constructor(protected readonly _injector: Injector) {
super(_injector, 'report');
}
@Validate()
licenseReport(@RequiredParam() body: LicenseReportRequest, limit?: number, offset?: number) {
const queryParams: QueryParam[] = [];
if (limit) {
queryParams.push({ key: 'limit', value: limit });
}
if (offset) {
queryParams.push({ key: 'offset', value: offset });
}
return this._post(body, `${this._defaultModelPath}/license`, queryParams);
}
}

View File

@ -1,7 +1,6 @@
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
import { Configuration } from './configuration';
import { HttpClient } from '@angular/common/http';
import { LicenseReportControllerService } from './api/licenseReportController.service';
import { ManualRedactionControllerService } from './api/manualRedactionController.service';
import { ReanalysisControllerService } from './api/reanalysisController.service';
import { RedactionLogControllerService } from './api/redactionLogController.service';
@ -19,7 +18,6 @@ import { NotificationControllerService } from './api/notificationController.serv
declarations: [],
exports: [],
providers: [
LicenseReportControllerService,
ManualRedactionControllerService,
ReanalysisControllerService,
RedactionLogControllerService,