@using Orchard.Azure.MediaServices @using Orchard.Azure.MediaServices.Models @using Orchard.Azure.MediaServices.Models.Assets @using Orchard.Azure.MediaServices.Models.Jobs @{ Style.Include("cloudmedia-edit-jobs.css", "cloudmedia-edit-jobs.min.css"); Style.Include("cloudmedia-progress.css", "cloudmedia-progress.min.css"); Script.Require("ShapesBase"); var cloudVideoPart = (CloudVideoPart)Model.CloudVideoPart; var isCreatingItem = cloudVideoPart == null || cloudVideoPart.Id == 0 || cloudVideoPart.MezzanineAsset == null; var isUploaded = !isCreatingItem && cloudVideoPart.MezzanineAsset.UploadState.Status == AssetUploadStatus.Uploaded; var jobsToDisplay = cloudVideoPart != null ? cloudVideoPart.Jobs.Where(x => x.Status != JobStatus.Archived).ToArray() : Enumerable.Empty(); var authorizedToManageJobs = AuthorizedFor(Permissions.ManageCloudMediaJobs); } @helper ShortDateTime(DateTime? value) { if (value != null) { @Display.DateTime(DateTimeUtc: value) } } @if (!isCreatingItem && jobsToDisplay.Any()) {
@T("Jobs") @foreach (var job in jobsToDisplay) { }
@T("Name") @T("Description") @T("Created") @T("Status") @T("Started") @T("Finished") @T("Error") @T("Actions")
@job.Name @job.Description @ShortDateTime(job.CreatedUtc) @if (job.Status == JobStatus.Processing) { var percentComplete = Convert.ToInt32(job.PercentComplete); @String.Format("Processing ({0}%)...", percentComplete)
} else { @T(job.Status.ToString()) }
@ShortDateTime(job.StartedUtc) @ShortDateTime(job.FinishedUtc) @job.ErrorMessage @if (authorizedToManageJobs) { if (job.CanArchive) { @Html.ActionLink(T("Archive").ToString(), "Archive", "Job", new { job.Record.Id, Area = "Orchard.Azure.MediaServices" }, new { itemprop = "UnsafeUrl RemoveUrl" }) } if (job.CanCancel) { @Html.ActionLink(T("Cancel").ToString(), "Cancel", "Job", new { job.Record.Id, Area = "Orchard.Azure.MediaServices" }, new { itemprop = "UnsafeUrl RemoveUrl" }) } }
} @{ var canCreateJobs = !isCreatingItem && isUploaded; var href = canCreateJobs ? Url.Action("Create", "Job", new RouteValueDictionary(new { cloudVideoPart.Id, Area = "Orchard.Azure.MediaServices" })) : "#"; var htmlAttributes = new Dictionary() { { "id", "create-link" }, { "class", "button grey" } }; } @if (authorizedToManageJobs) { if (!canCreateJobs) {

@T("Jobs can be created once the mezzanine video asset has finished uploaded and the cloud video item has been saved.")

} else {
@Html.Link(T("Create Job").Text, href, htmlAttributes)
} }