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

Developement of Sprint 12 #152

Merged
merged 145 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
a5faae3
Added DocumentController
Jun 13, 2021
53b7b4e
sending post request to server with axios
gandompm Jun 15, 2021
2f7b691
Merge pull request #121 from amosproj/dev
gandompm Jun 16, 2021
d2646a6
Replacing images in docx and return docx via request response
Jun 19, 2021
21eb0f4
Receiving image data from the frontend
Jun 19, 2021
aaeac34
sending multiple images with axios
gandompm Jun 20, 2021
1d3b13c
changed exportPDF url to CreateReport
Jun 21, 2021
e2472c3
Added Report request response including Report
Jun 21, 2021
ff61dd8
recieving the docx file from server
gandompm Jun 22, 2021
06827a5
renamed res response
Jun 22, 2021
8e72cd5
Resolved the CORS Error, recieving the calculation data from backend
SaiVarunVaranasi Jun 9, 2021
983602c
Resolved the CORS Error, recieving the calculation data from backend
SaiVarunVaranasi Jun 9, 2021
d9c403e
WIP
Jun 22, 2021
b3de555
WIP
Jun 22, 2021
a3b8425
Added response file download
Jun 22, 2021
cab6306
Trying to find the right headers for data transfer
Jun 23, 2021
a8a9c75
Merge Dev-#39 Frontend Backend
Jun 23, 2021
5d9f10b
gitignore
Jun 24, 2021
fd583a7
exporting in frontend side
gandompm Jun 27, 2021
2032409
Merge branch 'dev-#39' of https://github.com/amosproj/amos-ss2021-car…
gandompm Jun 27, 2021
3ac13c4
move export Pdf function to a separate module
gandompm Jun 27, 2021
b28d301
defining the backend request to a separate module
gandompm Jun 27, 2021
afcc25c
documenting and refactoring ui
gandompm Jun 27, 2021
72ffeff
Merge pull request #138 from amosproj/dev-#82
SaiVarunVaranasi Jun 29, 2021
0b1beb2
Implemented category seperation
SaiVarunVaranasi Jun 29, 2021
7fd1199
fixing shape of diagrams in pdf in compare page
gandompm Jun 29, 2021
d7a274f
Merge branch 'dev' into dev-#39
Waldleufer Jun 30, 2021
f9bc697
Merge Preparation
Waldleufer Jun 30, 2021
3c7e00a
Frontend Pipeline fixed.
Waldleufer Jun 30, 2021
d3017b5
mydashboard page reconfigured
IremToroslu Jun 30, 2021
c7edd83
Merge branch 'dev-#125' of https://github.com/amosproj/amos-ss2021-ca…
IremToroslu Jun 30, 2021
9367d50
Backend pipeline fix
SaiVarunVaranasi Jun 30, 2021
8aacffb
Card components restructured and resized
IremToroslu Jun 30, 2021
4e23312
mydasboard page card resized and reconfigured
IremToroslu Jun 30, 2021
b87eaaf
Fix the backend build errors
SaiVarunVaranasi Jun 30, 2021
cfa8b84
Merge branch 'dev-#39' of
SaiVarunVaranasi Jun 30, 2021
f98829c
Merge pull request #143 from amosproj/dev-#125
Waldleufer Jun 30, 2021
271f2e9
Merge pull request #144 from amosproj/dev
Waldleufer Jun 30, 2021
01da797
Configured the slideshow of the dashboard
manifau Jun 30, 2021
ff41ce3
Changed the naming convention for slideshow component
manifau Jun 30, 2021
808e2b9
Sort data recieved from API category/Secnario
SaiVarunVaranasi Jun 30, 2021
2a18194
Added getDummyProducts function
ScoutAtlas Jul 1, 2021
6266048
Reworked getSimaProducts
ScoutAtlas Jul 1, 2021
2a33e57
Included custom image to getSimaProducts()
ScoutAtlas Jul 1, 2021
cfaa65b
Updated Dummy Data
Waldleufer Jul 1, 2021
b0bf9c1
Merge branch 'dev-#107' of https://github.com/amosproj/amos-ss2021-ca…
Waldleufer Jul 1, 2021
83c9e25
Adapting Dummy Data
Waldleufer Jul 1, 2021
914bea1
Cleanup
Waldleufer Jul 1, 2021
c3ac305
Added footer for the dashboard
manifau Jul 1, 2021
da018f5
Creating three Slices for the Categories
Waldleufer Jul 1, 2021
80239c7
added services,solution and scenarios to dummy data
SaiVarunVaranasi Jul 1, 2021
95866ee
Added selectedType as parameter to functions
ScoutAtlas Jul 1, 2021
a34a6d2
Adding PropType to ProductSolutionsServices Component
Waldleufer Jul 1, 2021
2510c24
moved dummy data to another file
SaiVarunVaranasi Jul 1, 2021
5438ee0
Resolved Eslint Error
Waldleufer Jul 1, 2021
af99bd6
Merge branch 'dev-#107' of https://github.com/amosproj/amos-ss2021-ca…
Waldleufer Jul 1, 2021
1f6e71b
Fixes
Jul 1, 2021
6e422cf
changed slices
Jul 1, 2021
dd5f78b
fill data via type and category
Jul 1, 2021
b9f259c
Put data in corresponding slices
Waldleufer Jul 1, 2021
162157c
Only get projects once (after login)
Waldleufer Jul 1, 2021
f7a2294
Displaying only the Products of the corresponding Category
Waldleufer Jul 1, 2021
f899d53
Added optional chaining in switch case
Jul 1, 2021
736f65a
Footer reconfigured
manifau Jul 1, 2021
e5aa6b4
Changed docx template handling
Jul 1, 2021
59d3d03
Fixed download of file from backend
Jul 1, 2021
094dc7e
manual DetailsComponent Merge from Main
Jul 1, 2021
1d77dc1
my dashboard page restructured
IremToroslu Jul 1, 2021
cdb4e79
Subscribe section reconfigured.
IremToroslu Jul 1, 2021
e85f382
my dashboard page reconfigured
IremToroslu Jul 1, 2021
9e3ca04
Adding some more demo data
Waldleufer Jul 2, 2021
5fc85e8
Uniforming names of categories and types
Waldleufer Jul 2, 2021
6c36eca
Merge branch 'dev-#107' of https://github.com/amosproj/amos-ss2021-ca…
Waldleufer Jul 2, 2021
0b93a0c
Added more dummy data
Waldleufer Jul 2, 2021
2230274
Added a missing break;
Waldleufer Jul 2, 2021
99853e7
Added a function that handles scenarios in the (sorted) ProjectList
Waldleufer Jul 2, 2021
11ab92d
sorted the Projects alphabetically
Waldleufer Jul 2, 2021
3b24898
Renaming and Documentation
Waldleufer Jul 2, 2021
7650c31
Added a class for productObject
Waldleufer Jul 2, 2021
3d586af
Adding more dummy scenarios
Waldleufer Jul 2, 2021
dbbac37
adding loading bar for exporting pdf
gandompm Jul 2, 2021
a600c4a
product grid clickable card hover color changed.
IremToroslu Jul 2, 2021
5f780c8
resoliving CI Pipe line errors
gandompm Jul 2, 2021
946bcc2
deleting frontend pdf generater function
gandompm Jul 2, 2021
a97bfe5
Updating Documentation
Waldleufer Jul 2, 2021
ba80274
Merge pull request #146 from amosproj/dev-#107
Waldleufer Jul 2, 2021
9f13fc1
Removed unused Component
Waldleufer Jul 3, 2021
f4b838d
Introducing dummy Methods for Details Page
Waldleufer Jul 3, 2021
93d69cf
Implemented DummyData Switch
Waldleufer Jul 3, 2021
a0eba26
storing all infromation of selected product
gandompm Jul 3, 2021
cdbde7a
refactoring scenarioComponent
gandompm Jul 3, 2021
af1771c
Populating the SelectScenarioComponent
Waldleufer Jul 3, 2021
272e83f
Renaming and BugFixing
Waldleufer Jul 3, 2021
fab6c54
handling new scenario selection
gandompm Jul 3, 2021
6040845
passing the selected scenario type
gandompm Jul 3, 2021
cb1edf1
card components reconfigured.
IremToroslu Jul 3, 2021
90724d5
adding documentation
gandompm Jul 3, 2021
26886f1
mydashboard.css file reconfigured
IremToroslu Jul 3, 2021
6ef3eec
Merge pull request #148 from amosproj/dev-#17
Waldleufer Jul 4, 2021
71581d1
reconfiguration of mydashboardpage and detailspage
IremToroslu Jul 4, 2021
eb7c741
export button removed when it comes to compare page
IremToroslu Jul 4, 2021
8e0f6a4
card titles resized and card borders removed
IremToroslu Jul 5, 2021
76a1374
borders added back
IremToroslu Jul 5, 2021
c8c98e8
Turning Columns into Cols
Waldleufer Jul 5, 2021
895df20
removing unneeded fixed height
Waldleufer Jul 5, 2021
550df57
Using react-grid-system
Waldleufer Jul 5, 2021
81663af
Swaping out simple-flexbox with react-grid-system
Waldleufer Jul 5, 2021
80bec9b
Resized card components
IremToroslu Jul 5, 2021
0143aff
Fixing MiniCard Styling
Waldleufer Jul 5, 2021
ec0e9fd
Improved Favourites Content
Waldleufer Jul 5, 2021
beb08f7
Merge branch 'dev-#137' of https://github.com/amosproj/amos-ss2021-ca…
Waldleufer Jul 5, 2021
460ebec
Cleaning up unused files
Waldleufer Jul 5, 2021
a018620
Fitting the Header to Screen-width
Waldleufer Jul 5, 2021
25e5582
Cleaning up unused Code
Waldleufer Jul 5, 2021
184c1d0
Slideshow Container Alignment Improved
Waldleufer Jul 5, 2021
c592ce7
fixing console errors
Waldleufer Jul 5, 2021
cc419ed
Mooving Footer One level Up
Waldleufer Jul 5, 2021
86f74af
Removing non effective attributes
Waldleufer Jul 5, 2021
aa63646
Renaming Recent Projects
Waldleufer Jul 5, 2021
bcecc95
Changing out Simple-Flexbox with react-grid-system
Waldleufer Jul 5, 2021
2b00f26
Changed the naming convention of favorite card
manifau Jul 5, 2021
4f56fe2
Modifying answer section of FAQ
manifau Jul 5, 2021
5fdd199
height of the latest update section resized
IremToroslu Jul 5, 2021
d1a7230
Merge branch 'dev-#137' of https://github.com/amosproj/amos-ss2021-ca…
IremToroslu Jul 5, 2021
b2f04c9
Changed arrow
manifau Jul 5, 2021
50f87f3
text changed.
IremToroslu Jul 5, 2021
4100608
Updating Documentation
Waldleufer Jul 5, 2021
ec244b0
Merge pull request #135 from amosproj/dev-#107
Waldleufer Jul 5, 2021
baba5b0
Merge pull request #147 from amosproj/dev-#17
Waldleufer Jul 5, 2021
0d99040
Merge pull request #145 from amosproj/dev-#137
Waldleufer Jul 5, 2021
025bd16
fixing the exception
gandompm Jul 5, 2021
7b186d7
fixing ui
gandompm Jul 5, 2021
26cbe50
Merge branch 'dev' into dev-#39 - Merge Preparation
Waldleufer Jul 5, 2021
81f0227
Merge branch 'dev-#39' of https://github.com/amosproj/amos-ss2021-car…
Waldleufer Jul 5, 2021
2c19e74
Merge pull request #128 from amosproj/dev-#39
Waldleufer Jul 5, 2021
d658491
Use simaPro Data
Waldleufer Jul 6, 2021
89ab960
Gave LoadingComponent a makeover
Waldleufer Jul 6, 2021
2fd87fc
Fixed Industrial Application Typo
Waldleufer Jul 6, 2021
346d413
Removed Console.log
Waldleufer Jul 6, 2021
aceadda
Fixing odd indentations in Category texts
Waldleufer Jul 6, 2021
f300511
Fixed some Mobile Screen Edge Cases
Waldleufer Jul 6, 2021
54c779f
return postCalculation response in case of failure
Jul 6, 2021
315ac3d
template layouting
Jul 7, 2021
ffa3d08
Merge pull request #151 from amosproj/dev-#107
Waldleufer Jul 7, 2021
4820c78
Merge pull request #150 from amosproj/dev-#39
Waldleufer Jul 7, 2021
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
3 changes: 3 additions & 0 deletions backend/Backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

secrets.json
Templates/template-docx
Templates/template-modified.docx
Templates/jpegsample.jpg

# User-specific files
*.rsuser
Expand Down
6 changes: 6 additions & 0 deletions backend/Backend/Backend.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

<ItemGroup>
<PackageReference Include="AspNetCore.Proxy" Version="4.2.0" />
<PackageReference Include="CoreCompat.libgdiplus" Version="6.0.4-ci-84" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0-preview.5.21301.5" />
</ItemGroup>

<ItemGroup>
Expand All @@ -17,5 +19,9 @@
</Content>
</ItemGroup>

<ItemGroup>
<Folder Include="Templates\" />
</ItemGroup>

</Project>

61 changes: 61 additions & 0 deletions backend/Backend/Controllers/DocumentController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Backend.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Web;
namespace Backend.Controllers
{
[Route("[controller]")]
[ApiController]
public class DocumentController : ControllerBase
{
private readonly DocumentService _documentService;

public DocumentController(DocumentService documentService)
{
_documentService = documentService;
}

//[HttpPost("test")]
//public IActionResult test()
//{
// var files = DocumentService.GetFileModelsFromRequest(this.Request);

// return new OkResult();
//}

[HttpPost("CreateReport")]
public FileContentResult CreateReport()
{
string filepath = _documentService.createReport(this.Request);

string filename = "template-modified.docx";
byte[] filedata = System.IO.File.ReadAllBytes(filepath);
string contentType;
new FileExtensionContentTypeProvider().TryGetContentType(filepath, out contentType);

var cd = new System.Net.Mime.ContentDisposition {
FileName = filename,
Inline = false
};

System.IO.File.Delete(filepath);
Response.Headers.Add("Content-Disposition", cd.ToString());
Response.Headers.Add("Access-Control-Expose-Headers", "*");
//Response.Headers.Add("Content-Transfer-Encoding", "Binary");
//Response.Headers.Add("Content-Encoding", "gzip");
return File(filedata, contentType);
}

[HttpOptions("CreateReport")]
public IActionResult PreflightRoute()
{
return NoContent();
}

}
}
6 changes: 6 additions & 0 deletions backend/Backend/Controllers/SimaProController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ public Task ProxyCatchAll(string rest)
return this.HttpProxyAsync($"{rest}{queryString}", httpProxyOptions);
}

[HttpOptions]
public IActionResult PreflightRoute()
{
return NoContent();
}

}
}
56 changes: 56 additions & 0 deletions backend/Backend/Helper/XmlToDocxHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Xml.Linq;

namespace Backend.Helper
{
public static class XmlToDocxHelper
{

public static void ZipDOCX(this string unzipPath, string fileName)
{

if (File.Exists(fileName))
{
File.Delete(fileName);
}

ZipFile.CreateFromDirectory(unzipPath, fileName);

}

public static string UnzipDOCX(this string zipPath)
{
string[] subs = zipPath.Split('.', StringSplitOptions.RemoveEmptyEntries);

using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
if (Directory.Exists(subs[0]))
{
Directory.Delete(subs[0], true);
}

archive.ExtractToDirectory(subs[0]);

}

return subs[0];
}

//public static string XmlToString(this string xmlDirectory, string xmlPath)
//{
// XDocument document = XDocument.Load(xmlDirectory + xmlPath);
// string docString = document.ToString();

// return docString;
//}

//public static void StringToXml(this string xmlDirectory, string xmlPath, string documentString)
//{
// XDocument xDocument = XDocument.Parse(documentString, LoadOptions.PreserveWhitespace);
// xDocument.Save(xmlDirectory + xmlPath);
//}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
if (request.RequestUri.ToString().Contains("api/calculation"))
{
var requestResponse = await base.SendAsync(request, cancellationToken);
if (!requestResponse.IsSuccessStatusCode)
{
return requestResponse;
}
var contentString = await requestResponse.Content.ReadAsStringAsync();
//Retrieve the CalculationId from the post request
var responseContent = JObject.Parse(contentString);
Expand All @@ -43,7 +47,10 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
while (true)
{
calculationStateResponse = await base.SendAsync(calculationStateRequest, cancellationToken);

if (!calculationStateResponse.IsSuccessStatusCode)
{
return calculationStateResponse;
}
var calculationResponseContent = JObject.Parse(await calculationStateResponse.Content.ReadAsStringAsync());
var calculationResultStatus = calculationResponseContent["Result"].ToString();

Expand Down
116 changes: 116 additions & 0 deletions backend/Backend/Services/DocumentService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Drawing;
using System.IO;
using System.ComponentModel;
using Backend.Helper;
using Microsoft.AspNetCore.Http;

namespace Backend.Services
{
public class DocumentService
{
public string createReport(HttpRequest request)
{
var imageNumbers = new List<int>() { 7, 13, 11 };

GetFileModelsFromRequest(request, imageNumbers);

var unzipPath = @"Templates\template-docx.docx".UnzipDOCX();
var docxImagePath = unzipPath + @"\word\media\";


foreach (var number in imageNumbers)
{
File.Delete(docxImagePath + "image" + number.ToString() + ".png");
var image = Image.FromFile(@"Templates\image" + number.ToString() + ".png");
image.Save(docxImagePath + "image" + number.ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png);
image.Dispose();
File.Delete(@"Templates\image" + number.ToString() + ".png");
}

unzipPath.ZipDOCX(@"Templates\template-modified.docx");
Directory.Delete(@"Templates\template-docx",true);
return @"Templates\template-modified.docx";

//List<Image> images = new List<Image>() {
// Image.FromFile(@"Templates\image7.png"),
// Image.FromFile(@"Templates\image11.png"),
// Image.FromFile(@"Templates\image14.png")
//};

//File.Delete(imagePath + "image7.png");
//File.Delete(imagePath + "image11.png");
//File.Delete(imagePath + "image14.png");

//images[0].Save(imagePath + "image" + "7.png", System.Drawing.Imaging.ImageFormat.Png);
//images[1].Save(imagePath + "image" + "11.png", System.Drawing.Imaging.ImageFormat.Png);
//images[2].Save(imagePath + "image" + "14.png", System.Drawing.Imaging.ImageFormat.Png);


//File.Delete(@"Templates\image7.png");
//File.Delete(@"Templates\image11.png");
//File.Delete(@"Templates\image14.png");




}

public static void GetFileModelsFromRequest(HttpRequest request, List<int> imageNumbers)
{
foreach (var formField in request.Form)
{
// Form data
var stringValues = formField.Value.Select(x => x.ToString()).Select(y => y.Replace("data:image/jpeg;base64,",""));
var stringValueTuples = stringValues.Zip(imageNumbers);

foreach (var tuple in stringValueTuples)
{
//... process and add to the FileModel list
byte[] bytes = Convert.FromBase64String(tuple.First);

Image image;
using (MemoryStream ms = new MemoryStream(bytes))
{
image = Image.FromStream(ms);
image.Save(@"Templates\" + "image" + tuple.Second.ToString() +".png", System.Drawing.Imaging.ImageFormat.Png);
image.Dispose();
ms.Dispose();
}
}
}
}

//XDocument template = XDocument.Load(@"Templates\template-xml.xml");
//string document = template.ToString();

//var documentModified = ReplaceXmlInlineImageDate(document, @"Templates\jpegsample.jpg", "7");
//documentModified = ReplaceXmlInlineImageDate(documentModified, @"Templates\jpegsample.jpg", "11");
//documentModified = ReplaceXmlInlineImageDate(documentModified, @"Templates\jpegsample.jpg", "14");

//XDocument xDocument = XDocument.Parse(documentModified, LoadOptions.PreserveWhitespace);
//xDocument.Save(@"Templates\template-xml-edited.docx");

//private static string ReplaceXmlInlineImageDate(string document, string imagePath, string imageToBeReplacedNumber)
//{
// //load image from filesystem
// Image image = Image.FromFile(imagePath);
// Bitmap bitmap = new Bitmap(image);
// TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
// string imgContent = Convert.ToBase64String((byte[])converter.ConvertTo(bitmap, typeof(byte[])));

// //build document string
// string delimiterOpeningTag = "<pkg:part pkg:name=\"/word/media/image"+imageToBeReplacedNumber+".png\" pkg:contentType=\"image/png\" pkg:compression=\"store\">\r\n <pkg:binaryData>";
// string delimiterClosingTag = "</pkg:binaryData>\r\n </pkg:part>\r\n";
// var documentArray = document.Split(delimiterOpeningTag);
// var documentArray2 = documentArray[1].Split(delimiterClosingTag);
// var restString = String.Join(delimiterClosingTag, documentArray2, 1, documentArray2.Length - 1);
// var documentModified = documentArray[0] + delimiterOpeningTag + imgContent + delimiterClosingTag + restString;
// return documentModified;
//}
}
}
4 changes: 4 additions & 0 deletions backend/Backend/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AspNetCore.Proxy;
using Backend.Security;
using Backend.Middleware;
using Backend.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -49,6 +50,9 @@ public void ConfigureServices(IServiceCollection services)
});

services.AddProxies();

services.AddTransient<DocumentService>();

//Used to get the authenticate/process the Http requests.
services.AddTransient<SimaProLoginDelegatingHandler>();

Expand Down
Binary file added backend/Backend/Templates/jpegsample.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/Backend/Templates/template-docx.docx
Binary file not shown.
Loading