Feature #33: Enhanced Device Importing
Dynamic device importing. better input parsing and 5 additional import fields.
This commit is contained in:
@@ -184,7 +184,7 @@
|
||||
</script>
|
||||
}
|
||||
<div id="Devices_Export_Exporting" class="dialog" title="Exporting Devices...">
|
||||
<h4><i class="fa fa-lg fa-cog fa-spin" title="Please Wait"></i>Device Exporting devices...</h4>
|
||||
<h4><i class="fa fa-lg fa-cog fa-spin" title="Please Wait"></i>Exporting devices...</h4>
|
||||
</div>
|
||||
<div class="actionBar">
|
||||
<a id="Devices_Export_Button" href="#" class="button">Export Devices</a>
|
||||
|
||||
@@ -640,7 +640,7 @@ WriteLiteral(" class=\"fa fa-lg fa-cog fa-spin\"");
|
||||
|
||||
WriteLiteral(" title=\"Please Wait\"");
|
||||
|
||||
WriteLiteral("></i>Device Exporting devices...</h4>\r\n</div>\r\n<div");
|
||||
WriteLiteral("></i>Exporting devices...</h4>\r\n</div>\r\n<div");
|
||||
|
||||
WriteLiteral(" class=\"actionBar\"");
|
||||
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
@model Disco.Web.Models.Device.ImportModel
|
||||
@using Disco.Models.Services.Devices.Importing;
|
||||
@{
|
||||
Authorization.Require(Claims.Device.Actions.Import);
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import Devices");
|
||||
}
|
||||
<div id="Devices_Import">
|
||||
@using (Html.BeginForm(MVC.API.Device.ImportBegin(), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
<div id="importDialog" class="form" style="width: 450px">
|
||||
<h2>Import Devices</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.LabelFor(m => m.ImportFile)
|
||||
</th>
|
||||
<td>
|
||||
<input id="ImportFile" name="ImportFile" type="file" data-val="true" data-val-required="An Import File is required." /><br />
|
||||
@Html.ValidationMessageFor(m => m.ImportFile)
|
||||
<div>
|
||||
@Html.CheckBoxFor(m => m.HasHeader)
|
||||
@Html.LabelFor(m => m.HasHeader)
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="actions">
|
||||
<input type="submit" class="button" value="Begin Import" />
|
||||
</p>
|
||||
</div>
|
||||
<div id="Devices_Import_Loading_Dialog" class="dialog" title="Loading devices import...">
|
||||
<h4><i class="fa fa-lg fa-cog fa-spin" title="Please Wait"></i>Loading device import...</h4>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
var $Devices_Import_Loading_Dialog = null;
|
||||
|
||||
$('#ImportFile').closest('form').submit(function () {
|
||||
if ($Devices_Import_Loading_Dialog == null) {
|
||||
$Devices_Import_Loading_Dialog = $('#Devices_Import_Loading_Dialog').dialog({
|
||||
width: 400,
|
||||
height: 160,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
autoOpen: false
|
||||
});
|
||||
}
|
||||
|
||||
window.setTimeout(function () {
|
||||
$Devices_Import_Loading_Dialog.dialog('open');
|
||||
}, 200);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
<div id="Devices_Import_Documentation">
|
||||
<h3>CSV Import Specification</h3>
|
||||
<h4>Format</h4>
|
||||
<ul>
|
||||
<li>The import file must be in <strong>comma-separated values format</strong> (<a href="http://en.wikipedia.org/wiki/Comma-separated_values" target="_blank">CSV Reference</a>).</li>
|
||||
<li>Be conscious of editors removing leading zeros from serial numbers (ie: Microsoft Excel).</li>
|
||||
</ul>
|
||||
<h4>Fields</h4>
|
||||
<div class="smallMessage">The following fields/columns are available for to the import file. The Device Serial Number is the only required field, all other fields are optional. Fields can appear in any order.</div>
|
||||
<table class="tableData">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 100px;">Field Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var field in Model.HeaderTypes)
|
||||
{
|
||||
<tr>
|
||||
<th>@field.Item2</th>
|
||||
<td>
|
||||
@field.Item3
|
||||
@if (field.Item1 == DeviceImportFieldTypes.DeviceSerialNumber.ToString())
|
||||
{
|
||||
<strong>Required</strong>
|
||||
}
|
||||
else if (field.Item1 == DeviceImportFieldTypes.ModelId.ToString())
|
||||
{
|
||||
<span>(<a href="#" id="Devices_Import_Documentation_DeviceModels_Button">Show IDs</a>)</span>
|
||||
}
|
||||
else if (field.Item1 == DeviceImportFieldTypes.ProfileId.ToString())
|
||||
{
|
||||
<span>(<a href="#" id="Devices_Import_Documentation_DeviceProfiles_Button">Show IDs</a>)</span>
|
||||
}
|
||||
else if (field.Item1 == DeviceImportFieldTypes.BatchId.ToString())
|
||||
{
|
||||
<span>(<a href="#" id="Devices_Import_Documentation_DeviceBatches_Button">Show IDs</a>)</span>
|
||||
}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div id="Devices_Import_Documentation_DeviceModels_Dialog" class="dialog" title="Disco Device Model Ids">
|
||||
<table class="tableData">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Description</th>
|
||||
<th>Manufacturer</th>
|
||||
<th>Model</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var dm in Model.DeviceModels)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.ActionLink(dm.Id.ToString(), MVC.Config.DeviceModel.Index(dm.Id))</td>
|
||||
<td>@dm.ToString()</td>
|
||||
<td>@dm.Manufacturer</td>
|
||||
<td>@dm.Model</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="Devices_Import_Documentation_DeviceProfiles_Dialog" class="dialog" title="Disco Device Profile Ids">
|
||||
<table class="tableData">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Short Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var dp in Model.DeviceProfiles)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.ActionLink(dp.Id.ToString(), MVC.Config.DeviceProfile.Index(dp.Id))</td>
|
||||
<td>@dp.Name</td>
|
||||
<td>@dp.ShortName</td>
|
||||
<td>@dp.Description</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="Devices_Import_Documentation_DeviceBatches_Dialog" class="dialog" title="Disco Device Batch Ids">
|
||||
<table class="tableData">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Purchase Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var db in Model.DeviceBatches)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.ActionLink(db.Id.ToString(), MVC.Config.DeviceBatch.Index(db.Id))</td>
|
||||
<td>@db.Name</td>
|
||||
<td>@CommonHelpers.FriendlyDate(db.PurchaseDate)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
var dialogOptions = {
|
||||
width: 700,
|
||||
height: 600,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
autoOpen: false
|
||||
},
|
||||
$DeviceModelsDialog = null,
|
||||
$DeviceProfilesDialog = null,
|
||||
$DeviceBatchesDialog = null;
|
||||
|
||||
$('#Devices_Import_Documentation_DeviceModels_Button').click(function (e) {
|
||||
e.preventDefault();
|
||||
if (!$DeviceModelsDialog)
|
||||
$DeviceModelsDialog = $('#Devices_Import_Documentation_DeviceModels_Dialog').dialog(dialogOptions);
|
||||
$DeviceModelsDialog.dialog('open');
|
||||
});
|
||||
|
||||
$('#Devices_Import_Documentation_DeviceProfiles_Button').click(function (e) {
|
||||
e.preventDefault();
|
||||
if (!$DeviceProfilesDialog)
|
||||
$DeviceProfilesDialog = $('#Devices_Import_Documentation_DeviceProfiles_Dialog').dialog(dialogOptions);
|
||||
$DeviceProfilesDialog.dialog('open');
|
||||
});
|
||||
$('#Devices_Import_Documentation_DeviceBatches_Button').click(function (e) {
|
||||
e.preventDefault();
|
||||
if (!$DeviceBatchesDialog)
|
||||
$DeviceBatchesDialog = $('#Devices_Import_Documentation_DeviceBatches_Dialog').dialog(dialogOptions);
|
||||
$DeviceBatchesDialog.dialog('open');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
@if (Model.CompletedImportSessionContext != null)
|
||||
{
|
||||
<div id="Devices_Import_Completed_Dialog" class="dialog" title="Device Import Completed">
|
||||
<h3><i class="fa fa-lg fa-check"></i>Successfully imported/updated @Model.CompletedImportSessionContext.AffectedRecords device@(Model.CompletedImportSessionContext.AffectedRecords != 1 ? "s" : null).</h3>
|
||||
<div>File: <code>@Model.CompletedImportSessionContext.Filename</code></div>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
$('#Devices_Import_Completed_Dialog')
|
||||
.dialog({
|
||||
width: 500,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
autoOpen: true,
|
||||
buttons: {
|
||||
Close: function () {
|
||||
$(this).dialog('destroy');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@@ -0,0 +1,698 @@
|
||||
#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.Views.Device
|
||||
{
|
||||
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;
|
||||
|
||||
#line 2 "..\..\Views\Device\Import.cshtml"
|
||||
using Disco.Models.Services.Devices.Importing;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
using Disco.Services;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Views/Device/Import.cshtml")]
|
||||
public partial class Import : Disco.Services.Web.WebViewPage<Disco.Web.Models.Device.ImportModel>
|
||||
{
|
||||
public Import()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 3 "..\..\Views\Device\Import.cshtml"
|
||||
|
||||
Authorization.Require(Claims.Device.Actions.Import);
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import Devices");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n<div");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import\"");
|
||||
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
|
||||
#line 9 "..\..\Views\Device\Import.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 9 "..\..\Views\Device\Import.cshtml"
|
||||
using (Html.BeginForm(MVC.API.Device.ImportBegin(), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" id=\"importDialog\"");
|
||||
|
||||
WriteLiteral(" class=\"form\"");
|
||||
|
||||
WriteLiteral(" style=\"width: 450px\"");
|
||||
|
||||
WriteLiteral(">\r\n <h2>Import Devices</h2>\r\n <table>\r\n <tr>" +
|
||||
"\r\n <th>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 16 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Html.LabelFor(m => m.ImportFile));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </th>\r\n <td>\r\n <i" +
|
||||
"nput");
|
||||
|
||||
WriteLiteral(" id=\"ImportFile\"");
|
||||
|
||||
WriteLiteral(" name=\"ImportFile\"");
|
||||
|
||||
WriteLiteral(" type=\"file\"");
|
||||
|
||||
WriteLiteral(" data-val=\"true\"");
|
||||
|
||||
WriteLiteral(" data-val-required=\"An Import File is required.\"");
|
||||
|
||||
WriteLiteral(" /><br />\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 20 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Html.ValidationMessageFor(m => m.ImportFile));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 22 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Html.CheckBoxFor(m => m.HasHeader));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 23 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Html.LabelFor(m => m.HasHeader));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </div>\r\n </td>\r\n </tr" +
|
||||
">\r\n </table>\r\n <p");
|
||||
|
||||
WriteLiteral(" class=\"actions\"");
|
||||
|
||||
WriteLiteral(">\r\n <input");
|
||||
|
||||
WriteLiteral(" type=\"submit\"");
|
||||
|
||||
WriteLiteral(" class=\"button\"");
|
||||
|
||||
WriteLiteral(" value=\"Begin Import\"");
|
||||
|
||||
WriteLiteral(" />\r\n </p>\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Loading_Dialog\"");
|
||||
|
||||
WriteLiteral(" class=\"dialog\"");
|
||||
|
||||
WriteLiteral(" title=\"Loading devices import...\"");
|
||||
|
||||
WriteLiteral(">\r\n <h4><i");
|
||||
|
||||
WriteLiteral(" class=\"fa fa-lg fa-cog fa-spin\"");
|
||||
|
||||
WriteLiteral(" title=\"Please Wait\"");
|
||||
|
||||
WriteLiteral("></i>Loading device import...</h4>\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(@" <script>
|
||||
$(function () {
|
||||
var $Devices_Import_Loading_Dialog = null;
|
||||
|
||||
$('#ImportFile').closest('form').submit(function () {
|
||||
if ($Devices_Import_Loading_Dialog == null) {
|
||||
$Devices_Import_Loading_Dialog = $('#Devices_Import_Loading_Dialog').dialog({
|
||||
width: 400,
|
||||
height: 160,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
autoOpen: false
|
||||
});
|
||||
}
|
||||
|
||||
window.setTimeout(function () {
|
||||
$Devices_Import_Loading_Dialog.dialog('open');
|
||||
}, 200);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
");
|
||||
|
||||
|
||||
#line 56 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Documentation\"");
|
||||
|
||||
WriteLiteral(">\r\n <h3>CSV Import Specification</h3>\r\n <h4>Format</h4>\r\n <u" +
|
||||
"l>\r\n <li>The import file must be in <strong>comma-separated values fo" +
|
||||
"rmat</strong> (<a");
|
||||
|
||||
WriteLiteral(" href=\"http://en.wikipedia.org/wiki/Comma-separated_values\"");
|
||||
|
||||
WriteLiteral(" target=\"_blank\"");
|
||||
|
||||
WriteLiteral(">CSV Reference</a>).</li>\r\n <li>Be conscious of editors removing leadi" +
|
||||
"ng zeros from serial numbers (ie: Microsoft Excel).</li>\r\n </ul>\r\n " +
|
||||
" <h4>Fields</h4>\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"smallMessage\"");
|
||||
|
||||
WriteLiteral(">The following fields/columns are available for to the import file. The Device Se" +
|
||||
"rial Number is the only required field, all other fields are optional. Fields ca" +
|
||||
"n appear in any order.</div>\r\n <table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(">\r\n <thead>\r\n <tr>\r\n <th");
|
||||
|
||||
WriteLiteral(" style=\"width: 100px;\"");
|
||||
|
||||
WriteLiteral(">Field Name</th>\r\n <th>Description</th>\r\n </tr>" +
|
||||
"\r\n </thead>\r\n <tbody>\r\n");
|
||||
|
||||
|
||||
#line 74 "..\..\Views\Device\Import.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 74 "..\..\Views\Device\Import.cshtml"
|
||||
foreach (var field in Model.HeaderTypes)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n <th>");
|
||||
|
||||
|
||||
#line 77 "..\..\Views\Device\Import.cshtml"
|
||||
Write(field.Item2);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</th>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 79 "..\..\Views\Device\Import.cshtml"
|
||||
Write(field.Item3);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 80 "..\..\Views\Device\Import.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 80 "..\..\Views\Device\Import.cshtml"
|
||||
if (field.Item1 == DeviceImportFieldTypes.DeviceSerialNumber.ToString())
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <strong>Required</strong>\r\n");
|
||||
|
||||
|
||||
#line 83 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
else if (field.Item1 == DeviceImportFieldTypes.ModelId.ToString())
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <span>(<a");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Documentation_DeviceModels_Button\"");
|
||||
|
||||
WriteLiteral(">Show IDs</a>)</span>\r\n");
|
||||
|
||||
|
||||
#line 87 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
else if (field.Item1 == DeviceImportFieldTypes.ProfileId.ToString())
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <span>(<a");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Documentation_DeviceProfiles_Button\"");
|
||||
|
||||
WriteLiteral(">Show IDs</a>)</span>\r\n");
|
||||
|
||||
|
||||
#line 91 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
else if (field.Item1 == DeviceImportFieldTypes.BatchId.ToString())
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <span>(<a");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Documentation_DeviceBatches_Button\"");
|
||||
|
||||
WriteLiteral(">Show IDs</a>)</span>\r\n");
|
||||
|
||||
|
||||
#line 95 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr> \r\n");
|
||||
|
||||
|
||||
#line 99 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tbody>\r\n </table>\r\n\r\n\r\n <div");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Documentation_DeviceModels_Dialog\"");
|
||||
|
||||
WriteLiteral(" class=\"dialog\"");
|
||||
|
||||
WriteLiteral(" title=\"Disco Device Model Ids\"");
|
||||
|
||||
WriteLiteral(">\r\n <table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Description</th>
|
||||
<th>Manufacturer</th>
|
||||
<th>Model</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
");
|
||||
|
||||
|
||||
#line 115 "..\..\Views\Device\Import.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 115 "..\..\Views\Device\Import.cshtml"
|
||||
foreach (var dm in Model.DeviceModels)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n <td>");
|
||||
|
||||
|
||||
#line 118 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Html.ActionLink(dm.Id.ToString(), MVC.Config.DeviceModel.Index(dm.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 119 "..\..\Views\Device\Import.cshtml"
|
||||
Write(dm.ToString());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 120 "..\..\Views\Device\Import.cshtml"
|
||||
Write(dm.Manufacturer);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 121 "..\..\Views\Device\Import.cshtml"
|
||||
Write(dm.Model);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 123 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tbody>\r\n </table>\r\n </div>\r\n\r\n <div");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Documentation_DeviceProfiles_Dialog\"");
|
||||
|
||||
WriteLiteral(" class=\"dialog\"");
|
||||
|
||||
WriteLiteral(" title=\"Disco Device Profile Ids\"");
|
||||
|
||||
WriteLiteral(">\r\n <table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Short Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
");
|
||||
|
||||
|
||||
#line 139 "..\..\Views\Device\Import.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 139 "..\..\Views\Device\Import.cshtml"
|
||||
foreach (var dp in Model.DeviceProfiles)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n <td>");
|
||||
|
||||
|
||||
#line 142 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Html.ActionLink(dp.Id.ToString(), MVC.Config.DeviceProfile.Index(dp.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 143 "..\..\Views\Device\Import.cshtml"
|
||||
Write(dp.Name);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 144 "..\..\Views\Device\Import.cshtml"
|
||||
Write(dp.ShortName);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 145 "..\..\Views\Device\Import.cshtml"
|
||||
Write(dp.Description);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 147 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tbody>\r\n </table>\r\n </div>\r\n\r\n <div");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Documentation_DeviceBatches_Dialog\"");
|
||||
|
||||
WriteLiteral(" class=\"dialog\"");
|
||||
|
||||
WriteLiteral(" title=\"Disco Device Batch Ids\"");
|
||||
|
||||
WriteLiteral(">\r\n <table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Purchase Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
");
|
||||
|
||||
|
||||
#line 162 "..\..\Views\Device\Import.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 162 "..\..\Views\Device\Import.cshtml"
|
||||
foreach (var db in Model.DeviceBatches)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n <td>");
|
||||
|
||||
|
||||
#line 165 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Html.ActionLink(db.Id.ToString(), MVC.Config.DeviceBatch.Index(db.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 166 "..\..\Views\Device\Import.cshtml"
|
||||
Write(db.Name);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 167 "..\..\Views\Device\Import.cshtml"
|
||||
Write(CommonHelpers.FriendlyDate(db.PurchaseDate));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 169 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tbody>\r\n </table>\r\n </div>\r\n\r\n <script" +
|
||||
">\r\n $(function () {\r\n var dialogOptions = {\r\n " +
|
||||
" width: 700,\r\n height: 600,\r\n re" +
|
||||
"sizable: false,\r\n modal: true,\r\n autoOpen:" +
|
||||
" false\r\n },\r\n $DeviceModelsDialog = null,\r\n " +
|
||||
" $DeviceProfilesDialog = null,\r\n $DeviceBatchesDialog = n" +
|
||||
"ull;\r\n\r\n $(\'#Devices_Import_Documentation_DeviceModels_Button\').c" +
|
||||
"lick(function (e) {\r\n e.preventDefault();\r\n " +
|
||||
" if (!$DeviceModelsDialog)\r\n $DeviceModelsDialog = $(\'#D" +
|
||||
"evices_Import_Documentation_DeviceModels_Dialog\').dialog(dialogOptions);\r\n " +
|
||||
" $DeviceModelsDialog.dialog(\'open\');\r\n });\r\n\r\n " +
|
||||
" $(\'#Devices_Import_Documentation_DeviceProfiles_Button\').click(functio" +
|
||||
"n (e) {\r\n e.preventDefault();\r\n if (!$Devi" +
|
||||
"ceProfilesDialog)\r\n $DeviceProfilesDialog = $(\'#Devices_I" +
|
||||
"mport_Documentation_DeviceProfiles_Dialog\').dialog(dialogOptions);\r\n " +
|
||||
" $DeviceProfilesDialog.dialog(\'open\');\r\n });\r\n " +
|
||||
" $(\'#Devices_Import_Documentation_DeviceBatches_Button\').click(function (e) {" +
|
||||
"\r\n e.preventDefault();\r\n if (!$DeviceBatch" +
|
||||
"esDialog)\r\n $DeviceBatchesDialog = $(\'#Devices_Import_Doc" +
|
||||
"umentation_DeviceBatches_Dialog\').dialog(dialogOptions);\r\n $D" +
|
||||
"eviceBatchesDialog.dialog(\'open\');\r\n });\r\n });\r\n " +
|
||||
" </script>\r\n </div>\r\n</div>\r\n");
|
||||
|
||||
|
||||
#line 210 "..\..\Views\Device\Import.cshtml"
|
||||
if (Model.CompletedImportSessionContext != null)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Completed_Dialog\"");
|
||||
|
||||
WriteLiteral(" class=\"dialog\"");
|
||||
|
||||
WriteLiteral(" title=\"Device Import Completed\"");
|
||||
|
||||
WriteLiteral(">\r\n <h3><i");
|
||||
|
||||
WriteLiteral(" class=\"fa fa-lg fa-check\"");
|
||||
|
||||
WriteLiteral("></i>Successfully imported/updated ");
|
||||
|
||||
|
||||
#line 213 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Model.CompletedImportSessionContext.AffectedRecords);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" device");
|
||||
|
||||
|
||||
#line 213 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Model.CompletedImportSessionContext.AffectedRecords != 1 ? "s" : null);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(".</h3>\r\n <div>File: <code>");
|
||||
|
||||
|
||||
#line 214 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Model.CompletedImportSessionContext.Filename);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</code></div>\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(@" <script>
|
||||
$(function () {
|
||||
$('#Devices_Import_Completed_Dialog')
|
||||
.dialog({
|
||||
width: 500,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
autoOpen: true,
|
||||
buttons: {
|
||||
Close: function () {
|
||||
$(this).dialog('destroy');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
");
|
||||
|
||||
|
||||
#line 232 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -1,192 +0,0 @@
|
||||
@model Disco.Web.Models.Device.ImportModel
|
||||
@{
|
||||
Authorization.RequireAny(Claims.Device.Actions.Import, Claims.Device.Actions.Export);
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import/Export Devices");
|
||||
}
|
||||
@if (Authorization.Has(Claims.Device.Actions.Import)){
|
||||
<div id="deviceImport">
|
||||
@using (Html.BeginForm(MVC.API.Device.ImportParse(), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
@Html.ValidationSummary()
|
||||
<div id="importDialog" class="form" style="width: 450px">
|
||||
<h2>Import Devices</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.LabelFor(m => m.ImportFile)
|
||||
</th>
|
||||
<td>
|
||||
<input id="ImportFile" name="ImportFile" type="file" data-val="true" data-val-required="An Import File is required." />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="actions">
|
||||
<input type="submit" class="button" value="Import" />
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
<div id="documentation">
|
||||
<h3>CSV Import Specification</h3>
|
||||
<h4>Format</h4>
|
||||
<ul>
|
||||
<li>The import file must be in <strong>comma-separated values format</strong> (<a href="http://en.wikipedia.org/wiki/Comma-separated_values" target="_blank">CSV Reference</a>).</li>
|
||||
<li>The <strong>first line will be ignored</strong> (it is assumed the file includes headers).</li>
|
||||
<li>Be conscious of editors removing leading zeros from serial numbers (ie: Microsoft Excel).</li>
|
||||
</ul>
|
||||
<h4>Fields</h4>
|
||||
<div class="smallMessage">The following fields/columns are available for to the import file. The <strong>order of the fields</strong> must be as shown below.</div>
|
||||
<table class="tableData">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 100px;">Field Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Serial Number</th>
|
||||
<td><strong>Required</strong> - must contain the device serial number (maximum of 60 characters).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Device Model</th>
|
||||
<td>The <span class="code">ID</span> for the Device Model (<a href="#" id="showDeviceModels">Show IDs</a>). <em>Default: <span class="code">1</span> [@Html.ActionLink(Model.DeviceModels[0].ToString(), MVC.Config.DeviceModel.Index(Model.DeviceModels[0].Id))]</em>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Device Profile</th>
|
||||
<td>The <span class="code">ID</span> for the Device Profile (<a href="#" id="showDeviceProfiles">Show IDs</a>). <em>Default: <span class="code">1</span> [@Html.ActionLink(Model.DeviceProfiles[0].ToString(), MVC.Config.DeviceProfile.Index(Model.DeviceProfiles[0].Id))]</em>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Device Batch</th>
|
||||
<td>The <span class="code">ID</span> for the Device Batch (<a href="#" id="showDeviceBatches">Show IDs</a>). <em>Default: <span class="code"><None></span></em>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Assigned User</th>
|
||||
<td>The <span class="code">ID</span> for the User assigned to the device. <em>Default: <span class="code"><None></span></em>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Location</th>
|
||||
<td>Updates the Location of the device. Maximum of 250 characters. <em>Default: <span class="code"><None></span></em>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Asset Number</th>
|
||||
<td>Updates the Asset Number of the device. Maximum of 40 characters. <em>Default: <span class="code"><None></span></em>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div id="showDeviceModelsDialog" class="hiddenDialog" title="Disco Device Model Ids">
|
||||
<table class="tableData">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Description</th>
|
||||
<th>Manufacturer</th>
|
||||
<th>Model</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var dm in Model.DeviceModels)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.ActionLink(dm.Id.ToString(), MVC.Config.DeviceModel.Index(dm.Id))</td>
|
||||
<td>@dm.ToString()</td>
|
||||
<td>@dm.Manufacturer</td>
|
||||
<td>@dm.Model</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="showDeviceProfilesDialog" class="hiddenDialog" title="Disco Device Profile Ids">
|
||||
<table class="tableData">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Short Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var dp in Model.DeviceProfiles)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.ActionLink(dp.Id.ToString(), MVC.Config.DeviceProfile.Index(dp.Id))</td>
|
||||
<td>@dp.Name</td>
|
||||
<td>@dp.ShortName</td>
|
||||
<td>@dp.Description</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="showDeviceBatchesDialog" class="hiddenDialog" title="Disco Device Batch Ids">
|
||||
<table class="tableData">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Purchase Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var db in Model.DeviceBatches)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.ActionLink(db.Id.ToString(), MVC.Config.DeviceBatch.Index(db.Id))</td>
|
||||
<td>@db.Name</td>
|
||||
<td>@CommonHelpers.FriendlyDate(db.PurchaseDate)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
var dialogOptions = {
|
||||
width: 700,
|
||||
height: 600,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
autoOpen: false
|
||||
},
|
||||
$showDeviceModelsDialog = null,
|
||||
$showDeviceProfilesDialog = null,
|
||||
$showDeviceBatchesDialog = null;
|
||||
|
||||
$('#showDeviceModels').click(function (e) {
|
||||
e.preventDefault();
|
||||
if (!$showDeviceModelsDialog)
|
||||
$showDeviceModelsDialog = $('#showDeviceModelsDialog').dialog(dialogOptions);
|
||||
$showDeviceModelsDialog.dialog('open');
|
||||
});
|
||||
|
||||
$('#showDeviceProfiles').click(function (e) {
|
||||
e.preventDefault();
|
||||
if (!$showDeviceProfilesDialog)
|
||||
$showDeviceProfilesDialog = $('#showDeviceProfilesDialog').dialog(dialogOptions);
|
||||
$showDeviceProfilesDialog.dialog('open');
|
||||
});
|
||||
$('#showDeviceBatches').click(function (e) {
|
||||
e.preventDefault();
|
||||
if (!$showDeviceBatchesDialog)
|
||||
$showDeviceBatchesDialog = $('#showDeviceBatchesDialog').dialog(dialogOptions);
|
||||
$showDeviceBatchesDialog.dialog('open');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -1,553 +0,0 @@
|
||||
#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.Views.Device
|
||||
{
|
||||
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;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Views/Device/ImportExport.cshtml")]
|
||||
public partial class ImportExport : Disco.Services.Web.WebViewPage<Disco.Web.Models.Device.ImportModel>
|
||||
{
|
||||
public ImportExport()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Views\Device\ImportExport.cshtml"
|
||||
|
||||
Authorization.RequireAny(Claims.Device.Actions.Import, Claims.Device.Actions.Export);
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import/Export Devices");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 7 "..\..\Views\Device\ImportExport.cshtml"
|
||||
if (Authorization.Has(Claims.Device.Actions.Import)){
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("<div");
|
||||
|
||||
WriteLiteral(" id=\"deviceImport\"");
|
||||
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
|
||||
#line 9 "..\..\Views\Device\ImportExport.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 9 "..\..\Views\Device\ImportExport.cshtml"
|
||||
using (Html.BeginForm(MVC.API.Device.ImportParse(), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 11 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(Html.ValidationSummary());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 11 "..\..\Views\Device\ImportExport.cshtml"
|
||||
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" id=\"importDialog\"");
|
||||
|
||||
WriteLiteral(" class=\"form\"");
|
||||
|
||||
WriteLiteral(" style=\"width: 450px\"");
|
||||
|
||||
WriteLiteral(">\r\n <h2>Import Devices</h2>\r\n <table>\r\n <tr>" +
|
||||
"\r\n <th>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 17 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(Html.LabelFor(m => m.ImportFile));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </th>\r\n <td>\r\n <i" +
|
||||
"nput");
|
||||
|
||||
WriteLiteral(" id=\"ImportFile\"");
|
||||
|
||||
WriteLiteral(" name=\"ImportFile\"");
|
||||
|
||||
WriteLiteral(" type=\"file\"");
|
||||
|
||||
WriteLiteral(" data-val=\"true\"");
|
||||
|
||||
WriteLiteral(" data-val-required=\"An Import File is required.\"");
|
||||
|
||||
WriteLiteral(" />\r\n </td>\r\n </tr>\r\n </table>\r\n " +
|
||||
" <p");
|
||||
|
||||
WriteLiteral(" class=\"actions\"");
|
||||
|
||||
WriteLiteral(">\r\n <input");
|
||||
|
||||
WriteLiteral(" type=\"submit\"");
|
||||
|
||||
WriteLiteral(" class=\"button\"");
|
||||
|
||||
WriteLiteral(" value=\"Import\"");
|
||||
|
||||
WriteLiteral(" />\r\n </p>\r\n </div>\r\n");
|
||||
|
||||
|
||||
#line 28 "..\..\Views\Device\ImportExport.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" id=\"documentation\"");
|
||||
|
||||
WriteLiteral(">\r\n <h3>CSV Import Specification</h3>\r\n <h4>Format</h4>\r\n <u" +
|
||||
"l>\r\n <li>The import file must be in <strong>comma-separated values fo" +
|
||||
"rmat</strong> (<a");
|
||||
|
||||
WriteLiteral(" href=\"http://en.wikipedia.org/wiki/Comma-separated_values\"");
|
||||
|
||||
WriteLiteral(" target=\"_blank\"");
|
||||
|
||||
WriteLiteral(@">CSV Reference</a>).</li>
|
||||
<li>The <strong>first line will be ignored</strong> (it is assumed the file includes headers).</li>
|
||||
<li>Be conscious of editors removing leading zeros from serial numbers (ie: Microsoft Excel).</li>
|
||||
</ul>
|
||||
<h4>Fields</h4>
|
||||
<div");
|
||||
|
||||
WriteLiteral(" class=\"smallMessage\"");
|
||||
|
||||
WriteLiteral(">The following fields/columns are available for to the import file. The <strong>o" +
|
||||
"rder of the fields</strong> must be as shown below.</div>\r\n <table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(">\r\n <thead>\r\n <tr>\r\n <th");
|
||||
|
||||
WriteLiteral(" style=\"width: 100px;\"");
|
||||
|
||||
WriteLiteral(@">Field Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Serial Number</th>
|
||||
<td><strong>Required</strong> - must contain the device serial number (maximum of 60 characters).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Device Model</th>
|
||||
<td>The <span");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteLiteral(">ID</span> for the Device Model (<a");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(" id=\"showDeviceModels\"");
|
||||
|
||||
WriteLiteral(">Show IDs</a>). <em>Default: <span");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteLiteral(">1</span> [");
|
||||
|
||||
|
||||
#line 54 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(Html.ActionLink(Model.DeviceModels[0].ToString(), MVC.Config.DeviceModel.Index(Model.DeviceModels[0].Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("]</em>\r\n </td>\r\n </tr>\r\n <tr>\r\n " +
|
||||
" <th>Device Profile</th>\r\n <td>The <span");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteLiteral(">ID</span> for the Device Profile (<a");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(" id=\"showDeviceProfiles\"");
|
||||
|
||||
WriteLiteral(">Show IDs</a>). <em>Default: <span");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteLiteral(">1</span> [");
|
||||
|
||||
|
||||
#line 59 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(Html.ActionLink(Model.DeviceProfiles[0].ToString(), MVC.Config.DeviceProfile.Index(Model.DeviceProfiles[0].Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("]</em>\r\n </td>\r\n </tr>\r\n <tr>\r\n " +
|
||||
" <th>Device Batch</th>\r\n <td>The <span");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteLiteral(">ID</span> for the Device Batch (<a");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(" id=\"showDeviceBatches\"");
|
||||
|
||||
WriteLiteral(">Show IDs</a>). <em>Default: <span");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteLiteral("><None></span></em>\r\n </td>\r\n </tr>\r\n " +
|
||||
" <tr>\r\n <th>Assigned User</th>\r\n " +
|
||||
" <td>The <span");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteLiteral(">ID</span> for the User assigned to the device. <em>Default: <span");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteLiteral("><None></span></em>\r\n </td>\r\n </tr>\r\n " +
|
||||
" <tr>\r\n <th>Location</th>\r\n <td" +
|
||||
">Updates the Location of the device. Maximum of 250 characters. <em>Default: <sp" +
|
||||
"an");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteLiteral("><None></span></em>\r\n </td>\r\n </tr>\r\n " +
|
||||
" <tr>\r\n <th>Asset Number</th>\r\n " +
|
||||
" <td>Updates the Asset Number of the device. Maximum of 40 characters. <em>Defau" +
|
||||
"lt: <span");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteLiteral("><None></span></em>\r\n </td>\r\n </tr>\r\n " +
|
||||
" </tbody>\r\n </table>\r\n\r\n\r\n <div");
|
||||
|
||||
WriteLiteral(" id=\"showDeviceModelsDialog\"");
|
||||
|
||||
WriteLiteral(" class=\"hiddenDialog\"");
|
||||
|
||||
WriteLiteral(" title=\"Disco Device Model Ids\"");
|
||||
|
||||
WriteLiteral(">\r\n <table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Description</th>
|
||||
<th>Manufacturer</th>
|
||||
<th>Model</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
");
|
||||
|
||||
|
||||
#line 97 "..\..\Views\Device\ImportExport.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 97 "..\..\Views\Device\ImportExport.cshtml"
|
||||
foreach (var dm in Model.DeviceModels)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n <td>");
|
||||
|
||||
|
||||
#line 100 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(Html.ActionLink(dm.Id.ToString(), MVC.Config.DeviceModel.Index(dm.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 101 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(dm.ToString());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 102 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(dm.Manufacturer);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 103 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(dm.Model);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 105 "..\..\Views\Device\ImportExport.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tbody>\r\n </table>\r\n </div>\r\n\r\n <div");
|
||||
|
||||
WriteLiteral(" id=\"showDeviceProfilesDialog\"");
|
||||
|
||||
WriteLiteral(" class=\"hiddenDialog\"");
|
||||
|
||||
WriteLiteral(" title=\"Disco Device Profile Ids\"");
|
||||
|
||||
WriteLiteral(">\r\n <table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Short Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
");
|
||||
|
||||
|
||||
#line 121 "..\..\Views\Device\ImportExport.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 121 "..\..\Views\Device\ImportExport.cshtml"
|
||||
foreach (var dp in Model.DeviceProfiles)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n <td>");
|
||||
|
||||
|
||||
#line 124 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(Html.ActionLink(dp.Id.ToString(), MVC.Config.DeviceProfile.Index(dp.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 125 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(dp.Name);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 126 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(dp.ShortName);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 127 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(dp.Description);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 129 "..\..\Views\Device\ImportExport.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tbody>\r\n </table>\r\n </div>\r\n\r\n <div");
|
||||
|
||||
WriteLiteral(" id=\"showDeviceBatchesDialog\"");
|
||||
|
||||
WriteLiteral(" class=\"hiddenDialog\"");
|
||||
|
||||
WriteLiteral(" title=\"Disco Device Batch Ids\"");
|
||||
|
||||
WriteLiteral(">\r\n <table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Purchase Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
");
|
||||
|
||||
|
||||
#line 144 "..\..\Views\Device\ImportExport.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 144 "..\..\Views\Device\ImportExport.cshtml"
|
||||
foreach (var db in Model.DeviceBatches)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n <td>");
|
||||
|
||||
|
||||
#line 147 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(Html.ActionLink(db.Id.ToString(), MVC.Config.DeviceBatch.Index(db.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 148 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(db.Name);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n <td>");
|
||||
|
||||
|
||||
#line 149 "..\..\Views\Device\ImportExport.cshtml"
|
||||
Write(CommonHelpers.FriendlyDate(db.PurchaseDate));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 151 "..\..\Views\Device\ImportExport.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tbody>\r\n </table>\r\n </div>\r\n\r\n <script" +
|
||||
">\r\n $(function () {\r\n var dialogOptions = {\r\n " +
|
||||
" width: 700,\r\n height: 600,\r\n re" +
|
||||
"sizable: false,\r\n modal: true,\r\n autoOpen:" +
|
||||
" false\r\n },\r\n $showDeviceModelsDialog = null,\r\n " +
|
||||
" $showDeviceProfilesDialog = null,\r\n $showDeviceBatch" +
|
||||
"esDialog = null;\r\n\r\n $(\'#showDeviceModels\').click(function (e) {\r" +
|
||||
"\n e.preventDefault();\r\n if (!$showDeviceMo" +
|
||||
"delsDialog)\r\n $showDeviceModelsDialog = $(\'#showDeviceMod" +
|
||||
"elsDialog\').dialog(dialogOptions);\r\n $showDeviceModelsDialog." +
|
||||
"dialog(\'open\');\r\n });\r\n\r\n $(\'#showDeviceProfiles\')" +
|
||||
".click(function (e) {\r\n e.preventDefault();\r\n " +
|
||||
" if (!$showDeviceProfilesDialog)\r\n $showDeviceProfiles" +
|
||||
"Dialog = $(\'#showDeviceProfilesDialog\').dialog(dialogOptions);\r\n " +
|
||||
" $showDeviceProfilesDialog.dialog(\'open\');\r\n });\r\n " +
|
||||
" $(\'#showDeviceBatches\').click(function (e) {\r\n e.preventD" +
|
||||
"efault();\r\n if (!$showDeviceBatchesDialog)\r\n " +
|
||||
" $showDeviceBatchesDialog = $(\'#showDeviceBatchesDialog\').dialog(dialogOpt" +
|
||||
"ions);\r\n $showDeviceBatchesDialog.dialog(\'open\');\r\n " +
|
||||
" });\r\n });\r\n </script>\r\n </div>\r\n</div>\r\n");
|
||||
|
||||
|
||||
#line 192 "..\..\Views\Device\ImportExport.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,183 @@
|
||||
@model Disco.Web.Models.Device.ImportHeadersModel
|
||||
@{
|
||||
Authorization.Require(Claims.Device.Actions.Import);
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import Devices", MVC.Device.Import(), string.Format("File: {0}", Model.Context.Filename));
|
||||
}
|
||||
<div id="Devices_Import_Headers">
|
||||
|
||||
<h2>Define Import Columns</h2>
|
||||
|
||||
@if (Model.Context.RawData.Count > 10)
|
||||
{
|
||||
<h4 class="alert">@Model.Context.RawData.Count records were loaded, only the first 10 are shown here.</h4>
|
||||
}
|
||||
|
||||
<h4 id="Devices_Import_Headers_DeviceSerialNumberRequired" class="error">The Device Serial Number column must be defined.</h4>
|
||||
|
||||
<div id="Devices_Import_Headers_TableContainer">
|
||||
<table class="tableData">
|
||||
<thead>
|
||||
<tr>
|
||||
@foreach (var header in Model.Context.Header.Select((h, i) => Tuple.Create(h, i)))
|
||||
{
|
||||
<th data-headerindex="@header.Item2" class="header@(header.Item1.Item2.ToString())">@header.Item1.Item1</th>
|
||||
}
|
||||
</tr>
|
||||
<tr>
|
||||
@foreach (var header in Model.Context.Header.Select((h, i) => Tuple.Create(h, i)))
|
||||
{
|
||||
<td data-headerindex="@header.Item2" class="header@(header.Item1.Item2.ToString())">
|
||||
<ul class="importHeaderType" data-headerindex="@header.Item2" data-headertype="@header.Item1.Item2.ToString()">
|
||||
<li><a href="#"><span class="headerTypeTitle">@(Model.HeaderTypes.FirstOrDefault(h => h.Item1 == header.Item1.Item2).Item2)</span></a>
|
||||
<ul>
|
||||
@foreach (var headerType in Model.HeaderTypes)
|
||||
{
|
||||
<li data-headertype="@headerType.Item1"><a href="#">@headerType.Item2</a></li>
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in Model.Context.RawData.Take(10))
|
||||
{
|
||||
<tr>
|
||||
@foreach (var field in record.Select((h, i) => Tuple.Create(h, i)))
|
||||
{
|
||||
<td data-headerindex="@field.Item2">@field.Item1</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="actionBar">
|
||||
@using (Html.BeginForm(MVC.API.Device.ImportParse(Model.Context.SessionId, null)))
|
||||
{
|
||||
<a id="Devices_Import_Headers_Submit" href="#" class="button">Parse Device Import</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div id="Devices_Import_Parsing_Dialog" class="dialog" title="Parsing devices import...">
|
||||
<h4><i class="fa fa-lg fa-cog fa-spin" title="Please Wait"></i>Parsing device import...</h4>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
var headerTypes = {
|
||||
@foreach (var h in Model.HeaderTypes)
|
||||
{
|
||||
<text>'@(h.Item1)': '@(h.Item2)',</text>
|
||||
}
|
||||
};
|
||||
|
||||
var $Devices_Import_Headers_TableContainer = $('#Devices_Import_Headers_TableContainer');
|
||||
var $importHeaderTypes = $Devices_Import_Headers_TableContainer.find('thead').find('ul.importHeaderType');
|
||||
var $Devices_Import_Headers_DeviceSerialNumberRequired = $('#Devices_Import_Headers_DeviceSerialNumberRequired');
|
||||
var $Devices_Import_Headers_Submit = $('#Devices_Import_Headers_Submit');
|
||||
var $Devices_Import_Parsing_Dialog = null;
|
||||
|
||||
function getUsedHeaders() {
|
||||
return $importHeaderTypes.map(function () { return $(this).attr('data-headertype'); }).filter(function () { return this != 'IgnoreColumn' }).get();
|
||||
}
|
||||
|
||||
function updateHeaderOptions() {
|
||||
var usedHeaders = getUsedHeaders();
|
||||
var deviceSerialNumberPresent = (usedHeaders.indexOf('DeviceSerialNumber') >= 0);
|
||||
|
||||
if (deviceSerialNumberPresent) {
|
||||
$Devices_Import_Headers_Submit.attr('disabled', null);
|
||||
$Devices_Import_Headers_DeviceSerialNumberRequired.hide();
|
||||
} else {
|
||||
$Devices_Import_Headers_DeviceSerialNumberRequired.show();
|
||||
$Devices_Import_Headers_Submit.attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
$importHeaderTypes.each(function () {
|
||||
var $header = $(this);
|
||||
var $headerType = $header.attr('data-headertype');
|
||||
$header.find('li[data-headertype]').each(function () {
|
||||
var $headerOption = $(this);
|
||||
var $headerOptionType = $headerOption.attr('data-headertype');
|
||||
if ($headerOptionType === $headerType) {
|
||||
$headerOption.removeClass('ui-state-disabled');
|
||||
$headerOption.addClass('ui-state-highlight');
|
||||
} else if (usedHeaders.indexOf($headerOptionType) < 0) {
|
||||
$headerOption.removeClass('ui-state-disabled ui-state-highlight');
|
||||
} else {
|
||||
$headerOption.removeClass('ui-state-highlight');
|
||||
$headerOption.addClass('ui-state-disabled');
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function updateDataStyle(index, headerType) {
|
||||
$Devices_Import_Headers_TableContainer.find('tbody').find('td[data-headerindex="' + index + '"]').removeClass().addClass('header' + headerType);
|
||||
$Devices_Import_Headers_TableContainer.find('thead').find('td[data-headerindex="' + index + '"], th[data-headerindex="' + index + '"]').removeClass().addClass('header' + headerType);
|
||||
}
|
||||
|
||||
$Devices_Import_Headers_TableContainer.find('thead').on('menuselect', 'ul.importHeaderType', function (e, ui) {
|
||||
var headerType = ui.item.attr('data-headertype');
|
||||
|
||||
if (headerType !== undefined) {
|
||||
var $this = $(this).closest('ul.importHeaderType');
|
||||
var headerIndex = $this.attr('data-headerindex');
|
||||
var headerTypeName = headerTypes[headerType];
|
||||
$this.attr('data-headertype', headerType).find('span.headerTypeTitle').text(headerTypeName);
|
||||
updateDataStyle(headerIndex, headerType);
|
||||
updateHeaderOptions();
|
||||
}
|
||||
});
|
||||
|
||||
// Add Type Options
|
||||
$importHeaderTypes.each(function () {
|
||||
var $this = $(this);
|
||||
var thisHeaderIndex = $this.attr('data-headerindex');
|
||||
var thisHeaderType = $this.attr('data-headertype');
|
||||
updateDataStyle(thisHeaderIndex, thisHeaderType);
|
||||
}).menu({ position: { my: "left top", at: "left bottom" } });
|
||||
|
||||
updateHeaderOptions();
|
||||
|
||||
$('#Devices_Import_Headers_Submit').click(function () {
|
||||
|
||||
// Validate Device Serial Number Present
|
||||
var usedHeaders = getUsedHeaders();
|
||||
var deviceSerialNumberPresent = (usedHeaders.indexOf('DeviceSerialNumber') >= 0);
|
||||
if (!deviceSerialNumberPresent) {
|
||||
updateHeaderOptions();
|
||||
$Devices_Import_Headers_DeviceSerialNumberRequired.show('highlight');
|
||||
} else {
|
||||
var $form = $(this).closest('form');
|
||||
|
||||
// Build Form
|
||||
$importHeaderTypes.each(function () {
|
||||
var $this = $(this);
|
||||
var thisHeaderIndex = $this.attr('data-headerindex');
|
||||
var thisHeaderType = $this.attr('data-headertype');
|
||||
|
||||
$(document.createElement('input')).attr({ type: 'hidden', name: 'Headers[' + thisHeaderIndex + ']', value: thisHeaderType }).appendTo($form);
|
||||
});
|
||||
|
||||
// Submit Form
|
||||
if ($Devices_Import_Parsing_Dialog == null) {
|
||||
$Devices_Import_Parsing_Dialog = $('#Devices_Import_Parsing_Dialog').dialog({
|
||||
width: 400,
|
||||
height: 160,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
autoOpen: false
|
||||
});
|
||||
}
|
||||
$Devices_Import_Parsing_Dialog.dialog('open');
|
||||
$form.submit();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,557 @@
|
||||
#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.Views.Device
|
||||
{
|
||||
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;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Views/Device/ImportHeaders.cshtml")]
|
||||
public partial class ImportHeaders : Disco.Services.Web.WebViewPage<Disco.Web.Models.Device.ImportHeadersModel>
|
||||
{
|
||||
public ImportHeaders()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
|
||||
Authorization.Require(Claims.Device.Actions.Import);
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import Devices", MVC.Device.Import(), string.Format("File: {0}", Model.Context.Filename));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n<div");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Headers\"");
|
||||
|
||||
WriteLiteral(">\r\n\r\n <h2>Define Import Columns</h2>\r\n\r\n");
|
||||
|
||||
|
||||
#line 11 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 11 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
if (Model.Context.RawData.Count > 10)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <h4");
|
||||
|
||||
WriteLiteral(" class=\"alert\"");
|
||||
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 13 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(Model.Context.RawData.Count);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" records were loaded, only the first 10 are shown here.</h4>\r\n");
|
||||
|
||||
|
||||
#line 14 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <h4");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Headers_DeviceSerialNumberRequired\"");
|
||||
|
||||
WriteLiteral(" class=\"error\"");
|
||||
|
||||
WriteLiteral(">The Device Serial Number column must be defined.</h4>\r\n\r\n <div");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Headers_TableContainer\"");
|
||||
|
||||
WriteLiteral(">\r\n <table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(">\r\n <thead>\r\n <tr>\r\n");
|
||||
|
||||
|
||||
#line 22 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 22 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
foreach (var header in Model.Context.Header.Select((h, i) => Tuple.Create(h, i)))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <th");
|
||||
|
||||
WriteLiteral(" data-headerindex=\"");
|
||||
|
||||
|
||||
#line 24 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(header.Item2);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteAttribute("class", Tuple.Create(" class=\"", 984), Tuple.Create("\"", 1030)
|
||||
, Tuple.Create(Tuple.Create("", 992), Tuple.Create("header", 992), true)
|
||||
|
||||
#line 24 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 998), Tuple.Create<System.Object, System.Int32>(header.Item1.Item2.ToString()
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 998), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 24 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(header.Item1.Item1);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</th>\r\n");
|
||||
|
||||
|
||||
#line 25 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tr>\r\n <tr>\r\n");
|
||||
|
||||
|
||||
#line 28 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 28 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
foreach (var header in Model.Context.Header.Select((h, i) => Tuple.Create(h, i)))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <td");
|
||||
|
||||
WriteLiteral(" data-headerindex=\"");
|
||||
|
||||
|
||||
#line 30 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(header.Item2);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteAttribute("class", Tuple.Create(" class=\"", 1313), Tuple.Create("\"", 1359)
|
||||
, Tuple.Create(Tuple.Create("", 1321), Tuple.Create("header", 1321), true)
|
||||
|
||||
#line 30 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1327), Tuple.Create<System.Object, System.Int32>(header.Item1.Item2.ToString()
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 1327), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">\r\n <ul");
|
||||
|
||||
WriteLiteral(" class=\"importHeaderType\"");
|
||||
|
||||
WriteLiteral(" data-headerindex=\"");
|
||||
|
||||
|
||||
#line 31 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(header.Item2);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(" data-headertype=\"");
|
||||
|
||||
|
||||
#line 31 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(header.Item1.Item2.ToString());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">\r\n <li><a");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral("><span");
|
||||
|
||||
WriteLiteral(" class=\"headerTypeTitle\"");
|
||||
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 32 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(Model.HeaderTypes.FirstOrDefault(h => h.Item1 == header.Item1.Item2).Item2);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</span></a>\r\n <ul>\r\n");
|
||||
|
||||
|
||||
#line 34 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 34 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
foreach (var headerType in Model.HeaderTypes)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <li");
|
||||
|
||||
WriteLiteral(" data-headertype=\"");
|
||||
|
||||
|
||||
#line 36 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(headerType.Item1);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral("><a");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 36 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(headerType.Item2);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</a></li>\r\n");
|
||||
|
||||
|
||||
#line 37 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </ul>\r\n </li>\r" +
|
||||
"\n </ul>\r\n </td>\r\n");
|
||||
|
||||
|
||||
#line 42 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tr>\r\n </thead>\r\n <tbody>\r\n");
|
||||
|
||||
|
||||
#line 46 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 46 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
foreach (var record in Model.Context.RawData.Take(10))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n");
|
||||
|
||||
|
||||
#line 49 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 49 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
foreach (var field in record.Select((h, i) => Tuple.Create(h, i)))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <td");
|
||||
|
||||
WriteLiteral(" data-headerindex=\"");
|
||||
|
||||
|
||||
#line 51 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(field.Item2);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 51 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(field.Item1);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</td>\r\n");
|
||||
|
||||
|
||||
#line 52 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tr>\r\n");
|
||||
|
||||
|
||||
#line 54 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </tbody>\r\n </table>\r\n </div>\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"actionBar\"");
|
||||
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
|
||||
#line 59 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 59 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
using (Html.BeginForm(MVC.API.Device.ImportParse(Model.Context.SessionId, null)))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <a");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Headers_Submit\"");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(" class=\"button\"");
|
||||
|
||||
WriteLiteral(">Parse Device Import</a> \r\n");
|
||||
|
||||
|
||||
#line 62 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </div>\r\n</div>\r\n<div");
|
||||
|
||||
WriteLiteral(" id=\"Devices_Import_Parsing_Dialog\"");
|
||||
|
||||
WriteLiteral(" class=\"dialog\"");
|
||||
|
||||
WriteLiteral(" title=\"Parsing devices import...\"");
|
||||
|
||||
WriteLiteral(">\r\n <h4><i");
|
||||
|
||||
WriteLiteral(" class=\"fa fa-lg fa-cog fa-spin\"");
|
||||
|
||||
WriteLiteral(" title=\"Please Wait\"");
|
||||
|
||||
WriteLiteral("></i>Parsing device import...</h4>\r\n</div>\r\n<script>\r\n $(function () {\r\n " +
|
||||
" var headerTypes = {\r\n");
|
||||
|
||||
|
||||
#line 71 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 71 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
foreach (var h in Model.HeaderTypes)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" ");
|
||||
|
||||
WriteLiteral("\'");
|
||||
|
||||
|
||||
#line 73 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(h.Item1);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\': \'");
|
||||
|
||||
|
||||
#line 73 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
Write(h.Item2);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\',");
|
||||
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 74 "..\..\Views\Device\ImportHeaders.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" };\r\n\r\n var $Devices_Import_Headers_TableContainer = $(\'#Devices_Im" +
|
||||
"port_Headers_TableContainer\');\r\n var $importHeaderTypes = $Devices_Import" +
|
||||
"_Headers_TableContainer.find(\'thead\').find(\'ul.importHeaderType\');\r\n var " +
|
||||
"$Devices_Import_Headers_DeviceSerialNumberRequired = $(\'#Devices_Import_Headers_" +
|
||||
"DeviceSerialNumberRequired\');\r\n var $Devices_Import_Headers_Submit = $(\'#" +
|
||||
"Devices_Import_Headers_Submit\');\r\n var $Devices_Import_Parsing_Dialog = n" +
|
||||
"ull;\r\n\r\n function getUsedHeaders() {\r\n return $importHeaderTyp" +
|
||||
"es.map(function () { return $(this).attr(\'data-headertype\'); }).filter(function " +
|
||||
"() { return this != \'IgnoreColumn\' }).get();\r\n }\r\n\r\n function upda" +
|
||||
"teHeaderOptions() {\r\n var usedHeaders = getUsedHeaders();\r\n " +
|
||||
" var deviceSerialNumberPresent = (usedHeaders.indexOf(\'DeviceSerialNumber\') >= " +
|
||||
"0);\r\n\r\n if (deviceSerialNumberPresent) {\r\n $Devices_Im" +
|
||||
"port_Headers_Submit.attr(\'disabled\', null);\r\n $Devices_Import_Hea" +
|
||||
"ders_DeviceSerialNumberRequired.hide();\r\n } else {\r\n $" +
|
||||
"Devices_Import_Headers_DeviceSerialNumberRequired.show();\r\n $Devi" +
|
||||
"ces_Import_Headers_Submit.attr(\'disabled\', \'disabled\');\r\n }\r\n\r\n " +
|
||||
" $importHeaderTypes.each(function () {\r\n var $header = $(thi" +
|
||||
"s);\r\n var $headerType = $header.attr(\'data-headertype\');\r\n " +
|
||||
" $header.find(\'li[data-headertype]\').each(function () {\r\n " +
|
||||
" var $headerOption = $(this);\r\n var $headerOptionType = $" +
|
||||
"headerOption.attr(\'data-headertype\');\r\n if ($headerOptionType" +
|
||||
" === $headerType) {\r\n $headerOption.removeClass(\'ui-state" +
|
||||
"-disabled\');\r\n $headerOption.addClass(\'ui-state-highlight" +
|
||||
"\');\r\n } else if (usedHeaders.indexOf($headerOptionType) < 0) " +
|
||||
"{\r\n $headerOption.removeClass(\'ui-state-disabled ui-state" +
|
||||
"-highlight\');\r\n } else {\r\n $headerOpti" +
|
||||
"on.removeClass(\'ui-state-highlight\');\r\n $headerOption.add" +
|
||||
"Class(\'ui-state-disabled\');\r\n }\r\n })\r\n " +
|
||||
" });\r\n }\r\n\r\n function updateDataStyle(index, headerType) {\r\n " +
|
||||
" $Devices_Import_Headers_TableContainer.find(\'tbody\').find(\'td[data-head" +
|
||||
"erindex=\"\' + index + \'\"]\').removeClass().addClass(\'header\' + headerType);\r\n " +
|
||||
" $Devices_Import_Headers_TableContainer.find(\'thead\').find(\'td[data-header" +
|
||||
"index=\"\' + index + \'\"], th[data-headerindex=\"\' + index + \'\"]\').removeClass().add" +
|
||||
"Class(\'header\' + headerType);\r\n }\r\n\r\n $Devices_Import_Headers_Tabl" +
|
||||
"eContainer.find(\'thead\').on(\'menuselect\', \'ul.importHeaderType\', function (e, ui" +
|
||||
") {\r\n var headerType = ui.item.attr(\'data-headertype\');\r\n\r\n " +
|
||||
" if (headerType !== undefined) {\r\n var $this = $(this).closest(\'" +
|
||||
"ul.importHeaderType\');\r\n var headerIndex = $this.attr(\'data-heade" +
|
||||
"rindex\');\r\n var headerTypeName = headerTypes[headerType];\r\n " +
|
||||
" $this.attr(\'data-headertype\', headerType).find(\'span.headerTypeTitle\')" +
|
||||
".text(headerTypeName);\r\n updateDataStyle(headerIndex, headerType)" +
|
||||
";\r\n updateHeaderOptions();\r\n }\r\n });\r\n\r\n " +
|
||||
" // Add Type Options\r\n $importHeaderTypes.each(function () {\r\n " +
|
||||
" var $this = $(this);\r\n var thisHeaderIndex = $this.attr(\'data-header" +
|
||||
"index\');\r\n var thisHeaderType = $this.attr(\'data-headertype\');\r\n " +
|
||||
" updateDataStyle(thisHeaderIndex, thisHeaderType);\r\n }).menu({ posi" +
|
||||
"tion: { my: \"left top\", at: \"left bottom\" } });\r\n\r\n updateHeaderOptions()" +
|
||||
";\r\n\r\n $(\'#Devices_Import_Headers_Submit\').click(function () {\r\n\r\n " +
|
||||
" // Validate Device Serial Number Present\r\n var usedHeaders = getU" +
|
||||
"sedHeaders();\r\n var deviceSerialNumberPresent = (usedHeaders.indexOf(" +
|
||||
"\'DeviceSerialNumber\') >= 0);\r\n if (!deviceSerialNumberPresent) {\r\n " +
|
||||
" updateHeaderOptions();\r\n $Devices_Import_Headers_Dev" +
|
||||
"iceSerialNumberRequired.show(\'highlight\');\r\n } else {\r\n " +
|
||||
" var $form = $(this).closest(\'form\');\r\n\r\n // Build Form\r\n " +
|
||||
" $importHeaderTypes.each(function () {\r\n var $this = " +
|
||||
"$(this);\r\n var thisHeaderIndex = $this.attr(\'data-headerindex" +
|
||||
"\');\r\n var thisHeaderType = $this.attr(\'data-headertype\');\r\n\r\n" +
|
||||
" $(document.createElement(\'input\')).attr({ type: \'hidden\', na" +
|
||||
"me: \'Headers[\' + thisHeaderIndex + \']\', value: thisHeaderType }).appendTo($form)" +
|
||||
";\r\n });\r\n\r\n // Submit Form\r\n if ($D" +
|
||||
"evices_Import_Parsing_Dialog == null) {\r\n $Devices_Import_Par" +
|
||||
"sing_Dialog = $(\'#Devices_Import_Parsing_Dialog\').dialog({\r\n " +
|
||||
" width: 400,\r\n height: 160,\r\n r" +
|
||||
"esizable: false,\r\n modal: true,\r\n " +
|
||||
"autoOpen: false\r\n });\r\n }\r\n $De" +
|
||||
"vices_Import_Parsing_Dialog.dialog(\'open\');\r\n $form.submit();\r\n " +
|
||||
" }\r\n\r\n return false;\r\n });\r\n });\r\n</script>\r\n");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -1,15 +1,171 @@
|
||||
@model Disco.Web.Models.Device.ImportReviewModel
|
||||
@using Disco.BI.DeviceBI.Importing
|
||||
@using Disco.Models.Services.Devices.Importing;
|
||||
@using System.Data;
|
||||
@{
|
||||
Authorization.Require(Claims.Device.Actions.Import);
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import Devices", MVC.Device.ImportExport(), string.Format("File: {0}", Model.ImportFilename));
|
||||
|
||||
int importDeviceOkCount = Model.ImportDevices.Count(id => id.Errors.Count == 0);
|
||||
int importDeviceNewCount = Model.ImportDevices.Count(id => id.Errors.Count == 0 && id.Device == null);
|
||||
int importDeviceUpdateCount = Model.ImportDevices.Count(id => id.Errors.Count == 0 && id.Device != null);
|
||||
int importDeviceErrorCount = Model.ImportDevices.Count - importDeviceOkCount;
|
||||
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import Devices", MVC.Device.Import(), string.Format("File: {0}", Model.Context.Filename));
|
||||
}
|
||||
<div id="Devices_Import_Review">
|
||||
|
||||
<h2>Review Pending Changes</h2>
|
||||
|
||||
<h3>Parsed @Model.Context.Records.Count Device Record@(Model.Context.Records.Count != 1 ? "s" : null)</h3>
|
||||
<h4>
|
||||
@Model.StatisticImportRecords of @Model.Context.Records.Count Device@(Model.Context.Records.Count != 1 ? "s" : null) are ready for import.
|
||||
</h4>
|
||||
@if (Model.StatisticErrorRecords > 0)
|
||||
{
|
||||
<h4 class="field-validation-error">
|
||||
@(Model.StatisticErrorRecords) Record@(Model.StatisticErrorRecords != 1 ? "s" : null) will be skipped due to parse errors.
|
||||
</h4>
|
||||
}
|
||||
<div id="Devices_Import_Review_Navigation">
|
||||
<ul class="none">
|
||||
@if (Model.StatisticErrorRecords > 0)
|
||||
{<li class="actionDetached">
|
||||
<input id="Devices_Import_Review_Navigation_Error" type="checkbox" checked /><label for="Devices_Import_Review_Navigation_Error">Show Errors (@(Model.StatisticErrorRecords))</label>
|
||||
</li>}@if (Model.StatisticNewRecords > 0)
|
||||
{<li class="actionAdded">
|
||||
<input id="Devices_Import_Review_Navigation_New" type="checkbox" checked /><label for="Devices_Import_Review_Navigation_New">Show New Devices (@(Model.StatisticNewRecords))</label>
|
||||
</li>}@if (Model.StatisticModifiedRecords > 0)
|
||||
{<li class="actionModified">
|
||||
<input id="Devices_Import_Review_Navigation_Modified" type="checkbox" checked /><label for="Devices_Import_Review_Navigation_Modified">Show Modified Devices (@(Model.StatisticModifiedRecords))</label>
|
||||
</li>}@if (Model.StatisticUnmodifiedRecords > 0)
|
||||
{<li class="actionUnchanged">
|
||||
<input id="Devices_Import_Review_Navigation_Unchanged" type="checkbox" checked /><label for="Devices_Import_Review_Navigation_Unchanged">Show Unchanged Devices (@(Model.StatisticUnmodifiedRecords))</label>
|
||||
</li>}
|
||||
</ul>
|
||||
<script>
|
||||
$(function () {
|
||||
$navigationContainer = $('#Devices_Import_Review_Navigation');
|
||||
$tableBody = $('#Devices_Import_Review_TableContainer').find('tbody');
|
||||
|
||||
$navigationContainer.on('change', 'input', function () {
|
||||
$tableBody.find('tr').show();
|
||||
|
||||
$navigationContainer.find('input').each(function () {
|
||||
var $this = $(this);
|
||||
var action = $this.closest('li').attr('class');
|
||||
var records = $tableBody.find('tr.' + action);
|
||||
if ($this.is(':checked')) {
|
||||
records.show();
|
||||
} else {
|
||||
records.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<div id="Devices_Import_Review_TableContainer">
|
||||
<table class="tableData">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Action</th>
|
||||
<th>Row</th>
|
||||
@foreach (var header in Model.Context.ParsedHeaders)
|
||||
{
|
||||
<th>@(Model.HeaderTypes.FirstOrDefault(h => h.Item1 == header.Item2).Item2)</th>
|
||||
}
|
||||
</tr>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
@foreach (var header in Model.Context.ParsedHeaders)
|
||||
{
|
||||
<th>@header.Item1</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var recordEntry in Model.Context.Records.Select((r, i) => Tuple.Create(r, i)))
|
||||
{
|
||||
var record = recordEntry.Item1;
|
||||
<tr class="action@(record.RecordAction)">
|
||||
<td class="action"><i class="fa fa-fw"></i></td>
|
||||
<td>@(recordEntry.Item2 + 1)</td>
|
||||
@foreach (var field in record.Fields)
|
||||
{
|
||||
var friendlyValue = field.FriendlyValue;
|
||||
<td class="header@(field.FieldType) action@(field.FieldAction.HasValue ? field.FieldAction.ToString() : "Error")" data-previousvalue="@(field.FieldAction.HasValue && field.FieldAction.Value == System.Data.EntityState.Modified ? field.FriendlyPreviousValue : null)">
|
||||
@if (!field.FieldAction.HasValue)
|
||||
{
|
||||
<span class="errorMessage"><strong>Error:</strong> @field.ErrorMessage</span>
|
||||
<i class="fa fa-exclamation-triangle fa-fw"></i>
|
||||
}
|
||||
@if (string.IsNullOrEmpty(friendlyValue))
|
||||
{<span class="smallMessage"><None></span>}
|
||||
else if (field.FieldType == DeviceImportFieldTypes.DeviceSerialNumber && field.FieldAction.HasValue && field.FieldAction.Value != EntityState.Added)
|
||||
{
|
||||
@Html.ActionLink(friendlyValue, MVC.Device.Show((string)field.RawParsedValue), new { target="_blank" })}
|
||||
else if (field.FieldType == DeviceImportFieldTypes.AssignedUserId && field.FieldAction.HasValue && field.FieldAction.Value != EntityState.Unchanged)
|
||||
{
|
||||
@Html.ActionLink(friendlyValue, MVC.User.Show((string)field.RawParsedValue), new { target="_blank" })}
|
||||
else
|
||||
{@friendlyValue}
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="actionBar">
|
||||
<a id="Devices_Import_Review_ChangeHeaders" href="@Url.Action(MVC.Device.ImportHeaders(Model.Context.SessionId))" class="button"><i class="fa fa-caret-left"></i>Change Import Columns</a>
|
||||
@if (Model.StatisticImportRecords == 0)
|
||||
{
|
||||
<a id="Devices_Import_Review_Apply" href="#" class="button disabled" disabled><i class="fa fa-wrench"></i>Apply Device Import</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a id="Devices_Import_Review_Apply" href="@Url.Action(MVC.API.Device.ImportApply(Model.Context.SessionId))" class="button"><i class="fa fa-wrench"></i>Apply Device Import</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
$Devices_Import_Review_TableContainer = $('#Devices_Import_Review_TableContainer');
|
||||
|
||||
$Devices_Import_Review_TableContainer.find('tbody').tooltip({
|
||||
items: 'td.action, td.actionError, td.actionModified',
|
||||
content: function () {
|
||||
var $this = $(this);
|
||||
|
||||
if ($this.hasClass('action')) {
|
||||
var record = $(this).closest('tr');
|
||||
|
||||
if (record.hasClass('actionDetached')) {
|
||||
return '<strong>Error Parsing Record</strong><div>Review the record fields for details about any errors.</div><div class="smallMessage">This record will be skipped.</div>';
|
||||
} else if (record.hasClass('actionUnchanged')) {
|
||||
return '<strong>No Changes</strong><div>No changes were found while parsing this record.</div><div class="smallMessage">This record will be skipped.</div>';
|
||||
} else if (record.hasClass('actionModified')) {
|
||||
return '<strong>Pending Changes</strong><div>This record contains changes which will be applied.</div>';
|
||||
} else if (record.hasClass('actionAdded')) {
|
||||
return '<strong>New Record</strong><div>This record will be imported.</div>';
|
||||
}
|
||||
} else if ($this.hasClass('actionError')) {
|
||||
return $(this).find('span.errorMessage').html();
|
||||
} else if ($this.hasClass('actionModified')) {
|
||||
var v = $(this).attr('data-previousvalue');
|
||||
if (v) {
|
||||
return '<strong>Previous Value:</strong><br />' + v;
|
||||
} else {
|
||||
return '<strong>Previous Value:</strong><br /><em><None></em>';
|
||||
}
|
||||
}
|
||||
},
|
||||
position: {
|
||||
my: "left top",
|
||||
at: "left bottom",
|
||||
collision: "flipfit flip"
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@*
|
||||
<div id="deviceImportReview">
|
||||
@if (Model.ImportDevices.Count > 0)
|
||||
{
|
||||
@@ -248,4 +404,4 @@
|
||||
{
|
||||
<h2>No Devices were found in this file</h2>
|
||||
}
|
||||
</div>
|
||||
</div>*@
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
||||
<div class="actionBar">
|
||||
@if (Authorization.Has(Claims.Device.Actions.Import))
|
||||
{
|
||||
@Html.ActionLinkButton("Import Devices", MVC.Device.ImportExport())
|
||||
@Html.ActionLinkButton("Import Devices", MVC.Device.Import())
|
||||
}
|
||||
@if (Authorization.Has(Claims.Device.Actions.Export))
|
||||
{
|
||||
|
||||
@@ -115,14 +115,14 @@ WriteLiteral(">\r\n");
|
||||
#line hidden
|
||||
|
||||
#line 14 "..\..\Views\Device\Index.cshtml"
|
||||
Write(Html.ActionLinkButton("Import Devices", MVC.Device.ImportExport()));
|
||||
Write(Html.ActionLinkButton("Import Devices", MVC.Device.Import()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 14 "..\..\Views\Device\Index.cshtml"
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
</appSettings>
|
||||
|
||||
<system.web>
|
||||
<compilation>
|
||||
<assemblies>
|
||||
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
</assemblies>
|
||||
</compilation>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
Reference in New Issue
Block a user