mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-02-09 18:04:20 +01:00
refactor(@core): refactor data services for better integration (#1997)
With this change all components, which used data services before, now use abstract classes of service interfaces, mock services extend interface services, CoreModule contains code to inject a needed implementation of some service.
This commit is contained in:
parent
f17aa32c6d
commit
cac36f0717
67 changed files with 389 additions and 201 deletions
|
|
@ -1,28 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class CountryOrderService {
|
||||
|
||||
private countriesCategories = [
|
||||
'Sofas',
|
||||
'Furniture',
|
||||
'Lighting',
|
||||
'Tables',
|
||||
'Textiles',
|
||||
];
|
||||
private countriesCategoriesLength = this.countriesCategories.length;
|
||||
private generateRandomData(nPoints: number): number[] {
|
||||
return Array.from(Array(nPoints)).map(() => {
|
||||
return Math.round(Math.random() * 20);
|
||||
});
|
||||
}
|
||||
|
||||
getCountriesCategories(): Observable<string[]> {
|
||||
return observableOf(this.countriesCategories);
|
||||
}
|
||||
|
||||
getCountriesCategoriesData(): Observable<number[]> {
|
||||
return observableOf(this.generateRandomData(this.countriesCategoriesLength));
|
||||
}
|
||||
}
|
||||
6
src/app/@core/data/country-order.ts
Normal file
6
src/app/@core/data/country-order.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export abstract class CountryOrderData {
|
||||
abstract getCountriesCategories(): Observable<string[]>;
|
||||
abstract getCountriesCategoriesData(country: string): Observable<number[]>;
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
import { NgModule, ModuleWithProviders } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { UserService } from './users.service';
|
||||
import { ElectricityService } from './electricity.service';
|
||||
import { SmartTableService } from './smart-table.service';
|
||||
import { UserActivityService } from './user-activity.service';
|
||||
import { OrdersChartService } from './orders-chart.service';
|
||||
import { ProfitChartService } from './profit-chart.service';
|
||||
import { TrafficListService } from './traffic-list.service';
|
||||
import { PeriodsService } from './periods.service';
|
||||
import { EarningService } from './earning.service';
|
||||
import { OrdersProfitChartService } from './orders-profit-chart.service';
|
||||
import { TrafficBarService } from './traffic-bar.service';
|
||||
import { ProfitBarAnimationChartService } from './profit-bar-animation-chart.service';
|
||||
import { TemperatureHumidityService } from './temperature-humidity.service';
|
||||
import { SolarService } from './solar.service';
|
||||
import { TrafficChartService } from './traffic-chart.service';
|
||||
import { StatsBarService } from './stats-bar.service';
|
||||
import { CountryOrderService } from './country-order.service';
|
||||
import { StatsProgressBarService } from './stats-progress-bar.service';
|
||||
import { VisitorsAnalyticsService } from './visitors-analytics.service';
|
||||
import { SecurityCamerasService } from './security-cameras.service';
|
||||
|
||||
const SERVICES = [
|
||||
UserService,
|
||||
ElectricityService,
|
||||
SmartTableService,
|
||||
UserActivityService,
|
||||
OrdersChartService,
|
||||
ProfitChartService,
|
||||
TrafficListService,
|
||||
PeriodsService,
|
||||
EarningService,
|
||||
OrdersProfitChartService,
|
||||
TrafficBarService,
|
||||
ProfitBarAnimationChartService,
|
||||
TemperatureHumidityService,
|
||||
SolarService,
|
||||
TrafficChartService,
|
||||
StatsBarService,
|
||||
CountryOrderService,
|
||||
StatsProgressBarService,
|
||||
VisitorsAnalyticsService,
|
||||
SecurityCamerasService,
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
],
|
||||
providers: [
|
||||
...SERVICES,
|
||||
],
|
||||
})
|
||||
export class DataModule {
|
||||
static forRoot(): ModuleWithProviders {
|
||||
return <ModuleWithProviders>{
|
||||
ngModule: DataModule,
|
||||
providers: [
|
||||
...SERVICES,
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
|
||||
export class LiveUpdateChart {
|
||||
liveChart: { value: [string, number] }[];
|
||||
delta: {
|
||||
up: boolean;
|
||||
value: number;
|
||||
};
|
||||
dailyIncome: number;
|
||||
}
|
||||
|
||||
export class PieChart {
|
||||
value: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class EarningService {
|
||||
|
||||
private currentDate: Date = new Date();
|
||||
private currentValue = Math.random() * 1000;
|
||||
private ONE_DAY = 24 * 3600 * 1000;
|
||||
|
||||
private pieChartData = [
|
||||
{
|
||||
value: 50,
|
||||
name: 'Bitcoin',
|
||||
},
|
||||
{
|
||||
value: 25,
|
||||
name: 'Tether',
|
||||
},
|
||||
{
|
||||
value: 25,
|
||||
name: 'Ethereum',
|
||||
},
|
||||
];
|
||||
|
||||
private liveUpdateChartData = {
|
||||
bitcoin: {
|
||||
liveChart: [],
|
||||
delta: {
|
||||
up: true,
|
||||
value: 4,
|
||||
},
|
||||
dailyIncome: 45895,
|
||||
},
|
||||
tether: {
|
||||
liveChart: [],
|
||||
delta: {
|
||||
up: false,
|
||||
value: 9,
|
||||
},
|
||||
dailyIncome: 5862,
|
||||
},
|
||||
ethereum: {
|
||||
liveChart: [],
|
||||
delta: {
|
||||
up: false,
|
||||
value: 21,
|
||||
},
|
||||
dailyIncome: 584,
|
||||
},
|
||||
};
|
||||
|
||||
getDefaultLiveChartData(elementsNumber: number) {
|
||||
this.currentDate = new Date();
|
||||
this.currentValue = Math.random() * 1000;
|
||||
|
||||
return Array.from(Array(elementsNumber))
|
||||
.map(item => this.generateRandomLiveChartData());
|
||||
}
|
||||
|
||||
generateRandomLiveChartData() {
|
||||
this.currentDate = new Date(+this.currentDate + this.ONE_DAY);
|
||||
this.currentValue = this.currentValue + Math.random() * 20 - 11;
|
||||
|
||||
if (this.currentValue < 0) {
|
||||
this.currentValue = Math.random() * 100;
|
||||
}
|
||||
|
||||
return {
|
||||
value: [
|
||||
[
|
||||
this.currentDate.getFullYear(),
|
||||
this.currentDate.getMonth(),
|
||||
this.currentDate.getDate(),
|
||||
].join('/'),
|
||||
Math.round(this.currentValue),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
generateRandomEarningData(currency) {
|
||||
const data = this.liveUpdateChartData[currency.toLowerCase()];
|
||||
const newValue = this.generateRandomLiveChartData();
|
||||
|
||||
data.liveChart.shift();
|
||||
data.liveChart.push(newValue);
|
||||
|
||||
return observableOf(data.liveChart);
|
||||
}
|
||||
|
||||
getEarningLiveUpdateCardData(currency: string) {
|
||||
const data = this.liveUpdateChartData[currency.toLowerCase()];
|
||||
|
||||
data.liveChart = this.getDefaultLiveChartData(150);
|
||||
|
||||
return observableOf(data);
|
||||
}
|
||||
|
||||
getEarningPieChartData(): Observable<PieChart[]> {
|
||||
return observableOf(this.pieChartData);
|
||||
}
|
||||
}
|
||||
21
src/app/@core/data/earning.ts
Normal file
21
src/app/@core/data/earning.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface LiveUpdateChart {
|
||||
liveChart: { value: [string, number] }[];
|
||||
delta: {
|
||||
up: boolean;
|
||||
value: number;
|
||||
};
|
||||
dailyIncome: number;
|
||||
}
|
||||
|
||||
export interface PieChart {
|
||||
value: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export abstract class EarningData {
|
||||
abstract getEarningLiveUpdateCardData(currency: string): Observable<any[]>;
|
||||
abstract getEarningCardData(currency: string): Observable<LiveUpdateChart>;
|
||||
abstract getEarningPieChartData(): Observable<PieChart[]>;
|
||||
}
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
|
||||
class Month {
|
||||
month: string;
|
||||
delta: string;
|
||||
down: boolean;
|
||||
kWatts: string;
|
||||
cost: string;
|
||||
}
|
||||
|
||||
export class Electricity {
|
||||
title: string;
|
||||
active?: boolean;
|
||||
months: Month[];
|
||||
}
|
||||
|
||||
export class ElectricityChart {
|
||||
label: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class ElectricityService {
|
||||
|
||||
private listData: Electricity[] = [
|
||||
{
|
||||
title: '2015',
|
||||
months: [
|
||||
{ month: 'Jan', delta: '0.97', down: true, kWatts: '816', cost: '97' },
|
||||
{ month: 'Feb', delta: '1.83', down: true, kWatts: '806', cost: '95' },
|
||||
{ month: 'Mar', delta: '0.64', down: true, kWatts: '803', cost: '94' },
|
||||
{ month: 'Apr', delta: '2.17', down: false, kWatts: '818', cost: '98' },
|
||||
{ month: 'May', delta: '1.32', down: true, kWatts: '809', cost: '96' },
|
||||
{ month: 'Jun', delta: '0.05', down: true, kWatts: '808', cost: '96' },
|
||||
{ month: 'Jul', delta: '1.39', down: false, kWatts: '815', cost: '97' },
|
||||
{ month: 'Aug', delta: '0.73', down: true, kWatts: '807', cost: '95' },
|
||||
{ month: 'Sept', delta: '2.61', down: true, kWatts: '792', cost: '92' },
|
||||
{ month: 'Oct', delta: '0.16', down: true, kWatts: '791', cost: '92' },
|
||||
{ month: 'Nov', delta: '1.71', down: true, kWatts: '786', cost: '89' },
|
||||
{ month: 'Dec', delta: '0.37', down: false, kWatts: '789', cost: '91' },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '2016',
|
||||
active: true,
|
||||
months: [
|
||||
{ month: 'Jan', delta: '1.56', down: true, kWatts: '789', cost: '91' },
|
||||
{ month: 'Feb', delta: '0.33', down: false, kWatts: '791', cost: '92' },
|
||||
{ month: 'Mar', delta: '0.62', down: true, kWatts: '790', cost: '92' },
|
||||
{ month: 'Apr', delta: '1.93', down: true, kWatts: '783', cost: '87' },
|
||||
{ month: 'May', delta: '2.52', down: true, kWatts: '771', cost: '83' },
|
||||
{ month: 'Jun', delta: '0.39', down: false, kWatts: '774', cost: '85' },
|
||||
{ month: 'Jul', delta: '1.61', down: true, kWatts: '767', cost: '81' },
|
||||
{ month: 'Aug', delta: '1.41', down: true, kWatts: '759', cost: '76' },
|
||||
{ month: 'Sept', delta: '1.03', down: true, kWatts: '752', cost: '74' },
|
||||
{ month: 'Oct', delta: '2.94', down: false, kWatts: '769', cost: '82' },
|
||||
{ month: 'Nov', delta: '0.26', down: true, kWatts: '767', cost: '81' },
|
||||
{ month: 'Dec', delta: '1.62', down: true, kWatts: '760', cost: '76' },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '2017',
|
||||
months: [
|
||||
{ month: 'Jan', delta: '1.34', down: false, kWatts: '789', cost: '91' },
|
||||
{ month: 'Feb', delta: '0.95', down: false, kWatts: '793', cost: '93' },
|
||||
{ month: 'Mar', delta: '0.25', down: true, kWatts: '791', cost: '92' },
|
||||
{ month: 'Apr', delta: '1.72', down: false, kWatts: '797', cost: '95' },
|
||||
{ month: 'May', delta: '2.62', down: true, kWatts: '786', cost: '90' },
|
||||
{ month: 'Jun', delta: '0.72', down: false, kWatts: '789', cost: '91' },
|
||||
{ month: 'Jul', delta: '0.78', down: true, kWatts: '784', cost: '89' },
|
||||
{ month: 'Aug', delta: '0.36', down: true, kWatts: '782', cost: '88' },
|
||||
{ month: 'Sept', delta: '0.55', down: false, kWatts: '787', cost: '90' },
|
||||
{ month: 'Oct', delta: '1.81', down: true, kWatts: '779', cost: '86' },
|
||||
{ month: 'Nov', delta: '1.12', down: true, kWatts: '774', cost: '84' },
|
||||
{ month: 'Dec', delta: '0.52', down: false, kWatts: '776', cost: '95' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
private chartPoints = [
|
||||
490, 490, 495, 500,
|
||||
505, 510, 520, 530,
|
||||
550, 580, 630, 720,
|
||||
800, 840, 860, 870,
|
||||
870, 860, 840, 800,
|
||||
720, 200, 145, 130,
|
||||
130, 145, 200, 570,
|
||||
635, 660, 670, 670,
|
||||
660, 630, 580, 460,
|
||||
380, 350, 340, 340,
|
||||
340, 340, 340, 340,
|
||||
340, 340, 340,
|
||||
];
|
||||
|
||||
chartData: ElectricityChart[];
|
||||
|
||||
constructor() {
|
||||
this.chartData = this.chartPoints.map((p, index) => ({
|
||||
label: (index % 5 === 3) ? `${Math.round(index / 5)}` : '',
|
||||
value: p,
|
||||
}));
|
||||
}
|
||||
|
||||
getListData(): Observable<Electricity[]> {
|
||||
return observableOf(this.listData);
|
||||
}
|
||||
|
||||
getChartData(): Observable<ElectricityChart[]> {
|
||||
return observableOf(this.chartData);
|
||||
}
|
||||
}
|
||||
25
src/app/@core/data/electricity.ts
Normal file
25
src/app/@core/data/electricity.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface Month {
|
||||
month: string;
|
||||
delta: string;
|
||||
down: boolean;
|
||||
kWatts: string;
|
||||
cost: string;
|
||||
}
|
||||
|
||||
export interface Electricity {
|
||||
title: string;
|
||||
active?: boolean;
|
||||
months: Month[];
|
||||
}
|
||||
|
||||
export interface ElectricityChart {
|
||||
label: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export abstract class ElectricityData {
|
||||
abstract getListData(): Observable<Electricity[]>;
|
||||
abstract getChartData(): Observable<ElectricityChart[]>;
|
||||
}
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { PeriodsService } from './periods.service';
|
||||
|
||||
export class OrdersChart {
|
||||
chartLabel: string[];
|
||||
linesData: number[][];
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class OrdersChartService {
|
||||
|
||||
private year = [
|
||||
'2012',
|
||||
'2013',
|
||||
'2014',
|
||||
'2015',
|
||||
'2016',
|
||||
'2017',
|
||||
'2018',
|
||||
];
|
||||
|
||||
private data = { };
|
||||
|
||||
constructor(private period: PeriodsService) {
|
||||
this.data = {
|
||||
week: this.getDataForWeekPeriod(),
|
||||
month: this.getDataForMonthPeriod(),
|
||||
year: this.getDataForYearPeriod(),
|
||||
};
|
||||
}
|
||||
|
||||
private getDataForWeekPeriod(): OrdersChart {
|
||||
return {
|
||||
chartLabel: this.getDataLabels(42, this.period.getWeeks()),
|
||||
linesData: [
|
||||
[
|
||||
184, 267, 326, 366, 389, 399,
|
||||
392, 371, 340, 304, 265, 227,
|
||||
191, 158, 130, 108, 95, 91, 97,
|
||||
109, 125, 144, 166, 189, 212,
|
||||
236, 259, 280, 300, 316, 329,
|
||||
338, 342, 339, 329, 312, 288,
|
||||
258, 221, 178, 128, 71,
|
||||
],
|
||||
[
|
||||
158, 178, 193, 205, 212, 213,
|
||||
204, 190, 180, 173, 168, 164,
|
||||
162, 160, 159, 158, 159, 166,
|
||||
179, 195, 215, 236, 257, 276,
|
||||
292, 301, 304, 303, 300, 293,
|
||||
284, 273, 262, 251, 241, 234,
|
||||
232, 232, 232, 232, 232, 232,
|
||||
],
|
||||
[
|
||||
58, 137, 202, 251, 288, 312,
|
||||
323, 324, 311, 288, 257, 222,
|
||||
187, 154, 124, 100, 81, 68, 61,
|
||||
58, 61, 69, 80, 96, 115, 137,
|
||||
161, 186, 210, 233, 254, 271,
|
||||
284, 293, 297, 297, 297, 297,
|
||||
297, 297, 297, 297, 297,
|
||||
],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
private getDataForMonthPeriod(): OrdersChart {
|
||||
return {
|
||||
chartLabel: this.getDataLabels(47, this.period.getMonths()),
|
||||
linesData: [
|
||||
[
|
||||
5, 63, 113, 156, 194, 225,
|
||||
250, 270, 283, 289, 290,
|
||||
286, 277, 264, 244, 220,
|
||||
194, 171, 157, 151, 150,
|
||||
152, 155, 160, 166, 170,
|
||||
167, 153, 135, 115, 97,
|
||||
82, 71, 64, 63, 62, 61,
|
||||
62, 65, 73, 84, 102,
|
||||
127, 159, 203, 259, 333,
|
||||
],
|
||||
[
|
||||
6, 83, 148, 200, 240,
|
||||
265, 273, 259, 211,
|
||||
122, 55, 30, 28, 36,
|
||||
50, 68, 88, 109, 129,
|
||||
146, 158, 163, 165,
|
||||
173, 187, 208, 236,
|
||||
271, 310, 346, 375,
|
||||
393, 400, 398, 387,
|
||||
368, 341, 309, 275,
|
||||
243, 220, 206, 202,
|
||||
207, 222, 247, 286, 348,
|
||||
],
|
||||
[
|
||||
398, 348, 315, 292, 274,
|
||||
261, 251, 243, 237, 231,
|
||||
222, 209, 192, 172, 152,
|
||||
132, 116, 102, 90, 80, 71,
|
||||
64, 58, 53, 49, 48, 54, 66,
|
||||
84, 104, 125, 142, 156, 166,
|
||||
172, 174, 172, 167, 159, 149,
|
||||
136, 121, 105, 86, 67, 45, 22,
|
||||
],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
private getDataForYearPeriod(): OrdersChart {
|
||||
return {
|
||||
chartLabel: this.getDataLabels(42, this.year),
|
||||
linesData: [
|
||||
[
|
||||
190, 269, 327, 366, 389, 398,
|
||||
396, 387, 375, 359, 343, 327,
|
||||
312, 298, 286, 276, 270, 268,
|
||||
265, 258, 247, 234, 220, 204,
|
||||
188, 172, 157, 142, 128, 116,
|
||||
106, 99, 95, 94, 92, 89, 84,
|
||||
77, 69, 60, 49, 36, 22,
|
||||
],
|
||||
[
|
||||
265, 307, 337, 359, 375, 386,
|
||||
393, 397, 399, 397, 390, 379,
|
||||
365, 347, 326, 305, 282, 261,
|
||||
241, 223, 208, 197, 190, 187,
|
||||
185, 181, 172, 160, 145, 126,
|
||||
105, 82, 60, 40, 26, 19, 22,
|
||||
43, 82, 141, 220, 321,
|
||||
],
|
||||
[
|
||||
9, 165, 236, 258, 244, 206,
|
||||
186, 189, 209, 239, 273, 307,
|
||||
339, 365, 385, 396, 398, 385,
|
||||
351, 300, 255, 221, 197, 181,
|
||||
170, 164, 162, 161, 159, 154,
|
||||
146, 135, 122, 108, 96, 87,
|
||||
83, 82, 82, 82, 82, 82, 82,
|
||||
],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
getDataLabels(nPoints: number, labelsArray: string[]): string[] {
|
||||
const labelsArrayLength = labelsArray.length;
|
||||
const step = Math.round(nPoints / labelsArrayLength);
|
||||
|
||||
return Array.from(Array(nPoints)).map((item, index) => {
|
||||
const dataIndex = Math.round(index / step);
|
||||
|
||||
return index % step === 0 ? labelsArray[dataIndex] : '';
|
||||
});
|
||||
}
|
||||
|
||||
getOrdersChartData(period: string): OrdersChart {
|
||||
return this.data[period];
|
||||
}
|
||||
}
|
||||
8
src/app/@core/data/orders-chart.ts
Normal file
8
src/app/@core/data/orders-chart.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
export interface OrdersChart {
|
||||
chartLabel: string[];
|
||||
linesData: number[][];
|
||||
}
|
||||
|
||||
export abstract class OrdersChartData {
|
||||
abstract getOrdersChartData(period: string): OrdersChart;
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
import { of as observableOf, Observable } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { OrdersChart, OrdersChartService } from './orders-chart.service';
|
||||
import { ProfitChart, ProfitChartService } from './profit-chart.service';
|
||||
|
||||
export class OrderProfitChartSummary {
|
||||
title: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class OrdersProfitChartService {
|
||||
|
||||
private summary = [
|
||||
{
|
||||
title: 'Marketplace',
|
||||
value: 3654,
|
||||
},
|
||||
{
|
||||
title: 'Last Month',
|
||||
value: 946,
|
||||
},
|
||||
{
|
||||
title: 'Last Week',
|
||||
value: 654,
|
||||
},
|
||||
{
|
||||
title: 'Today',
|
||||
value: 230,
|
||||
},
|
||||
];
|
||||
|
||||
constructor(private ordersChartService: OrdersChartService,
|
||||
private profitChartService: ProfitChartService) {
|
||||
}
|
||||
|
||||
getOrderProfitChartSummary(): Observable<OrderProfitChartSummary[]> {
|
||||
return observableOf(this.summary);
|
||||
}
|
||||
|
||||
getOrdersChartData(period: string): Observable<OrdersChart> {
|
||||
return observableOf(this.ordersChartService.getOrdersChartData(period));
|
||||
}
|
||||
|
||||
getProfitChartData(period: string): Observable<ProfitChart> {
|
||||
return observableOf(this.profitChartService.getProfitChartData(period));
|
||||
}
|
||||
}
|
||||
14
src/app/@core/data/orders-profit-chart.ts
Normal file
14
src/app/@core/data/orders-profit-chart.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { Observable } from 'rxjs';
|
||||
import { OrdersChart } from './orders-chart';
|
||||
import { ProfitChart } from './profit-chart';
|
||||
|
||||
export interface OrderProfitChartSummary {
|
||||
title: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export abstract class OrdersProfitChartData {
|
||||
abstract getOrderProfitChartSummary(): Observable<OrderProfitChartSummary[]>;
|
||||
abstract getOrdersChartData(period: string): Observable<OrdersChart>;
|
||||
abstract getProfitChartData(period: string): Observable<ProfitChart>;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class PeriodsService {
|
||||
getYears() {
|
||||
return [
|
||||
'2010', '2011', '2012',
|
||||
'2013', '2014', '2015',
|
||||
'2016', '2017', '2018',
|
||||
];
|
||||
}
|
||||
|
||||
getMonths() {
|
||||
return [
|
||||
'Jan', 'Feb', 'Mar',
|
||||
'Apr', 'May', 'Jun',
|
||||
'Jul', 'Aug', 'Sep',
|
||||
'Oct', 'Nov', 'Dec',
|
||||
];
|
||||
}
|
||||
|
||||
getWeeks() {
|
||||
return [
|
||||
'Mon',
|
||||
'Tue',
|
||||
'Wed',
|
||||
'Thu',
|
||||
'Fri',
|
||||
'Sat',
|
||||
'Sun',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class ProfitBarAnimationChartService {
|
||||
|
||||
private data: any;
|
||||
|
||||
constructor() {
|
||||
this.data = {
|
||||
firstLine: this.getDataForFirstLine(),
|
||||
secondLine: this.getDataForSecondLine(),
|
||||
};
|
||||
}
|
||||
|
||||
getDataForFirstLine(): number[] {
|
||||
return this.createEmptyArray(100)
|
||||
.map((_, index) => {
|
||||
const oneFifth = index / 5;
|
||||
|
||||
return (Math.sin(oneFifth) * (oneFifth - 10) + index / 6) * 5;
|
||||
});
|
||||
}
|
||||
|
||||
getDataForSecondLine(): number[] {
|
||||
return this.createEmptyArray(100)
|
||||
.map((_, index) => {
|
||||
const oneFifth = index / 5;
|
||||
|
||||
return (Math.cos(oneFifth) * (oneFifth - 10) + index / 6) * 5;
|
||||
});
|
||||
}
|
||||
|
||||
createEmptyArray(nPoints: number) {
|
||||
return Array.from(Array(nPoints));
|
||||
}
|
||||
|
||||
getChartData(): Observable<{ firstLine: number[]; secondLine: number[]; }> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
}
|
||||
5
src/app/@core/data/profit-bar-animation-chart.ts
Normal file
5
src/app/@core/data/profit-bar-animation-chart.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export abstract class ProfitBarAnimationChartData {
|
||||
abstract getChartData(): Observable<{ firstLine: number[]; secondLine: number[]; }>;
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { PeriodsService } from './periods.service';
|
||||
|
||||
export class ProfitChart {
|
||||
chartLabel: string[];
|
||||
data: number[][];
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class ProfitChartService {
|
||||
|
||||
private year = [
|
||||
'2012',
|
||||
'2013',
|
||||
'2014',
|
||||
'2015',
|
||||
'2016',
|
||||
'2017',
|
||||
'2018',
|
||||
];
|
||||
|
||||
private data = { };
|
||||
|
||||
constructor(private period: PeriodsService) {
|
||||
this.data = {
|
||||
week: this.getDataForWeekPeriod(),
|
||||
month: this.getDataForMonthPeriod(),
|
||||
year: this.getDataForYearPeriod(),
|
||||
};
|
||||
}
|
||||
|
||||
private getDataForWeekPeriod(): ProfitChart {
|
||||
const nPoint = this.period.getWeeks().length;
|
||||
|
||||
return {
|
||||
chartLabel: this.period.getWeeks(),
|
||||
data: [
|
||||
this.getRandomData(nPoint),
|
||||
this.getRandomData(nPoint),
|
||||
this.getRandomData(nPoint),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
private getDataForMonthPeriod(): ProfitChart {
|
||||
const nPoint = this.period.getMonths().length;
|
||||
|
||||
return {
|
||||
chartLabel: this.period.getMonths(),
|
||||
data: [
|
||||
this.getRandomData(nPoint),
|
||||
this.getRandomData(nPoint),
|
||||
this.getRandomData(nPoint),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
private getDataForYearPeriod(): ProfitChart {
|
||||
const nPoint = this.year.length;
|
||||
|
||||
return {
|
||||
chartLabel: this.year,
|
||||
data: [
|
||||
this.getRandomData(nPoint),
|
||||
this.getRandomData(nPoint),
|
||||
this.getRandomData(nPoint),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
private getRandomData(nPoints: number): number[] {
|
||||
return Array.from(Array(nPoints)).map(() => {
|
||||
return Math.round(Math.random() * 500);
|
||||
});
|
||||
}
|
||||
|
||||
getProfitChartData(period: string): ProfitChart {
|
||||
return this.data[period];
|
||||
}
|
||||
}
|
||||
8
src/app/@core/data/profit-chart.ts
Normal file
8
src/app/@core/data/profit-chart.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
export interface ProfitChart {
|
||||
chartLabel: string[];
|
||||
data: number[][];
|
||||
}
|
||||
|
||||
export abstract class ProfitChartData {
|
||||
abstract getProfitChartData(period: string): ProfitChart;
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
|
||||
export class Camera {
|
||||
title: string;
|
||||
source: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SecurityCamerasService {
|
||||
|
||||
private cameras: Camera[] = [
|
||||
{
|
||||
title: 'Camera #1',
|
||||
source: 'assets/images/camera1.jpg',
|
||||
},
|
||||
{
|
||||
title: 'Camera #2',
|
||||
source: 'assets/images/camera2.jpg',
|
||||
},
|
||||
{
|
||||
title: 'Camera #3',
|
||||
source: 'assets/images/camera3.jpg',
|
||||
},
|
||||
{
|
||||
title: 'Camera #4',
|
||||
source: 'assets/images/camera4.jpg',
|
||||
},
|
||||
];
|
||||
|
||||
getCamerasData(): Observable<Camera[]> {
|
||||
return observableOf(this.cameras);
|
||||
}
|
||||
}
|
||||
10
src/app/@core/data/security-cameras.ts
Normal file
10
src/app/@core/data/security-cameras.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface Camera {
|
||||
title: string;
|
||||
source: string;
|
||||
}
|
||||
|
||||
export abstract class SecurityCamerasData {
|
||||
abstract getCamerasData(): Observable<Camera[]>;
|
||||
}
|
||||
|
|
@ -1,431 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class SmartTableService {
|
||||
|
||||
data = [{
|
||||
id: 1,
|
||||
firstName: 'Mark',
|
||||
lastName: 'Otto',
|
||||
username: '@mdo',
|
||||
email: 'mdo@gmail.com',
|
||||
age: '28',
|
||||
}, {
|
||||
id: 2,
|
||||
firstName: 'Jacob',
|
||||
lastName: 'Thornton',
|
||||
username: '@fat',
|
||||
email: 'fat@yandex.ru',
|
||||
age: '45',
|
||||
}, {
|
||||
id: 3,
|
||||
firstName: 'Larry',
|
||||
lastName: 'Bird',
|
||||
username: '@twitter',
|
||||
email: 'twitter@outlook.com',
|
||||
age: '18',
|
||||
}, {
|
||||
id: 4,
|
||||
firstName: 'John',
|
||||
lastName: 'Snow',
|
||||
username: '@snow',
|
||||
email: 'snow@gmail.com',
|
||||
age: '20',
|
||||
}, {
|
||||
id: 5,
|
||||
firstName: 'Jack',
|
||||
lastName: 'Sparrow',
|
||||
username: '@jack',
|
||||
email: 'jack@yandex.ru',
|
||||
age: '30',
|
||||
}, {
|
||||
id: 6,
|
||||
firstName: 'Ann',
|
||||
lastName: 'Smith',
|
||||
username: '@ann',
|
||||
email: 'ann@gmail.com',
|
||||
age: '21',
|
||||
}, {
|
||||
id: 7,
|
||||
firstName: 'Barbara',
|
||||
lastName: 'Black',
|
||||
username: '@barbara',
|
||||
email: 'barbara@yandex.ru',
|
||||
age: '43',
|
||||
}, {
|
||||
id: 8,
|
||||
firstName: 'Sevan',
|
||||
lastName: 'Bagrat',
|
||||
username: '@sevan',
|
||||
email: 'sevan@outlook.com',
|
||||
age: '13',
|
||||
}, {
|
||||
id: 9,
|
||||
firstName: 'Ruben',
|
||||
lastName: 'Vardan',
|
||||
username: '@ruben',
|
||||
email: 'ruben@gmail.com',
|
||||
age: '22',
|
||||
}, {
|
||||
id: 10,
|
||||
firstName: 'Karen',
|
||||
lastName: 'Sevan',
|
||||
username: '@karen',
|
||||
email: 'karen@yandex.ru',
|
||||
age: '33',
|
||||
}, {
|
||||
id: 11,
|
||||
firstName: 'Mark',
|
||||
lastName: 'Otto',
|
||||
username: '@mark',
|
||||
email: 'mark@gmail.com',
|
||||
age: '38',
|
||||
}, {
|
||||
id: 12,
|
||||
firstName: 'Jacob',
|
||||
lastName: 'Thornton',
|
||||
username: '@jacob',
|
||||
email: 'jacob@yandex.ru',
|
||||
age: '48',
|
||||
}, {
|
||||
id: 13,
|
||||
firstName: 'Haik',
|
||||
lastName: 'Hakob',
|
||||
username: '@haik',
|
||||
email: 'haik@outlook.com',
|
||||
age: '48',
|
||||
}, {
|
||||
id: 14,
|
||||
firstName: 'Garegin',
|
||||
lastName: 'Jirair',
|
||||
username: '@garegin',
|
||||
email: 'garegin@gmail.com',
|
||||
age: '40',
|
||||
}, {
|
||||
id: 15,
|
||||
firstName: 'Krikor',
|
||||
lastName: 'Bedros',
|
||||
username: '@krikor',
|
||||
email: 'krikor@yandex.ru',
|
||||
age: '32',
|
||||
}, {
|
||||
'id': 16,
|
||||
'firstName': 'Francisca',
|
||||
'lastName': 'Brady',
|
||||
'username': '@Gibson',
|
||||
'email': 'franciscagibson@comtours.com',
|
||||
'age': 11,
|
||||
}, {
|
||||
'id': 17,
|
||||
'firstName': 'Tillman',
|
||||
'lastName': 'Figueroa',
|
||||
'username': '@Snow',
|
||||
'email': 'tillmansnow@comtours.com',
|
||||
'age': 34,
|
||||
}, {
|
||||
'id': 18,
|
||||
'firstName': 'Jimenez',
|
||||
'lastName': 'Morris',
|
||||
'username': '@Bryant',
|
||||
'email': 'jimenezbryant@comtours.com',
|
||||
'age': 45,
|
||||
}, {
|
||||
'id': 19,
|
||||
'firstName': 'Sandoval',
|
||||
'lastName': 'Jacobson',
|
||||
'username': '@Mcbride',
|
||||
'email': 'sandovalmcbride@comtours.com',
|
||||
'age': 32,
|
||||
}, {
|
||||
'id': 20,
|
||||
'firstName': 'Griffin',
|
||||
'lastName': 'Torres',
|
||||
'username': '@Charles',
|
||||
'email': 'griffincharles@comtours.com',
|
||||
'age': 19,
|
||||
}, {
|
||||
'id': 21,
|
||||
'firstName': 'Cora',
|
||||
'lastName': 'Parker',
|
||||
'username': '@Caldwell',
|
||||
'email': 'coracaldwell@comtours.com',
|
||||
'age': 27,
|
||||
}, {
|
||||
'id': 22,
|
||||
'firstName': 'Cindy',
|
||||
'lastName': 'Bond',
|
||||
'username': '@Velez',
|
||||
'email': 'cindyvelez@comtours.com',
|
||||
'age': 24,
|
||||
}, {
|
||||
'id': 23,
|
||||
'firstName': 'Frieda',
|
||||
'lastName': 'Tyson',
|
||||
'username': '@Craig',
|
||||
'email': 'friedacraig@comtours.com',
|
||||
'age': 45,
|
||||
}, {
|
||||
'id': 24,
|
||||
'firstName': 'Cote',
|
||||
'lastName': 'Holcomb',
|
||||
'username': '@Rowe',
|
||||
'email': 'coterowe@comtours.com',
|
||||
'age': 20,
|
||||
}, {
|
||||
'id': 25,
|
||||
'firstName': 'Trujillo',
|
||||
'lastName': 'Mejia',
|
||||
'username': '@Valenzuela',
|
||||
'email': 'trujillovalenzuela@comtours.com',
|
||||
'age': 16,
|
||||
}, {
|
||||
'id': 26,
|
||||
'firstName': 'Pruitt',
|
||||
'lastName': 'Shepard',
|
||||
'username': '@Sloan',
|
||||
'email': 'pruittsloan@comtours.com',
|
||||
'age': 44,
|
||||
}, {
|
||||
'id': 27,
|
||||
'firstName': 'Sutton',
|
||||
'lastName': 'Ortega',
|
||||
'username': '@Black',
|
||||
'email': 'suttonblack@comtours.com',
|
||||
'age': 42,
|
||||
}, {
|
||||
'id': 28,
|
||||
'firstName': 'Marion',
|
||||
'lastName': 'Heath',
|
||||
'username': '@Espinoza',
|
||||
'email': 'marionespinoza@comtours.com',
|
||||
'age': 47,
|
||||
}, {
|
||||
'id': 29,
|
||||
'firstName': 'Newman',
|
||||
'lastName': 'Hicks',
|
||||
'username': '@Keith',
|
||||
'email': 'newmankeith@comtours.com',
|
||||
'age': 15,
|
||||
}, {
|
||||
'id': 30,
|
||||
'firstName': 'Boyle',
|
||||
'lastName': 'Larson',
|
||||
'username': '@Summers',
|
||||
'email': 'boylesummers@comtours.com',
|
||||
'age': 32,
|
||||
}, {
|
||||
'id': 31,
|
||||
'firstName': 'Haynes',
|
||||
'lastName': 'Vinson',
|
||||
'username': '@Mckenzie',
|
||||
'email': 'haynesmckenzie@comtours.com',
|
||||
'age': 15,
|
||||
}, {
|
||||
'id': 32,
|
||||
'firstName': 'Miller',
|
||||
'lastName': 'Acosta',
|
||||
'username': '@Young',
|
||||
'email': 'milleryoung@comtours.com',
|
||||
'age': 55,
|
||||
}, {
|
||||
'id': 33,
|
||||
'firstName': 'Johnston',
|
||||
'lastName': 'Brown',
|
||||
'username': '@Knight',
|
||||
'email': 'johnstonknight@comtours.com',
|
||||
'age': 29,
|
||||
}, {
|
||||
'id': 34,
|
||||
'firstName': 'Lena',
|
||||
'lastName': 'Pitts',
|
||||
'username': '@Forbes',
|
||||
'email': 'lenaforbes@comtours.com',
|
||||
'age': 25,
|
||||
}, {
|
||||
'id': 35,
|
||||
'firstName': 'Terrie',
|
||||
'lastName': 'Kennedy',
|
||||
'username': '@Branch',
|
||||
'email': 'terriebranch@comtours.com',
|
||||
'age': 37,
|
||||
}, {
|
||||
'id': 36,
|
||||
'firstName': 'Louise',
|
||||
'lastName': 'Aguirre',
|
||||
'username': '@Kirby',
|
||||
'email': 'louisekirby@comtours.com',
|
||||
'age': 44,
|
||||
}, {
|
||||
'id': 37,
|
||||
'firstName': 'David',
|
||||
'lastName': 'Patton',
|
||||
'username': '@Sanders',
|
||||
'email': 'davidsanders@comtours.com',
|
||||
'age': 26,
|
||||
}, {
|
||||
'id': 38,
|
||||
'firstName': 'Holden',
|
||||
'lastName': 'Barlow',
|
||||
'username': '@Mckinney',
|
||||
'email': 'holdenmckinney@comtours.com',
|
||||
'age': 11,
|
||||
}, {
|
||||
'id': 39,
|
||||
'firstName': 'Baker',
|
||||
'lastName': 'Rivera',
|
||||
'username': '@Montoya',
|
||||
'email': 'bakermontoya@comtours.com',
|
||||
'age': 47,
|
||||
}, {
|
||||
'id': 40,
|
||||
'firstName': 'Belinda',
|
||||
'lastName': 'Lloyd',
|
||||
'username': '@Calderon',
|
||||
'email': 'belindacalderon@comtours.com',
|
||||
'age': 21,
|
||||
}, {
|
||||
'id': 41,
|
||||
'firstName': 'Pearson',
|
||||
'lastName': 'Patrick',
|
||||
'username': '@Clements',
|
||||
'email': 'pearsonclements@comtours.com',
|
||||
'age': 42,
|
||||
}, {
|
||||
'id': 42,
|
||||
'firstName': 'Alyce',
|
||||
'lastName': 'Mckee',
|
||||
'username': '@Daugherty',
|
||||
'email': 'alycedaugherty@comtours.com',
|
||||
'age': 55,
|
||||
}, {
|
||||
'id': 43,
|
||||
'firstName': 'Valencia',
|
||||
'lastName': 'Spence',
|
||||
'username': '@Olsen',
|
||||
'email': 'valenciaolsen@comtours.com',
|
||||
'age': 20,
|
||||
}, {
|
||||
'id': 44,
|
||||
'firstName': 'Leach',
|
||||
'lastName': 'Holcomb',
|
||||
'username': '@Humphrey',
|
||||
'email': 'leachhumphrey@comtours.com',
|
||||
'age': 28,
|
||||
}, {
|
||||
'id': 45,
|
||||
'firstName': 'Moss',
|
||||
'lastName': 'Baxter',
|
||||
'username': '@Fitzpatrick',
|
||||
'email': 'mossfitzpatrick@comtours.com',
|
||||
'age': 51,
|
||||
}, {
|
||||
'id': 46,
|
||||
'firstName': 'Jeanne',
|
||||
'lastName': 'Cooke',
|
||||
'username': '@Ward',
|
||||
'email': 'jeanneward@comtours.com',
|
||||
'age': 59,
|
||||
}, {
|
||||
'id': 47,
|
||||
'firstName': 'Wilma',
|
||||
'lastName': 'Briggs',
|
||||
'username': '@Kidd',
|
||||
'email': 'wilmakidd@comtours.com',
|
||||
'age': 53,
|
||||
}, {
|
||||
'id': 48,
|
||||
'firstName': 'Beatrice',
|
||||
'lastName': 'Perry',
|
||||
'username': '@Gilbert',
|
||||
'email': 'beatricegilbert@comtours.com',
|
||||
'age': 39,
|
||||
}, {
|
||||
'id': 49,
|
||||
'firstName': 'Whitaker',
|
||||
'lastName': 'Hyde',
|
||||
'username': '@Mcdonald',
|
||||
'email': 'whitakermcdonald@comtours.com',
|
||||
'age': 35,
|
||||
}, {
|
||||
'id': 50,
|
||||
'firstName': 'Rebekah',
|
||||
'lastName': 'Duran',
|
||||
'username': '@Gross',
|
||||
'email': 'rebekahgross@comtours.com',
|
||||
'age': 40,
|
||||
}, {
|
||||
'id': 51,
|
||||
'firstName': 'Earline',
|
||||
'lastName': 'Mayer',
|
||||
'username': '@Woodward',
|
||||
'email': 'earlinewoodward@comtours.com',
|
||||
'age': 52,
|
||||
}, {
|
||||
'id': 52,
|
||||
'firstName': 'Moran',
|
||||
'lastName': 'Baxter',
|
||||
'username': '@Johns',
|
||||
'email': 'moranjohns@comtours.com',
|
||||
'age': 20,
|
||||
}, {
|
||||
'id': 53,
|
||||
'firstName': 'Nanette',
|
||||
'lastName': 'Hubbard',
|
||||
'username': '@Cooke',
|
||||
'email': 'nanettecooke@comtours.com',
|
||||
'age': 55,
|
||||
}, {
|
||||
'id': 54,
|
||||
'firstName': 'Dalton',
|
||||
'lastName': 'Walker',
|
||||
'username': '@Hendricks',
|
||||
'email': 'daltonhendricks@comtours.com',
|
||||
'age': 25,
|
||||
}, {
|
||||
'id': 55,
|
||||
'firstName': 'Bennett',
|
||||
'lastName': 'Blake',
|
||||
'username': '@Pena',
|
||||
'email': 'bennettpena@comtours.com',
|
||||
'age': 13,
|
||||
}, {
|
||||
'id': 56,
|
||||
'firstName': 'Kellie',
|
||||
'lastName': 'Horton',
|
||||
'username': '@Weiss',
|
||||
'email': 'kellieweiss@comtours.com',
|
||||
'age': 48,
|
||||
}, {
|
||||
'id': 57,
|
||||
'firstName': 'Hobbs',
|
||||
'lastName': 'Talley',
|
||||
'username': '@Sanford',
|
||||
'email': 'hobbssanford@comtours.com',
|
||||
'age': 28,
|
||||
}, {
|
||||
'id': 58,
|
||||
'firstName': 'Mcguire',
|
||||
'lastName': 'Donaldson',
|
||||
'username': '@Roman',
|
||||
'email': 'mcguireroman@comtours.com',
|
||||
'age': 38,
|
||||
}, {
|
||||
'id': 59,
|
||||
'firstName': 'Rodriquez',
|
||||
'lastName': 'Saunders',
|
||||
'username': '@Harper',
|
||||
'email': 'rodriquezharper@comtours.com',
|
||||
'age': 20,
|
||||
}, {
|
||||
'id': 60,
|
||||
'firstName': 'Lou',
|
||||
'lastName': 'Conner',
|
||||
'username': '@Sanchez',
|
||||
'email': 'lousanchez@comtours.com',
|
||||
'age': 16,
|
||||
}];
|
||||
|
||||
getData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
4
src/app/@core/data/smart-table.ts
Normal file
4
src/app/@core/data/smart-table.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
export abstract class SmartTableData {
|
||||
abstract getData(): any[];
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class SolarService {
|
||||
private value = 42;
|
||||
|
||||
getSolarData(): Observable<number> {
|
||||
return observableOf(this.value);
|
||||
}
|
||||
}
|
||||
5
src/app/@core/data/solar.ts
Normal file
5
src/app/@core/data/solar.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export abstract class SolarData {
|
||||
abstract getSolarData(): Observable<number>;
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class StatsBarService {
|
||||
|
||||
private statsBarData: number[] = [
|
||||
300, 520, 435, 530,
|
||||
730, 620, 660, 860,
|
||||
];
|
||||
|
||||
getStatsBarData(): Observable<number[]> {
|
||||
return observableOf(this.statsBarData);
|
||||
}
|
||||
}
|
||||
5
src/app/@core/data/stats-bar.ts
Normal file
5
src/app/@core/data/stats-bar.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export abstract class StatsBarData {
|
||||
abstract getStatsBarData(): Observable<number[]>;
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
|
||||
export class ProgressInfo {
|
||||
title: string;
|
||||
value: number;
|
||||
activeProgress: number;
|
||||
description: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class StatsProgressBarService {
|
||||
private progressInfoData: ProgressInfo[] = [
|
||||
{
|
||||
title: 'Today’s Profit',
|
||||
value: 572900,
|
||||
activeProgress: 70,
|
||||
description: 'Better than last week (70%)',
|
||||
},
|
||||
{
|
||||
title: 'New Orders',
|
||||
value: 6378,
|
||||
activeProgress: 30,
|
||||
description: 'Better than last week (30%)',
|
||||
},
|
||||
{
|
||||
title: 'New Comments',
|
||||
value: 200,
|
||||
activeProgress: 55,
|
||||
description: 'Better than last week (55%)',
|
||||
},
|
||||
];
|
||||
|
||||
getProgressInfoData(): Observable<ProgressInfo[]> {
|
||||
return observableOf(this.progressInfoData);
|
||||
}
|
||||
}
|
||||
12
src/app/@core/data/stats-progress-bar.ts
Normal file
12
src/app/@core/data/stats-progress-bar.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface ProgressInfo {
|
||||
title: string;
|
||||
value: number;
|
||||
activeProgress: number;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export abstract class StatsProgressBarData {
|
||||
abstract getProgressInfoData(): Observable<ProgressInfo[]>;
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
|
||||
export class Temperature {
|
||||
value: number;
|
||||
min: number;
|
||||
max: number;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class TemperatureHumidityService {
|
||||
|
||||
private temperatureDate: Temperature = {
|
||||
value: 24,
|
||||
min: 12,
|
||||
max: 30,
|
||||
};
|
||||
|
||||
private humidityDate: Temperature = {
|
||||
value: 87,
|
||||
min: 0,
|
||||
max: 100,
|
||||
};
|
||||
|
||||
getTemperatureData(): Observable<Temperature> {
|
||||
return observableOf(this.temperatureDate);
|
||||
}
|
||||
|
||||
getHumidityData(): Observable<Temperature> {
|
||||
return observableOf(this.humidityDate);
|
||||
}
|
||||
}
|
||||
12
src/app/@core/data/temperature-humidity.ts
Normal file
12
src/app/@core/data/temperature-humidity.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface Temperature {
|
||||
value: number;
|
||||
min: number;
|
||||
max: number;
|
||||
}
|
||||
|
||||
export abstract class TemperatureHumidityData {
|
||||
abstract getTemperatureData(): Observable<Temperature>;
|
||||
abstract getHumidityData(): Observable<Temperature>;
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
import { PeriodsService } from './periods.service';
|
||||
|
||||
export class TrafficBar {
|
||||
data: number[];
|
||||
labels: string[];
|
||||
formatter: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class TrafficBarService {
|
||||
|
||||
private data = { };
|
||||
|
||||
constructor(private period: PeriodsService) {
|
||||
this.data = {
|
||||
week: this.getDataForWeekPeriod(),
|
||||
month: this.getDataForMonthPeriod(),
|
||||
year: this.getDataForYearPeriod(),
|
||||
};
|
||||
}
|
||||
|
||||
getDataForWeekPeriod(): TrafficBar {
|
||||
return {
|
||||
data: [10, 15, 19, 7, 20, 13, 15],
|
||||
labels: this.period.getWeeks(),
|
||||
formatter: '{c0} MB',
|
||||
};
|
||||
}
|
||||
|
||||
getDataForMonthPeriod(): TrafficBar {
|
||||
return {
|
||||
data: [0.5, 0.3, 0.8, 0.2, 0.3, 0.7, 0.8, 1, 0.7, 0.8, 0.6, 0.7],
|
||||
labels: this.period.getMonths(),
|
||||
formatter: '{c0} GB',
|
||||
};
|
||||
}
|
||||
|
||||
getDataForYearPeriod(): TrafficBar {
|
||||
return {
|
||||
data: [10, 15, 19, 7, 20, 13, 15, 19, 11],
|
||||
labels: this.period.getYears(),
|
||||
formatter: '{c0} GB',
|
||||
};
|
||||
}
|
||||
|
||||
getTrafficBarData(period: string): Observable<TrafficBar> {
|
||||
return observableOf(this.data[period]);
|
||||
}
|
||||
}
|
||||
11
src/app/@core/data/traffic-bar.ts
Normal file
11
src/app/@core/data/traffic-bar.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface TrafficBar {
|
||||
data: number[];
|
||||
labels: string[];
|
||||
formatter: string;
|
||||
}
|
||||
|
||||
export abstract class TrafficBarData {
|
||||
abstract getTrafficBarData(period: string): Observable<TrafficBar>;
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class TrafficChartService {
|
||||
|
||||
private data: number[] = [
|
||||
300, 520, 435, 530,
|
||||
730, 620, 660, 860,
|
||||
];
|
||||
|
||||
getTrafficChartData(): Observable<number[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
}
|
||||
5
src/app/@core/data/traffic-chart.ts
Normal file
5
src/app/@core/data/traffic-chart.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export abstract class TrafficChartData {
|
||||
abstract getTrafficChartData(): Observable<number[]>;
|
||||
}
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
import { PeriodsService } from './periods.service';
|
||||
|
||||
export class TrafficList {
|
||||
date: string;
|
||||
value: number;
|
||||
delta: {
|
||||
up: boolean;
|
||||
value: number;
|
||||
};
|
||||
comparison: {
|
||||
prevDate: string;
|
||||
prevValue: number;
|
||||
nextDate: string;
|
||||
nextValue: number;
|
||||
};
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class TrafficListService {
|
||||
|
||||
private getRandom = (roundTo: number) => Math.round(Math.random() * roundTo);
|
||||
private data = {};
|
||||
|
||||
constructor(private period: PeriodsService) {
|
||||
this.data = {
|
||||
week: this.getDataWeek(),
|
||||
month: this.getDataMonth(),
|
||||
year: this.getDataYear(),
|
||||
};
|
||||
}
|
||||
|
||||
private getDataWeek(): TrafficList[] {
|
||||
const getFirstDateInPeriod = () => {
|
||||
const weeks = this.period.getWeeks();
|
||||
|
||||
return weeks[weeks.length - 1];
|
||||
};
|
||||
|
||||
return this.reduceData(this.period.getWeeks(), getFirstDateInPeriod);
|
||||
}
|
||||
|
||||
private getDataMonth(): TrafficList[] {
|
||||
const getFirstDateInPeriod = () => {
|
||||
const months = this.period.getMonths();
|
||||
const date = new Date();
|
||||
const prevYear = date.getFullYear() - 1;
|
||||
|
||||
return `${months[months.length - 1]}, ${prevYear}`;
|
||||
};
|
||||
|
||||
return this.reduceData(this.period.getMonths(), getFirstDateInPeriod);
|
||||
}
|
||||
|
||||
private getDataYear(): TrafficList[] {
|
||||
const getFirstDateInPeriod = () => {
|
||||
const years = this.period.getYears();
|
||||
|
||||
return `${parseInt(years[0], 10) - 1}`;
|
||||
};
|
||||
|
||||
return this.reduceData(this.period.getYears(), getFirstDateInPeriod);
|
||||
}
|
||||
|
||||
private reduceData(timePeriods: string[], getFirstDateInPeriod: () => string): TrafficList[] {
|
||||
return timePeriods.reduce((result, timePeriod, index) => {
|
||||
const hasResult = result[index - 1];
|
||||
const prevDate = hasResult ?
|
||||
result[index - 1].comparison.nextDate :
|
||||
getFirstDateInPeriod();
|
||||
const prevValue = hasResult ?
|
||||
result[index - 1].comparison.nextValue :
|
||||
this.getRandom(100);
|
||||
const nextValue = this.getRandom(100);
|
||||
const deltaValue = prevValue - nextValue;
|
||||
|
||||
const item = {
|
||||
date: timePeriod,
|
||||
value: this.getRandom(1000),
|
||||
delta: {
|
||||
up: deltaValue <= 0,
|
||||
value: Math.abs(deltaValue),
|
||||
},
|
||||
comparison: {
|
||||
prevDate,
|
||||
prevValue,
|
||||
nextDate: timePeriod,
|
||||
nextValue,
|
||||
},
|
||||
};
|
||||
|
||||
return [...result, item];
|
||||
}, []);
|
||||
}
|
||||
|
||||
getTrafficListData(period: string): Observable<TrafficList> {
|
||||
return observableOf(this.data[period]);
|
||||
}
|
||||
}
|
||||
20
src/app/@core/data/traffic-list.ts
Normal file
20
src/app/@core/data/traffic-list.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface TrafficList {
|
||||
date: string;
|
||||
value: number;
|
||||
delta: {
|
||||
up: boolean;
|
||||
value: number;
|
||||
};
|
||||
comparison: {
|
||||
prevDate: string;
|
||||
prevValue: number;
|
||||
nextDate: string;
|
||||
nextValue: number;
|
||||
};
|
||||
}
|
||||
|
||||
export abstract class TrafficListData {
|
||||
abstract getTrafficListData(period: string): Observable<TrafficList>;
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
import { PeriodsService } from './periods.service';
|
||||
|
||||
export class UserActive {
|
||||
date: string;
|
||||
pagesVisitCount: number;
|
||||
deltaUp: boolean;
|
||||
newVisits: number;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserActivityService {
|
||||
|
||||
private getRandom = (roundTo: number) => Math.round(Math.random() * roundTo);
|
||||
private generateUserActivityRandomData(date) {
|
||||
return {
|
||||
date,
|
||||
pagesVisitCount: this.getRandom(1000),
|
||||
deltaUp: this.getRandom(1) % 2 === 0,
|
||||
newVisits: this.getRandom(100),
|
||||
};
|
||||
}
|
||||
|
||||
data = {};
|
||||
|
||||
constructor(private periods: PeriodsService) {
|
||||
this.data = {
|
||||
week: this.getDataWeek(),
|
||||
month: this.getDataMonth(),
|
||||
year: this.getDataYear(),
|
||||
};
|
||||
}
|
||||
|
||||
private getDataWeek(): UserActive[] {
|
||||
return this.periods.getWeeks().map((week) => {
|
||||
return this.generateUserActivityRandomData(week);
|
||||
});
|
||||
}
|
||||
|
||||
private getDataMonth(): UserActive[] {
|
||||
const currentDate = new Date();
|
||||
const days = currentDate.getDate();
|
||||
const month = this.periods.getMonths()[currentDate.getMonth()];
|
||||
|
||||
return Array.from(Array(days)).map((_, index) => {
|
||||
const date = `${index + 1} ${month}`;
|
||||
|
||||
return this.generateUserActivityRandomData(date);
|
||||
});
|
||||
}
|
||||
|
||||
private getDataYear(): UserActive[] {
|
||||
return this.periods.getYears().map((year) => {
|
||||
return this.generateUserActivityRandomData(year);
|
||||
});
|
||||
}
|
||||
|
||||
getUserActivityData(period: string): Observable<UserActive[]> {
|
||||
return observableOf(this.data[period]);
|
||||
}
|
||||
}
|
||||
12
src/app/@core/data/user-activity.ts
Normal file
12
src/app/@core/data/user-activity.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface UserActive {
|
||||
date: string;
|
||||
pagesVisitCount: number;
|
||||
deltaUp: boolean;
|
||||
newVisits: number;
|
||||
}
|
||||
|
||||
export abstract class UserActivityData {
|
||||
abstract getUserActivityData(period: string): Observable<UserActive[]>;
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
class User {
|
||||
name: string;
|
||||
picture: string;
|
||||
}
|
||||
|
||||
export class Contacts {
|
||||
user: User;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export class RecentUsers extends Contacts {
|
||||
time: number;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserService {
|
||||
|
||||
private time: Date = new Date;
|
||||
|
||||
private users = {
|
||||
nick: { name: 'Nick Jones', picture: 'assets/images/nick.png' },
|
||||
eva: { name: 'Eva Moor', picture: 'assets/images/eva.png' },
|
||||
jack: { name: 'Jack Williams', picture: 'assets/images/jack.png' },
|
||||
lee: { name: 'Lee Wong', picture: 'assets/images/lee.png' },
|
||||
alan: { name: 'Alan Thompson', picture: 'assets/images/alan.png' },
|
||||
kate: { name: 'Kate Martinez', picture: 'assets/images/kate.png' },
|
||||
};
|
||||
private types = {
|
||||
mobile: 'mobile',
|
||||
home: 'home',
|
||||
work: 'work',
|
||||
};
|
||||
private contacts: Contacts[] = [
|
||||
{ user: this.users.nick, type: this.types.mobile },
|
||||
{ user: this.users.eva, type: this.types.home },
|
||||
{ user: this.users.jack, type: this.types.mobile },
|
||||
{ user: this.users.lee, type: this.types.mobile },
|
||||
{ user: this.users.alan, type: this.types.home },
|
||||
{ user: this.users.kate, type: this.types.work },
|
||||
];
|
||||
private recentUsers: RecentUsers[] = [
|
||||
{ user: this.users.alan, type: this.types.home, time: this.time.setHours(21, 12)},
|
||||
{ user: this.users.eva, type: this.types.home, time: this.time.setHours(17, 45)},
|
||||
{ user: this.users.nick, type: this.types.mobile, time: this.time.setHours(5, 29)},
|
||||
{ user: this.users.lee, type: this.types.mobile, time: this.time.setHours(11, 24)},
|
||||
{ user: this.users.jack, type: this.types.mobile, time: this.time.setHours(10, 45)},
|
||||
{ user: this.users.kate, type: this.types.work, time: this.time.setHours(9, 42)},
|
||||
{ user: this.users.kate, type: this.types.work, time: this.time.setHours(9, 31)},
|
||||
{ user: this.users.jack, type: this.types.mobile, time: this.time.setHours(8, 0)},
|
||||
];
|
||||
|
||||
getUsers(): Observable<any> {
|
||||
return observableOf(this.users);
|
||||
}
|
||||
|
||||
getContacts(): Observable<Contacts[]> {
|
||||
return observableOf(this.contacts);
|
||||
}
|
||||
|
||||
getRecentUsers(): Observable<RecentUsers[]> {
|
||||
return observableOf(this.recentUsers);
|
||||
}
|
||||
}
|
||||
21
src/app/@core/data/users.ts
Normal file
21
src/app/@core/data/users.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface User {
|
||||
name: string;
|
||||
picture: string;
|
||||
}
|
||||
|
||||
export interface Contacts {
|
||||
user: User;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface RecentUsers extends Contacts {
|
||||
time: number;
|
||||
}
|
||||
|
||||
export abstract class UserData {
|
||||
abstract getUsers(): Observable<User[]>;
|
||||
abstract getContacts(): Observable<Contacts[]>;
|
||||
abstract getRecentUsers(): Observable<RecentUsers[]>;
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
import { PeriodsService } from './periods.service';
|
||||
|
||||
export class OutlineData {
|
||||
label: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class VisitorsAnalyticsService {
|
||||
|
||||
constructor(private periodService: PeriodsService) {
|
||||
}
|
||||
|
||||
private pieChartValue = 75;
|
||||
private innerLinePoints: number[] = [
|
||||
94, 188, 225, 244, 253, 254, 249, 235, 208,
|
||||
173, 141, 118, 105, 97, 94, 96, 104, 121, 147,
|
||||
183, 224, 265, 302, 333, 358, 375, 388, 395,
|
||||
400, 400, 397, 390, 377, 360, 338, 310, 278,
|
||||
241, 204, 166, 130, 98, 71, 49, 32, 20, 13, 9,
|
||||
];
|
||||
private outerLinePoints: number[] = [
|
||||
85, 71, 59, 50, 45, 42, 41, 44 , 58, 88,
|
||||
136 , 199, 267, 326, 367, 391, 400, 397,
|
||||
376, 319, 200, 104, 60, 41, 36, 37, 44,
|
||||
55, 74, 100 , 131, 159, 180, 193, 199, 200,
|
||||
195, 184, 164, 135, 103, 73, 50, 33, 22, 15, 11,
|
||||
];
|
||||
private generateOutlineLineData(): OutlineData[] {
|
||||
const months = this.periodService.getMonths();
|
||||
const outerLinePointsLength = this.outerLinePoints.length;
|
||||
const monthsLength = months.length;
|
||||
|
||||
return this.outerLinePoints.map((p, index) => {
|
||||
const monthIndex = Math.round(index / 4);
|
||||
const label = (index % Math.round(outerLinePointsLength / monthsLength) === 0)
|
||||
? months[monthIndex]
|
||||
: '';
|
||||
|
||||
return {
|
||||
label,
|
||||
value: p,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getInnerLineChartData(): Observable<number[]> {
|
||||
return observableOf(this.innerLinePoints);
|
||||
}
|
||||
|
||||
getOutlineLineChartData(): Observable<OutlineData[]> {
|
||||
return observableOf(this.generateOutlineLineData());
|
||||
}
|
||||
|
||||
getPieChartData(): Observable<number> {
|
||||
return observableOf(this.pieChartValue);
|
||||
}
|
||||
}
|
||||
12
src/app/@core/data/visitors-analytics.ts
Normal file
12
src/app/@core/data/visitors-analytics.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface OutlineData {
|
||||
label: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export abstract class VisitorsAnalyticsData {
|
||||
abstract getInnerLineChartData(): Observable<number[]>;
|
||||
abstract getOutlineLineChartData(): Observable<OutlineData[]>;
|
||||
abstract getPieChartData(): Observable<number>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue