(function () { function getSyncTargetName(targets, id) { var target = targets.filter(function (t) { return t.Id == id; })[0]; return target ? target.Name : 'Unknown Device'; } function getSyncJobHtml(job) { var html = ''; html += "
"; html += '
'; html += '
'; html += '
'; html += '
'; var imgUrl; if (job.PrimaryImageItemId) { imgUrl = ApiClient.getScaledImageUrl(job.PrimaryImageItemId, { type: "Primary", width: 400, tag: job.PrimaryImageTag }); } if (imgUrl) { html += '
'; html += "
"; } if (job.Status == 'Completed') { html += '
'; } else if (job.Status == 'Queued') { html += '
'; } else if (job.Status == 'Transcoding' || job.Status == 'Transferring') { html += '
'; } else if (job.Status == 'Cancelled') { html += '
'; } else if (job.Status == 'TranscodingFailed') { html += '
'; } // cardContent html += "
"; // cardScalable html += "
"; html += '
'; var textLines = []; if (job.ParentName) { textLines.push(job.ParentName); } textLines.push(job.Name); if (job.ItemCount == 1) { textLines.push(job.ItemCount + ' item'); } else { textLines.push(job.ItemCount + ' items'); } if (!job.ParentName) { textLines.push(' '); } for (var i = 0, length = textLines.length; i < length; i++) { html += "
"; html += textLines[i]; html += "
"; } //if (!plugin.isExternal) { // html += "
"; // html += plugin.price > 0 ? "$" + plugin.price.toFixed(2) : Globalize.translate('LabelFree'); // html += RatingHelpers.getStoreRatingHtml(plugin.avgRating, plugin.id, plugin.name); // html += ""; // html += " " + Globalize.translate('LabelNumberReviews').replace("{0}", plugin.totalRatings); // html += ""; // html += "
"; //} //var installedPlugin = plugin.isApp ? null : installedPlugins.filter(function (ip) { // return ip.Name == plugin.name; //})[0]; //html += "
"; //if (installedPlugin) { // html += Globalize.translate('LabelVersionInstalled').replace("{0}", installedPlugin.Version); //} else { // html += ' '; //} //html += "
"; // cardFooter html += "
"; // cardBox html += "
"; // card html += "
"; return html; } function loadData(page, jobs, targets) { var html = ''; var lastTargetName = ''; for (var i = 0, length = jobs.length; i < length; i++) { var job = jobs[i]; var targetName = getSyncTargetName(targets, job.TargetId); if (targetName != lastTargetName) { html += '

' + targetName + '

'; lastTargetName = targetName; } html += getSyncJobHtml(job); } $('.syncActivity', page).html(html).trigger('create'); } $(document).on('pageshow', "#dashboardSyncPage", function () { Dashboard.showLoadingMsg(); var page = this; var promise1 = ApiClient.getJSON(ApiClient.getUrl('Sync/Jobs')); var promise2 = ApiClient.getJSON(ApiClient.getUrl('Sync/Targets')); $.when(promise1, promise2).done(function (response1, response2) { loadData(page, response1[0].Items, response2[0]); Dashboard.hideLoadingMsg(); }); }).on('pageinit', "#dashboardSyncPage", function () { var page = this; }); })();