mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding some simple UI (and stubbed action) for module installation
--HG-- branch : dev
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Modules.ViewModels;
|
||||
using Orchard.Mvc.Results;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Modules.Controllers {
|
||||
public class AdminController : Controller {
|
||||
@@ -26,7 +30,37 @@ namespace Orchard.Modules.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult Add() {
|
||||
return View(new ModulesIndexViewModel());
|
||||
return View(new ModuleAddViewModel());
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Add")]
|
||||
public ActionResult AddPOST() {
|
||||
// module not used for anything other than display (and that only to not have object in the view 'T')
|
||||
var viewModel = new ModuleAddViewModel();
|
||||
try {
|
||||
UpdateModel(viewModel);
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageModules, T("Couldn't upload module package.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Request.Files[0].FileName)) {
|
||||
ModelState.AddModelError("File", T("Select a file to upload.").ToString());
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return View("add", viewModel);
|
||||
|
||||
foreach (string fileName in Request.Files) {
|
||||
var file = Request.Files[fileName];
|
||||
//todo: upload & process module package
|
||||
}
|
||||
|
||||
//todo: add success message
|
||||
return RedirectToAction("index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Uploading module package failed: {0}", exception.Message));
|
||||
return View("add", viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult Features() {
|
||||
|
@@ -75,7 +75,7 @@
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\ModuleService.cs" />
|
||||
<Compile Include="ViewModels\ModuleEditViewModel.cs" />
|
||||
<Compile Include="ViewModels\ModuleAddViewModel.cs" />
|
||||
<Compile Include="ViewModels\ModulesIndexViewModel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@@ -0,0 +1,6 @@
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Modules.ViewModels {
|
||||
public class ModuleAddViewModel : BaseViewModel {
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Modules.ViewModels {
|
||||
public class ModuleEditViewModel : BaseViewModel {
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@@ -1,2 +1,12 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<object>" %>
|
||||
<h1><%=Html.TitleForPage(T("Install a Module").ToString()) %></h1>
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ModuleAddViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Modules.ViewModels" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<h1><%=Html.TitleForPage(T("Install a Module").ToString()) %></h1><%
|
||||
using (Html.BeginFormAntiForgeryPost(Url.Action("add", new { area = "Orchard.Modules" }), FormMethod.Post, new { enctype = "multipart/form-data" })) { %>
|
||||
<%=Html.ValidationSummary()
|
||||
%><fieldset>
|
||||
<label for="ModulePackage"><%:T("Module Package") %></label>
|
||||
<input type="file" id="ModulePackage" name="ModulePackage" />
|
||||
</fieldset>
|
||||
<button type="submit" class="button primaryAction"><%:T("Install") %></button><%
|
||||
} %>
|
Reference in New Issue
Block a user