Skip to content

Commit

Permalink
Merge pull request #8 from buildersoftdev/v3/main
Browse files Browse the repository at this point in the history
V3/main
  • Loading branch information
eneshoxha authored Nov 19, 2022
2 parents 753f5ca + 31d2692 commit 8bd3df3
Show file tree
Hide file tree
Showing 930 changed files with 101,245 additions and 1,674 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/v3-main_bs-andyx-v3-portal-dev01.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy ASP.Net Core app to Azure Web App - bs-andyx-v3-portal-dev01

on:
push:
branches:
- v3/main
workflow_dispatch:

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.x'
include-prerelease: true

- name: Build with dotnet
run: dotnet build --configuration Release

- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp

deploy:
runs-on: windows-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: .net-app

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'bs-andyx-v3-portal-dev01'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_EF2DA002592B4138B59601597BFB10AA }}
package: .
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p align="center">
<img src="https://user-images.githubusercontent.com/10813728/202870468-20d05267-a8e6-4f93-a579-f249b8bd1268.png" alt="Sublime's custom image"/>
</p>

What is Andy X Portal?
============

Expand All @@ -16,7 +20,7 @@ and make pull-requests.

## Reporting security issues and bugs

Security issues and bugs should be reported privately, via email, [email protected]. You should receive a response within 24 hours.
Security issues and bugs should be reported privately, via email, [email protected]. You should receive a response within 24 hours.

## Related projects

Expand Down
15 changes: 9 additions & 6 deletions src/Andy.X.Portal/Andy.X.Portal.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<UserSecretsId>bb695a85-1150-4030-aa62-fee35a111e5b</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
Expand All @@ -14,7 +14,14 @@
</PropertyGroup>

<ItemGroup>
<None Include="src\wwwroot\js\site.js" />
<Compile Remove="Models\Products\Components\**" />
<Compile Remove="src\**" />
<Content Remove="Models\Products\Components\**" />
<Content Remove="src\**" />
<EmbeddedResource Remove="Models\Products\Components\**" />
<EmbeddedResource Remove="src\**" />
<None Remove="Models\Products\Components\**" />
<None Remove="src\**" />
</ItemGroup>

<ItemGroup>
Expand All @@ -23,8 +30,4 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="Models\Products\Components\" />
</ItemGroup>

</Project>
2 changes: 0 additions & 2 deletions src/Andy.X.Portal/Configurations/XNodeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
public class XNodeConfiguration
{
public string ServiceUrl { get; set; }
public string Username { get; set; }
public string Password { get; set; }
}
}
28 changes: 28 additions & 0 deletions src/Andy.X.Portal/Controllers/ClustersController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Andy.X.Portal.Services.Clusters;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace Andy.X.Portal.Controllers
{
[Authorize]
public class ClustersController : Controller
{
private readonly ClusterService clusterService;

public ClustersController(ClusterService clusterService)
{
this.clusterService = clusterService;
}

public IActionResult Index()
{
var user = new Models.User()
{
Password = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Password").Value,
Username = HttpContext.User.Identity.Name
};
return View(clusterService.GetClustersDetailsViewModel(user));
}
}
}
15 changes: 9 additions & 6 deletions src/Andy.X.Portal/Controllers/ComponentsController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using Andy.X.Portal.Services.Components;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace Andy.X.Portal.Controllers
{
[Authorize]
public class ComponentsController : Controller
{
private readonly ComponentService componentService;
Expand All @@ -14,12 +17,12 @@ public ComponentsController(ComponentService componentService)

public IActionResult Details(string tenant, string product, string id)
{
return View(componentService.GetComponentDetailsViewModel(tenant, product, id));
}

public IActionResult Lineage(string tenant, string product, string id)
{
return View(componentService.GetStreamLineageViewModel(tenant, product, id));
var user = new Models.User()
{
Password = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Password").Value,
Username = HttpContext.User.Identity.Name
};
return View(componentService.GetComponentDetailsViewModel(user, tenant, product, id));
}
}
}
25 changes: 0 additions & 25 deletions src/Andy.X.Portal/Controllers/ConsumersController.cs

This file was deleted.

74 changes: 73 additions & 1 deletion src/Andy.X.Portal/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,100 @@
using Andy.X.Portal.Models;
using Andy.X.Portal.Models.Home;
using Andy.X.Portal.Services.Home;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Andy.X.Portal.Services.User;

namespace Andy.X.Portal.Controllers
{

public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly HomeService _homeService;
private readonly UserService _userService;

public HomeController(ILogger<HomeController> logger)
public HomeController(ILogger<HomeController> logger, HomeService homeService, UserService userService)
{
_logger = logger;
_homeService = homeService;
_userService = userService;
}

[Authorize]
public IActionResult Index()
{
var user = new Models.User()
{
Password = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Password").Value,
Username = HttpContext.User.Identity.Name
};
return View(_homeService.GetHomeViewModel(user));
}

[Authorize]
public IActionResult License()
{
return View();
}

public IActionResult Login(string ReturnUrl = "/")
{
User objLoginModel = new User();
objLoginModel.ReturnUrl = ReturnUrl;
return View(objLoginModel);
}

[HttpPost]
public async Task<IActionResult> Login(User objLoginModel)
{
if (ModelState.IsValid)
{
string user = objLoginModel.Username;
string password = objLoginModel.Password;
string role = "";
if (_userService.TryGetUserRole(user, password, out role) != true)
{
//Add logic here to display some message to user
ViewBag.Message = "Invalid Credential";
return View(objLoginModel);
}
else
{
//A claim is a statement about a subject by an issuer and
//represent attributes of the subject that are useful in the context of authentication and authorization operations.
var claims = new List<Claim>() {
new Claim(ClaimTypes.NameIdentifier, Convert.ToString(user)),
new Claim(ClaimTypes.Name, user),
new Claim(ClaimTypes.Role, role),
new Claim("Password", password)
};
//Initialize a new instance of the ClaimsIdentity with the claims and authentication scheme
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
//Initialize a new instance of the ClaimsPrincipal with ClaimsIdentity
var principal = new ClaimsPrincipal(identity);
//SignInAsync is a Extension method for Sign in a principal for the specified scheme.
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, new AuthenticationProperties()
{
IsPersistent = objLoginModel.RememberLogin
});
return LocalRedirect(objLoginModel.ReturnUrl);
}
}
return View(objLoginModel);
}

[Authorize]
public IActionResult Privacy()
{
return View();
Expand Down
17 changes: 14 additions & 3 deletions src/Andy.X.Portal/Controllers/ProducersController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Andy.X.Portal.Services.Producers;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace Andy.X.Portal.Controllers
{
Expand All @@ -14,12 +15,22 @@ public ProducersController(ProducerService producerService)

public IActionResult Index()
{
return View(producerService.GetProducerListViewModel());
var user = new Models.User()
{
Password = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Password").Value,
Username = HttpContext.User.Identity.Name
};
return View(producerService.GetProducerListViewModel(user));
}

public IActionResult Details(string id)
public IActionResult Details(string tenant, string product, string component, string topic, string id)
{
return View(producerService.GetProducerDetailsViewModel(id));
var user = new Models.User()
{
Password = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Password").Value,
Username = HttpContext.User.Identity.Name
};
return View(producerService.GetProducerDetailsViewModel(user, tenant, product, component, topic, id));
}
}
}
17 changes: 15 additions & 2 deletions src/Andy.X.Portal/Controllers/ProductsController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using Andy.X.Portal.Services.Products;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace Andy.X.Portal.Controllers
{
[Authorize]
public class ProductsController : Controller
{
private readonly ProductService productService;
Expand All @@ -14,12 +17,22 @@ public ProductsController(ProductService productService)

public IActionResult Index()
{
return View(productService.GetProductListViewModel());
var user = new Models.User()
{
Password = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Password").Value,
Username = HttpContext.User.Identity.Name
};
return View(productService.GetProductListViewModel(user));
}

public IActionResult Details(string tenant, string id)
{
return View(productService.GetProductDetailsViewModel(tenant, id));
var user = new Models.User()
{
Password = HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Password").Value,
Username = HttpContext.User.Identity.Name
};
return View(productService.GetProductDetailsViewModel(user, tenant, id));
}
}
}
Loading

0 comments on commit 8bd3df3

Please sign in to comment.