Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atualizando branch main com Iteration 2 finalizada #25

Merged
merged 19 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
31b5ef9
Atualização das Versões do Node e Angular utilizadas para compilação
alexfariakof Feb 1, 2024
91b3ac7
Removendo arquivos do tipo mock da compilação do projeto angular
alexfariakof Feb 1, 2024
c067da9
Reestruturação de arquivos e pastas
alexfariakof Feb 1, 2024
10d515f
Tratamento de erro quando gráficos são inicializados sem dados
alexfariakof Feb 1, 2024
a9cdb04
Manutenção na descontinuação do uso de toPromise() pelo RxJS
alexfariakof Feb 1, 2024
0c8b1d7
Versão finalizada da Iteração 2
alexfariakof Feb 1, 2024
864b526
Configurações com nova versão do Node, npm e Angular CLI
alexfariakof Feb 1, 2024
b46746a
Nova Versão
alexfariakof Feb 1, 2024
48b3372
Configuração de compilação do projeto SPA antes de subir o container
alexfariakof Feb 1, 2024
00b4e50
Remoção de duplicação de Código
alexfariakof Feb 1, 2024
1f94f23
Remoção de configuração CORS desnecessárias na aplicação SPA
alexfariakof Feb 1, 2024
4dafe51
Configurações para Assegurar correto funcionamento debug com Docker
alexfariakof Feb 1, 2024
03e726e
Update chart.common.options.ts
alexfariakof Feb 1, 2024
31d6f90
Merge branch 'staging' into develop
alexfariakof Feb 1, 2024
bb0e010
Correção bugs DEFAULT_CHART_OPTIONS
alexfariakof Feb 1, 2024
2d65052
Merge branch 'staging' into develop
alexfariakof Feb 1, 2024
ecd82b5
Merge branch 'staging' into develop
alexfariakof Feb 1, 2024
b9cfb4d
Merge branch 'staging' into develop
alexfariakof Feb 1, 2024
3e70c28
Merge pull request #24 from alexfariakof/develop
alexfariakof Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions HomeBrokerSPA/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ COPY . .
WORKDIR /src/HomeBrokerSPA
RUN apt-get update && \
apt-get install -y curl && \
curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
apt-get install -y nodejs
RUN npm install -g [email protected] && \
npm install -g @angular/core@15 @angular/cli@15
npm install -g @angular/core@17 @angular/cli@17

RUN dotnet build --restore -c Release -o /app/build
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false
Expand Down
4 changes: 2 additions & 2 deletions HomeBrokerSPA/Dockerfile-Development
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ COPY . .
WORKDIR /src/HomeBrokerSPA
RUN apt-get update && \
apt-get install -y curl && \
curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
apt-get install -y nodejs
RUN npm install -g [email protected] && \
npm install -g @angular/core@15 @angular/cli@15
npm install -g @angular/core@17 @angular/cli@17
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/aspnet:8.0 as final
Expand Down
4 changes: 2 additions & 2 deletions HomeBrokerSPA/Dockerfile-Production
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ COPY . .
WORKDIR /src/HomeBrokerSPA
RUN apt-get update && \
apt-get install -y curl && \
curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
apt-get install -y nodejs
RUN npm install -g [email protected] && \
npm install -g @angular/core@15 @angular/cli@15
npm install -g @angular/core@17 @angular/cli@17
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/aspnet:8.0 as final
Expand Down
2 changes: 1 addition & 1 deletion HomeBrokerSPA/HomeBrokerChart/HomeBrokerChart.esproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<JavaScriptTestFramework>Jasmine</JavaScriptTestFramework>
<!-- Command to run on project build -->
<BuildCommand Condition=" '$(Configuration)' == 'Debug'" >npm run build"</BuildCommand>
<BuildCommand> npm run build"</BuildCommand>
<!-- Command to create an optimized build of the project that's ready for publishing -->
<ProductionBuildCommand>npm run build</ProductionBuildCommand>
<!-- Folder where production build objects will be placed -->
Expand Down
4 changes: 2 additions & 2 deletions HomeBrokerSPA/HomeBrokerChart/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion HomeBrokerSPA/HomeBrokerChart/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "home_broker_chart",
"version": "1.0.0",
"version": "1.0.1",
"scripts": {
"ng": "ng",
"prestart": "node aspnetcore-https",
Expand Down
2 changes: 1 addition & 1 deletion HomeBrokerSPA/HomeBrokerChart/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { HomeModule } from './pages/home/home.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { Acoesodule } from './pages/acoes/acoes.module';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { CustomInterceptor } from './shared/interceptors/http.interceptor.service';
import { PeriodFilterComponent } from './shared/components';
import { CustomInterceptor } from './interceptors/http.interceptor.service';

@NgModule({
declarations: [AppComponent, NavMenuComponent ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpErrorResponse
import { Observable, throwError, BehaviorSubject } from 'rxjs';
import { catchError, finalize } from 'rxjs/operators';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { LoadingComponent } from '../components';
import { LoadingComponent } from '../shared/components';

@Injectable()
export class CustomInterceptor implements HttpInterceptor {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChartCommonOptions, ChartOptions } from "./chart.common.options";
import { seriesData } from "./mock.chart.data";

describe('ChartCommonOptions', () => {
let chartOptions: ChartOptions | any;
Expand Down Expand Up @@ -37,28 +36,37 @@ describe('ChartCommonOptions', () => {
};
});

it('should initialize chart options with the provided height', () => {
ChartCommonOptions.initializeChartOptions(chartOptions, 500);
it('should initialize chart options with Default Options', () => {
// Arrange & Act
const chartOptions = ChartCommonOptions.DEFAULT_CHART_OPTIONS;
ChartCommonOptions.initializeChartData(chartOptions, [], []);

expect(chartOptions.chart.height).toEqual(500);
// Assert
expect(chartOptions).not.toBeNull();
});

it('should initialize chart data with given data and labelXAxis', () => {
// Arrange
const data = [10, 20, 30];
const labelXAxis = ['Jan', 'Feb', 'Mar'];

// Act
ChartCommonOptions.initializeChartData(chartOptions, data, labelXAxis);

// Assert
expect(chartOptions.series).toEqual(data);
expect(chartOptions.xaxis.categories).toEqual(labelXAxis);
});

it('should format data by rounding to two decimal places', () => {
// Arrange
const input = [10.123, 20.456, 30.789];
const expectedOutput = [10.12, 20.46, 30.79];

// Act
const result = ChartCommonOptions.formatData(input);

// Assert
expect(result).toEqual(expectedOutput);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import { ApexAxisChartSeries, ApexChart, ApexXAxis, ApexDataLabels, ApexYAxis, ApexFill, ApexStroke, ApexMarkers, ApexGrid, ApexTitleSubtitle, ApexPlotOptions } from "ng-apexcharts";
import {
ApexAxisChartSeries,
ApexChart,
ApexXAxis,
ApexDataLabels,
ApexYAxis,
ApexFill,
ApexStroke,
ApexMarkers,
ApexGrid,
ApexTitleSubtitle,
ApexPlotOptions,
} from "ng-apexcharts";

export type ChartOptions = {
series: ApexAxisChartSeries;
Expand All @@ -16,11 +28,56 @@ export type ChartOptions = {
};

export class ChartCommonOptions {
static initializeChartOptions(chartOptions: ChartOptions, height: number): void {
// Lógica comum para inicializar os ChartOptions
// ...
chartOptions.chart.height = height;
}
static readonly DEFAULT_CHART_OPTIONS: ChartOptions | any = {
series: [{ name: "X", color: "#000", data: [0, 0, 0, 0, 0] }],
chart: {
height: (document.body.clientHeight / 3) - 16,
type: "line",
zoom: {
type: "x",
enabled: false,
autoScaleYaxis: false,
},
},
fill: {
type: "gradient",
gradient: {
shadeIntensity: 1,
inverseColors: false,
opacityFrom: 0.5,
opacityTo: 0,
stops: [1, 2, 4, 8],
},
},
dataLabels: {
enabled: false,
},
stroke: {
width: [2],
curve: "straight",
},
title: {
text: "Nenhuma informação encontrada...",
align: "left",
},
grid: {
row: {
colors: ["#f3f3f3", "transparent"],
opacity: 0.5,
},
},
xaxis: {
labels: {
show: false,
},
},
yaxis: [
{
opposite: true,
},
],
colors: []
};

static initializeChartData(chartOptions: any, data: any[], labelXAxis: any[]): void {
chartOptions.series = data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './chart.common.options';
export * from './mock.chart.data';
export * from './chart.mock.data';
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { NgApexchartsModule } from 'ng-apexcharts';
import { FormsModule } from '@angular/forms';
import { seriesData } from '../chart.options/mock.chart.data';
import { seriesData } from '../chart.options/chart.mock.data';
import { PeriodStartDateObservable, PeriodEndDateObservable } from 'src/app/shared/observables';
import * as dayjs from 'dayjs';
import { ChartCommonOptions } from '../chart.options';


describe('Test Unit LineChartComponent', () => {
let component: LineChartComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CustomValidators } from './../../../validators/custom.validators';
import { Component, ViewChild, OnInit } from '@angular/core';
import { ChartComponent } from "ng-apexcharts";
import { ChartComponent } from "ng-apexcharts";
import { ChartService } from '../../../services';
import { PeriodStartDateObservable, PeriodEndDateObservable } from 'src/app/shared/observables';
import { ChartCommonOptions, ChartOptions } from '../chart.options';
Expand All @@ -11,24 +11,24 @@ import { ChartCommonOptions, ChartOptions } from '../chart.options';
styleUrls: ['./line.chart.component.css']
})

export class LineChartComponent implements OnInit{
export class LineChartComponent implements OnInit {
@ViewChild("chart") chart!: ChartComponent;
public chartOptions: ChartOptions | any;

constructor(public chartService:ChartService, public obsStartDate: PeriodStartDateObservable, public obsEndDate: PeriodEndDateObservable) {}
constructor(public chartService: ChartService, public obsStartDate: PeriodStartDateObservable, public obsEndDate: PeriodEndDateObservable) { }

ngOnInit(): void {
if (CustomValidators.IsValidPeriod(this.obsStartDate.startDate.toString(), this.obsEndDate.endDate.toString()))
this.initializeComponent();
else
ChartCommonOptions.initializeChartOptions(this.chartOptions, (document.body.clientHeight / 3) - 16);
this.chartOptions = ChartCommonOptions.DEFAULT_CHART_OPTIONS;
}

public initializeComponent = async ():Promise<void> =>{
public initializeComponent = async (): Promise<void> => {
const smaData = await this.chartService.getSMA(this.obsStartDate.startDate, this.obsEndDate.endDate);
const ema9Data = await this.chartService.getEMA(9,this.obsStartDate.startDate, this.obsEndDate.endDate);
const ema12Data = await this.chartService.getEMA(12,this.obsStartDate.startDate, this.obsEndDate.endDate);
const ema26Data = await this.chartService.getEMA(26,this.obsStartDate.startDate, this.obsEndDate.endDate);
const ema9Data = await this.chartService.getEMA(9, this.obsStartDate.startDate, this.obsEndDate.endDate);
const ema12Data = await this.chartService.getEMA(12, this.obsStartDate.startDate, this.obsEndDate.endDate);
const ema26Data = await this.chartService.getEMA(26, this.obsStartDate.startDate, this.obsEndDate.endDate);

const data = [
{ name: "EMA 9", data: ChartCommonOptions.formatData(ema9Data.values) || [] },
Expand All @@ -39,7 +39,7 @@ export class LineChartComponent implements OnInit{

this.chartOptions = {
chart: {
height: (document.body.clientHeight/3)-16,
height: (document.body.clientHeight / 3) - 16,
type: "area",
zoom: {
type: "x",
Expand All @@ -60,7 +60,7 @@ export class LineChartComponent implements OnInit{
inverseColors: false,
opacityFrom: 0.5,
opacityTo: 0,
stops: [1, 2, 4, 8 ]
stops: [1, 2, 4, 8]
}
},
dataLabels: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@ import { PeriodStartDateObservable, PeriodEndDateObservable } from 'src/app/shar
import { ChartService } from 'src/app/shared/services';
import { CustomValidators } from 'src/app/shared/validators';
import { ChartOptions, ChartCommonOptions } from '../chart.options';

@Component({
selector: 'app-macd-chart',
templateUrl: './macd.chart.component.html',
styleUrls: ['./macd.chart.component.css']
})

export class MacdChartComponent {
@ViewChild("chart") chart!: ChartComponent;
public chartMacdOptions: ChartOptions | any;
public magazineLuizaHistoryPrices: IMagazineLuizaHistoryPrice[] = [];

constructor( public chartService:ChartService, public obsStartDate: PeriodStartDateObservable, public obsEndDate: PeriodEndDateObservable) {}
constructor( public chartService:ChartService, public obsStartDate: PeriodStartDateObservable, public obsEndDate: PeriodEndDateObservable) { }

async ngOnInit(): Promise<void> {
if (CustomValidators.IsValidPeriod(this.obsStartDate.startDate.toString(), this.obsEndDate.endDate.toString())) {
this.initializeComponent();
} else {
ChartCommonOptions.initializeChartOptions(this.chartMacdOptions, (document.body.clientHeight / 3) - 16);
this.chartMacdOptions = ChartCommonOptions.DEFAULT_CHART_OPTIONS;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { lastValueFrom } from 'rxjs';
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Dayjs } from "dayjs";
Expand All @@ -13,22 +14,27 @@ export class ChartService {
}

async get(startDate:Dayjs| string, endDate: Dayjs | string): Promise<IMagazineLuizaHistoryPrice[]> {
const result:IMagazineLuizaHistoryPrice[] = await this.http.get<any>(`${ this.routeUrl }/${startDate}/${endDate}`).toPromise();
const magazineLuizaHistoryPrice$ = this.http.get<any>(`${ this.routeUrl }/${startDate}/${endDate}`);
const result = await lastValueFrom(magazineLuizaHistoryPrice$) as IMagazineLuizaHistoryPrice[];
return result;
}

async getSMA(startDate:Dayjs| string, endDate: Dayjs | string): Promise<any> {
const result = await this.http.get<any>(`${ this.routeUrl }/getsma/${startDate}/${endDate}`).toPromise();
const getSMA$ = this.http.get<any>(`${ this.routeUrl }/getsma/${startDate}/${endDate}`);
const result = await lastValueFrom(getSMA$);
return result;
}

async getEMA(periodDays: number, startDate:Dayjs| string, endDate: Dayjs | string): Promise<any> {
const result = await this.http.get<any>(`${ this.routeUrl }/getema/${periodDays}/${startDate}/${endDate}`).toPromise();
const getEMA$ = this.http.get<any>(`${ this.routeUrl }/getema/${periodDays}/${startDate}/${endDate}`);
const result = await lastValueFrom(getEMA$);
return result;

}

async getMACD(startDate:Dayjs| string, endDate: Dayjs | string): Promise<any> {
const result = await this.http.get<any>(`${ this.routeUrl }/getmacd/${startDate}/${endDate}`).toPromise();
const getMACD$ = this.http.get<any>(`${ this.routeUrl }/getmacd/${startDate}/${endDate}`);
const result = await lastValueFrom(getMACD$);
return result;
}
}
3 changes: 3 additions & 0 deletions HomeBrokerSPA/HomeBrokerChart/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
],
"include": [
"src/**/*.d.ts"
],
"exclude": [
"src/**/*mock*.ts"
]
}
Loading
Loading