Skip to content

Commit

Permalink
Vendor Management Portal in a Separate Project #431 (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofPajak authored Nov 5, 2023
1 parent 00045e6 commit 0aaf2cd
Show file tree
Hide file tree
Showing 2,152 changed files with 279,900 additions and 92 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,9 @@ src/Web/Grand.Web.Admin/App_Data/DataProtectionKeys/*
src/Web/Grand.Web/App_Data/Download/*
!src/Web/Grand.Web/App_Data/Download/Index.htm
src/Web/Grand.Web/App_Data/TempUploads/*
!src/Web/Grand.Web/App_Data/TempUploads/Index.htm
!src/Web/Grand.Web/App_Data/TempUploads/Index.htm
src/Web/Grand.Web.Vendor/App_Data/InstalledPlugins.cfg
src/Web/Grand.Web.Vendor/App_Data/Settings.cfg
src/Web/Grand.Web.Vendor/Plugins/*
src/Web/Grand.Web.Vendor/App_Data/DataProtectionKeys/*
src/Web/Grand.Web.Vendor/wwwroot/assets/images/thumbs/*.**
7 changes: 7 additions & 0 deletions GrandNode.sln
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grand.Web.Admin.Tests", "sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grand.Web.Common.Tests", "src\Tests\Grand.Web.Common.Tests\Grand.Web.Common.Tests.csproj", "{6969D83E-567C-47A7-8E7F-7FE40940704E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grand.Web.Vendor", "src\Web\Grand.Web.Vendor\Grand.Web.Vendor.csproj", "{061F07B8-067A-43E6-B0FF-250027EE705F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -330,6 +332,10 @@ Global
{6969D83E-567C-47A7-8E7F-7FE40940704E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6969D83E-567C-47A7-8E7F-7FE40940704E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6969D83E-567C-47A7-8E7F-7FE40940704E}.Release|Any CPU.Build.0 = Release|Any CPU
{061F07B8-067A-43E6-B0FF-250027EE705F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{061F07B8-067A-43E6-B0FF-250027EE705F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{061F07B8-067A-43E6-B0FF-250027EE705F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{061F07B8-067A-43E6-B0FF-250027EE705F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -384,6 +390,7 @@ Global
{50049A49-D27E-4200-9875-F6C486FD608D} = {6360202A-F931-4BBD-ADBD-C9A628EE59F8}
{0B2B4B1B-EBF7-447F-9E5F-C55CE3247929} = {6360202A-F931-4BBD-ADBD-C9A628EE59F8}
{6969D83E-567C-47A7-8E7F-7FE40940704E} = {6360202A-F931-4BBD-ADBD-C9A628EE59F8}
{061F07B8-067A-43E6-B0FF-250027EE705F} = {38ECA068-176F-463C-A1D7-044341D4CACB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {88B478F4-FD3B-4C24-9E84-4FAAF0254397}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ public virtual IEnumerable<DefaultPermission> GetDefaultPermissions()
CustomerGroupSystemName = SystemCustomerGroupNames.Vendors,
Permissions = new[]
{
StandardPermission.AccessAdminPanel,
StandardPermission.ManageProducts,
StandardPermission.ManageFiles,
StandardPermission.ManagePictures,
StandardPermission.ManageOrders,
StandardPermission.ManageVendorReviews,
StandardPermission.ManageShipments
StandardPermission.ManageShipments,
StandardPermission.ManageMerchandiseReturns
}
},
new DefaultPermission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,18 @@ protected virtual async Task InstallPages()
Body = "<p>Knowledgebase homepage. You can edit this in the admin site.</p>",
PageLayoutId = defaultPageLayout.Id,
Published = true
}
},
new Page
{
SystemName = "VendorPortalInfo",
IncludeInSitemap = false,
IsPasswordProtected = false,
DisplayOrder = 1,
Title = "Welcome to our Vendor Management Hub!",
Body = "<p>Manage your product catalog, oversee customer orders, and streamline your shipping processes. Your vendor dashboard is the command center for your success. Stay organized, serve your customers efficiently, and watch your business thrive.</p>",
PageLayoutId = defaultPageLayout.Id,
Published = true
}
};
await _pageRepository.InsertAsync(pages);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Grand.Domain.Data;
using Grand.Domain.Pages;
using Grand.Infrastructure.Migrations;
using Microsoft.Extensions.DependencyInjection;

namespace Grand.Business.System.Services.Migrations._2._2;

public class MigrationAddLandingPage: IMigration
{
public int Priority => 0;
public DbVersion Version => new(2, 2);
public Guid Identity => new("0833f104-54d5-41d0-83da-375d2520f709");
public string Name => "Add new landing page - VendorPortalInfo";
public bool UpgradeProcess(IDatabaseContext database, IServiceProvider serviceProvider)
{
var pageLayoutRepository = serviceProvider.GetRequiredService<IRepository<PageLayout>>();
var defaultPageLayout =
pageLayoutRepository.Table.FirstOrDefault(tt => tt.Name == "Default layout");

var repository = serviceProvider.GetRequiredService<IRepository<Page>>();
var page = new Page {
SystemName = "VendorPortalInfo",
IncludeInSitemap = false,
IsPasswordProtected = false,
DisplayOrder = 1,
Title = "Welcome to our Vendor Management Hub!",
Body =
"<p>Manage your product catalog, oversee customer orders, and streamline your shipping processes. Your vendor dashboard is the command center for your success. Stay organized, serve your customers efficiently, and watch your business thrive.</p>",
PageLayoutId = defaultPageLayout?.Id,
Published = true
};
repository.Insert(page);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class MigrationUpdateResourceString : IMigration
{
public int Priority => 0;
public DbVersion Version => new(2, 2);
public Guid Identity => new("40AE285E-247E-4ABA-A892-479F22297580");
public Guid Identity => new("FA844964-DB84-457C-B517-E0EF521AE44B");
public string Name => "Update resource string for english language 2.2";

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public enum TranslationResourceArea
Admin = 1,
Front = 2,
Plugin = 3,
Other = 4
Other = 4,
Vendor = 5
}
}
27 changes: 18 additions & 9 deletions src/Core/Grand.Infrastructure/Validators/FluentValidationFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,31 @@ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionE

foreach (var argument in context.ActionArguments.Where(x => !CommonHelper.IsSimpleType(x.Value?.GetType())))
{
Type genericType = typeof(IValidator<>).MakeGenericType(argument.Value!.GetType());
var validator = (IValidator)_serviceProvider.GetService(genericType);
if (validator is null) continue;
var contextValidator = new ValidationContext<object>(argument.Value);
var result = await validator.ValidateAsync(contextValidator);
if (result.IsValid) continue;

if (!result.IsValid) {
foreach (var error in result.Errors) {
Type targetType = argument.Value!.GetType();
Type[] implementedInterfaces = new[] { targetType }.Concat(targetType.GetInterfaces()).ToArray();
foreach (Type interfaceType in implementedInterfaces)
{
Type genericType = typeof(IValidator<>).MakeGenericType(interfaceType);
var validator = (IValidator)_serviceProvider.GetService(genericType);
if (validator is null)
{
continue;
}
var contextValidator = new ValidationContext<object>(argument.Value);
var result = await validator.ValidateAsync(contextValidator);
if (result.IsValid) continue;
foreach (var error in result.Errors)
{
context.ModelState.AddModelError(error.PropertyName, error.ErrorMessage);
}
}

var hasJsonData = context.HttpContext.Request.ContentType?.Contains("application/json") ?? false;
if (!hasJsonData) continue;
if (context.ModelState.IsValid) continue;
context.Result = new BadRequestObjectResult(context.ModelState);
return;

}

await next();
Expand Down
12 changes: 12 additions & 0 deletions src/Tests/Grand.Web.Admin.Tests/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"Grand.Web.Admin.Tests": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:64107;http://localhost:64108"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
</div>
}
<div class="form-group">
<admin-label asp-for="PaymentStatus" asp-display-hint="false" class="control-label col-3 col-md-3 col-sm-3 pt-2"></admin-label>
<admin-label asp-for="PaymentStatus" asp-display-hint="false" class="control-label col-3 col-md-3 col-sm-3"></admin-label>
<div class="col-9 col-md-9 col-sm-9">
@{
var labelStatus = "";
Expand Down
1 change: 0 additions & 1 deletion src/Web/Grand.Web.Admin/Controllers/BaseAdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace Grand.Web.Admin.Controllers
[AuthorizeAdmin]
[AutoValidateAntiforgeryToken]
[Area(Constants.AreaAdmin)]
[AuthorizeVendor]
[AuthorizeMenu]
public abstract class BaseAdminController : BaseController
{
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Grand.Web.Admin/Controllers/SettingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ public async Task<IActionResult> GeneralCommon()
//datettime settings
var dateTimeSettings = _settingService.LoadSetting<DateTimeSettings>(storeScope);
model.DateTimeSettings.DefaultStoreTimeZoneId = dateTimeSettings.DefaultStoreTimeZoneId;
var iswindows = Infrastructure.OperatingSystem.IsWindows();
var iswindows = Grand.Infrastructure.OperatingSystem.IsWindows();
foreach (TimeZoneInfo timeZone in _dateTimeService.GetSystemTimeZones())
{
var name = iswindows ? timeZone.DisplayName : $"{timeZone.StandardName} ({timeZone.Id})";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Grand.Web.Common.Themes;
using Microsoft.AspNetCore.Mvc.Razor;

namespace Grand.Web.Admin.Infrastructure
{
public class AdminViewLocationExpander : IViewLocationExpander
{
private const string AreaAdminKey = "AdminTheme";


public void PopulateValues(ViewLocationExpanderContext context)
{
if (!(context.AreaName?.Equals("Admin") ?? false)) return;

var themeContext = (IThemeContext)context.ActionContext.HttpContext.RequestServices.GetService(typeof(IThemeContext));
context.Values[AreaAdminKey] = themeContext?.AdminAreaThemeName;
}

public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{

if ((context.AreaName?.Equals("Admin") ?? false) && context.Values.TryGetValue(AreaAdminKey, out var adminTheme))
{
viewLocations = new[] {
$"/Areas/{{2}}/Themes/{adminTheme}/Views/{{1}}/{{0}}.cshtml",
$"/Areas/{{2}}/Themes/{adminTheme}/Views/Shared/{{0}}.cshtml"
}
.Concat(viewLocations);
}
return viewLocations;
}
}
}
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/AddressAttributeProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Common;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Common;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/BlogCategoryProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Blogs;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/CheckoutAttributeProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Orders;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/ContactAttributeProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Messages;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/CountryProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Directory;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/CourseProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Courses;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/CurrencyProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Directory;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/CustomerAttributeProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Customers;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Customers;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/DeliveryDateProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Shipping;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Settings;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Settings;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/MessageTemplateProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Messages;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Messages;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Catalog;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/ProductAttributeProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Catalog;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
1 change: 1 addition & 0 deletions src/Web/Grand.Web.Admin/Mapper/ShippingMethodProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Shipping;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Grand.Infrastructure.Mapper;
using Grand.Web.Admin.Extensions;
using Grand.Web.Admin.Models.Catalog;
using Grand.Web.Common.Extensions;

namespace Grand.Web.Admin.Mapper
{
Expand Down
Loading

0 comments on commit 0aaf2cd

Please sign in to comment.