mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-17 07:50:12 +01:00
feat(data): update data module, add new mock data (#1960)
This commit is contained in:
parent
773c14e74a
commit
47d232b606
53 changed files with 635 additions and 256 deletions
|
|
@ -6,7 +6,12 @@ import { of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
import { throwIfAlreadyLoaded } from './module-import-guard';
|
import { throwIfAlreadyLoaded } from './module-import-guard';
|
||||||
import { DataModule } from './data/data.module';
|
import { DataModule } from './data/data.module';
|
||||||
import { AnalyticsService } from './utils/analytics.service';
|
import {
|
||||||
|
AnalyticsService,
|
||||||
|
LayoutService,
|
||||||
|
PlayerService,
|
||||||
|
StateService,
|
||||||
|
} from './utils';
|
||||||
|
|
||||||
const socialLinks = [
|
const socialLinks = [
|
||||||
{
|
{
|
||||||
|
|
@ -71,6 +76,9 @@ export const NB_CORE_PROVIDERS = [
|
||||||
provide: NbRoleProvider, useClass: NbSimpleRoleProvider,
|
provide: NbRoleProvider, useClass: NbSimpleRoleProvider,
|
||||||
},
|
},
|
||||||
AnalyticsService,
|
AnalyticsService,
|
||||||
|
LayoutService,
|
||||||
|
PlayerService,
|
||||||
|
StateService,
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
||||||
28
src/app/@core/data/country-order.service.ts
Normal file
28
src/app/@core/data/country-order.service.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,9 +3,7 @@ import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
import { UserService } from './users.service';
|
import { UserService } from './users.service';
|
||||||
import { ElectricityService } from './electricity.service';
|
import { ElectricityService } from './electricity.service';
|
||||||
import { StateService } from './state.service';
|
|
||||||
import { SmartTableService } from './smart-table.service';
|
import { SmartTableService } from './smart-table.service';
|
||||||
import { PlayerService } from './player.service';
|
|
||||||
import { UserActivityService } from './user-activity.service';
|
import { UserActivityService } from './user-activity.service';
|
||||||
import { OrdersChartService } from './orders-chart.service';
|
import { OrdersChartService } from './orders-chart.service';
|
||||||
import { ProfitChartService } from './profit-chart.service';
|
import { ProfitChartService } from './profit-chart.service';
|
||||||
|
|
@ -15,14 +13,19 @@ import { EarningService } from './earning.service';
|
||||||
import { OrdersProfitChartService } from './orders-profit-chart.service';
|
import { OrdersProfitChartService } from './orders-profit-chart.service';
|
||||||
import { TrafficBarService } from './traffic-bar.service';
|
import { TrafficBarService } from './traffic-bar.service';
|
||||||
import { ProfitBarAnimationChartService } from './profit-bar-animation-chart.service';
|
import { ProfitBarAnimationChartService } from './profit-bar-animation-chart.service';
|
||||||
import { LayoutService } from './layout.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 = [
|
const SERVICES = [
|
||||||
UserService,
|
UserService,
|
||||||
ElectricityService,
|
ElectricityService,
|
||||||
StateService,
|
|
||||||
SmartTableService,
|
SmartTableService,
|
||||||
PlayerService,
|
|
||||||
UserActivityService,
|
UserActivityService,
|
||||||
OrdersChartService,
|
OrdersChartService,
|
||||||
ProfitChartService,
|
ProfitChartService,
|
||||||
|
|
@ -32,7 +35,14 @@ const SERVICES = [
|
||||||
OrdersProfitChartService,
|
OrdersProfitChartService,
|
||||||
TrafficBarService,
|
TrafficBarService,
|
||||||
ProfitBarAnimationChartService,
|
ProfitBarAnimationChartService,
|
||||||
LayoutService,
|
TemperatureHumidityService,
|
||||||
|
SolarService,
|
||||||
|
TrafficChartService,
|
||||||
|
StatsBarService,
|
||||||
|
CountryOrderService,
|
||||||
|
StatsProgressBarService,
|
||||||
|
VisitorsAnalyticsService,
|
||||||
|
SecurityCamerasService,
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,29 @@
|
||||||
import { Injectable } from '@angular/core';
|
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()
|
@Injectable()
|
||||||
export class ElectricityService {
|
export class ElectricityService {
|
||||||
|
|
||||||
private data = [
|
private listData: Electricity[] = [
|
||||||
{
|
{
|
||||||
title: '2015',
|
title: '2015',
|
||||||
months: [
|
months: [
|
||||||
|
|
@ -58,11 +78,35 @@ export class ElectricityService {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
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() {
|
constructor() {
|
||||||
|
this.chartData = this.chartPoints.map((p, index) => ({
|
||||||
|
label: (index % 5 === 3) ? `${Math.round(index / 5)}` : '',
|
||||||
|
value: p,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: observables
|
getListData(): Observable<Electricity[]> {
|
||||||
getData() {
|
return observableOf(this.listData);
|
||||||
return this.data;
|
}
|
||||||
|
|
||||||
|
getChartData(): Observable<ElectricityChart[]> {
|
||||||
|
return observableOf(this.chartData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ export class ProfitBarAnimationChartService {
|
||||||
return Array.from(Array(nPoints));
|
return Array.from(Array(nPoints));
|
||||||
}
|
}
|
||||||
|
|
||||||
getChartData(): Observable<{ firstLine: number[]; secondLine: number[] }> {
|
getChartData(): Observable<{ firstLine: number[]; secondLine: number[]; }> {
|
||||||
return observableOf(this.data);
|
return observableOf(this.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
34
src/app/@core/data/security-cameras.service.ts
Normal file
34
src/app/@core/data/security-cameras.service.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/app/@core/data/solar.service.ts
Normal file
11
src/app/@core/data/solar.service.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/app/@core/data/stats-bar.service.ts
Normal file
15
src/app/@core/data/stats-bar.service.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/app/@core/data/stats-progress-bar.service.ts
Normal file
37
src/app/@core/data/stats-progress-bar.service.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/app/@core/data/temperature-humidity.service.ts
Normal file
32
src/app/@core/data/temperature-humidity.service.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/app/@core/data/traffic-chart.service.ts
Normal file
16
src/app/@core/data/traffic-chart.service.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,6 +13,14 @@ export class UserActive {
|
||||||
export class UserActivityService {
|
export class UserActivityService {
|
||||||
|
|
||||||
private getRandom = (roundTo: number) => Math.round(Math.random() * roundTo);
|
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 = {};
|
data = {};
|
||||||
|
|
||||||
|
|
@ -26,38 +34,25 @@ export class UserActivityService {
|
||||||
|
|
||||||
private getDataWeek(): UserActive[] {
|
private getDataWeek(): UserActive[] {
|
||||||
return this.periods.getWeeks().map((week) => {
|
return this.periods.getWeeks().map((week) => {
|
||||||
return {
|
return this.generateUserActivityRandomData(week);
|
||||||
date: week,
|
|
||||||
pagesVisitCount: this.getRandom(1000),
|
|
||||||
deltaUp: this.getRandom(1) % 2 === 0,
|
|
||||||
newVisits: this.getRandom(100),
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDataMonth(): UserActive[] {
|
private getDataMonth(): UserActive[] {
|
||||||
const date = new Date();
|
const currentDate = new Date();
|
||||||
const days = date.getDate();
|
const days = currentDate.getDate();
|
||||||
const month = this.periods.getMonths()[date.getMonth()];
|
const month = this.periods.getMonths()[currentDate.getMonth()];
|
||||||
|
|
||||||
return Array.from(Array(days)).map((_, index) => {
|
return Array.from(Array(days)).map((_, index) => {
|
||||||
return {
|
const date = `${index + 1} ${month}`;
|
||||||
date: `${index + 1} ${month}`,
|
|
||||||
pagesVisitCount: this.getRandom(1000),
|
return this.generateUserActivityRandomData(date);
|
||||||
deltaUp: this.getRandom(1) % 2 === 0,
|
|
||||||
newVisits: this.getRandom(100),
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDataYear(): UserActive[] {
|
private getDataYear(): UserActive[] {
|
||||||
return this.periods.getYears().map((year) => {
|
return this.periods.getYears().map((year) => {
|
||||||
return {
|
return this.generateUserActivityRandomData(year);
|
||||||
date: year,
|
|
||||||
pagesVisitCount: this.getRandom(1000),
|
|
||||||
deltaUp: this.getRandom(1) % 2 === 0,
|
|
||||||
newVisits: this.getRandom(100),
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,25 @@
|
||||||
import { of as observableOf, Observable } from 'rxjs';
|
import { of as observableOf, Observable } from 'rxjs';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
class User {
|
||||||
|
name: string;
|
||||||
|
picture: string;
|
||||||
|
}
|
||||||
|
|
||||||
let counter = 0;
|
export class Contacts {
|
||||||
|
user: User;
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RecentUsers extends Contacts {
|
||||||
|
time: number;
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserService {
|
export class UserService {
|
||||||
|
|
||||||
|
private time: Date = new Date;
|
||||||
|
|
||||||
private users = {
|
private users = {
|
||||||
nick: { name: 'Nick Jones', picture: 'assets/images/nick.png' },
|
nick: { name: 'Nick Jones', picture: 'assets/images/nick.png' },
|
||||||
eva: { name: 'Eva Moor', picture: 'assets/images/eva.png' },
|
eva: { name: 'Eva Moor', picture: 'assets/images/eva.png' },
|
||||||
|
|
@ -16,23 +29,39 @@ export class UserService {
|
||||||
alan: { name: 'Alan Thompson', picture: 'assets/images/alan.png' },
|
alan: { name: 'Alan Thompson', picture: 'assets/images/alan.png' },
|
||||||
kate: { name: 'Kate Martinez', picture: 'assets/images/kate.png' },
|
kate: { name: 'Kate Martinez', picture: 'assets/images/kate.png' },
|
||||||
};
|
};
|
||||||
|
private types = {
|
||||||
private userArray: any[];
|
mobile: 'mobile',
|
||||||
|
home: 'home',
|
||||||
constructor() {
|
work: 'work',
|
||||||
// this.userArray = Object.values(this.users);
|
};
|
||||||
}
|
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> {
|
getUsers(): Observable<any> {
|
||||||
return observableOf(this.users);
|
return observableOf(this.users);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserArray(): Observable<any[]> {
|
getContacts(): Observable<Contacts[]> {
|
||||||
return observableOf(this.userArray);
|
return observableOf(this.contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUser(): Observable<any> {
|
getRecentUsers(): Observable<RecentUsers[]> {
|
||||||
counter = (counter + 1) % this.userArray.length;
|
return observableOf(this.recentUsers);
|
||||||
return observableOf(this.userArray[counter]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
60
src/app/@core/data/visitors-analytics.service.ts
Normal file
60
src/app/@core/data/visitors-analytics.service.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/app/@core/utils/index.ts
Normal file
11
src/app/@core/utils/index.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { LayoutService } from './layout.service';
|
||||||
|
import { AnalyticsService } from './analytics.service';
|
||||||
|
import { PlayerService } from './player.service';
|
||||||
|
import { StateService } from './state.service';
|
||||||
|
|
||||||
|
export {
|
||||||
|
LayoutService,
|
||||||
|
AnalyticsService,
|
||||||
|
PlayerService,
|
||||||
|
StateService,
|
||||||
|
};
|
||||||
|
|
@ -2,8 +2,8 @@ import { Component, Input, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { NbMenuService, NbSidebarService } from '@nebular/theme';
|
import { NbMenuService, NbSidebarService } from '@nebular/theme';
|
||||||
import { UserService } from '../../../@core/data/users.service';
|
import { UserService } from '../../../@core/data/users.service';
|
||||||
import { AnalyticsService } from '../../../@core/utils/analytics.service';
|
import { AnalyticsService } from '../../../@core/utils';
|
||||||
import { LayoutService } from '../../../@core/data/layout.service';
|
import { LayoutService } from '../../../@core/utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-header',
|
selector: 'ngx-header',
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
import { StateService } from '../../../@core/data/state.service';
|
import { StateService } from '../../../@core/utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-theme-settings',
|
selector: 'ngx-theme-settings',
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
||||||
NbThemeService,
|
NbThemeService,
|
||||||
} from '@nebular/theme';
|
} from '@nebular/theme';
|
||||||
|
|
||||||
import { StateService } from '../../../@core/data/state.service';
|
import { StateService } from '../../../@core/utils/state.service';
|
||||||
|
|
||||||
// TODO: move layouts into the framework
|
// TODO: move layouts into the framework
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<nb-tab tabTitle="Recent">
|
<nb-tab tabTitle="Recent">
|
||||||
<div class="contact" *ngFor="let c of recent">
|
<div class="contact" *ngFor="let c of recent">
|
||||||
<nb-user [picture]="c.user.picture" [name]="c.user.name" [title]="c.type" size="large"></nb-user>
|
<nb-user [picture]="c.user.picture" [name]="c.user.name" [title]="c.type" size="large"></nb-user>
|
||||||
<span class="time">{{ c.time }}</span>
|
<span class="time">{{ c.time | date: 'shortTime' }}</span>
|
||||||
</div>
|
</div>
|
||||||
</nb-tab>
|
</nb-tab>
|
||||||
</nb-tabset>
|
</nb-tabset>
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,46 @@
|
||||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
import { Component, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService, NbMediaBreakpoint, NbMediaBreakpointsService } from '@nebular/theme';
|
import { NbThemeService, NbMediaBreakpoint, NbMediaBreakpointsService } from '@nebular/theme';
|
||||||
|
import { takeWhile } from 'rxjs/operators';
|
||||||
|
import { forkJoin } from 'rxjs';
|
||||||
|
|
||||||
import { UserService } from '../../../@core/data/users.service';
|
import { Contacts, RecentUsers, UserService } from '../../../@core/data/users.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-contacts',
|
selector: 'ngx-contacts',
|
||||||
styleUrls: ['./contacts.component.scss'],
|
styleUrls: ['./contacts.component.scss'],
|
||||||
templateUrl: './contacts.component.html',
|
templateUrl: './contacts.component.html',
|
||||||
})
|
})
|
||||||
export class ContactsComponent implements OnInit, OnDestroy {
|
export class ContactsComponent implements OnDestroy {
|
||||||
|
|
||||||
|
private alive = true;
|
||||||
|
|
||||||
contacts: any[];
|
contacts: any[];
|
||||||
recent: any[];
|
recent: any[];
|
||||||
breakpoint: NbMediaBreakpoint;
|
breakpoint: NbMediaBreakpoint;
|
||||||
breakpoints: any;
|
breakpoints: any;
|
||||||
themeSubscription: any;
|
|
||||||
|
|
||||||
constructor(private userService: UserService,
|
constructor(private userService: UserService,
|
||||||
private themeService: NbThemeService,
|
private themeService: NbThemeService,
|
||||||
private breakpointService: NbMediaBreakpointsService) {
|
private breakpointService: NbMediaBreakpointsService) {
|
||||||
|
|
||||||
this.breakpoints = this.breakpointService.getBreakpointsMap();
|
this.breakpoints = this.breakpointService.getBreakpointsMap();
|
||||||
this.themeSubscription = this.themeService.onMediaQueryChange()
|
this.themeService.onMediaQueryChange()
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
.subscribe(([oldValue, newValue]) => {
|
.subscribe(([oldValue, newValue]) => {
|
||||||
this.breakpoint = newValue;
|
this.breakpoint = newValue;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
forkJoin(
|
||||||
|
this.userService.getContacts(),
|
||||||
this.userService.getUsers()
|
this.userService.getRecentUsers(),
|
||||||
.subscribe((users: any) => {
|
)
|
||||||
this.contacts = [
|
.pipe(takeWhile(() => this.alive))
|
||||||
{user: users.nick, type: 'mobile'},
|
.subscribe(([contacts, recent]: [Contacts[], RecentUsers[]]) => {
|
||||||
{user: users.eva, type: 'home'},
|
this.contacts = contacts;
|
||||||
{user: users.jack, type: 'mobile'},
|
this.recent = recent;
|
||||||
{user: users.lee, type: 'mobile'},
|
|
||||||
{user: users.alan, type: 'home'},
|
|
||||||
{user: users.kate, type: 'work'},
|
|
||||||
];
|
|
||||||
|
|
||||||
this.recent = [
|
|
||||||
{user: users.alan, type: 'home', time: '9:12 pm'},
|
|
||||||
{user: users.eva, type: 'home', time: '7:45 pm'},
|
|
||||||
{user: users.nick, type: 'mobile', time: '5:29 pm'},
|
|
||||||
{user: users.lee, type: 'mobile', time: '11:24 am'},
|
|
||||||
{user: users.jack, type: 'mobile', time: '10:45 am'},
|
|
||||||
{user: users.kate, type: 'work', time: '9:42 am'},
|
|
||||||
{user: users.kate, type: 'work', time: '9:31 am'},
|
|
||||||
{user: users.jack, type: 'mobile', time: '8:01 am'},
|
|
||||||
];
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.themeSubscription.unsubscribe();
|
this.alive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-xxxl-3 col-xxl-4 col-lg-5 col-md-6">
|
<div class="col-xxxl-3 col-xxl-4 col-lg-5 col-md-6">
|
||||||
<ngx-solar [chartValue]="72"></ngx-solar>
|
<ngx-solar [chartValue]="solarValue"></ngx-solar>
|
||||||
|
|
||||||
<ngx-kitten></ngx-kitten>
|
<ngx-kitten></ngx-kitten>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import {Component, OnDestroy} from '@angular/core';
|
import {Component, OnDestroy} from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { takeWhile } from 'rxjs/operators' ;
|
import { takeWhile } from 'rxjs/operators' ;
|
||||||
|
import { SolarService } from '../../@core/data/solar.service';
|
||||||
|
|
||||||
interface CardSettings {
|
interface CardSettings {
|
||||||
title: string;
|
title: string;
|
||||||
|
|
@ -17,6 +18,7 @@ export class DashboardComponent implements OnDestroy {
|
||||||
|
|
||||||
private alive = true;
|
private alive = true;
|
||||||
|
|
||||||
|
solarValue: number;
|
||||||
lightCard: CardSettings = {
|
lightCard: CardSettings = {
|
||||||
title: 'Light',
|
title: 'Light',
|
||||||
iconClass: 'nb-lightbulb',
|
iconClass: 'nb-lightbulb',
|
||||||
|
|
@ -74,12 +76,19 @@ export class DashboardComponent implements OnDestroy {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(private themeService: NbThemeService) {
|
constructor(private themeService: NbThemeService,
|
||||||
|
private solarService: SolarService) {
|
||||||
this.themeService.getJsTheme()
|
this.themeService.getJsTheme()
|
||||||
.pipe(takeWhile(() => this.alive))
|
.pipe(takeWhile(() => this.alive))
|
||||||
.subscribe(theme => {
|
.subscribe(theme => {
|
||||||
this.statusCards = this.statusCardsByThemes[theme.name];
|
this.statusCards = this.statusCardsByThemes[theme.name];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.solarService.getSolarData()
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
|
.subscribe((data) => {
|
||||||
|
this.solarValue = data;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { delay, takeWhile } from 'rxjs/operators';
|
import { delay, takeWhile } from 'rxjs/operators';
|
||||||
import { AfterViewInit, Component, OnDestroy } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { LayoutService } from '../../../../@core/data/layout.service';
|
import { LayoutService } from '../../../../@core/utils';
|
||||||
|
import { ElectricityChart } from '../../../../@core/data/electricity.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-electricity-chart',
|
selector: 'ngx-electricity-chart',
|
||||||
|
|
@ -18,23 +19,13 @@ export class ElectricityChartComponent implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
private alive = true;
|
private alive = true;
|
||||||
|
|
||||||
|
@Input() data: ElectricityChart[];
|
||||||
|
|
||||||
option: any;
|
option: any;
|
||||||
data: Array<any>;
|
|
||||||
echartsIntance: any;
|
echartsIntance: any;
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
|
|
||||||
const points = [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];
|
|
||||||
|
|
||||||
this.data = points.map((p, index) => ({
|
|
||||||
label: (index % 5 === 3) ? `${Math.round(index / 5)}` : '',
|
|
||||||
value: p,
|
|
||||||
}));
|
|
||||||
|
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<nb-tabset fullWidth>
|
<nb-tabset fullWidth>
|
||||||
<nb-tab *ngFor="let year of data" [tabTitle]="year.title" [active]="year.active">
|
<nb-tab *ngFor="let year of listData" [tabTitle]="year.title" [active]="year.active">
|
||||||
<div class="stats-month" *ngFor="let month of year.months">
|
<div class="stats-month" *ngFor="let month of year.months">
|
||||||
<div>
|
<div>
|
||||||
<span class="month">{{ month.month }}</span>
|
<span class="month">{{ month.month }}</span>
|
||||||
|
|
@ -52,6 +52,6 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ngx-electricity-chart></ngx-electricity-chart>
|
<ngx-electricity-chart [data]="chartData"></ngx-electricity-chart>
|
||||||
</div>
|
</div>
|
||||||
</nb-card>
|
</nb-card>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import { Component, OnDestroy } from '@angular/core';
|
import { Component, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
|
|
||||||
import { ElectricityService } from '../../../@core/data/electricity.service';
|
import { Electricity, ElectricityChart, ElectricityService } from '../../../@core/data/electricity.service';
|
||||||
|
import { takeWhile } from 'rxjs/operators';
|
||||||
|
import { forkJoin } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-electricity',
|
selector: 'ngx-electricity',
|
||||||
|
|
@ -10,7 +12,10 @@ import { ElectricityService } from '../../../@core/data/electricity.service';
|
||||||
})
|
})
|
||||||
export class ElectricityComponent implements OnDestroy {
|
export class ElectricityComponent implements OnDestroy {
|
||||||
|
|
||||||
data: Array<any>;
|
private alive = true;
|
||||||
|
|
||||||
|
listData: Electricity[];
|
||||||
|
chartData: ElectricityChart[];
|
||||||
|
|
||||||
type = 'week';
|
type = 'week';
|
||||||
types = ['week', 'month', 'year'];
|
types = ['week', 'month', 'year'];
|
||||||
|
|
@ -18,15 +23,26 @@ export class ElectricityComponent implements OnDestroy {
|
||||||
currentTheme: string;
|
currentTheme: string;
|
||||||
themeSubscription: any;
|
themeSubscription: any;
|
||||||
|
|
||||||
constructor(private eService: ElectricityService, private themeService: NbThemeService) {
|
constructor(private electricityService: ElectricityService,
|
||||||
this.data = this.eService.getData();
|
private themeService: NbThemeService) {
|
||||||
|
this.themeService.getJsTheme()
|
||||||
this.themeSubscription = this.themeService.getJsTheme().subscribe(theme => {
|
.pipe(takeWhile(() => this.alive))
|
||||||
this.currentTheme = theme.name;
|
.subscribe(theme => {
|
||||||
|
this.currentTheme = theme.name;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
forkJoin(
|
||||||
|
this.electricityService.getListData(),
|
||||||
|
this.electricityService.getChartData(),
|
||||||
|
)
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
|
.subscribe(([listData, chartData]) => {
|
||||||
|
this.listData = listData;
|
||||||
|
this.chartData = chartData;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.themeSubscription.unsubscribe();
|
this.alive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Component, HostBinding, Input, OnDestroy } from '@angular/core';
|
import { Component, HostBinding, Input, OnDestroy } from '@angular/core';
|
||||||
import { PlayerService, Track } from '../../../../@core/data/player.service';
|
import { PlayerService, Track } from '../../../../@core/utils/player.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-player',
|
selector: 'ngx-player',
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,35 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component, OnDestroy } from '@angular/core';
|
||||||
|
import { Camera, SecurityCamerasService } from '../../../@core/data/security-cameras.service';
|
||||||
|
import { takeWhile } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-security-cameras',
|
selector: 'ngx-security-cameras',
|
||||||
styleUrls: ['./security-cameras.component.scss'],
|
styleUrls: ['./security-cameras.component.scss'],
|
||||||
templateUrl: './security-cameras.component.html',
|
templateUrl: './security-cameras.component.html',
|
||||||
})
|
})
|
||||||
export class SecurityCamerasComponent {
|
export class SecurityCamerasComponent implements OnDestroy {
|
||||||
|
|
||||||
cameras: any[] = [{
|
private alive = true;
|
||||||
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',
|
|
||||||
}];
|
|
||||||
|
|
||||||
selectedCamera: any = this.cameras[0];
|
|
||||||
|
|
||||||
userMenu = [{
|
|
||||||
title: 'Profile',
|
|
||||||
}, {
|
|
||||||
title: 'Log out',
|
|
||||||
}];
|
|
||||||
|
|
||||||
|
cameras: Camera[];
|
||||||
|
selectedCamera: Camera;
|
||||||
isSingleView = false;
|
isSingleView = false;
|
||||||
|
|
||||||
|
constructor(private securityCamerasService: SecurityCamerasService) {
|
||||||
|
this.securityCamerasService.getCamerasData()
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
|
.subscribe((cameras: Camera[]) => {
|
||||||
|
this.cameras = cameras;
|
||||||
|
this.selectedCamera = this.cameras[0];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
selectCamera(camera: any) {
|
selectCamera(camera: any) {
|
||||||
this.selectedCamera = camera;
|
this.selectedCamera = camera;
|
||||||
this.isSingleView = true;
|
this.isSingleView = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.alive = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ export class SolarComponent implements AfterViewInit, OnDestroy {
|
||||||
@Input('chartValue')
|
@Input('chartValue')
|
||||||
set chartValue(value: number) {
|
set chartValue(value: number) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|
||||||
if (this.option.series) {
|
if (this.option.series) {
|
||||||
this.option.series[0].data[0].value = value;
|
this.option.series[0].data[0].value = value;
|
||||||
this.option.series[0].data[1].value = 100 - value;
|
this.option.series[0].data[1].value = 100 - value;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<div class="slider-container">
|
<div class="slider-container">
|
||||||
<ngx-temperature-dragger [(value)]="temperature" (power)="temperatureOff = !$event"
|
<ngx-temperature-dragger [(value)]="temperature" (power)="temperatureOff = !$event"
|
||||||
[min]="12" [max]="30" [disableArcColor]="colors.layoutBg"
|
[min]="temperatureData.min" [max]="temperatureData.max" [disableArcColor]="colors.layoutBg"
|
||||||
[fillColors]="colors.temperature">
|
[fillColors]="colors.temperature">
|
||||||
|
|
||||||
<div class="slider-value-container" [ngClass]="{ 'off': temperatureOff }">
|
<div class="slider-value-container" [ngClass]="{ 'off': temperatureOff }">
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
<div class="slider-container">
|
<div class="slider-container">
|
||||||
<ngx-temperature-dragger [(value)]="humidity" (power)="humidityOff = !$event"
|
<ngx-temperature-dragger [(value)]="humidity" (power)="humidityOff = !$event"
|
||||||
[min]="0" [max]="100" [disableArcColor]="colors.layoutBg"
|
[min]="humidityData.min" [max]="humidityData.max" [disableArcColor]="colors.layoutBg"
|
||||||
[fillColors]="colors.temperature">
|
[fillColors]="colors.temperature">
|
||||||
|
|
||||||
<div class="slider-value-container" [ngClass]="{ 'off': humidityOff }">
|
<div class="slider-value-container" [ngClass]="{ 'off': humidityOff }">
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
import { Component, OnDestroy } from '@angular/core';
|
import { Component, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
|
import { Temperature, TemperatureHumidityService } from '../../../@core/data/temperature-humidity.service';
|
||||||
|
import { takeWhile } from 'rxjs/operators';
|
||||||
|
import { forkJoin } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-temperature',
|
selector: 'ngx-temperature',
|
||||||
|
|
@ -8,24 +11,43 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
})
|
})
|
||||||
export class TemperatureComponent implements OnDestroy {
|
export class TemperatureComponent implements OnDestroy {
|
||||||
|
|
||||||
temperature = 24;
|
private alive = true;
|
||||||
|
|
||||||
|
temperatureData: Temperature;
|
||||||
|
temperature: number;
|
||||||
temperatureOff = false;
|
temperatureOff = false;
|
||||||
temperatureMode = 'cool';
|
temperatureMode = 'cool';
|
||||||
|
|
||||||
humidity = 87;
|
humidityData: Temperature;
|
||||||
|
humidity: number;
|
||||||
humidityOff = false;
|
humidityOff = false;
|
||||||
humidityMode = 'heat';
|
humidityMode = 'heat';
|
||||||
|
|
||||||
colors: any;
|
colors: any;
|
||||||
themeSubscription: any;
|
themeSubscription: any;
|
||||||
|
|
||||||
constructor(private theme: NbThemeService) {
|
constructor(private theme: NbThemeService,
|
||||||
this.themeSubscription = this.theme.getJsTheme().subscribe(config => {
|
private temperatureHumidityService: TemperatureHumidityService) {
|
||||||
|
this.theme.getJsTheme()
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
|
.subscribe(config => {
|
||||||
this.colors = config.variables;
|
this.colors = config.variables;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
forkJoin(
|
||||||
|
this.temperatureHumidityService.getTemperatureData(),
|
||||||
|
this.temperatureHumidityService.getHumidityData(),
|
||||||
|
)
|
||||||
|
.subscribe(([temperatureData, humidityData]: [Temperature, Temperature]) => {
|
||||||
|
this.temperatureData = temperatureData;
|
||||||
|
this.temperature = this.temperatureData.value;
|
||||||
|
|
||||||
|
this.humidityData = humidityData;
|
||||||
|
this.humidity = this.humidityData.value;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.themeSubscription.unsubscribe();
|
this.alive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
import { delay, takeWhile } from 'rxjs/operators';
|
import { delay, takeWhile } from 'rxjs/operators';
|
||||||
import { AfterViewInit, Component, OnDestroy } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { LayoutService } from '../../../@core/data/layout.service';
|
import { LayoutService } from '../../../@core/utils';
|
||||||
|
|
||||||
const points = [300, 520, 435, 530, 730, 620, 660, 860];
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-traffic-chart',
|
selector: 'ngx-traffic-chart',
|
||||||
|
|
@ -20,6 +18,8 @@ export class TrafficChartComponent implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
private alive = true;
|
private alive = true;
|
||||||
|
|
||||||
|
@Input() points: number[];
|
||||||
|
|
||||||
type = 'month';
|
type = 'month';
|
||||||
types = ['week', 'month', 'year'];
|
types = ['week', 'month', 'year'];
|
||||||
option: any = {};
|
option: any = {};
|
||||||
|
|
@ -53,7 +53,7 @@ export class TrafficChartComponent implements AfterViewInit, OnDestroy {
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
boundaryGap: false,
|
boundaryGap: false,
|
||||||
data: points,
|
data: this.points,
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
boundaryGap: [0, '5%'],
|
boundaryGap: [0, '5%'],
|
||||||
|
|
@ -114,7 +114,7 @@ export class TrafficChartComponent implements AfterViewInit, OnDestroy {
|
||||||
color: trafficTheme.shadowLineDarkBg,
|
color: trafficTheme.shadowLineDarkBg,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: points.map(p => p - 15),
|
data: this.points.map(p => p - 15),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'line',
|
type: 'line',
|
||||||
|
|
@ -153,7 +153,7 @@ export class TrafficChartComponent implements AfterViewInit, OnDestroy {
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: points,
|
data: this.points,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { Component, OnDestroy } from '@angular/core';
|
import { Component, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
|
import { takeWhile } from 'rxjs/operators';
|
||||||
|
import { TrafficChartService } from '../../../@core/data/traffic-chart.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-traffic',
|
selector: 'ngx-traffic',
|
||||||
|
|
@ -19,24 +21,36 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
</div>
|
</div>
|
||||||
</nb-card-header>
|
</nb-card-header>
|
||||||
<nb-card-body class="p-0">
|
<nb-card-body class="p-0">
|
||||||
<ngx-traffic-chart></ngx-traffic-chart>
|
<ngx-traffic-chart [points]="trafficChartPoints"></ngx-traffic-chart>
|
||||||
</nb-card-body>
|
</nb-card-body>
|
||||||
</nb-card>
|
</nb-card>
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class TrafficComponent implements OnDestroy {
|
export class TrafficComponent implements OnDestroy {
|
||||||
|
|
||||||
|
private alive = true;
|
||||||
|
|
||||||
|
trafficChartPoints: number[];
|
||||||
type = 'month';
|
type = 'month';
|
||||||
types = ['week', 'month', 'year'];
|
types = ['week', 'month', 'year'];
|
||||||
currentTheme: string;
|
currentTheme: string;
|
||||||
themeSubscription: any;
|
|
||||||
|
|
||||||
constructor(private themeService: NbThemeService) {
|
constructor(private themeService: NbThemeService,
|
||||||
this.themeSubscription = this.themeService.getJsTheme().subscribe(theme => {
|
private trafficChartService: TrafficChartService) {
|
||||||
|
this.themeService.getJsTheme()
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
|
.subscribe(theme => {
|
||||||
this.currentTheme = theme.name;
|
this.currentTheme = theme.name;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.trafficChartService.getTrafficChartData()
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
|
.subscribe((data) => {
|
||||||
|
this.trafficChartPoints = data;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.themeSubscription.unsubscribe();
|
this.alive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
import { delay, takeWhile } from 'rxjs/operators';
|
import { delay, takeWhile } from 'rxjs/operators';
|
||||||
|
|
||||||
import { OrdersChart } from '../../../../@core/data/orders-chart.service';
|
import { OrdersChart } from '../../../../@core/data/orders-chart.service';
|
||||||
import { LayoutService } from '../../../../@core/data/layout.service';
|
import { LayoutService } from '../../../../@core/utils/layout.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-orders-chart',
|
selector: 'ngx-orders-chart',
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
import { takeWhile } from 'rxjs/operators';
|
import { takeWhile } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ProfitChart } from '../../../../@core/data/profit-chart.service';
|
import { ProfitChart } from '../../../../@core/data/profit-chart.service';
|
||||||
import { LayoutService } from '../../../../@core/data/layout.service';
|
import { LayoutService } from '../../../../@core/utils/layout.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-profit-chart',
|
selector: 'ngx-profit-chart',
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { AfterViewInit, Component, Input, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { takeWhile } from 'rxjs/operators';
|
import { takeWhile } from 'rxjs/operators';
|
||||||
import { LayoutService } from '../../../../@core/data/layout.service';
|
import { LayoutService } from '../../../../@core/utils/layout.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { Component, OnDestroy } from '@angular/core';
|
import { Component, OnDestroy } from '@angular/core';
|
||||||
import { NbMediaBreakpoint, NbMediaBreakpointsService, NbThemeService } from '@nebular/theme';
|
import { NbMediaBreakpoint, NbMediaBreakpointsService, NbThemeService } from '@nebular/theme';
|
||||||
import { takeWhile } from 'rxjs/operators';
|
import { takeWhile } from 'rxjs/operators';
|
||||||
|
import { CountryOrderService } from '../../../@core/data/country-order.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-country-orders',
|
selector: 'ngx-country-orders',
|
||||||
|
|
@ -25,33 +26,36 @@ export class CountryOrdersComponent implements OnDestroy {
|
||||||
|
|
||||||
private alive = true;
|
private alive = true;
|
||||||
|
|
||||||
private getRandomData(nPoints: number): number[] {
|
|
||||||
return Array.from(Array(nPoints)).map(() => {
|
|
||||||
return Math.round(Math.random() * 20);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
countryName = '';
|
countryName = '';
|
||||||
countryData = [];
|
countryData: number[] = [];
|
||||||
countriesCategories = ['Sofas', 'Furniture', 'Lighting', 'Tables', 'Textiles'];
|
countriesCategories: string[];
|
||||||
breakpoint: NbMediaBreakpoint = { name: '', width: 0 };
|
breakpoint: NbMediaBreakpoint = { name: '', width: 0 };
|
||||||
breakpoints: any;
|
breakpoints: any;
|
||||||
|
|
||||||
constructor(private themeService: NbThemeService,
|
constructor(private themeService: NbThemeService,
|
||||||
private breakpointService: NbMediaBreakpointsService) {
|
private breakpointService: NbMediaBreakpointsService,
|
||||||
|
private countryOrderService: CountryOrderService) {
|
||||||
this.breakpoints = this.breakpointService.getBreakpointsMap();
|
this.breakpoints = this.breakpointService.getBreakpointsMap();
|
||||||
this.themeService.onMediaQueryChange()
|
this.themeService.onMediaQueryChange()
|
||||||
.pipe(takeWhile(() => this.alive))
|
.pipe(takeWhile(() => this.alive))
|
||||||
.subscribe(([oldValue, newValue]) => {
|
.subscribe(([oldValue, newValue]) => {
|
||||||
this.breakpoint = newValue;
|
this.breakpoint = newValue;
|
||||||
});
|
});
|
||||||
|
this.countryOrderService.getCountriesCategories()
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
|
.subscribe((countriesCategories) => {
|
||||||
|
this.countriesCategories = countriesCategories;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
selectCountryById(countryName: string) {
|
selectCountryById(countryName: string) {
|
||||||
const nPoint = this.countriesCategories.length;
|
|
||||||
|
|
||||||
this.countryName = countryName;
|
this.countryName = countryName;
|
||||||
this.countryData = this.getRandomData(nPoint);
|
|
||||||
|
this.countryOrderService.getCountriesCategoriesData()
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
|
.subscribe((countryData) => {
|
||||||
|
this.countryData = countryData;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { delay, takeWhile } from 'rxjs/operators';
|
import { delay, takeWhile } from 'rxjs/operators';
|
||||||
import { AfterViewInit, Component, Input, OnChanges, OnDestroy } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnChanges, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { LayoutService } from '../../../../@core/data/layout.service';
|
import { LayoutService } from '../../../../@core/utils/layout.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-earning-live-update-chart',
|
selector: 'ngx-earning-live-update-chart',
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
import { delay, takeWhile } from 'rxjs/operators';
|
import { delay, takeWhile } from 'rxjs/operators';
|
||||||
import { AfterViewInit, Component, OnDestroy } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { LayoutService } from '../../../../@core/data/layout.service';
|
import { LayoutService } from '../../../../@core/utils';
|
||||||
|
|
||||||
const points = [300, 520, 435, 530, 730, 620, 660, 860];
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-stats-ares-chart',
|
selector: 'ngx-stats-ares-chart',
|
||||||
|
|
@ -19,6 +17,8 @@ export class StatsAreaChartComponent implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
private alive = true;
|
private alive = true;
|
||||||
|
|
||||||
|
@Input() points: number[];
|
||||||
|
|
||||||
echartsIntance: any;
|
echartsIntance: any;
|
||||||
option: any = {};
|
option: any = {};
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ export class StatsAreaChartComponent implements AfterViewInit, OnDestroy {
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
boundaryGap: false,
|
boundaryGap: false,
|
||||||
data: points,
|
data: this.points,
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
boundaryGap: [0, '5%'],
|
boundaryGap: [0, '5%'],
|
||||||
|
|
@ -111,7 +111,7 @@ export class StatsAreaChartComponent implements AfterViewInit, OnDestroy {
|
||||||
color: trafficTheme.shadowLineDarkBg,
|
color: trafficTheme.shadowLineDarkBg,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: points.map(p => p - 15),
|
data: this.points.map(p => p - 15),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'line',
|
type: 'line',
|
||||||
|
|
@ -150,7 +150,7 @@ export class StatsAreaChartComponent implements AfterViewInit, OnDestroy {
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: points,
|
data: this.points,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -23,5 +23,5 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ngx-stats-ares-chart></ngx-stats-ares-chart>
|
<ngx-stats-ares-chart [points]="chartData"></ngx-stats-ares-chart>
|
||||||
</nb-card-body>
|
</nb-card-body>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,27 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component, OnDestroy } from '@angular/core';
|
||||||
|
import { StatsBarService } from '../../../../@core/data/stats-bar.service';
|
||||||
|
import { takeWhile } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-stats-card-back',
|
selector: 'ngx-stats-card-back',
|
||||||
styleUrls: ['./stats-card-back.component.scss'],
|
styleUrls: ['./stats-card-back.component.scss'],
|
||||||
templateUrl: './stats-card-back.component.html',
|
templateUrl: './stats-card-back.component.html',
|
||||||
})
|
})
|
||||||
export class StatsCardBackComponent {
|
export class StatsCardBackComponent implements OnDestroy {
|
||||||
|
|
||||||
|
private alive = true;
|
||||||
|
|
||||||
|
chartData: number[];
|
||||||
|
|
||||||
|
constructor(private statsBarData: StatsBarService) {
|
||||||
|
this.statsBarData.getStatsBarData()
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
|
.subscribe((data) => {
|
||||||
|
this.chartData = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.alive = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { AfterViewInit, Component, Input, OnDestroy } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { takeWhile } from 'rxjs/operators';
|
import { takeWhile } from 'rxjs/operators';
|
||||||
import { LayoutService } from '../../../../@core/data/layout.service';
|
import { LayoutService } from '../../../../@core/utils/layout.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-stats-bar-animation-chart',
|
selector: 'ngx-stats-bar-animation-chart',
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,27 @@
|
||||||
import {Component} from '@angular/core';
|
import { Component, OnDestroy } from '@angular/core';
|
||||||
|
import { ProgressInfo, StatsProgressBarService } from '../../../@core/data/stats-progress-bar.service';
|
||||||
|
import { takeWhile } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-progress-section',
|
selector: 'ngx-progress-section',
|
||||||
styleUrls: ['./progress-section.component.scss'],
|
styleUrls: ['./progress-section.component.scss'],
|
||||||
templateUrl: './progress-section.component.html',
|
templateUrl: './progress-section.component.html',
|
||||||
})
|
})
|
||||||
export class ECommerceProgressSectionComponent {
|
export class ECommerceProgressSectionComponent implements OnDestroy {
|
||||||
progressInfoData = [
|
|
||||||
{
|
private alive = true;
|
||||||
title: 'Today’s Profit',
|
|
||||||
value: 572900,
|
progressInfoData: ProgressInfo[];
|
||||||
activeProgress: 70,
|
|
||||||
description: 'Better than last week (70%)',
|
constructor(private statsProgressBarService: StatsProgressBarService) {
|
||||||
},
|
this.statsProgressBarService.getProgressInfoData()
|
||||||
{
|
.pipe(takeWhile(() => this.alive))
|
||||||
title: 'New Orders',
|
.subscribe((data) => {
|
||||||
value: 6378,
|
this.progressInfoData = data;
|
||||||
activeProgress: 30,
|
});
|
||||||
description: 'Better than last week (30%)',
|
}
|
||||||
},
|
|
||||||
{
|
ngOnDestroy() {
|
||||||
title: 'New Comments',
|
this.alive = true;
|
||||||
value: 200,
|
}
|
||||||
activeProgress: 55,
|
|
||||||
description: 'Better than last week (55%)',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { AfterViewInit, Component, Input, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { takeWhile } from 'rxjs/operators';
|
import { takeWhile } from 'rxjs/operators';
|
||||||
import { LayoutService } from '../../../../@core/data/layout.service';
|
import { LayoutService } from '../../../../@core/utils/layout.service';
|
||||||
|
|
||||||
declare const echarts: any;
|
declare const echarts: any;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
<nb-reveal-card [showToggleButton]="false" [revealed]="revealed">
|
<nb-reveal-card [showToggleButton]="false" [revealed]="revealed">
|
||||||
<nb-card-front>
|
<nb-card-front>
|
||||||
<nb-card size="small">
|
<nb-card size="small">
|
||||||
<ngx-traffic-cards-header (periodChange)="setPeriod($event)"></ngx-traffic-cards-header>
|
<ngx-traffic-cards-header [type]="period" (periodChange)="setPeriodAngGetData($event)"></ngx-traffic-cards-header>
|
||||||
<ngx-traffic-front-card [frontCardData]="trafficListData"></ngx-traffic-front-card>
|
<ngx-traffic-front-card [frontCardData]="trafficListData"></ngx-traffic-front-card>
|
||||||
<i class="nb-arrow-up" (click)="toggleView()"></i>
|
<i class="nb-arrow-up" (click)="toggleView()"></i>
|
||||||
</nb-card>
|
</nb-card>
|
||||||
</nb-card-front>
|
</nb-card-front>
|
||||||
<nb-card-back>
|
<nb-card-back>
|
||||||
<nb-card size="small">
|
<nb-card size="small">
|
||||||
<ngx-traffic-cards-header (periodChange)="setPeriod($event)"></ngx-traffic-cards-header>
|
<ngx-traffic-cards-header [type]="period" (periodChange)="setPeriodAngGetData($event)"></ngx-traffic-cards-header>
|
||||||
<ngx-traffic-back-card [trafficBarData]="trafficBarData"></ngx-traffic-back-card>
|
<ngx-traffic-back-card [trafficBarData]="trafficBarData"></ngx-traffic-back-card>
|
||||||
<i class="nb-arrow-down" (click)="toggleView()"></i>
|
<i class="nb-arrow-down" (click)="toggleView()"></i>
|
||||||
</nb-card>>
|
</nb-card>
|
||||||
</nb-card-back>
|
</nb-card-back>
|
||||||
</nb-reveal-card>
|
</nb-reveal-card>
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@ export class TrafficRevealCardComponent implements OnDestroy {
|
||||||
this.revealed = !this.revealed;
|
this.revealed = !this.revealed;
|
||||||
}
|
}
|
||||||
|
|
||||||
setPeriod(value: string): void {
|
setPeriodAngGetData(value: string): void {
|
||||||
|
this.period = value;
|
||||||
|
|
||||||
this.getTrafficFrontCardData(value);
|
this.getTrafficFrontCardData(value);
|
||||||
this.getTrafficBackCardData(value);
|
this.getTrafficBackCardData(value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
import { Component, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { takeWhile } from 'rxjs/operators';
|
import { takeWhile } from 'rxjs/operators';
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ import { UserActivityService, UserActive } from '../../../@core/data/user-activi
|
||||||
</nb-card>
|
</nb-card>
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class ECommerceUserActivityComponent implements OnDestroy, OnInit {
|
export class ECommerceUserActivityComponent implements OnDestroy {
|
||||||
|
|
||||||
private alive = true;
|
private alive = true;
|
||||||
|
|
||||||
|
|
@ -65,14 +65,13 @@ export class ECommerceUserActivityComponent implements OnDestroy, OnInit {
|
||||||
.subscribe(theme => {
|
.subscribe(theme => {
|
||||||
this.currentTheme = theme.name;
|
this.currentTheme = theme.name;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.getUserActivity(this.type);
|
this.getUserActivity(this.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserActivity(period: string) {
|
getUserActivity(period: string) {
|
||||||
this.userActivityService.getUserActivityData(period)
|
this.userActivityService.getUserActivityData(period)
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
.subscribe(userActivityData => {
|
.subscribe(userActivityData => {
|
||||||
this.userActivity = userActivityData;
|
this.userActivity = userActivityData;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { delay, takeWhile } from 'rxjs/operators';
|
import { delay, takeWhile } from 'rxjs/operators';
|
||||||
import { AfterViewInit, Component, OnDestroy } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { LayoutService } from '../../../../@core/data/layout.service';
|
import { LayoutService } from '../../../../@core/utils';
|
||||||
|
import { OutlineData } from '../../../../@core/data/visitors-analytics.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-visitors-analytics-chart',
|
selector: 'ngx-visitors-analytics-chart',
|
||||||
|
|
@ -17,49 +18,18 @@ import { LayoutService } from '../../../../@core/data/layout.service';
|
||||||
export class ECommerceVisitorsAnalyticsChartComponent implements AfterViewInit, OnDestroy {
|
export class ECommerceVisitorsAnalyticsChartComponent implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
private alive = true;
|
private alive = true;
|
||||||
private innerLinePoints: number[] = [
|
|
||||||
94, 188, 225, 244, 253, 254, 249, 235, 208,
|
@Input() chartData: {
|
||||||
173, 141, 118, 105, 97, 94, 96, 104, 121, 147,
|
innerLine: number[];
|
||||||
183, 224, 265, 302, 333, 358, 375, 388, 395,
|
outerLine: OutlineData[];
|
||||||
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 months: string[] = [
|
|
||||||
'Jan', 'Feb', 'Mar',
|
|
||||||
'Apr', 'May', 'Jun',
|
|
||||||
'Jul', 'Aug', 'Sep',
|
|
||||||
'Oct', 'Nov', 'Dec',
|
|
||||||
];
|
|
||||||
|
|
||||||
option: any;
|
option: any;
|
||||||
data: Array<any>;
|
|
||||||
themeSubscription: any;
|
themeSubscription: any;
|
||||||
echartsIntance: any;
|
echartsIntance: any;
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService) {
|
||||||
const outerLinePointsLength = this.outerLinePoints.length;
|
|
||||||
const monthsLength = this.months.length;
|
|
||||||
|
|
||||||
this.data = this.outerLinePoints.map((p, index) => {
|
|
||||||
const monthIndex = Math.round(index / 4);
|
|
||||||
const label = (index % Math.round(outerLinePointsLength / monthsLength) === 0)
|
|
||||||
? this.months[monthIndex]
|
|
||||||
: '';
|
|
||||||
|
|
||||||
return {
|
|
||||||
label,
|
|
||||||
value: p,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
this.layoutService.onChangeLayoutSize()
|
this.layoutService.onChangeLayoutSize()
|
||||||
.pipe(
|
.pipe(
|
||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
|
|
@ -115,7 +85,7 @@ export class ECommerceVisitorsAnalyticsChartComponent implements AfterViewInit,
|
||||||
type: 'category',
|
type: 'category',
|
||||||
boundaryGap: false,
|
boundaryGap: false,
|
||||||
offset: 25,
|
offset: 25,
|
||||||
data: this.data.map(i => i.label),
|
data: this.chartData.outerLine.map(i => i.label),
|
||||||
axisTick: {
|
axisTick: {
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
|
|
@ -204,7 +174,7 @@ export class ECommerceVisitorsAnalyticsChartComponent implements AfterViewInit,
|
||||||
}]),
|
}]),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: this.data.map(i => i.value),
|
data: this.chartData.outerLine.map(i => i.value),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -244,7 +214,7 @@ export class ECommerceVisitorsAnalyticsChartComponent implements AfterViewInit,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: this.innerLinePoints,
|
data: this.chartData.innerLine,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@
|
||||||
<div class="chart-header">
|
<div class="chart-header">
|
||||||
<ngx-legend-chart [legendItems]="chartLegend"></ngx-legend-chart>
|
<ngx-legend-chart [legendItems]="chartLegend"></ngx-legend-chart>
|
||||||
</div>
|
</div>
|
||||||
<ngx-visitors-analytics-chart></ngx-visitors-analytics-chart>
|
<ngx-visitors-analytics-chart [chartData]="visitorsAnalyticsData"></ngx-visitors-analytics-chart>
|
||||||
</div>
|
</div>
|
||||||
</nb-card-body>
|
</nb-card-body>
|
||||||
|
|
||||||
<ngx-slide-out [showVisitorsStatistics]="true">
|
<ngx-slide-out [showVisitorsStatistics]="true">
|
||||||
<ngx-visitors-statistics></ngx-visitors-statistics>
|
<ngx-visitors-statistics [value]="pieChartValue"></ngx-visitors-statistics>
|
||||||
</ngx-slide-out>
|
</ngx-slide-out>
|
||||||
</nb-card>
|
</nb-card>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import { Component, OnDestroy } from '@angular/core';
|
import { Component, OnDestroy } from '@angular/core';
|
||||||
import { takeWhile } from 'rxjs/operators';
|
import { takeWhile } from 'rxjs/operators';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
|
import { OutlineData, VisitorsAnalyticsService } from '../../../@core/data/visitors-analytics.service';
|
||||||
|
import { forkJoin } from 'rxjs';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
@ -11,14 +13,32 @@ import { NbThemeService } from '@nebular/theme';
|
||||||
export class ECommerceVisitorsAnalyticsComponent implements OnDestroy {
|
export class ECommerceVisitorsAnalyticsComponent implements OnDestroy {
|
||||||
private alive = true;
|
private alive = true;
|
||||||
|
|
||||||
|
pieChartValue: number;
|
||||||
chartLegend: {iconColor: string; title: string}[];
|
chartLegend: {iconColor: string; title: string}[];
|
||||||
|
visitorsAnalyticsData: { innerLine: number[]; outerLine: OutlineData[]; };
|
||||||
|
|
||||||
constructor(private themeService: NbThemeService) {
|
constructor(private themeService: NbThemeService,
|
||||||
|
private visitorsAnalyticsChartService: VisitorsAnalyticsService) {
|
||||||
this.themeService.getJsTheme()
|
this.themeService.getJsTheme()
|
||||||
.pipe(takeWhile(() => this.alive))
|
.pipe(takeWhile(() => this.alive))
|
||||||
.subscribe(theme => {
|
.subscribe(theme => {
|
||||||
this.setLegendItems(theme.variables.visitorsLegend);
|
this.setLegendItems(theme.variables.visitorsLegend);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
forkJoin(
|
||||||
|
this.visitorsAnalyticsChartService.getInnerLineChartData(),
|
||||||
|
this.visitorsAnalyticsChartService.getOutlineLineChartData(),
|
||||||
|
this.visitorsAnalyticsChartService.getPieChartData(),
|
||||||
|
)
|
||||||
|
.pipe(takeWhile(() => this.alive))
|
||||||
|
.subscribe(([innerLine, outerLine, pieChartValue]: [number[], OutlineData[], number]) => {
|
||||||
|
this.visitorsAnalyticsData = {
|
||||||
|
innerLine: innerLine,
|
||||||
|
outerLine: outerLine,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.pieChartValue = pieChartValue;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setLegendItems(visitorsLegend): void {
|
setLegendItems(visitorsLegend): void {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { AfterViewInit, Component, OnDestroy } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnDestroy } from '@angular/core';
|
||||||
import { NbThemeService } from '@nebular/theme';
|
import { NbThemeService } from '@nebular/theme';
|
||||||
import { delay, takeWhile } from 'rxjs/operators';
|
import { delay, takeWhile } from 'rxjs/operators';
|
||||||
import { LayoutService } from '../../../../@core/data/layout.service';
|
import { LayoutService } from '../../../../@core/utils/layout.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
@ -12,10 +12,11 @@ import { LayoutService } from '../../../../@core/data/layout.service';
|
||||||
export class ECommerceVisitorsStatisticsComponent implements AfterViewInit, OnDestroy {
|
export class ECommerceVisitorsStatisticsComponent implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
private alive = true;
|
private alive = true;
|
||||||
private value = 75;
|
|
||||||
|
@Input() value: number;
|
||||||
|
|
||||||
option: any = {};
|
option: any = {};
|
||||||
chartLegend: {iconColor: string; title: string}[];
|
chartLegend: { iconColor: string; title: string }[];
|
||||||
echartsIntance: any;
|
echartsIntance: any;
|
||||||
|
|
||||||
constructor(private theme: NbThemeService,
|
constructor(private theme: NbThemeService,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue