Update: Plugin Framework Install & UI
This commit is contained in:
@@ -4,12 +4,21 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.BI.Interop.Community;
|
||||
using Disco.Services.Plugins;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class PluginController : dbAdminController
|
||||
{
|
||||
public virtual ActionResult UpdateLibraryCatalogue()
|
||||
{
|
||||
var status = PluginLibraryUpdateTask.ScheduleNow();
|
||||
|
||||
status.SetFinishedUrl(Url.Action(MVC.Config.Plugins.Install()));
|
||||
|
||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(status.SessionId));
|
||||
}
|
||||
|
||||
public virtual ActionResult Uninstall(string id, bool UninstallData)
|
||||
{
|
||||
@@ -23,7 +32,29 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(status.SessionId));
|
||||
}
|
||||
|
||||
public virtual ActionResult Install(HttpPostedFileBase Plugin)
|
||||
public virtual ActionResult Install(string PluginId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(PluginId))
|
||||
throw new ArgumentNullException("PluginId", "A PluginId must be supplied");
|
||||
|
||||
var catalogue = Plugins.LoadCatalogue(dbContext);
|
||||
var plugin = catalogue.Plugins.FirstOrDefault(p => p.Id.Equals(PluginId));
|
||||
|
||||
if (plugin == null)
|
||||
throw new ArgumentNullException("PluginId", "Plugin not found in catalogue");
|
||||
|
||||
// Already Installed?
|
||||
if (Plugins.PluginInstalled(plugin.Id))
|
||||
throw new InvalidOperationException("This plugin is already installed");
|
||||
|
||||
var tempPluginLocation = Path.Combine(dbContext.DiscoConfiguration.PluginPackagesLocation, string.Format("{0}.discoPlugin", plugin.Id));
|
||||
|
||||
var status = InstallPluginTask.InstallPlugin(plugin.LatestDownloadUrl, tempPluginLocation, true);
|
||||
|
||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(status.SessionId));
|
||||
}
|
||||
|
||||
public virtual ActionResult InstallLocal(HttpPostedFileBase Plugin)
|
||||
{
|
||||
if (Plugin == null || Plugin.ContentLength <= 0 || string.IsNullOrWhiteSpace(Plugin.FileName))
|
||||
throw new ArgumentException("A discoPlugin file must be uploaded", "Plugin");
|
||||
@@ -36,10 +67,9 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
if (System.IO.File.Exists(tempPluginLocation))
|
||||
System.IO.File.Delete(tempPluginLocation);
|
||||
|
||||
|
||||
Plugin.SaveAs(tempPluginLocation);
|
||||
|
||||
var status = InstallPluginTask.InstallPlugin(tempPluginLocation, true);
|
||||
var status = InstallPluginTask.InstallLocalPlugin(tempPluginLocation, true);
|
||||
|
||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(status.SessionId));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user