Skip to content

Commit 47d232b

Browse files
authored
feat(data): update data module, add new mock data (#1960)
1 parent 773c14e commit 47d232b

File tree

53 files changed

+635
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+635
-256
lines changed

src/app/@core/core.module.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import { of as observableOf } from 'rxjs';
66

77
import { throwIfAlreadyLoaded } from './module-import-guard';
88
import { DataModule } from './data/data.module';
9-
import { AnalyticsService } from './utils/analytics.service';
9+
import {
10+
AnalyticsService,
11+
LayoutService,
12+
PlayerService,
13+
StateService,
14+
} from './utils';
1015

1116
const socialLinks = [
1217
{
@@ -71,6 +76,9 @@ export const NB_CORE_PROVIDERS = [
7176
provide: NbRoleProvider, useClass: NbSimpleRoleProvider,
7277
},
7378
AnalyticsService,
79+
LayoutService,
80+
PlayerService,
81+
StateService,
7482
];
7583

7684
@NgModule({
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Injectable } from '@angular/core';
2+
import { of as observableOf, Observable } from 'rxjs';
3+
4+
@Injectable()
5+
export class CountryOrderService {
6+
7+
private countriesCategories = [
8+
'Sofas',
9+
'Furniture',
10+
'Lighting',
11+
'Tables',
12+
'Textiles',
13+
];
14+
private countriesCategoriesLength = this.countriesCategories.length;
15+
private generateRandomData(nPoints: number): number[] {
16+
return Array.from(Array(nPoints)).map(() => {
17+
return Math.round(Math.random() * 20);
18+
});
19+
}
20+
21+
getCountriesCategories(): Observable<string[]> {
22+
return observableOf(this.countriesCategories);
23+
}
24+
25+
getCountriesCategoriesData(): Observable<number[]> {
26+
return observableOf(this.generateRandomData(this.countriesCategoriesLength));
27+
}
28+
}

src/app/@core/data/data.module.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { CommonModule } from '@angular/common';
33

44
import { UserService } from './users.service';
55
import { ElectricityService } from './electricity.service';
6-
import { StateService } from './state.service';
76
import { SmartTableService } from './smart-table.service';
8-
import { PlayerService } from './player.service';
97
import { UserActivityService } from './user-activity.service';
108
import { OrdersChartService } from './orders-chart.service';
119
import { ProfitChartService } from './profit-chart.service';
@@ -15,14 +13,19 @@ import { EarningService } from './earning.service';
1513
import { OrdersProfitChartService } from './orders-profit-chart.service';
1614
import { TrafficBarService } from './traffic-bar.service';
1715
import { ProfitBarAnimationChartService } from './profit-bar-animation-chart.service';
18-
import { LayoutService } from './layout.service';
16+
import { TemperatureHumidityService } from './temperature-humidity.service';
17+
import { SolarService } from './solar.service';
18+
import { TrafficChartService } from './traffic-chart.service';
19+
import { StatsBarService } from './stats-bar.service';
20+
import { CountryOrderService } from './country-order.service';
21+
import { StatsProgressBarService } from './stats-progress-bar.service';
22+
import { VisitorsAnalyticsService } from './visitors-analytics.service';
23+
import { SecurityCamerasService } from './security-cameras.service';
1924

2025
const SERVICES = [
2126
UserService,
2227
ElectricityService,
23-
StateService,
2428
SmartTableService,
25-
PlayerService,
2629
UserActivityService,
2730
OrdersChartService,
2831
ProfitChartService,
@@ -32,7 +35,14 @@ const SERVICES = [
3235
OrdersProfitChartService,
3336
TrafficBarService,
3437
ProfitBarAnimationChartService,
35-
LayoutService,
38+
TemperatureHumidityService,
39+
SolarService,
40+
TrafficChartService,
41+
StatsBarService,
42+
CountryOrderService,
43+
StatsProgressBarService,
44+
VisitorsAnalyticsService,
45+
SecurityCamerasService,
3646
];
3747

3848
@NgModule({

src/app/@core/data/electricity.service.ts

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
import { Injectable } from '@angular/core';
2+
import { of as observableOf, Observable } from 'rxjs';
3+
4+
class Month {
5+
month: string;
6+
delta: string;
7+
down: boolean;
8+
kWatts: string;
9+
cost: string;
10+
}
11+
12+
export class Electricity {
13+
title: string;
14+
active?: boolean;
15+
months: Month[];
16+
}
17+
18+
export class ElectricityChart {
19+
label: string;
20+
value: number;
21+
}
222

323
@Injectable()
424
export class ElectricityService {
525

6-
private data = [
26+
private listData: Electricity[] = [
727
{
828
title: '2015',
929
months: [
@@ -58,11 +78,35 @@ export class ElectricityService {
5878
},
5979
];
6080

81+
private chartPoints = [
82+
490, 490, 495, 500,
83+
505, 510, 520, 530,
84+
550, 580, 630, 720,
85+
800, 840, 860, 870,
86+
870, 860, 840, 800,
87+
720, 200, 145, 130,
88+
130, 145, 200, 570,
89+
635, 660, 670, 670,
90+
660, 630, 580, 460,
91+
380, 350, 340, 340,
92+
340, 340, 340, 340,
93+
340, 340, 340,
94+
];
95+
96+
chartData: ElectricityChart[];
97+
6198
constructor() {
99+
this.chartData = this.chartPoints.map((p, index) => ({
100+
label: (index % 5 === 3) ? `${Math.round(index / 5)}` : '',
101+
value: p,
102+
}));
103+
}
104+
105+
getListData(): Observable<Electricity[]> {
106+
return observableOf(this.listData);
62107
}
63108

64-
// TODO: observables
65-
getData() {
66-
return this.data;
109+
getChartData(): Observable<ElectricityChart[]> {
110+
return observableOf(this.chartData);
67111
}
68112
}

src/app/@core/data/profit-bar-animation-chart.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class ProfitBarAnimationChartService {
3535
return Array.from(Array(nPoints));
3636
}
3737

38-
getChartData(): Observable<{ firstLine: number[]; secondLine: number[] }> {
38+
getChartData(): Observable<{ firstLine: number[]; secondLine: number[]; }> {
3939
return observableOf(this.data);
4040
}
4141
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Injectable } from '@angular/core';
2+
import { of as observableOf, Observable } from 'rxjs';
3+
4+
export class Camera {
5+
title: string;
6+
source: string;
7+
}
8+
9+
@Injectable()
10+
export class SecurityCamerasService {
11+
12+
private cameras: Camera[] = [
13+
{
14+
title: 'Camera #1',
15+
source: 'assets/images/camera1.jpg',
16+
},
17+
{
18+
title: 'Camera #2',
19+
source: 'assets/images/camera2.jpg',
20+
},
21+
{
22+
title: 'Camera #3',
23+
source: 'assets/images/camera3.jpg',
24+
},
25+
{
26+
title: 'Camera #4',
27+
source: 'assets/images/camera4.jpg',
28+
},
29+
];
30+
31+
getCamerasData(): Observable<Camera[]> {
32+
return observableOf(this.cameras);
33+
}
34+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Injectable } from '@angular/core';
2+
import { of as observableOf, Observable } from 'rxjs';
3+
4+
@Injectable()
5+
export class SolarService {
6+
private value = 42;
7+
8+
getSolarData(): Observable<number> {
9+
return observableOf(this.value);
10+
}
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Injectable } from '@angular/core';
2+
import { of as observableOf, Observable } from 'rxjs';
3+
4+
@Injectable()
5+
export class StatsBarService {
6+
7+
private statsBarData: number[] = [
8+
300, 520, 435, 530,
9+
730, 620, 660, 860,
10+
];
11+
12+
getStatsBarData(): Observable<number[]> {
13+
return observableOf(this.statsBarData);
14+
}
15+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Injectable } from '@angular/core';
2+
import { of as observableOf, Observable } from 'rxjs';
3+
4+
export class ProgressInfo {
5+
title: string;
6+
value: number;
7+
activeProgress: number;
8+
description: string;
9+
}
10+
11+
@Injectable()
12+
export class StatsProgressBarService {
13+
private progressInfoData: ProgressInfo[] = [
14+
{
15+
title: 'Today’s Profit',
16+
value: 572900,
17+
activeProgress: 70,
18+
description: 'Better than last week (70%)',
19+
},
20+
{
21+
title: 'New Orders',
22+
value: 6378,
23+
activeProgress: 30,
24+
description: 'Better than last week (30%)',
25+
},
26+
{
27+
title: 'New Comments',
28+
value: 200,
29+
activeProgress: 55,
30+
description: 'Better than last week (55%)',
31+
},
32+
];
33+
34+
getProgressInfoData(): Observable<ProgressInfo[]> {
35+
return observableOf(this.progressInfoData);
36+
}
37+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Injectable } from '@angular/core';
2+
import { of as observableOf, Observable } from 'rxjs';
3+
4+
export class Temperature {
5+
value: number;
6+
min: number;
7+
max: number;
8+
}
9+
10+
@Injectable()
11+
export class TemperatureHumidityService {
12+
13+
private temperatureDate: Temperature = {
14+
value: 24,
15+
min: 12,
16+
max: 30,
17+
};
18+
19+
private humidityDate: Temperature = {
20+
value: 87,
21+
min: 0,
22+
max: 100,
23+
};
24+
25+
getTemperatureData(): Observable<Temperature> {
26+
return observableOf(this.temperatureDate);
27+
}
28+
29+
getHumidityData(): Observable<Temperature> {
30+
return observableOf(this.humidityDate);
31+
}
32+
}

0 commit comments

Comments
 (0)