#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.34014
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Disco.Web.Areas.Config.Views.Plugins
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Text;
    using System.Web;
    using System.Web.Helpers;
    using System.Web.Mvc;
    using System.Web.Mvc.Ajax;
    using System.Web.Mvc.Html;
    using System.Web.Routing;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.WebPages;
    using Disco;
    using Disco.BI.Extensions;
    using Disco.Models.Repository;
    using Disco.Services;
    using Disco.Services.Authorization;
    
    #line 2 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
    using Disco.Services.Plugins;
    
    #line default
    #line hidden
    using Disco.Services.Web;
    using Disco.Web;
    using Disco.Web.Extensions;
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
    [System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/Plugins/Install.cshtml")]
    public partial class Install : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.Plugins.InstallModel>
    {
        public Install()
        {
        }
        public override void Execute()
        {
            
            #line 3 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
  
    Authorization.Require(Claims.Config.Plugin.Install);

    var canInstallLocal = Authorization.Has(Claims.Config.Plugin.InstallLocal);

    ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Plugins", MVC.Config.Plugins.Index(), "Install Plugin");

            
            #line default
            #line hidden
WriteLiteral("\r\n<div");

WriteLiteral(" id=\"pluginCatalog\"");

WriteLiteral(">\r\n    <h4");

WriteLiteral(" id=\"pluginCatalogHeading\"");

WriteLiteral(">The plugin catalogue [<a");

WriteLiteral(" href=\"https://discoict.com.au/\"");

WriteLiteral(">https://discoict.com.au</a>] was last updated ");

            
            #line 11 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                                                                                                                    Write(CommonHelpers.FriendlyDate((Model.Catalogue.ResponseTimestamp > DateTime.Now ? DateTime.Now : Model.Catalogue.ResponseTimestamp)));

            
            #line default
            #line hidden
WriteLiteral("\r\n    </h4>\r\n");

            
            #line 13 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
    
            
            #line default
            #line hidden
            
            #line 13 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
     if (Model.Catalogue.Plugins.Count == 0)
    { 

            
            #line default
            #line hidden
WriteLiteral("        <div");

WriteLiteral(" class=\"form\"");

WriteLiteral(" style=\"width: 450px; padding: 100px 0;\"");

WriteLiteral(">\r\n            <h2>No Plugins are Available</h2>\r\n        </div>  \r\n");

            
            #line 18 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
    }
    else
    {
        var plugins = Model.Catalogue.Plugins;
        int itemsPerColumn = plugins.Count / 3;
        var itemNextId = 0;

            
            #line default
            #line hidden
WriteLiteral("        <table");

WriteLiteral(" id=\"pageMenu\"");

WriteLiteral(">\r\n            <tr>\r\n");

            
            #line 26 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                
            
            #line default
            #line hidden
            
            #line 26 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                 for (int i = 0; i < 3; i++)
                {

            
            #line default
            #line hidden
WriteLiteral("                    <td>\r\n");

            
            #line 29 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                        
            
            #line default
            #line hidden
            
            #line 29 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                          
                    int itemsForThisColumn = itemsPerColumn + (plugins.Count % 3 > i ? 1 : 0);
                    for (int i2 = 0; i2 < itemsForThisColumn && itemNextId < plugins.Count; i2++)
                    {
                        var plugin = plugins[itemNextId];
                        itemNextId++;
                        var installedPlugin = Plugins.PluginInstalled(plugin.Id) ? Plugins.GetPlugin(plugin.Id) : null;

            
            #line default
            #line hidden
WriteLiteral("                            <div");

WriteAttribute("class", Tuple.Create(" class=\"", 1662), Tuple.Create("\"", 1755)
, Tuple.Create(Tuple.Create("", 1670), Tuple.Create("pageMenuArea", 1670), true)
, Tuple.Create(Tuple.Create(" ", 1682), Tuple.Create("pluginItem", 1683), true)
            
            #line 36 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
, Tuple.Create(Tuple.Create("", 1693), Tuple.Create<System.Object, System.Int32>(installedPlugin != null ? " pluginInstalled" : string.Empty
            
            #line default
            #line hidden
, 1693), false)
);

WriteLiteral(">\r\n                                <h2");

WriteLiteral(" class=\"pluginName\"");

WriteLiteral("><i");

WriteLiteral(" class=\"fa fa-cogs\"");

WriteLiteral("></i>");

            
            #line 37 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                                                            Write(plugin.Name);

            
            #line default
            #line hidden
WriteLiteral("\r\n");

            
            #line 38 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                    
            
            #line default
            #line hidden
            
            #line 38 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                     if (installedPlugin == null)
                                    {

            
            #line default
            #line hidden
WriteLiteral("                                        <a");

WriteLiteral(" class=\"pluginInstallLink button\"");

WriteAttribute("href", Tuple.Create(" href=\"", 2035), Tuple.Create("\"", 2090)
            
            #line 40 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
   , Tuple.Create(Tuple.Create("", 2042), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Plugin.Install(plugin.Id))
            
            #line default
            #line hidden
, 2042), false)
);

WriteLiteral(">Install</a>\r\n");

            
            #line 41 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                    }
                                    else
                                    {
                                        if (Version.Parse(plugin.LatestVersion) > installedPlugin.Version)
                                        {

            
            #line default
            #line hidden
WriteLiteral("                                        <a");

WriteLiteral(" class=\"pluginUpdateLink button\"");

WriteAttribute("href", Tuple.Create(" href=\"", 2450), Tuple.Create("\"", 2504)
            
            #line 46 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
  , Tuple.Create(Tuple.Create("", 2457), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Plugin.Update(plugin.Id))
            
            #line default
            #line hidden
, 2457), false)
);

WriteLiteral(">Update</a>    \r\n");

            
            #line 47 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                        }
                                        else
                                        {

            
            #line default
            #line hidden
WriteLiteral("                                        <a");

WriteLiteral(" class=\"pluginInstalledLink button disabled\"");

WriteLiteral(" href=\"#\"");

WriteLiteral(">Installed</a>    \r\n");

            
            #line 51 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                        }
                                    }

            
            #line default
            #line hidden
WriteLiteral("                                </h2>\r\n                                <div");

WriteLiteral(" class=\"pluginItemBlurb\"");

WriteLiteral(">");

            
            #line 54 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                                         Write(new HtmlString(plugin.Blurb));

            
            #line default
            #line hidden
WriteLiteral("</div>\r\n                                <div");

WriteLiteral(" class=\"pageMenuBlurb\"");

WriteLiteral(">\r\n                                    <span");

WriteLiteral(" class=\"pluginId\"");

WriteLiteral(">");

            
            #line 56 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                                      Write(plugin.Id);

            
            #line default
            #line hidden
WriteLiteral("</span> | <span");

WriteLiteral(" class=\"pluginVersion\"");

WriteLiteral(">v");

            
            #line 56 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                                                                                        Write(plugin.LatestVersion);

            
            #line default
            #line hidden
WriteLiteral("</span> | ");

            
            #line 56 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                                                                                                                        Write(plugin.Author);

            
            #line default
            #line hidden
WriteLiteral(" | <a");

WriteAttribute("href", Tuple.Create(" href=\"", 3211), Tuple.Create("\"", 3229)
            
            #line 56 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                                                                       , Tuple.Create(Tuple.Create("", 3218), Tuple.Create<System.Object, System.Int32>(plugin.Url
            
            #line default
            #line hidden
, 3218), false)
);

WriteLiteral(" title=\"More Information\"");

WriteLiteral(" target=\"_blank\"");

WriteLiteral("><i");

WriteLiteral(" class=\"fa fa-external-link\"");

WriteLiteral("></i></a>\r\n                                </div>\r\n                            </" +
"div>\r\n");

            
            #line 59 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                    }
                        
            
            #line default
            #line hidden
WriteLiteral("\r\n                    </td>\r\n");

            
            #line 62 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                }

            
            #line default
            #line hidden
WriteLiteral("            </tr>\r\n        </table>\r\n");

            
            #line 65 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
    }

            
            #line default
            #line hidden
WriteLiteral("</div>\r\n<div");

WriteLiteral(" id=\"dialogInstallPlugin\"");

WriteLiteral(" title=\"Install this Plugin?\"");

WriteLiteral(">\r\n    <h2");

WriteLiteral(" id=\"dialogInstallPluginName\"");

WriteLiteral("></h2>\r\n    <h4");

WriteLiteral(" id=\"dialogInstallPluginDetails\"");

WriteLiteral("></h4>\r\n\r\n    <div");

WriteLiteral(" style=\"padding: 0.7em 0.7em; margin-top: 8px;\"");

WriteLiteral(" class=\"ui-state-highlight ui-corner-all\"");

WriteLiteral(">\r\n        <i");

WriteLiteral(" class=\"fa fa-exclamation-triangle fa-lg information\"");

WriteLiteral("></i>&nbsp;Warning: All plugins run with the same level of network privileges as " +
"the Disco Web App.<br />\r\n        <strong>Only Install plugins from a trusted so" +
"urce.</strong>\r\n    </div>\r\n</div>\r\n");

            
            #line 76 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
 if (canInstallLocal)
{

            
            #line default
            #line hidden
WriteLiteral("    <div");

WriteLiteral(" id=\"dialogUploadPlugin\"");

WriteLiteral(" title=\"Install Plugin Package\"");

WriteLiteral(">\r\n        <div");

WriteLiteral(" style=\"padding-bottom: 10px;\"");

WriteLiteral(">\r\n");

            
            #line 80 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
            
            
            #line default
            #line hidden
            
            #line 80 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
             using (Html.BeginForm(MVC.API.Plugin.InstallLocal(), FormMethod.Post, new { enctype = "multipart/form-data" }))
            {

            
            #line default
            #line hidden
WriteLiteral("                <label");

WriteLiteral(" for=\"pluginFile\"");

WriteLiteral(">Plugin Package: </label>\r\n");

WriteLiteral("                <input");

WriteLiteral(" id=\"pluginFile\"");

WriteLiteral(" name=\"Plugin\"");

WriteLiteral(" type=\"file\"");

WriteLiteral(" />\r\n");

            
            #line 84 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
            }

            
            #line default
            #line hidden
WriteLiteral("        </div>\r\n        <div");

WriteLiteral(" style=\"padding: 0.7em 0.7em; margin-top: 8px;\"");

WriteLiteral(" class=\"ui-state-error ui-corner-all\"");

WriteLiteral(">\r\n            <i");

WriteLiteral(" class=\"fa fa-exclamation-triangle fa-lg\"");

WriteLiteral("></i>&nbsp;Warning: All plugins run with the same level of network privileges as " +
"the Disco Web App.<br />\r\n            <strong>Only install plugins from a truste" +
"d source.</strong>\r\n        </div>\r\n    </div>\r\n");

            
            #line 91 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
}

            
            #line default
            #line hidden
WriteLiteral("<script>\r\n    $(function () {\r\n        var $selectedPlugin;\r\n        var $selecte" +
"dPluginUrl;\r\n\r\n        // Install\r\n        var $dialogInstall = $(\'#dialogInstal" +
"lPlugin\').dialog({\r\n            resizable: false,\r\n            modal: true,\r\n   " +
"         width: 350,\r\n            autoOpen: false,\r\n            buttons: {\r\n    " +
"            \"Install\": function () {\r\n                    if ($selectedPlugin ==" +
" null || !$selectedPluginUrl) {\r\n                        $(this).dialog(\"close\")" +
";\r\n                        return;\r\n                    }\r\n                    $" +
"(this).dialog(\"disable\");\r\n\r\n                    window.location.href = $selecte" +
"dPluginUrl;\r\n                },\r\n                Cancel: function () {\r\n        " +
"            $selectedPlugin = null;\r\n                    $(this).dialog(\"close\")" +
";\r\n                }\r\n            }\r\n        });\r\n        $(\'#pageMenu\').find(\'a" +
".pluginInstallLink\').click(function () {\r\n            $this = $(this);\r\n\r\n      " +
"      $selectedPlugin = $this.closest(\'.pluginItem\');\r\n            $selectedPlug" +
"inUrl = $this.attr(\'href\');\r\n\r\n            $(\'#dialogInstallPluginName\').text($s" +
"electedPlugin.find(\'.pluginName\').text());\r\n            $(\'#dialogInstallPluginD" +
"etails\').text($selectedPlugin.find(\'.pluginId\').text() + \' | \' + $selectedPlugin" +
".find(\'.pluginVersion\').text());\r\n\r\n            $dialogInstall.dialog(\'option\', " +
"\'title\', \'Install this Plugin?\');\r\n            $dialogInstall.dialog(\'open\');\r\n\r" +
"\n            return false;\r\n        });\r\n        $(\'#pageMenu\').find(\'a.pluginUp" +
"dateLink\').click(function () {\r\n            $this = $(this);\r\n\r\n            $sel" +
"ectedPlugin = $this.closest(\'.pluginItem\');\r\n            $selectedPluginUrl = $t" +
"his.attr(\'href\');\r\n\r\n            $(\'#dialogInstallPluginName\').text($selectedPlu" +
"gin.find(\'.pluginName\').text());\r\n            $(\'#dialogInstallPluginDetails\').t" +
"ext($selectedPlugin.find(\'.pluginId\').text() + \' | \' + $selectedPlugin.find(\'.pl" +
"uginVersion\').text());\r\n\r\n            $dialogInstall.dialog(\'option\', \'title\', \'" +
"Update this Plugin?\');\r\n            $dialogInstall.dialog(\'open\');\r\n\r\n          " +
"  return false;\r\n        });\r\n\r\n");

            
            #line 148 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
        
            
            #line default
            #line hidden
            
            #line 148 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
         if (canInstallLocal)
        {
            
            #line default
            #line hidden
WriteLiteral(@"
        // Upload
        var $dialogUpload = $('#dialogUploadPlugin').dialog({
            resizable: false,
            modal: true,
            width: 350,
            autoOpen: false,
            buttons: {
                ""Upload & Install"": function () {
                    var pluginFile = $('#pluginFile');
                    if (pluginFile.val()) {
                        pluginFile.closest('form').submit();
                        $(this).dialog('disable');
                    } else {
                        alert('Choose a Plugin Package to Upload');
                    }
                },
                Cancel: function () {
                    $(this).dialog(""close"");
                }
            }
        });
        $('#buttonUpload').click(function () {
            $dialogUpload.dialog('open');
            return false;
        });
        ");

            
            #line 175 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
               }

            
            #line default
            #line hidden
WriteLiteral("    });\r\n</script>\r\n<div");

WriteLiteral(" class=\"actionBar\"");

WriteLiteral(">\r\n");

WriteLiteral("    ");

            
            #line 179 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
Write(Html.ActionLinkButton("Update Catalogue", MVC.API.Plugin.UpdateLibraryCatalogue()));

            
            #line default
            #line hidden
WriteLiteral("\r\n");

            
            #line 180 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
    
            
            #line default
            #line hidden
            
            #line 180 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
     if (canInstallLocal)
    {
        
            
            #line default
            #line hidden
            
            #line 182 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
   Write(Html.ActionLinkButton("Install Plugin Package", MVC.API.Plugin.InstallLocal(), "buttonUpload"));

            
            #line default
            #line hidden
            
            #line 182 "..\..\Areas\Config\Views\Plugins\Install.cshtml"
                                                                                                       
    }

            
            #line default
            #line hidden
WriteLiteral("</div>\r\n");

        }
    }
}
#pragma warning restore 1591
