Skip to content

Commit 94c816f

Browse files
authored
Merge pull request #3864 from IgniteUI/sstoychev/fix-lite-ds
fix(grid-lite): changing random data gen to use built-in avatars
2 parents 7069c59 + d5867da commit 94c816f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/app/grid-lite/grid-lite-data.service.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,21 @@ export type User = {
3535
export class GridLiteDataService {
3636
private counter = 0;
3737

38-
private firstNames = ['John', 'Jane', 'Bob', 'Alice', 'Charlie', 'Diana', 'Eve', 'Frank', 'Grace', 'Henry',
39-
'Ivy', 'Jack', 'Kate', 'Liam', 'Mia', 'Noah', 'Olivia', 'Peter', 'Quinn', 'Rachel'];
38+
private maleFirstNames = ['John', 'Bob', 'Charlie', 'Frank', 'Henry', 'Jack', 'Liam', 'Noah', 'Peter'];
39+
private femaleFirstNames = ['Jane', 'Alice', 'Diana', 'Eve', 'Grace', 'Ivy', 'Kate', 'Mia', 'Olivia', 'Quinn', 'Rachel'];
4040
private lastNames = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Garcia', 'Miller', 'Davis',
4141
'Rodriguez', 'Martinez', 'Wilson', 'Anderson', 'Taylor', 'Thomas', 'Moore', 'Jackson', 'White', 'Harris'];
4242
private productNames = ['Widget', 'Gadget', 'Doohickey', 'Thingamajig', 'Gizmo', 'Contraption',
4343
'Device', 'Tool', 'Apparatus', 'Instrument', 'Machine', 'Equipment'];
4444
private priorities: ('Low' | 'Standard' | 'High')[] = ['Low', 'Standard', 'High'];
4545

46+
private randomFirstName(): { name: string; gender: 'men' | 'women' } {
47+
const isMale = this.randomBoolean();
48+
return isMale
49+
? { name: this.randomElement(this.maleFirstNames), gender: 'men' }
50+
: { name: this.randomElement(this.femaleFirstNames), gender: 'women' };
51+
}
52+
4653
private randomInt(min: number, max: number): number {
4754
return Math.floor(Math.random() * (max - min + 1)) + min;
4855
}
@@ -86,7 +93,7 @@ export class GridLiteDataService {
8693
}
8794

8895
createUserSimple(): UserSimple {
89-
const firstName = this.randomElement(this.firstNames);
96+
const { name: firstName } = this.randomFirstName();
9097
const lastName = this.randomElement(this.lastNames);
9198
return {
9299
id: this.generateId(),
@@ -97,7 +104,7 @@ export class GridLiteDataService {
97104
}
98105

99106
createUser(): User {
100-
const firstName = this.randomElement(this.firstNames);
107+
const { name: firstName, gender } = this.randomFirstName();
101108
const lastName = this.randomElement(this.lastNames);
102109
const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@example.com`;
103110

@@ -107,7 +114,7 @@ export class GridLiteDataService {
107114
lastName,
108115
age: this.randomInt(18, 90),
109116
email,
110-
avatar: `https://i.pravatar.cc/150?img=${this.randomInt(1, 70)}`,
117+
avatar: `assets/images/${gender}/${this.randomInt(1, 70)}.jpg`,
111118
active: this.randomBoolean(),
112119
priority: this.randomElement(this.priorities),
113120
satisfaction: this.randomInt(0, 5),

0 commit comments

Comments
 (0)