build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
+58
-58
@@ -1,62 +1,62 @@
|
||||
const activities: any[] = [
|
||||
{ activity: 'client', path: '/clients'},
|
||||
{ activity: 'groups', path: '/groups'},
|
||||
{ activity: 'centers', path: '/centers'},
|
||||
{ activity: 'accounting', path: '/accounting'},
|
||||
{ activity: 'users', path: '/users'},
|
||||
{ activity: 'organization', path: '/organization'},
|
||||
{ activity: 'system', path: '/system'},
|
||||
{ activity: 'templates', path: '/templates'},
|
||||
{ activity: 'self-service users', path: '/self-service/users'},
|
||||
{ activity: 'self-service app-configuration', path: '/self-service/app-configuration'},
|
||||
{ activity: 'task management', path: '/self-service/task-management'},
|
||||
{ activity: 'create group', path: ''},
|
||||
{ activity: 'create center', path: '/centers/create'},
|
||||
{ activity: 'configuration', path: '/system/global-configurations'},
|
||||
{ activity: 'tasks', path: '/self-service/task-management'},
|
||||
{ activity: 'create template', path: '/self-service/task-management'},
|
||||
{ activity: 'create loan product', path: '/products/loan-products/create'},
|
||||
{ activity: 'create saving product', path: '/products/saving-products/create'},
|
||||
{ activity: 'roles', path: '/system/roles-and-permissions'},
|
||||
{ activity: 'add role', path: '/system/roles-and-permissions/add'},
|
||||
{ activity: 'configure maker checker tasks', path: ''},
|
||||
{ activity: 'loan products', path: '/products/loan-products'},
|
||||
{ activity: 'charges', path: '/products/charges'},
|
||||
{ activity: 'saving products', path: '/products/saving-products'},
|
||||
{ activity: 'offices', path: '/organization/offices'},
|
||||
{ activity: 'create office', path: '/organization/offices/create'},
|
||||
{ activity: 'currency configurations', path: '/organization/currencies'},
|
||||
{ activity: 'user settings', path: ''},
|
||||
{ activity: 'employees', path: '/organization/employees'},
|
||||
{ activity: 'create employee', path: '/organization/employees/create'},
|
||||
{ activity: 'manage funds', path: ''},
|
||||
{ activity: 'chart of accounts', path: '/accounting/chart-of-accounts'},
|
||||
{ activity: 'frequent postings', path: '/accounting/frequent-postings'},
|
||||
{ activity: 'journal entry', path: '/accounting/journal-entries'},
|
||||
{ activity: 'search transaction', path: ''},
|
||||
{ activity: 'account closure', path: '/accounting/closing-entries'},
|
||||
{ activity: 'accounting rules', path: '/accounting/accounting-rules'},
|
||||
{ activity: 'add accounting rule', path: '/accounting/accounting-rules/create'},
|
||||
{ activity: 'data tables', path: '/system/data-tables'},
|
||||
{ activity: 'create data table', path: '/system/data-tables/create'},
|
||||
{ activity: 'add code', path: '/system/codes/create'},
|
||||
{ activity: 'jobs', path: '/system/scheduler-jobs'},
|
||||
{ activity: 'codes', path: '/system/codes'},
|
||||
{ activity: 'reports', path: '/reports'},
|
||||
{ activity: 'create report', path: ''},
|
||||
{ activity: 'holidays', path: '/organization/holidays'},
|
||||
{ activity: 'create holiday', path: ''},
|
||||
{ activity: 'add member', path: '/clients/:clientId/family-members/add'},
|
||||
{ activity: 'create charge', path: ''},
|
||||
{ activity: 'enter collection sheet', path: ''},
|
||||
{ activity: 'product mix', path: '/products/products-mix'},
|
||||
{ activity: 'add product mix', path: ''},
|
||||
{ activity: 'bulk loan reassignment', path: '/accounting/closing-entries/create'},
|
||||
{ activity: 'audit', path: '/products/audit-trails'},
|
||||
{ activity: 'create accounting closure', path: ''},
|
||||
{ activity: 'navigation', path: '/navigation'},
|
||||
{ activity: 'system users', path: '/self-service/users'},
|
||||
{ activity: '', path: 'home'}
|
||||
{ activity: 'client', path: '/clients' },
|
||||
{ activity: 'groups', path: '/groups' },
|
||||
{ activity: 'centers', path: '/centers' },
|
||||
{ activity: 'accounting', path: '/accounting' },
|
||||
{ activity: 'users', path: '/users' },
|
||||
{ activity: 'organization', path: '/organization' },
|
||||
{ activity: 'system', path: '/system' },
|
||||
{ activity: 'templates', path: '/templates' },
|
||||
{ activity: 'self-service users', path: '/self-service/users' },
|
||||
{ activity: 'self-service app-configuration', path: '/self-service/app-configuration' },
|
||||
{ activity: 'task management', path: '/self-service/task-management' },
|
||||
{ activity: 'create group', path: '' },
|
||||
{ activity: 'create center', path: '/centers/create' },
|
||||
{ activity: 'configuration', path: '/system/global-configurations' },
|
||||
{ activity: 'tasks', path: '/self-service/task-management' },
|
||||
{ activity: 'create template', path: '/self-service/task-management' },
|
||||
{ activity: 'create loan product', path: '/products/loan-products/create' },
|
||||
{ activity: 'create saving product', path: '/products/saving-products/create' },
|
||||
{ activity: 'roles', path: '/system/roles-and-permissions' },
|
||||
{ activity: 'add role', path: '/system/roles-and-permissions/add' },
|
||||
{ activity: 'configure maker checker tasks', path: '' },
|
||||
{ activity: 'loan products', path: '/products/loan-products' },
|
||||
{ activity: 'charges', path: '/products/charges' },
|
||||
{ activity: 'saving products', path: '/products/saving-products' },
|
||||
{ activity: 'offices', path: '/organization/offices' },
|
||||
{ activity: 'create office', path: '/organization/offices/create' },
|
||||
{ activity: 'currency configurations', path: '/organization/currencies' },
|
||||
{ activity: 'user settings', path: '' },
|
||||
{ activity: 'employees', path: '/organization/employees' },
|
||||
{ activity: 'create employee', path: '/organization/employees/create' },
|
||||
{ activity: 'manage funds', path: '' },
|
||||
{ activity: 'chart of accounts', path: '/accounting/chart-of-accounts' },
|
||||
{ activity: 'frequent postings', path: '/accounting/frequent-postings' },
|
||||
{ activity: 'journal entry', path: '/accounting/journal-entries' },
|
||||
{ activity: 'search transaction', path: '' },
|
||||
{ activity: 'account closure', path: '/accounting/closing-entries' },
|
||||
{ activity: 'accounting rules', path: '/accounting/accounting-rules' },
|
||||
{ activity: 'add accounting rule', path: '/accounting/accounting-rules/create' },
|
||||
{ activity: 'data tables', path: '/system/data-tables' },
|
||||
{ activity: 'create data table', path: '/system/data-tables/create' },
|
||||
{ activity: 'add code', path: '/system/codes/create' },
|
||||
{ activity: 'jobs', path: '/system/scheduler-jobs' },
|
||||
{ activity: 'codes', path: '/system/codes' },
|
||||
{ activity: 'reports', path: '/reports' },
|
||||
{ activity: 'create report', path: '' },
|
||||
{ activity: 'holidays', path: '/organization/holidays' },
|
||||
{ activity: 'create holiday', path: '' },
|
||||
{ activity: 'add member', path: '/clients/:clientId/family-members/add' },
|
||||
{ activity: 'create charge', path: '' },
|
||||
{ activity: 'enter collection sheet', path: '' },
|
||||
{ activity: 'product mix', path: '/products/products-mix' },
|
||||
{ activity: 'add product mix', path: '' },
|
||||
{ activity: 'bulk loan reassignment', path: '/accounting/closing-entries/create' },
|
||||
{ activity: 'audit', path: '/products/audit-trails' },
|
||||
{ activity: 'create accounting closure', path: '' },
|
||||
{ activity: 'navigation', path: '/navigation' },
|
||||
{ activity: 'system users', path: '/self-service/users' },
|
||||
{ activity: '', path: 'home' }
|
||||
];
|
||||
|
||||
export { activities };
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('AmountCollectedPieComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ AmountCollectedPieComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [AmountCollectedPieComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -18,7 +18,6 @@ import Chart from 'chart.js';
|
||||
styleUrls: ['./amount-collected-pie.component.scss']
|
||||
})
|
||||
export class AmountCollectedPieComponent implements OnInit {
|
||||
|
||||
/** Static Form control for office Id */
|
||||
officeId = new UntypedFormControl();
|
||||
/** Office Data */
|
||||
@@ -35,9 +34,11 @@ export class AmountCollectedPieComponent implements OnInit {
|
||||
* @param {HomeService} homeService Home Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private homeService: HomeService,
|
||||
private route: ActivatedRoute) {
|
||||
this.route.data.subscribe( (data: { offices: any }) => {
|
||||
constructor(
|
||||
private homeService: HomeService,
|
||||
private route: ActivatedRoute
|
||||
) {
|
||||
this.route.data.subscribe((data: { offices: any }) => {
|
||||
this.officeData = data.offices;
|
||||
});
|
||||
}
|
||||
@@ -57,7 +58,7 @@ export class AmountCollectedPieComponent implements OnInit {
|
||||
getChartData() {
|
||||
this.officeId.valueChanges.subscribe((value: number) => {
|
||||
this.homeService.getCollectedAmount(value).subscribe((response: any) => {
|
||||
const data = Object.entries(response[0]).map(entry => entry[1]);
|
||||
const data = Object.entries(response[0]).map((entry) => entry[1]);
|
||||
if (!(data[0] === 0 && data[1] === 0)) {
|
||||
this.setChart(data);
|
||||
this.hideOutput = false;
|
||||
@@ -80,11 +81,19 @@ export class AmountCollectedPieComponent implements OnInit {
|
||||
this.chart = new Chart('collection-pie', {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: ['Pending', 'Collected'],
|
||||
datasets: [{
|
||||
backgroundColor: ['dodgerblue', 'red'],
|
||||
data: data
|
||||
}]
|
||||
labels: [
|
||||
'Pending',
|
||||
'Collected'
|
||||
],
|
||||
datasets: [
|
||||
{
|
||||
backgroundColor: [
|
||||
'dodgerblue',
|
||||
'red'
|
||||
],
|
||||
data: data
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
layout: {
|
||||
@@ -100,5 +109,4 @@ export class AmountCollectedPieComponent implements OnInit {
|
||||
this.chart.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('AmountDisbursedPieComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ AmountDisbursedPieComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [AmountDisbursedPieComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -18,26 +18,27 @@ import Chart from 'chart.js';
|
||||
styleUrls: ['./amount-disbursed-pie.component.scss']
|
||||
})
|
||||
export class AmountDisbursedPieComponent implements OnInit {
|
||||
|
||||
/** Static Form control for office Id */
|
||||
officeId = new UntypedFormControl();
|
||||
/** Office Data */
|
||||
officeData: any;
|
||||
/** Chart.js chart */
|
||||
chart: any;
|
||||
/** Substitute for resolver */
|
||||
hideOutput = true;
|
||||
/** Shows fallback element */
|
||||
showFallback = true;
|
||||
/** Static Form control for office Id */
|
||||
officeId = new UntypedFormControl();
|
||||
/** Office Data */
|
||||
officeData: any;
|
||||
/** Chart.js chart */
|
||||
chart: any;
|
||||
/** Substitute for resolver */
|
||||
hideOutput = true;
|
||||
/** Shows fallback element */
|
||||
showFallback = true;
|
||||
|
||||
/**
|
||||
* Fetches offices data from `resolve`.
|
||||
* @param {HomeService} homeService Home Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private homeService: HomeService,
|
||||
private route: ActivatedRoute) {
|
||||
this.route.data.subscribe( (data: { offices: any }) => {
|
||||
constructor(
|
||||
private homeService: HomeService,
|
||||
private route: ActivatedRoute
|
||||
) {
|
||||
this.route.data.subscribe((data: { offices: any }) => {
|
||||
this.officeData = data.offices;
|
||||
});
|
||||
}
|
||||
@@ -57,7 +58,7 @@ export class AmountDisbursedPieComponent implements OnInit {
|
||||
getChartData() {
|
||||
this.officeId.valueChanges.subscribe((value: number) => {
|
||||
this.homeService.getDisbursedAmount(value).subscribe((response: any) => {
|
||||
const data = Object.entries(response[0]).map(entry => entry[1]);
|
||||
const data = Object.entries(response[0]).map((entry) => entry[1]);
|
||||
if (!(data[0] === 0 && data[1] === 0)) {
|
||||
this.setChart(data);
|
||||
this.showFallback = false;
|
||||
@@ -80,11 +81,19 @@ export class AmountDisbursedPieComponent implements OnInit {
|
||||
this.chart = new Chart('disbursement-pie', {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: ['Pending', 'Disbursed'],
|
||||
datasets: [{
|
||||
backgroundColor: ['dodgerblue', 'red'],
|
||||
data: data
|
||||
}]
|
||||
labels: [
|
||||
'Pending',
|
||||
'Disbursed'
|
||||
],
|
||||
datasets: [
|
||||
{
|
||||
backgroundColor: [
|
||||
'dodgerblue',
|
||||
'red'
|
||||
],
|
||||
data: data
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
layout: {
|
||||
@@ -100,5 +109,4 @@ export class AmountDisbursedPieComponent implements OnInit {
|
||||
this.chart.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('ClientTrendsBarComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ClientTrendsBarComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [ClientTrendsBarComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -23,7 +23,6 @@ import Chart from 'chart.js';
|
||||
styleUrls: ['./client-trends-bar.component.scss']
|
||||
})
|
||||
export class ClientTrendsBarComponent implements OnInit {
|
||||
|
||||
/** Static Form control for office Id */
|
||||
officeId = new UntypedFormControl();
|
||||
/** Static Form control for time scale */
|
||||
@@ -41,10 +40,12 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Dates} dateUtils Date Utils
|
||||
*/
|
||||
constructor(private homeService: HomeService,
|
||||
private route: ActivatedRoute,
|
||||
private dateUtils: Dates) {
|
||||
this.route.data.subscribe( (data: { offices: any }) => {
|
||||
constructor(
|
||||
private homeService: HomeService,
|
||||
private route: ActivatedRoute,
|
||||
private dateUtils: Dates
|
||||
) {
|
||||
this.route.data.subscribe((data: { offices: any }) => {
|
||||
this.officeData = data.offices;
|
||||
});
|
||||
}
|
||||
@@ -67,7 +68,8 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
* Fetches data accordingly and sets charts based on fetched data.
|
||||
*/
|
||||
getChartData() {
|
||||
merge(this.officeId.valueChanges, this.timescale.valueChanges).pipe(skip(1))
|
||||
merge(this.officeId.valueChanges, this.timescale.valueChanges)
|
||||
.pipe(skip(1))
|
||||
.subscribe(() => {
|
||||
const officeId = this.officeId.value;
|
||||
const timescale = this.timescale.value;
|
||||
@@ -75,7 +77,10 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
case 'Day':
|
||||
const clientsByDay = this.homeService.getClientTrendsByDay(officeId);
|
||||
const loansByDay = this.homeService.getLoanTrendsByDay(officeId);
|
||||
forkJoin([clientsByDay, loansByDay]).subscribe((data: any[]) => {
|
||||
forkJoin([
|
||||
clientsByDay,
|
||||
loansByDay
|
||||
]).subscribe((data: any[]) => {
|
||||
const dayLabels = this.getLabels(timescale);
|
||||
const clientCounts = this.getCounts(data[0], dayLabels, timescale, 'client');
|
||||
const loanCounts = this.getCounts(data[1], dayLabels, timescale, 'loan');
|
||||
@@ -86,7 +91,10 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
case 'Week':
|
||||
const clientsByWeek = this.homeService.getClientTrendsByWeek(officeId);
|
||||
const loansByWeek = this.homeService.getLoanTrendsByWeek(officeId);
|
||||
forkJoin([clientsByWeek, loansByWeek]).subscribe((data: any[]) => {
|
||||
forkJoin([
|
||||
clientsByWeek,
|
||||
loansByWeek
|
||||
]).subscribe((data: any[]) => {
|
||||
const weekLabels = this.getLabels(timescale);
|
||||
const clientCounts = this.getCounts(data[0], weekLabels, timescale, 'client');
|
||||
const loanCounts = this.getCounts(data[1], weekLabels, timescale, 'loan');
|
||||
@@ -97,7 +105,10 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
case 'Month':
|
||||
const clientsByMonth = this.homeService.getClientTrendsByMonth(officeId);
|
||||
const loansByMonth = this.homeService.getLoanTrendsByMonth(officeId);
|
||||
forkJoin([clientsByMonth, loansByMonth]).subscribe((data: any[]) => {
|
||||
forkJoin([
|
||||
clientsByMonth,
|
||||
loansByMonth
|
||||
]).subscribe((data: any[]) => {
|
||||
const monthLabels = this.getLabels(timescale);
|
||||
const clientCounts = this.getCounts(data[0], monthLabels, timescale, 'client');
|
||||
const loanCounts = this.getCounts(data[1], monthLabels, timescale, 'loan');
|
||||
@@ -106,7 +117,7 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,9 +141,7 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
while (labelsArray.length < 12) {
|
||||
date.setDate(date.getDate() - 7);
|
||||
/** Gets current week number */
|
||||
const weekNumber = Math.ceil(
|
||||
(((date.getTime() - onejan.getTime()) / 86400000) + onejan.getDay() + 1) / 7
|
||||
);
|
||||
const weekNumber = Math.ceil(((date.getTime() - onejan.getTime()) / 86400000 + onejan.getDay() + 1) / 7);
|
||||
labelsArray.push(weekNumber);
|
||||
}
|
||||
break;
|
||||
@@ -155,7 +164,7 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
* @param {string} type 'client' or 'loan'.
|
||||
*/
|
||||
getCounts(response: any[], labels: any[], timescale: string, type: string) {
|
||||
let counts: number[] = [];
|
||||
let counts: number[] = [];
|
||||
switch (timescale) {
|
||||
case 'Day':
|
||||
labels.forEach((label: any) => {
|
||||
@@ -197,10 +206,10 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
switch (type) {
|
||||
case 'client':
|
||||
counts.push(span.count);
|
||||
break;
|
||||
break;
|
||||
case 'loan':
|
||||
counts.push(span.lcount);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
counts.push(0);
|
||||
@@ -236,22 +245,22 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
backgroundColor: 'red',
|
||||
borderColor: 'red',
|
||||
borderWidth: 2,
|
||||
fill: false,
|
||||
fill: false
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'Values',
|
||||
fontColor: '#1074B9'
|
||||
}
|
||||
},
|
||||
}
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'Values',
|
||||
fontColor: '#1074B9'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -261,5 +270,4 @@ export class ClientTrendsBarComponent implements OnInit {
|
||||
this.chart.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('DashboardComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ DashboardComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [DashboardComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -14,7 +14,6 @@ import { activities } from '../activities';
|
||||
styleUrls: ['./dashboard.component.scss']
|
||||
})
|
||||
export class DashboardComponent implements OnInit {
|
||||
|
||||
/** Array of all user activities */
|
||||
userActivity: string[];
|
||||
/** Array of most recent user activities */
|
||||
@@ -52,10 +51,16 @@ export class DashboardComponent implements OnInit {
|
||||
uniqueActivities.push(activity);
|
||||
}
|
||||
});
|
||||
const topEightRecentActivities =
|
||||
uniqueActivities
|
||||
.filter((activity: string) => !['/', '/login', '/home', '/dashboard'].includes(activity))
|
||||
.slice(0, 8);
|
||||
const topEightRecentActivities = uniqueActivities
|
||||
.filter(
|
||||
(activity: string) => ![
|
||||
'/',
|
||||
'/login',
|
||||
'/home',
|
||||
'/dashboard'
|
||||
].includes(activity)
|
||||
)
|
||||
.slice(0, 8);
|
||||
return topEightRecentActivities;
|
||||
}
|
||||
|
||||
@@ -63,18 +68,24 @@ export class DashboardComponent implements OnInit {
|
||||
* Returns top eight frequent activities.
|
||||
*/
|
||||
getFrequentActivities() {
|
||||
const frequencyCounts: any = {};
|
||||
let index = this.userActivity.length;
|
||||
const frequencyCounts: any = {};
|
||||
let index = this.userActivity.length;
|
||||
while (index) {
|
||||
frequencyCounts[this.userActivity[--index]] = (frequencyCounts[this.userActivity[index]] || 0) + 1;
|
||||
}
|
||||
const frequencyCountsArray = Object.entries(frequencyCounts);
|
||||
const topEigthFrequentActivities =
|
||||
frequencyCountsArray
|
||||
.sort((a: any, b: any) => b[1] - a[1])
|
||||
.map((entry: any[]) => entry[0])
|
||||
.filter((activity: string) => !['/', '/login', '/home', '/dashboard'].includes(activity))
|
||||
.slice(0, 8);
|
||||
const topEigthFrequentActivities = frequencyCountsArray
|
||||
.sort((a: any, b: any) => b[1] - a[1])
|
||||
.map((entry: any[]) => entry[0])
|
||||
.filter(
|
||||
(activity: string) => ![
|
||||
'/',
|
||||
'/login',
|
||||
'/home',
|
||||
'/dashboard'
|
||||
].includes(activity)
|
||||
)
|
||||
.slice(0, 8);
|
||||
return topEigthFrequentActivities;
|
||||
}
|
||||
|
||||
@@ -89,10 +100,10 @@ export class DashboardComponent implements OnInit {
|
||||
* Sets filtered activities for autocomplete.
|
||||
*/
|
||||
setFilteredActivities() {
|
||||
this.filteredActivities = this.searchText.valueChanges
|
||||
.pipe(
|
||||
map((activity: any) => typeof activity === 'string' ? activity : activity.activity),
|
||||
map((activityName: string) => activityName ? this.filterActivity(activityName) : this.allActivities));
|
||||
this.filteredActivities = this.searchText.valueChanges.pipe(
|
||||
map((activity: any) => (typeof activity === 'string' ? activity : activity.activity)),
|
||||
map((activityName: string) => (activityName ? this.filterActivity(activityName) : this.allActivities))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,8 +113,6 @@ export class DashboardComponent implements OnInit {
|
||||
*/
|
||||
private filterActivity(activityName: string): any {
|
||||
const filterValue = activityName.toLowerCase();
|
||||
return this.allActivities.filter(activity => activity.activity.toLowerCase().indexOf(filterValue) === 0);
|
||||
return this.allActivities.filter((activity) => activity.activity.toLowerCase().indexOf(filterValue) === 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ const routes: Routes = [
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -46,4 +47,4 @@ const routes: Routes = [
|
||||
exports: [RouterModule],
|
||||
providers: [OfficesResolver]
|
||||
})
|
||||
export class HomeRoutingModule { }
|
||||
export class HomeRoutingModule {}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('HomeComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ HomeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [HomeComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit} from '@angular/core';
|
||||
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router, NavigationEnd } from '@angular/router';
|
||||
import { UntypedFormControl } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
@@ -29,7 +29,6 @@ import { NextStepDialogComponent } from '../configuration-wizard/next-step-dialo
|
||||
styleUrls: ['./home.component.scss']
|
||||
})
|
||||
export class HomeComponent implements OnInit, AfterViewInit {
|
||||
|
||||
/** Username of authenticated user. */
|
||||
username: string;
|
||||
/** Activity Form. */
|
||||
@@ -42,13 +41,13 @@ export class HomeComponent implements OnInit, AfterViewInit {
|
||||
allActivities: any[] = activities;
|
||||
|
||||
/* Reference of dashboard button */
|
||||
@ViewChild('buttonDashboard', {static: false}) buttonDashboard: ElementRef<any>;
|
||||
@ViewChild('buttonDashboard', { static: false }) buttonDashboard: ElementRef<any>;
|
||||
/* Template for popover on dashboard button */
|
||||
@ViewChild('templateButtonDashboard', {static: false}) templateButtonDashboard: TemplateRef<any>;
|
||||
@ViewChild('templateButtonDashboard', { static: false }) templateButtonDashboard: TemplateRef<any>;
|
||||
/* Reference of search activity */
|
||||
@ViewChild('searchActivity', {static: false}) searchActivity: ElementRef<any>;
|
||||
@ViewChild('searchActivity', { static: false }) searchActivity: ElementRef<any>;
|
||||
/* Template for popover on search activity */
|
||||
@ViewChild('templateSearchActivity', {static: false}) templateSearchActivity: TemplateRef<any>;
|
||||
@ViewChild('templateSearchActivity', { static: false }) templateSearchActivity: TemplateRef<any>;
|
||||
|
||||
/**
|
||||
* @param {AuthenticationService} authenticationService Authentication Service.
|
||||
@@ -58,12 +57,14 @@ export class HomeComponent implements OnInit, AfterViewInit {
|
||||
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
|
||||
* @param {PopoverService} popoverService PopoverService.
|
||||
*/
|
||||
constructor(private authenticationService: AuthenticationService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService) { }
|
||||
constructor(
|
||||
private authenticationService: AuthenticationService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Sets the username of the authenticated user.
|
||||
@@ -83,10 +84,10 @@ export class HomeComponent implements OnInit, AfterViewInit {
|
||||
* Sets filtered activities for autocomplete.
|
||||
*/
|
||||
setFilteredActivities() {
|
||||
this.filteredActivities = this.searchText.valueChanges
|
||||
.pipe(
|
||||
map((activity: any) => typeof activity === 'string' ? activity : activity.activity),
|
||||
map((activityName: string) => activityName ? this.filterActivity(activityName) : this.allActivities));
|
||||
this.filteredActivities = this.searchText.valueChanges.pipe(
|
||||
map((activity: any) => (typeof activity === 'string' ? activity : activity.activity)),
|
||||
map((activityName: string) => (activityName ? this.filterActivity(activityName) : this.allActivities))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +97,7 @@ export class HomeComponent implements OnInit, AfterViewInit {
|
||||
*/
|
||||
private filterActivity(activityName: string): any {
|
||||
const filterValue = activityName.toLowerCase();
|
||||
return this.allActivities.filter(activity => activity.activity.toLowerCase().indexOf(filterValue) === 0);
|
||||
return this.allActivities.filter((activity) => activity.activity.toLowerCase().indexOf(filterValue) === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +107,12 @@ export class HomeComponent implements OnInit, AfterViewInit {
|
||||
* @param position String.
|
||||
* @param backdrop Boolean.
|
||||
*/
|
||||
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void {
|
||||
showPopover(
|
||||
template: TemplateRef<any>,
|
||||
target: HTMLElement | ElementRef<any>,
|
||||
position: string,
|
||||
backdrop: boolean
|
||||
): void {
|
||||
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
|
||||
}
|
||||
|
||||
@@ -140,23 +146,23 @@ export class HomeComponent implements OnInit, AfterViewInit {
|
||||
* Next Step (Organization) Dialog Configuration Wizard.
|
||||
*/
|
||||
openNextStepDialog() {
|
||||
const nextStepDialogRef = this.dialog.open( NextStepDialogComponent, {
|
||||
const nextStepDialogRef = this.dialog.open(NextStepDialogComponent, {
|
||||
data: {
|
||||
nextStepName: 'Setup Organization',
|
||||
previousStepName: 'Home Tour',
|
||||
stepPercentage: 10
|
||||
},
|
||||
}
|
||||
});
|
||||
nextStepDialogRef.afterClosed().subscribe((response: { nextStep: boolean }) => {
|
||||
if (response.nextStep) {
|
||||
this.configurationWizardService.showHome = false;
|
||||
this.configurationWizardService.showHomeSearchActivity = false;
|
||||
this.configurationWizardService.showCreateOffice = true;
|
||||
this.router.navigate(['/organization']);
|
||||
if (response.nextStep) {
|
||||
this.configurationWizardService.showHome = false;
|
||||
this.configurationWizardService.showHomeSearchActivity = false;
|
||||
this.configurationWizardService.showCreateOffice = true;
|
||||
this.router.navigate(['/organization']);
|
||||
} else {
|
||||
this.configurationWizardService.showHome = false;
|
||||
this.configurationWizardService.showHomeSearchActivity = false;
|
||||
this.router.navigate(['/home']);
|
||||
this.configurationWizardService.showHome = false;
|
||||
this.configurationWizardService.showHomeSearchActivity = false;
|
||||
this.router.navigate(['/home']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import { SessionTimeoutDialogComponent } from './timeout-dialog/session-timeout-
|
||||
SharedModule,
|
||||
PipesModule,
|
||||
HomeRoutingModule,
|
||||
TranslateModule,
|
||||
TranslateModule
|
||||
],
|
||||
declarations: [
|
||||
HomeComponent,
|
||||
@@ -39,6 +39,6 @@ import { SessionTimeoutDialogComponent } from './timeout-dialog/session-timeout-
|
||||
WarningDialogComponent,
|
||||
SessionTimeoutDialogComponent
|
||||
],
|
||||
providers: [ ]
|
||||
providers: []
|
||||
})
|
||||
export class HomeModule { }
|
||||
export class HomeModule {}
|
||||
|
||||
@@ -12,20 +12,17 @@ import { Observable } from 'rxjs';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class HomeService {
|
||||
|
||||
/**
|
||||
* @param {HttpClient} http Http Client to send requests.
|
||||
*/
|
||||
constructor(private http: HttpClient) { }
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
/**
|
||||
* @param {number} officeId Office Id.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getCollectedAmount(officeId: number): Observable<any> {
|
||||
const httpParams = new HttpParams()
|
||||
.set('R_officeId', officeId.toString())
|
||||
.set('genericResultSet', 'false');
|
||||
const httpParams = new HttpParams().set('R_officeId', officeId.toString()).set('genericResultSet', 'false');
|
||||
return this.http.get('/runreports/Demand Vs Collection', { params: httpParams });
|
||||
}
|
||||
|
||||
@@ -34,9 +31,7 @@ export class HomeService {
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getDisbursedAmount(officeId: number): Observable<any> {
|
||||
const httpParams = new HttpParams()
|
||||
.set('R_officeId', officeId.toString())
|
||||
.set('genericResultSet', 'false');
|
||||
const httpParams = new HttpParams().set('R_officeId', officeId.toString()).set('genericResultSet', 'false');
|
||||
return this.http.get('/runreports/Disbursal Vs Awaitingdisbursal', { params: httpParams });
|
||||
}
|
||||
|
||||
@@ -45,9 +40,7 @@ export class HomeService {
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getClientTrendsByDay(officeId: number): Observable<any> {
|
||||
const httpParams = new HttpParams()
|
||||
.set('R_officeId', officeId.toString())
|
||||
.set('genericResultSet', 'false');
|
||||
const httpParams = new HttpParams().set('R_officeId', officeId.toString()).set('genericResultSet', 'false');
|
||||
return this.http.get('/runreports/ClientTrendsByDay', { params: httpParams });
|
||||
}
|
||||
|
||||
@@ -56,9 +49,7 @@ export class HomeService {
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getClientTrendsByWeek(officeId: number): Observable<any> {
|
||||
const httpParams = new HttpParams()
|
||||
.set('R_officeId', officeId.toString())
|
||||
.set('genericResultSet', 'false');
|
||||
const httpParams = new HttpParams().set('R_officeId', officeId.toString()).set('genericResultSet', 'false');
|
||||
return this.http.get('/runreports/ClientTrendsByWeek', { params: httpParams });
|
||||
}
|
||||
|
||||
@@ -67,9 +58,7 @@ export class HomeService {
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getClientTrendsByMonth(officeId: number): Observable<any> {
|
||||
const httpParams = new HttpParams()
|
||||
.set('R_officeId', officeId.toString())
|
||||
.set('genericResultSet', 'false');
|
||||
const httpParams = new HttpParams().set('R_officeId', officeId.toString()).set('genericResultSet', 'false');
|
||||
return this.http.get('/runreports/ClientTrendsByMonth', { params: httpParams });
|
||||
}
|
||||
|
||||
@@ -78,9 +67,7 @@ export class HomeService {
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getLoanTrendsByDay(officeId: number): Observable<any> {
|
||||
const httpParams = new HttpParams()
|
||||
.set('R_officeId', officeId.toString())
|
||||
.set('genericResultSet', 'false');
|
||||
const httpParams = new HttpParams().set('R_officeId', officeId.toString()).set('genericResultSet', 'false');
|
||||
return this.http.get('/runreports/LoanTrendsByDay', { params: httpParams });
|
||||
}
|
||||
|
||||
@@ -89,9 +76,7 @@ export class HomeService {
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getLoanTrendsByWeek(officeId: number): Observable<any> {
|
||||
const httpParams = new HttpParams()
|
||||
.set('R_officeId', officeId.toString())
|
||||
.set('genericResultSet', 'false');
|
||||
const httpParams = new HttpParams().set('R_officeId', officeId.toString()).set('genericResultSet', 'false');
|
||||
return this.http.get('/runreports/LoanTrendsByWeek', { params: httpParams });
|
||||
}
|
||||
|
||||
@@ -100,10 +85,7 @@ export class HomeService {
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getLoanTrendsByMonth(officeId: number): Observable<any> {
|
||||
const httpParams = new HttpParams()
|
||||
.set('R_officeId', officeId.toString())
|
||||
.set('genericResultSet', 'false');
|
||||
const httpParams = new HttpParams().set('R_officeId', officeId.toString()).set('genericResultSet', 'false');
|
||||
return this.http.get('/runreports/LoanTrendsByMonth', { params: httpParams });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,34 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from 'environments/environment';
|
||||
import { interval, merge, fromEvent, Observable} from 'rxjs';
|
||||
import { takeUntil, repeat, map} from 'rxjs/operators';
|
||||
import { interval, merge, fromEvent, Observable } from 'rxjs';
|
||||
import { takeUntil, repeat, map } from 'rxjs/operators';
|
||||
|
||||
/**
|
||||
* Idle timeout service used to track idle user
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class IdleTimeoutService {
|
||||
// max timeout for an idle user
|
||||
readonly timeoutDelay = environment.session.timeout.idleTimeout || 300000; // 5 minutes
|
||||
|
||||
// max timeout for an idle user
|
||||
readonly timeoutDelay = environment.session.timeout.idleTimeout || 300000; // 5 minutes
|
||||
// observable timeout
|
||||
readonly $onSessionTimeout: Observable<void>;
|
||||
|
||||
// observable timeout
|
||||
readonly $onSessionTimeout: Observable<void>;
|
||||
|
||||
constructor() {
|
||||
const events = ['mousemove', 'keydown', 'wheel', 'mousedown', 'scroll'];
|
||||
const $signal = merge(...events.map(eventName => fromEvent(document, eventName)));
|
||||
this.$onSessionTimeout = interval(this.timeoutDelay).pipe(
|
||||
takeUntil($signal),
|
||||
map(() => undefined),
|
||||
repeat()
|
||||
);
|
||||
}
|
||||
constructor() {
|
||||
const events = [
|
||||
'mousemove',
|
||||
'keydown',
|
||||
'wheel',
|
||||
'mousedown',
|
||||
'scroll'
|
||||
];
|
||||
const $signal = merge(...events.map((eventName) => fromEvent(document, eventName)));
|
||||
this.$onSessionTimeout = interval(this.timeoutDelay).pipe(
|
||||
takeUntil($signal),
|
||||
map(() => undefined),
|
||||
repeat()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('SessionTimeoutDialogComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ SessionTimeoutDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [SessionTimeoutDialogComponent]
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(SessionTimeoutDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
@@ -7,8 +7,5 @@ import { MatDialogRef } from '@angular/material/dialog';
|
||||
styleUrls: ['./session-timeout-dialog.component.scss']
|
||||
})
|
||||
export class SessionTimeoutDialogComponent {
|
||||
|
||||
constructor(public dialogRef: MatDialogRef<SessionTimeoutDialogComponent>) {
|
||||
}
|
||||
|
||||
constructor(public dialogRef: MatDialogRef<SessionTimeoutDialogComponent>) {}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import { environment } from '../../../environments/environment';
|
||||
styleUrls: ['./warning-dialog.component.scss']
|
||||
})
|
||||
export class WarningDialogComponent {
|
||||
|
||||
title: string;
|
||||
content: string;
|
||||
buttonText: string;
|
||||
@@ -18,5 +17,4 @@ export class WarningDialogComponent {
|
||||
this.content = environment.warningDialog.content;
|
||||
this.buttonText = environment.warningDialog.buttonText;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user