mirror of
https://github.com/valitydev/control-center.git
synced 2024-11-06 02:25:17 +00:00
IMP-201: Change default loading period to 1 month (#352)
This commit is contained in:
parent
0c85ee9a32
commit
af263c950b
@ -71,8 +71,8 @@ export class AppComponent {
|
||||
services: TERMINALS_ROUTING_CONFIG.services,
|
||||
},
|
||||
{
|
||||
label: 'Repairing',
|
||||
url: '/repairing',
|
||||
label: 'Machines',
|
||||
url: '/machines',
|
||||
services: REPAIRING_ROUTING_CONFIG.services,
|
||||
},
|
||||
{
|
||||
|
@ -2,9 +2,15 @@ import { Component, OnInit, DestroyRef } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { NonNullableFormBuilder } from '@angular/forms';
|
||||
import { PartyID } from '@vality/domain-proto/domain';
|
||||
import { DialogService, LoadOptions, QueryParamsService, clean } from '@vality/ng-core';
|
||||
import {
|
||||
DialogService,
|
||||
LoadOptions,
|
||||
QueryParamsService,
|
||||
clean,
|
||||
getValueChanges,
|
||||
} from '@vality/ng-core';
|
||||
import { debounceTime } from 'rxjs';
|
||||
import { startWith, take } from 'rxjs/operators';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
import { CLAIM_STATUSES } from '../../api/claim-management';
|
||||
import { PartyStoreService } from '../party';
|
||||
@ -42,8 +48,8 @@ export class ClaimsComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.filtersForm.patchValue(this.qp.params);
|
||||
this.filtersForm.valueChanges
|
||||
.pipe(startWith(null), debounceTime(500), takeUntilDestroyed(this.destroyRef))
|
||||
getValueChanges(this.filtersForm)
|
||||
.pipe(debounceTime(500), takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(() => {
|
||||
this.load();
|
||||
});
|
||||
|
@ -1,15 +1,15 @@
|
||||
<cc-page-layout title="Repairing">
|
||||
<mat-card>
|
||||
<mat-card-content
|
||||
[formGroup]="filters"
|
||||
style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px"
|
||||
>
|
||||
<cc-page-layout title="Machines">
|
||||
<cc-page-layout-actions>
|
||||
<v-more-filters-button [filters]="filters"></v-more-filters-button>
|
||||
</cc-page-layout-actions>
|
||||
<v-filters #filters [active]="active" merge (clear)="filtersForm.reset()">
|
||||
<ng-template [formGroup]="filtersForm">
|
||||
<v-date-range-field formControlName="timespan"></v-date-range-field>
|
||||
<v-list-field formControlName="ids" label="IDs"></v-list-field>
|
||||
<mat-form-field>
|
||||
<mat-label>Namespace</mat-label>
|
||||
<input formControlName="ns" matInput />
|
||||
</mat-form-field>
|
||||
<v-date-range-field formControlName="timespan"></v-date-range-field>
|
||||
<cc-domain-object-field
|
||||
formControlName="provider_id"
|
||||
name="provider"
|
||||
@ -30,8 +30,8 @@
|
||||
<mat-label>Error message</mat-label>
|
||||
<input formControlName="error_message" matInput />
|
||||
</mat-form-field>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</ng-template>
|
||||
</v-filters>
|
||||
|
||||
<v-table
|
||||
[columns]="columns"
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Component, OnInit, DestroyRef } from '@angular/core';
|
||||
import { Component, OnInit, DestroyRef, Inject } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
import { NonNullableFormBuilder } from '@angular/forms';
|
||||
import {
|
||||
DialogResponseStatus,
|
||||
DialogService,
|
||||
@ -11,20 +11,25 @@ import {
|
||||
NotifyLogService,
|
||||
DateRange,
|
||||
getNoTimeZoneIsoString,
|
||||
countProps,
|
||||
createDateRangeToToday,
|
||||
isEqualDateRange,
|
||||
getValueChanges,
|
||||
} from '@vality/ng-core';
|
||||
import { repairer } from '@vality/repairer-proto';
|
||||
import { Namespace, ProviderID, RepairStatus, Machine } from '@vality/repairer-proto/repairer';
|
||||
import { endOfDay } from 'date-fns';
|
||||
import isNil from 'lodash-es/isNil';
|
||||
import omit from 'lodash-es/omit';
|
||||
import startCase from 'lodash-es/startCase';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { filter, map, switchMap } from 'rxjs/operators';
|
||||
import { filter, switchMap, debounceTime } from 'rxjs/operators';
|
||||
|
||||
import { getEnumKey } from '@cc/utils';
|
||||
|
||||
import { RepairManagementService } from '../../api/repairer';
|
||||
import { NotificationService } from '../../shared/services/notification';
|
||||
import { createProviderColumn } from '../../shared/utils/table/create-provider-column';
|
||||
import { DATE_RANGE_DAYS } from '../../tokens';
|
||||
|
||||
import { RepairByScenarioDialogComponent } from './components/repair-by-scenario-dialog/repair-by-scenario-dialog.component';
|
||||
import { MachinesService } from './services/machines.service';
|
||||
@ -47,10 +52,10 @@ export class RepairingComponent implements OnInit {
|
||||
machines$ = this.machinesService.searchResult$;
|
||||
inProgress$ = this.machinesService.doAction$;
|
||||
hasMore$ = this.machinesService.hasMore$;
|
||||
filters = this.fb.group({
|
||||
filtersForm = this.fb.group({
|
||||
ids: [null as string[]],
|
||||
ns: null as string,
|
||||
timespan: null as DateRange,
|
||||
timespan: createDateRangeToToday(this.dateRangeDays),
|
||||
provider_id: null as string,
|
||||
status: null as RepairStatus,
|
||||
error_message: null as string,
|
||||
@ -84,29 +89,27 @@ export class RepairingComponent implements OnInit {
|
||||
field: 'error_message',
|
||||
},
|
||||
];
|
||||
active = 0;
|
||||
|
||||
constructor(
|
||||
private machinesService: MachinesService,
|
||||
private fb: FormBuilder,
|
||||
private fb: NonNullableFormBuilder,
|
||||
private qp: QueryParamsService<Filters>,
|
||||
private dialogService: DialogService,
|
||||
private repairManagementService: RepairManagementService,
|
||||
private notificationService: NotificationService,
|
||||
private log: NotifyLogService,
|
||||
private destroyRef: DestroyRef,
|
||||
@Inject(DATE_RANGE_DAYS) private dateRangeDays: number,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.filters.patchValue(this.qp.params);
|
||||
this.filters.valueChanges
|
||||
.pipe(
|
||||
map(() => clean(this.filters.value)),
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
)
|
||||
.subscribe((v: Filters) => this.qp.set(v));
|
||||
this.qp.params$
|
||||
.pipe(
|
||||
map(({ ids, ns, timespan, provider_id, status, error_message }) =>
|
||||
this.filtersForm.patchValue(this.qp.params);
|
||||
getValueChanges(this.filtersForm)
|
||||
.pipe(debounceTime(500), takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((params: Filters) => {
|
||||
const { ids, ns, timespan, provider_id, status, error_message } = params;
|
||||
void this.qp.set(clean(params));
|
||||
this.machinesService.search(
|
||||
clean({
|
||||
ids,
|
||||
ns,
|
||||
@ -121,10 +124,11 @@ export class RepairingComponent implements OnInit {
|
||||
}
|
||||
: null,
|
||||
}),
|
||||
),
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
)
|
||||
.subscribe((params) => this.machinesService.search(params));
|
||||
);
|
||||
this.active =
|
||||
countProps(omit(clean(params), 'timespan')) +
|
||||
+!isEqualDateRange(timespan, createDateRangeToToday(this.dateRangeDays));
|
||||
});
|
||||
}
|
||||
|
||||
update(size: number) {
|
||||
@ -153,7 +157,7 @@ export class RepairingComponent implements OnInit {
|
||||
)
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.notificationService.success();
|
||||
this.log.success();
|
||||
},
|
||||
error: (err) => this.log.error(err),
|
||||
});
|
||||
|
@ -19,6 +19,7 @@ import {
|
||||
ListFieldModule,
|
||||
EnumKeyPipe,
|
||||
EnumKeysPipe,
|
||||
FiltersModule,
|
||||
} from '@vality/ng-core';
|
||||
|
||||
import { PageLayoutModule, ThriftPipesModule } from '@cc/app/shared';
|
||||
@ -55,6 +56,7 @@ import { RepairingComponent } from './repairing.component';
|
||||
PageLayoutModule,
|
||||
ListFieldModule,
|
||||
ThriftPipesModule,
|
||||
FiltersModule,
|
||||
],
|
||||
declarations: [RepairingComponent, RepairByScenarioDialogComponent],
|
||||
})
|
||||
|
@ -33,7 +33,7 @@ const ROUTES: Routes = [
|
||||
import('./withdrawals/withdrawals.module').then((m) => m.WithdrawalsModule),
|
||||
},
|
||||
{
|
||||
path: 'repairing',
|
||||
path: 'machines',
|
||||
loadChildren: () => import('./repairing/repairing.module').then((m) => m.RepairingModule),
|
||||
},
|
||||
{
|
||||
|
@ -4,8 +4,8 @@
|
||||
</cc-page-layout-actions>
|
||||
<v-filters #filters [active]="active" merge (clear)="filtersForm.reset()">
|
||||
<ng-template [formGroup]="filtersForm">
|
||||
<cc-merchant-field formControlName="merchant"></cc-merchant-field>
|
||||
<v-date-range-field formControlName="dateRange"></v-date-range-field>
|
||||
<cc-merchant-field formControlName="merchant"></cc-merchant-field>
|
||||
<mat-form-field>
|
||||
<mat-label>Status</mat-label>
|
||||
<mat-select formControlName="status">
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Component, OnInit, DestroyRef } from '@angular/core';
|
||||
import { Component, OnInit, DestroyRef, Inject } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
import { NonNullableFormBuilder } from '@angular/forms';
|
||||
import { PartyID } from '@vality/domain-proto/domain';
|
||||
import { StatWithdrawal } from '@vality/fistful-proto/fistful_stat';
|
||||
import {
|
||||
@ -14,8 +14,12 @@ import {
|
||||
getNoTimeZoneIsoString,
|
||||
DialogResponseStatus,
|
||||
NumberRange,
|
||||
createDateRangeToToday,
|
||||
isEqualDateRange,
|
||||
getValueChanges,
|
||||
} from '@vality/ng-core';
|
||||
import { endOfDay } from 'date-fns';
|
||||
import omit from 'lodash-es/omit';
|
||||
import startCase from 'lodash-es/startCase';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
|
||||
@ -27,6 +31,7 @@ import { FailMachinesDialogComponent, Type } from '../../shared/components/fail-
|
||||
import { AmountCurrencyService } from '../../shared/services';
|
||||
import { createProviderColumn } from '../../shared/utils/table/create-provider-column';
|
||||
import { createTerminalColumn } from '../../shared/utils/table/create-terminal-column';
|
||||
import { DATE_RANGE_DAYS, DEBOUNCE_TIME_MS } from '../../tokens';
|
||||
|
||||
import { CreateAdjustmentDialogComponent } from './components/create-adjustment-dialog/create-adjustment-dialog.component';
|
||||
import { FetchWithdrawalsService } from './services/fetch-withdrawals.service';
|
||||
@ -50,7 +55,7 @@ interface WithdrawalsForm {
|
||||
})
|
||||
export class WithdrawalsComponent implements OnInit {
|
||||
filtersForm = this.fb.group<WithdrawalsForm>({
|
||||
dateRange: null,
|
||||
dateRange: createDateRangeToToday(this.dateRangeDays),
|
||||
merchant: null,
|
||||
status: null,
|
||||
amount: null,
|
||||
@ -59,7 +64,6 @@ export class WithdrawalsComponent implements OnInit {
|
||||
errorMessage: null,
|
||||
providerId: null,
|
||||
terminalId: null,
|
||||
...this.qp.params,
|
||||
});
|
||||
active = 0;
|
||||
withdrawals$ = this.fetchWithdrawalsService.result$;
|
||||
@ -111,19 +115,19 @@ export class WithdrawalsComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private fetchWithdrawalsService: FetchWithdrawalsService,
|
||||
private fb: FormBuilder,
|
||||
private fb: NonNullableFormBuilder,
|
||||
private qp: QueryParamsService<Partial<WithdrawalsForm>>,
|
||||
private amountCurrencyService: AmountCurrencyService,
|
||||
private dialogService: DialogService,
|
||||
private destroyRef: DestroyRef,
|
||||
@Inject(DATE_RANGE_DAYS) private dateRangeDays: number,
|
||||
@Inject(DEBOUNCE_TIME_MS) private debounceTimeMs: number,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.filtersForm.valueChanges
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((v) => void this.qp.set(clean(v)));
|
||||
this.qp.params$
|
||||
.pipe(debounceTime(500), takeUntilDestroyed(this.destroyRef))
|
||||
this.filtersForm.patchValue(Object.assign({}, this.qp.params));
|
||||
getValueChanges(this.filtersForm)
|
||||
.pipe(debounceTime(this.debounceTimeMs), takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(() => this.update());
|
||||
}
|
||||
|
||||
@ -138,7 +142,8 @@ export class WithdrawalsComponent implements OnInit {
|
||||
errorMessage,
|
||||
providerId,
|
||||
terminalId,
|
||||
} = this.qp.params;
|
||||
} = this.filtersForm.value;
|
||||
void this.qp.set(clean(this.filtersForm.value));
|
||||
const params = clean({
|
||||
party_id: merchant,
|
||||
from_time: dateRange?.start && getNoTimeZoneIsoString(dateRange?.start),
|
||||
@ -153,7 +158,9 @@ export class WithdrawalsComponent implements OnInit {
|
||||
withdrawal_provider_id: providerId,
|
||||
});
|
||||
this.fetchWithdrawalsService.load(params, options);
|
||||
this.active = countProps(params);
|
||||
this.active =
|
||||
countProps(omit(params, 'from_time', 'to_time')) +
|
||||
+!isEqualDateRange(dateRange, createDateRangeToToday(this.dateRangeDays));
|
||||
}
|
||||
|
||||
more() {
|
||||
|
@ -20,7 +20,7 @@ export const DEFAULT_MAT_DATE_FORMATS: MatDateFormats = {
|
||||
};
|
||||
|
||||
export const DATE_RANGE_DAYS = new InjectionToken<number>('DATE_RANGE_DAYS');
|
||||
export const DEFAULT_DATE_RANGE_DAYS: number = 365;
|
||||
export const DEFAULT_DATE_RANGE_DAYS: number = 30;
|
||||
|
||||
export const DEBOUNCE_TIME_MS = new InjectionToken<number>('DEBOUNCE_TIME_MS');
|
||||
export const DEFAULT_DEBOUNCE_TIME_MS: number = 300;
|
||||
|
Loading…
Reference in New Issue
Block a user