Feature: Device Importing & Exporting

This commit is contained in:
Gary Sharp
2013-07-25 17:46:20 +10:00
parent a3aaed1d13
commit ad6b1b19b6
67 changed files with 3058 additions and 266 deletions
-23
View File
@@ -1,23 +0,0 @@
@model Disco.Web.Models.Device.ImportModel
@{
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import Devices");
}
@using (Html.BeginForm(MVC.API.Device.ImportParse(), FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.ValidationSummary()
<div id="importDialog" class="form" style="width: 450px">
<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>
}
-129
View File
@@ -1,129 +0,0 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18051
//
// 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.BI.Extensions;
using Disco.Models.Repository;
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 : System.Web.Mvc.WebViewPage<Disco.Web.Models.Device.ImportModel>
{
public Import()
{
}
public override void Execute()
{
#line 2 "..\..\Views\Device\Import.cshtml"
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import Devices");
#line default
#line hidden
WriteLiteral("\r\n");
#line 5 "..\..\Views\Device\Import.cshtml"
using (Html.BeginForm(MVC.API.Device.ImportParse(), FormMethod.Post, new { enctype = "multipart/form-data" }))
{
#line default
#line hidden
#line 7 "..\..\Views\Device\Import.cshtml"
Write(Html.ValidationSummary());
#line default
#line hidden
#line 7 "..\..\Views\Device\Import.cshtml"
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" id=\"importDialog\"");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 450px\"");
WriteLiteral(">\r\n <table>\r\n <tr>\r\n <th>\r\n");
WriteLiteral(" ");
#line 12 "..\..\Views\Device\Import.cshtml"
Write(Html.LabelFor(m => m.ImportFile));
#line default
#line hidden
WriteLiteral("\r\n </th>\r\n <td>\r\n <input");
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 23 "..\..\Views\Device\Import.cshtml"
}
#line default
#line hidden
}
}
}
#pragma warning restore 1591
+192
View File
@@ -0,0 +1,192 @@
@model Disco.Web.Models.Device.ImportModel
@{
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import/Export Devices");
}
<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">&lt;None&gt;</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">&lt;None&gt;</span></em>
</td>
</tr>
<tr>
<th>Location</th>
<td>Updates the Location of the device. Maximum of 250 characters. <em>Default: <span class="code">&lt;None&gt;</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">&lt;None&gt;</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 class="actionBar">
@Html.ActionLinkButton("Export All Devices", MVC.API.Device.ExportAllDevices())
</div>
</div>
@@ -0,0 +1,547 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18051
//
// 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.BI.Extensions;
using Disco.Models.Repository;
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 : System.Web.Mvc.WebViewPage<Disco.Web.Models.Device.ImportModel>
{
public ImportExport()
{
}
public override void Execute()
{
#line 2 "..\..\Views\Device\ImportExport.cshtml"
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import/Export Devices");
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" id=\"deviceImport\"");
WriteLiteral(">\r\n");
#line 6 "..\..\Views\Device\ImportExport.cshtml"
#line default
#line hidden
#line 6 "..\..\Views\Device\ImportExport.cshtml"
using (Html.BeginForm(MVC.API.Device.ImportParse(), FormMethod.Post, new { enctype = "multipart/form-data" }))
{
#line default
#line hidden
#line 8 "..\..\Views\Device\ImportExport.cshtml"
Write(Html.ValidationSummary());
#line default
#line hidden
#line 8 "..\..\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 14 "..\..\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 25 "..\..\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 51 "..\..\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 56 "..\..\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(">&lt;None&gt;</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(">&lt;None&gt;</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(">&lt;None&gt;</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(">&lt;None&gt;</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 94 "..\..\Views\Device\ImportExport.cshtml"
#line default
#line hidden
#line 94 "..\..\Views\Device\ImportExport.cshtml"
foreach (var dm in Model.DeviceModels)
{
#line default
#line hidden
WriteLiteral(" <tr>\r\n <td>");
#line 97 "..\..\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 98 "..\..\Views\Device\ImportExport.cshtml"
Write(dm.ToString());
#line default
#line hidden
WriteLiteral("</td>\r\n <td>");
#line 99 "..\..\Views\Device\ImportExport.cshtml"
Write(dm.Manufacturer);
#line default
#line hidden
WriteLiteral("</td>\r\n <td>");
#line 100 "..\..\Views\Device\ImportExport.cshtml"
Write(dm.Model);
#line default
#line hidden
WriteLiteral("</td>\r\n </tr>\r\n");
#line 102 "..\..\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 118 "..\..\Views\Device\ImportExport.cshtml"
#line default
#line hidden
#line 118 "..\..\Views\Device\ImportExport.cshtml"
foreach (var dp in Model.DeviceProfiles)
{
#line default
#line hidden
WriteLiteral(" <tr>\r\n <td>");
#line 121 "..\..\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 122 "..\..\Views\Device\ImportExport.cshtml"
Write(dp.Name);
#line default
#line hidden
WriteLiteral("</td>\r\n <td>");
#line 123 "..\..\Views\Device\ImportExport.cshtml"
Write(dp.ShortName);
#line default
#line hidden
WriteLiteral("</td>\r\n <td>");
#line 124 "..\..\Views\Device\ImportExport.cshtml"
Write(dp.Description);
#line default
#line hidden
WriteLiteral("</td>\r\n </tr>\r\n");
#line 126 "..\..\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 141 "..\..\Views\Device\ImportExport.cshtml"
#line default
#line hidden
#line 141 "..\..\Views\Device\ImportExport.cshtml"
foreach (var db in Model.DeviceBatches)
{
#line default
#line hidden
WriteLiteral(" <tr>\r\n <td>");
#line 144 "..\..\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 145 "..\..\Views\Device\ImportExport.cshtml"
Write(db.Name);
#line default
#line hidden
WriteLiteral("</td>\r\n <td>");
#line 146 "..\..\Views\Device\ImportExport.cshtml"
Write(CommonHelpers.FriendlyDate(db.PurchaseDate));
#line default
#line hidden
WriteLiteral("</td>\r\n </tr>\r\n");
#line 148 "..\..\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\r\n <div");
WriteLiteral(" class=\"actionBar\"");
WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 190 "..\..\Views\Device\ImportExport.cshtml"
Write(Html.ActionLinkButton("Export All Devices", MVC.API.Device.ExportAllDevices()));
#line default
#line hidden
WriteLiteral("\r\n </div>\r\n</div>\r\n");
}
}
}
#pragma warning restore 1591
+249
View File
@@ -0,0 +1,249 @@
@model Disco.Web.Models.Device.ImportReviewModel
@using Disco.BI.DeviceBI.Importing
@{
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;
}
<div id="deviceImportReview">
@if (Model.ImportDevices.Count > 0)
{
<h2>Parsed @Model.ImportDevices.Count Device Record@(Model.ImportDevices.Count != 1 ? "s" : null)</h2>
<h4>
@importDeviceOkCount of @Model.ImportDevices.Count Device@(Model.ImportDevices.Count != 1 ? "s" : null) are ready for import.
</h4>
if (importDeviceErrorCount > 0)
{
<h4 id="errorMessage">
@(importDeviceErrorCount) Record@(importDeviceErrorCount != 1 ? "s" : null) will be skipped if the import continues
</h4>
}
<div id="devicesNavigation">
<ul class="none">
@if (importDeviceNewCount > 0)
{<li class="statusNew">
<input id="devicesNavigationNew" type="checkbox" checked="checked" /><label for="devicesNavigationNew">Show New Devices (@(Model.ImportDevices.Count(id => id.Errors.Count == 0 && id.Device == null)))</label>
</li>}@if (importDeviceUpdateCount > 0)
{<li class="statusUpdate">
<input id="devicesNavigationUpdate" type="checkbox" checked="checked" /><label for="devicesNavigationUpdate">Show Updates (@(Model.ImportDevices.Count(id => id.Errors.Count == 0 && id.Device != null)))</label>
</li>}@if (importDeviceErrorCount > 0)
{<li class="statusError">
<input id="devicesNavigationError" type="checkbox" checked="checked" /><label for="devicesNavigationError">Show Errors (@(Model.ImportDevices.Count(id => id.Errors.Count != 0)))</label>
</li>}
</ul>
<script>
$(function () {
$devices = $('#devices');
$rows = $devices.children('tbody').children('tr');
$('#devicesNavigationNew').change(function () {
if ($(this).is(':checked'))
$rows.filter('.statusNew').show();
else
$rows.filter('.statusNew').hide();
});
$('#devicesNavigationUpdate').change(function () {
if ($(this).is(':checked'))
$rows.filter('.statusUpdate').show();
else
$rows.filter('.statusUpdate').hide();
});
$('#devicesNavigationError').change(function () {
if ($(this).is(':checked'))
$rows.filter('.statusError').show();
else
$rows.filter('.statusError').hide();
});
});
</script>
</div>
<table id="devices">
<thead>
<tr>
<th class="row">Row</th>
<th class="action">Action</th>
<th class="serialNumber">Serial Number</th>
<th class="model">Model</th>
<th class="profile">Profile</th>
<th class="batch">Batch</th>
<th class="assignedUser">Assigned User</th>
<th class="location">Location</th>
<th class="assetNumber">Asset Number</th>
</tr>
</thead>
<tbody>
@foreach (var device in Model.ImportDevices)
{
bool isUpdate = device.Device != null;
string error;
<tr class="status@(device.ImportStatus())">
<td class="row">
@((Model.ImportDevices.IndexOf(device) + 1))
</td>
<td class="action">
@(device.ImportStatus())
</td>
<td class="serialNumber">
@if (device.Device == null)
{
@device.SerialNumber
}
else
{
@Html.ActionLink(device.SerialNumber, MVC.Device.Show(device.SerialNumber), new { target = "_blank" })
}
@if (device.Errors.TryGetValue("SerialNumber", out error))
{
<div class="error">@error</div>
}
</td>
<td class="model">
@if (device.Errors.TryGetValue("DeviceModelId", out error))
{
<div class="error">@error</div>
}
else
{
if (!isUpdate || device.DeviceModelId != device.Device.DeviceModelId)
{
<img class="modelImage" alt="Model Image" src="@Url.Action(MVC.API.DeviceModel.Image(device.DeviceModel.Id, device.DeviceModel.ImageHash()))" />
@device.DeviceModel.ToString()
}
else
{
<span class="smallMessage">No Change</span>
}
}</td>
<td class="profile">
@if (device.Errors.TryGetValue("DeviceProfileId", out error))
{
<div class="error">@error</div>
}
else
{
if (!isUpdate || device.DeviceProfileId != device.Device.DeviceProfileId)
{
@device.DeviceProfile.ToString()
}
else
{
<span class="smallMessage">No Change</span>
}
}</td>
<td class="batch">
@if (device.Errors.TryGetValue("DeviceBatchId", out error))
{
<div class="error">@error</div>
}
else
{
if (!isUpdate || device.DeviceBatchId != device.Device.DeviceBatchId)
{
if (device.DeviceBatch == null)
{
<text>&lt;None&gt;</text>
}
else
{
@device.DeviceBatch.ToString()
}
}
else
{
<span class="smallMessage">No Change</span>
}
}</td>
<td class="assignedUser">
@if (device.Errors.TryGetValue("AssignedUserId", out error))
{
<div class="error">@error</div>
}
else
{
if (!isUpdate || device.AssignedUserId != device.Device.AssignedUserId)
{
if (device.AssignedUser == null)
{
<text>&lt;None&gt;</text>
}
else
{
@device.AssignedUser.ToString()
}
}
else
{
<span class="smallMessage">No Change</span>
}
}</td>
<td class="location">
@if (device.Errors.TryGetValue("Location", out error))
{
<div class="error">@error</div>
}
else
{
if (!isUpdate || device.Location != device.Device.Location)
{
if (device.Location == null)
{
<text>&lt;None&gt;</text>
}
else
{
@device.Location
}
}
else
{
<span class="smallMessage">No Change</span>
}
}</td>
<td class="assetNumber">
@if (device.Errors.TryGetValue("AssetNumber", out error))
{
<div class="error">@error</div>
}
else
{
if (!isUpdate || device.AssetNumber != device.Device.AssetNumber)
{
if (device.AssetNumber == null)
{
<text>&lt;None&gt;</text>
}
else
{
@device.AssetNumber
}
}
else
{
<span class="smallMessage">No Change</span>
}
}</td>
</tr>
}
</tbody>
</table>
if (importDeviceOkCount > 0)
{
<div class="actionBar">
@Html.ActionLinkButton(string.Format("Import {0} Device{1}", importDeviceOkCount, importDeviceOkCount != 1 ? "s" : null), MVC.API.Device.ImportProcess(Model.ImportParseTaskId))
</div>
}
}
else
{
<h2>No Devices were found in this file</h2>
}
</div>
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -5,6 +5,6 @@
Search for a Device</h3>
@Html.Partial(MVC.Shared.Views._SearchDialog, "devices")
<div class="actionBar">
@Html.ActionLinkButton("Import Devices", MVC.Device.Import())
@Html.ActionLinkButton("Import/Export Devices", MVC.Device.ImportExport())
@Html.ActionLinkButton("Add Offline Device", MVC.Device.AddOffline())
</div>
+1 -1
View File
@@ -67,7 +67,7 @@ WriteLiteral(" ");
#line 8 "..\..\Views\Device\Index.cshtml"
Write(Html.ActionLinkButton("Import Devices", MVC.Device.Import()));
Write(Html.ActionLinkButton("Import/Export Devices", MVC.Device.ImportExport()));
#line default