Skip to content

Commit

Permalink
Merge pull request #119 from amosproj/main
Browse files Browse the repository at this point in the history
sprint-09-release
  • Loading branch information
MartinDuersch authored Jun 16, 2021
2 parents 7d7a65b + 5d197ac commit d95c013
Show file tree
Hide file tree
Showing 112 changed files with 1,635 additions and 15,144 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Reactjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
push:
branches: [ main, release ]
pull_request:
branches: [ main, frontend-dev, release ]
branches: [ main, frontend-dev, release, dev ]

jobs:
buildAndTest:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ main, release ]
pull_request:
branches: [ main, backend-dev, release ]
branches: [ main, backend-dev, release, dev ]

jobs:
build:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
.idea
/.vs/slnx.sqlite-journal
.vs/slnx.sqlite

frontend/yarn.lock
68 changes: 68 additions & 0 deletions backend/Backend/Middleware/RequestInterceptorDelegatingHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.IO.Compression;
using System.IO;
using System.Text;

namespace Backend.Middleware
{
// Catch the http post request(postCalculationRequest) from front-end.
// Further process the request and send back the Results to fornt-end.
public class RequestInterceptorDelegatingHandler : DelegatingHandler
{
private readonly string baseUrl;

public RequestInterceptorDelegatingHandler(IConfiguration configuration)
{
baseUrl = Environment.GetEnvironmentVariable("BaseUrl") ?? configuration["BaseUrl"];
}

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
CancellationToken cancellationToken)
{
if (request.RequestUri.ToString().Contains("api/calculation"))
{
var requestResponse = await base.SendAsync(request, cancellationToken);
var contentString = await requestResponse.Content.ReadAsStringAsync();
//Retrieve the CalculationId from the post request
var responseContent = JObject.Parse(contentString);
var calculationId = responseContent["Result"]["CalculationId"].ToString();

// Get the status of the calculation based on the CalculationId earlier created.
var calculationStateRequest = new HttpRequestMessage(new HttpMethod("GET"), baseUrl + "calculation/state/" + calculationId) { };
HttpResponseMessage calculationStateResponse;

Thread.Sleep(500);
//Checks of the calculation is completed.
//Results: Calulating,Storing,Stored,Not Stored, Not Found
while (true)
{
calculationStateResponse = await base.SendAsync(calculationStateRequest, cancellationToken);

var calculationResponseContent = JObject.Parse(await calculationStateResponse.Content.ReadAsStringAsync());
var calculationResultStatus = calculationResponseContent["Result"].ToString();

if (calculationResultStatus == "Stored")
{
break;
}
Thread.Sleep(500);
}
//If the calculation is stored.Send a post post request to retrieve the results and send back to the front-end.
var calculationResultRequest = new HttpRequestMessage(new HttpMethod("POST"), baseUrl + "calculation/result/" + calculationId) {
Content = new StringContent(JsonConvert.SerializeObject(""), Encoding.UTF8, "application/json")
};
HttpResponseMessage calculationResultResponse = await base.SendAsync(calculationResultRequest, cancellationToken);
return calculationResultResponse;
}

return await base.SendAsync(request, cancellationToken);

}
}
}
14 changes: 14 additions & 0 deletions backend/Backend/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AspNetCore.Proxy;
using Backend.Security;
using Backend.Middleware;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
Expand All @@ -14,6 +15,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net;

namespace Backend
{
Expand All @@ -39,13 +42,24 @@ public void ConfigureServices(IServiceCollection services)
services.AddProxies();
//Used to get the authenticate/process the Http requests.
services.AddTransient<SimaProLoginDelegatingHandler>();

//Used to intercept and process frontend requests.
services.AddTransient<RequestInterceptorDelegatingHandler>();
//Decompress the gZip results recieved from the api
HttpClientHandler handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };

services.AddHttpClient("SimaProClient",
client => {
var baseUrl = Environment.GetEnvironmentVariable("BaseUrl") ?? Configuration["BaseUrl"];
client.BaseAddress = new Uri(baseUrl);
//client.Timeout = TimeSpan.FromSeconds(30);
})
.ConfigurePrimaryHttpMessageHandler(() => {
return handler;
})
.AddHttpMessageHandler<RequestInterceptorDelegatingHandler>()
.AddHttpMessageHandler<SimaProLoginDelegatingHandler>();

}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
Binary file not shown.
Binary file added deliverables/2021-06-09 Kanban Board.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added deliverables/2021-06-16 Kanban Board.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock

package-lock.json
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.4",
"@react-pdf/renderer": "^2.0.12",
"apexcharts": "^3.26.1",
"axios": "^0.21.1",
"cors": "^2.8.5",
"html2canvas": "^1.0.0-rc.7",
"jspdf": "^2.3.1",
"jspdf-autotable": "^3.5.14",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 0 additions & 8 deletions frontend/src/assets/icons/checkbox-off.js

This file was deleted.

9 changes: 0 additions & 9 deletions frontend/src/assets/icons/checkbox-on.js

This file was deleted.

10 changes: 0 additions & 10 deletions frontend/src/assets/icons/icon-agents.js

This file was deleted.

28 changes: 0 additions & 28 deletions frontend/src/assets/icons/icon-arrow-down.js

This file was deleted.

26 changes: 0 additions & 26 deletions frontend/src/assets/icons/icon-arrow-up.js

This file was deleted.

9 changes: 0 additions & 9 deletions frontend/src/assets/icons/icon-arrow.js

This file was deleted.

10 changes: 0 additions & 10 deletions frontend/src/assets/icons/icon-articles.js

This file was deleted.

9 changes: 0 additions & 9 deletions frontend/src/assets/icons/icon-bell-new.js

This file was deleted.

18 changes: 0 additions & 18 deletions frontend/src/assets/icons/icon-browse.js

This file was deleted.

11 changes: 0 additions & 11 deletions frontend/src/assets/icons/icon-building.js

This file was deleted.

9 changes: 0 additions & 9 deletions frontend/src/assets/icons/icon-burger.js

This file was deleted.

8 changes: 0 additions & 8 deletions frontend/src/assets/icons/icon-circle.js

This file was deleted.

10 changes: 0 additions & 10 deletions frontend/src/assets/icons/icon-contacts.js

This file was deleted.

8 changes: 0 additions & 8 deletions frontend/src/assets/icons/icon-heart.js

This file was deleted.

11 changes: 0 additions & 11 deletions frontend/src/assets/icons/icon-home.js

This file was deleted.

17 changes: 0 additions & 17 deletions frontend/src/assets/icons/icon-ideas.js

This file was deleted.

10 changes: 0 additions & 10 deletions frontend/src/assets/icons/icon-inbox.js

This file was deleted.

Loading

0 comments on commit d95c013

Please sign in to comment.