diff --git a/src/app/api/payments/analytics/riskSeriesMapper.service.ts b/src/app/api/payments/analytics/riskSeriesMapper.service.ts
index 04fd1f3..20a2ca1 100644
--- a/src/app/api/payments/analytics/riskSeriesMapper.service.ts
+++ b/src/app/api/payments/analytics/riskSeriesMapper.service.ts
@@ -12,7 +12,7 @@ export class RiskSeriesMapperService {
({
name: value.score,
data: value.offsetCountRatio.map((offsetCountRatioValue) => ({
- x: this.getX(offsetCountRatioValue.offset, response.splitUnit),
+ x: new Date(offsetCountRatioValue.offset),
y: offsetCountRatioValue.countRatio,
fillColor: this.getFillColor(value),
})),
@@ -30,18 +30,4 @@ export class RiskSeriesMapperService {
return '#c4c4c4';
}
}
-
- private getX(value: number, splitUnit: string) {
- const additionalForFixZeroStart = 1;
- switch (splitUnit) {
- case 'hour':
- return new Date(value).getHours() + additionalForFixZeroStart;
- case 'month':
- return new Date(value).getMonth() + additionalForFixZeroStart;
- case 'day':
- return new Date(value).getDay() + additionalForFixZeroStart;
- default:
- return new Date(value).getDay() + additionalForFixZeroStart;
- }
- }
}
diff --git a/src/app/sections/analytics/analytics.module.ts b/src/app/sections/analytics/analytics.module.ts
index 9c00624..4db5679 100644
--- a/src/app/sections/analytics/analytics.module.ts
+++ b/src/app/sections/analytics/analytics.module.ts
@@ -33,6 +33,7 @@ import { EmptySearchResultModule } from '../../shared/components/empty-search-re
import { FbInfoCardModule } from '../../shared/components/fb-info-card';
import { ShowMorePanelModule } from '../../shared/components/show-more-panel';
import { SharedPipesModule } from '../../shared/pipes';
+import { ArraySortPipe } from '../../shared/pipes/sort-by-field.pipe';
import { AnalyticsRoutingModule } from './analytics-routing.module';
import { AnalyticsComponent } from './analytics.component';
import { BaseAnalyticsComponent } from './components/base/base-analytics.component';
@@ -76,6 +77,13 @@ import { BaseAnalyticsService } from './components/base/services/base-analytics.
FraudSummaryListModule,
],
declarations: [AnalyticsComponent, BaseAnalyticsComponent, BaseAnalyticsSearchComponent],
- providers: [AnalyticsService, RiskSeriesMapperService, BaseAnalyticsService, DatePipe, BaseAnalyticsUtilService],
+ providers: [
+ AnalyticsService,
+ RiskSeriesMapperService,
+ BaseAnalyticsService,
+ DatePipe,
+ BaseAnalyticsUtilService,
+ ArraySortPipe,
+ ],
})
export class AnalyticsModule {}
diff --git a/src/app/sections/analytics/components/base/base-analytics.component.html b/src/app/sections/analytics/components/base/base-analytics.component.html
index 487f3cd..b989433 100644
--- a/src/app/sections/analytics/components/base/base-analytics.component.html
+++ b/src/app/sections/analytics/components/base/base-analytics.component.html
@@ -31,7 +31,6 @@
fxFlex="25"
[headerText]="blockedSum"
[value]="blockedSum$"
- [units]="'$'"
[type]="errorStyle"
>
@@ -56,7 +55,7 @@
diff --git a/src/app/sections/analytics/components/base/components/fraud-summary-list/components/fraud-summary-header/fraud-summary-header.component.html b/src/app/sections/analytics/components/base/components/fraud-summary-list/components/fraud-summary-header/fraud-summary-header.component.html
index 9540182..af587a8 100644
--- a/src/app/sections/analytics/components/base/components/fraud-summary-list/components/fraud-summary-header/fraud-summary-header.component.html
+++ b/src/app/sections/analytics/components/base/components/fraud-summary-list/components/fraud-summary-header/fraud-summary-header.component.html
@@ -4,5 +4,5 @@
Checked rule
Sum
Count
- Ratio
+ Ratio, %
diff --git a/src/app/sections/analytics/components/base/components/fraud-summary-list/components/fraud-summary-item/fraud-summary-item.component.html b/src/app/sections/analytics/components/base/components/fraud-summary-list/components/fraud-summary-item/fraud-summary-item.component.html
index d4c8572..763d7e5 100644
--- a/src/app/sections/analytics/components/base/components/fraud-summary-list/components/fraud-summary-item/fraud-summary-item.component.html
+++ b/src/app/sections/analytics/components/base/components/fraud-summary-list/components/fraud-summary-item/fraud-summary-item.component.html
@@ -4,5 +4,5 @@
{{ summary.checkedRule }}
{{ summary.summary.sum }}
{{ summary.summary.count }}
- {{ numberFormat(summary.summary.ratio) }}%
+ {{ numberFormat(summary.summary.ratio) | number: '.1-4' }}
diff --git a/src/app/sections/analytics/components/base/components/search/base-analytics-search.component.ts b/src/app/sections/analytics/components/base/components/search/base-analytics-search.component.ts
index e179b24..c262440 100644
--- a/src/app/sections/analytics/components/base/components/search/base-analytics-search.component.ts
+++ b/src/app/sections/analytics/components/base/components/search/base-analytics-search.component.ts
@@ -16,10 +16,10 @@ import { BaseAnalyticsService } from '../../services/base-analytics.service';
export class BaseAnalyticsSearchComponent implements OnInit {
@Output() valueChanges: EventEmitter = new EventEmitter();
- @Input() inProgress: Observable;
-
currencies$ = this.baseAnalyticsService.currencies$;
+ @Input() inProgress: Observable;
+
units = ['1 day', '1 week', 'last month', 'last year'];
form: FormGroup = this.fb.group({
@@ -37,25 +37,33 @@ export class BaseAnalyticsSearchComponent implements OnInit {
@Inject(LAYOUT_GAP_M) public layoutGapM: string
) {
this.form.valueChanges.pipe(debounceTime(600), map(removeEmptyProperties)).subscribe((v) => {
+ this.router.navigate([location.pathname], { queryParams: v });
const params = Object.create(v);
params.partyId = v.partyId;
params.shopId = v.shopId;
params.type = v.type;
params.time = v.time;
- this.router.navigate([location.pathname], { queryParams: params });
this.valueChanges.emit(v);
});
this.route.queryParams.pipe(take(1)).subscribe((v) => this.form.patchValue(v));
}
ngOnInit(): void {
- this.currencies$.pipe(take(1)).subscribe((value) =>
+ this.currencies$.pipe(take(1)).subscribe((value) => {
this.form.setValue({
- partyId: '',
- shopId: '',
- type: value[0],
- time: this.units[0],
- })
- );
+ partyId: this.route.snapshot.queryParamMap.get('partyId')
+ ? this.route.snapshot.queryParamMap.get('partyId')
+ : '',
+ shopId: this.route.snapshot.queryParamMap.get('shopId')
+ ? this.route.snapshot.queryParamMap.get('shopId')
+ : '',
+ type: this.route.snapshot.queryParamMap.get('type')
+ ? this.route.snapshot.queryParamMap.get('type')
+ : value[0],
+ time: this.route.snapshot.queryParamMap.get('time')
+ ? this.route.snapshot.queryParamMap.get('time')
+ : this.units[0],
+ });
+ });
}
}
diff --git a/src/app/sections/analytics/components/base/services/base-analytics.service.ts b/src/app/sections/analytics/components/base/services/base-analytics.service.ts
index 35219bf..35b8676 100644
--- a/src/app/sections/analytics/components/base/services/base-analytics.service.ts
+++ b/src/app/sections/analytics/components/base/services/base-analytics.service.ts
@@ -62,6 +62,7 @@ export class BaseAnalyticsService {
shareReplay(1)
);
merge(
+ this.currencies$,
this.attemptedPayments$,
this.blockedPayments$,
this.ratioOfBlocked$,
diff --git a/src/app/shared/components/charts/bar-chart/default-config.ts b/src/app/shared/components/charts/bar-chart/default-config.ts
index fb4371c..c14ed70 100644
--- a/src/app/shared/components/charts/bar-chart/default-config.ts
+++ b/src/app/shared/components/charts/bar-chart/default-config.ts
@@ -32,7 +32,7 @@ export const DEFAULT_CONFIG: ApexOptions = {
},
},
xaxis: {
- type: 'category',
+ type: 'datetime',
labels: {
offsetY: -5,
rotate: 0,
diff --git a/src/app/shared/components/fb-info-card/fb-info-card.component.html b/src/app/shared/components/fb-info-card/fb-info-card.component.html
index 89b03e7..001b878 100644
--- a/src/app/shared/components/fb-info-card/fb-info-card.component.html
+++ b/src/app/shared/components/fb-info-card/fb-info-card.component.html
@@ -1,6 +1,6 @@
{{ headerText }}
- {{ numberFormat(valueNumber) }} {{ units }}
+ {{ numberFormat(valueNumber | number: '.1-4') }} {{ units }}
diff --git a/src/app/shared/pipes/shared-pipes.module.ts b/src/app/shared/pipes/shared-pipes.module.ts
index 621c76d..4164797 100644
--- a/src/app/shared/pipes/shared-pipes.module.ts
+++ b/src/app/shared/pipes/shared-pipes.module.ts
@@ -1,10 +1,11 @@
import { NgModule } from '@angular/core';
import { PaymentStatusToColorPipe } from './payment-status-to-color.pipe';
+import { ArraySortPipe } from './sort-by-field.pipe';
import { TemplateToRulesPipe } from './template-to-rules.pipe';
@NgModule({
- declarations: [TemplateToRulesPipe, PaymentStatusToColorPipe],
- exports: [TemplateToRulesPipe, PaymentStatusToColorPipe],
+ declarations: [TemplateToRulesPipe, PaymentStatusToColorPipe, ArraySortPipe],
+ exports: [TemplateToRulesPipe, PaymentStatusToColorPipe, ArraySortPipe],
})
export class SharedPipesModule {}
diff --git a/src/app/shared/pipes/sort-by-field.pipe.ts b/src/app/shared/pipes/sort-by-field.pipe.ts
new file mode 100644
index 0000000..6d778f2
--- /dev/null
+++ b/src/app/shared/pipes/sort-by-field.pipe.ts
@@ -0,0 +1,28 @@
+import { Pipe, PipeTransform } from '@angular/core';
+
+@Pipe({ name: 'sort' })
+export class ArraySortPipe implements PipeTransform {
+ transform(array: any, field: string): any[] {
+ if (!Array.isArray(array)) {
+ return;
+ }
+ array.sort((a: any, b: any) => {
+ if (this.deepValue(a, field) < this.deepValue(b, field)) {
+ return 1;
+ } else if (this.deepValue(a, field) > this.deepValue(b, field)) {
+ return -1;
+ } else {
+ return 0;
+ }
+ });
+ return array;
+ }
+
+ deepValue(obj, path) {
+ const pathList = path.split('.');
+ for (let i = 0, len = pathList.length; i < len; i += 1) {
+ obj = obj[pathList[i]];
+ }
+ return obj;
+ }
+}