Skip to content

Commit

Permalink
Merge pull request #24 from alexfariakof/develop
Browse files Browse the repository at this point in the history
Entrega final Iteração 2 com revisão e refinamento de código e bugs corrigidos
  • Loading branch information
alexfariakof authored Feb 1, 2024
2 parents 0c8b1d7 + b9cfb4d commit 3e70c28
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 81 deletions.
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.

Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ describe('ChartCommonOptions', () => {
};
});

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

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

it('should initialize chart data with given data and labelXAxis', () => {
Expand Down
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,62 +28,56 @@ export type ChartOptions = {
};

export class ChartCommonOptions {

static initializeNullChartOptions(height: number): ChartOptions | any{
return {
series: [
{ name: "X", color: "#000", data: [0, 0, 0, 0, 0 ] }
],
chart: {

height: height,
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]
}
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,
},
dataLabels: {
enabled: false
},
fill: {
type: "gradient",
gradient: {
shadeIntensity: 1,
inverseColors: false,
opacityFrom: 0.5,
opacityTo: 0,
stops: [1, 2, 4, 8],
},
stroke: {
width: [2],
curve: "straight"
},
dataLabels: {
enabled: false,
},
stroke: {
width: [2],
curve: "straight",
},
title: {
text: "Nenhuma informação encontrada...",
align: "left",
},
grid: {
row: {
colors: ["#f3f3f3", "transparent"],
opacity: 0.5,
},
title: {
text: "Nenhuma informação encontrada...",
align: "left"
},
xaxis: {
labels: {
show: false,
},
grid: {
row: {
colors: ["#f3f3f3", "transparent"],
opacity: 0.5
}
},
yaxis: [
{
opposite: true,
},
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,4 +1,3 @@
import { seriesData } from './../chart.options/chart.mock.data';
import { CustomValidators } from './../../../validators/custom.validators';
import { Component, ViewChild, OnInit } from '@angular/core';
import { ChartComponent } from "ng-apexcharts";
Expand All @@ -22,7 +21,7 @@ export class LineChartComponent implements OnInit {
if (CustomValidators.IsValidPeriod(this.obsStartDate.startDate.toString(), this.obsEndDate.endDate.toString()))
this.initializeComponent();
else
this.chartOptions = ChartCommonOptions.initializeNullChartOptions((document.body.clientHeight / 3) - 16);
this.chartOptions = ChartCommonOptions.DEFAULT_CHART_OPTIONS;
}

public initializeComponent = async (): Promise<void> => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { seriesData } from './../chart.options/chart.mock.data';
import { Component, ViewChild } from '@angular/core';
import { ChartComponent } from 'ng-apexcharts';
import { IMagazineLuizaHistoryPrice } from 'src/app/shared/interfaces';
import { PeriodStartDateObservable, PeriodEndDateObservable } from 'src/app/shared/observables';
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;
Expand All @@ -22,7 +23,7 @@ export class MacdChartComponent {
if (CustomValidators.IsValidPeriod(this.obsStartDate.startDate.toString(), this.obsEndDate.endDate.toString())) {
this.initializeComponent();
} else {
this.chartMacdOptions = ChartCommonOptions.initializeNullChartOptions((document.body.clientHeight / 3) - 16);
this.chartMacdOptions = ChartCommonOptions.DEFAULT_CHART_OPTIONS;
}
}

Expand Down
18 changes: 15 additions & 3 deletions HomeBrokerSPA/HomeBrokerSPA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@
<None Remove="$(SpaRoot)**" />
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
</ItemGroup>


<PropertyGroup>
<Build>
DebugEnsureNodeEnv;
DockerDebuggeeProgram;
</Build>
</PropertyGroup>

<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<!-- Ensure Node.js is installed -->
<Exec Command="node --version" ContinueOnError="true">
Expand All @@ -38,6 +45,12 @@
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
</Target>


<Target Name="DockerDebuggeeProgram" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug'">
<!-- Ensure angular project compilation -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --configuration production" />
</Target>

<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
Expand All @@ -52,7 +65,6 @@
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</ResolvedFileToPublish>
</ItemGroup>
</Target>

</Target>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1development_1json__JsonSchema="https://json.schemastore.org/appsscript.json" /></VisualStudio></ProjectExtensions>
</Project>
13 changes: 0 additions & 13 deletions HomeBrokerSPA/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@
var appVersion = "v1";
var appDescription = $"API para gerar dados históricos da variação de preços da Magazine Luiza S.A.em um determinado período.";

builder.Services.AddCors(c =>
{
c.AddDefaultPolicy(builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});

builder.Services.AddRouting(options => options.LowercaseUrls = true);
builder.Services.AddControllers();
builder.Services.AddScoped(typeof(IHomeBrokerBusiness), typeof(HomeBrokerBusiness));
Expand Down Expand Up @@ -55,9 +44,7 @@
else
app.UseHttpsRedirection();

app.UseCors();
app.UseHsts();

app.UseSwagger();
app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", $"{appName} {appVersion}"); });

Expand Down
5 changes: 2 additions & 3 deletions HomeBrokerSPA/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,23 @@
},
"Swagger": {
"commandName": "Project",
"workingDirectory": "./",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Swagger"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"dotnetWatchProfile": true,
"workingDirectory": "./",
"hotReloadEnabled": true,
"leaveRunningOnClose": false,
"remoteDebugMachine": "https://localhost:5001;http://localhost:5000"
},
"Unit Tests in Watch Mode": {
"workingDirectory": "../",
"commandName": "Executable",
"executablePath": "powershell.exe",
"commandLineArgs": "powershell -File \".\\dotnet_test_watch_mode.ps1\"",
"launchBrowser": false,
"workingDirectory": "../",
"debugType": "",
"leaveRunningOnClose": false
}
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.dcproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<SpaRoot>.\HomeBrokerSPA\HomeBrokerChart\</SpaRoot>
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<DockerPublishLocally>False</DockerPublishLocally>
Expand All @@ -17,4 +18,33 @@
<None Include="docker-compose.dev.yml" />
<None Include="docker-compose.prod.yml" />
</ItemGroup>

<ItemGroup>
<!-- Don't publish the SPA source files and dont1t show them in the project files list -->
<Content Remove="$(SpaRoot)**" />
<None Remove="$(SpaRoot)**" />
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)/**" />
</ItemGroup>

<PropertyGroup>
<Build>
DebugEnsureNodeEnv;
DebugEnsureDist;
</Build>
</PropertyGroup>

<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<!-- Ensure Node.js is installed -->
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
</Target>

<Target Name="DebugEnsureDist" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' ">
<!-- Ensure angular project compilation -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --configuration production" />
</Target>
</Project>

0 comments on commit 3e70c28

Please sign in to comment.