2011-08-23 23:31:28 +03:00
|
|
|
//URLs
|
|
|
|
var addSeriesUrl = '../AddSeries/AddExistingSeries';
|
|
|
|
var addNewSeriesUrl = '../AddSeries/AddNewSeries';
|
|
|
|
var existingSeriesUrl = '../AddSeries/ExistingSeries';
|
|
|
|
var addNewUrl = '../AddSeries/AddNew';
|
|
|
|
|
|
|
|
var deleteRootDirUrl = '../AddSeries/DeleteRootDir';
|
|
|
|
var saveRootDirUrl = '../AddSeries/SaveRootDir';
|
|
|
|
var rootListUrl = '../AddSeries/RootList';
|
|
|
|
|
|
|
|
|
|
|
|
//ExistingSeries
|
|
|
|
$(".masterQualitySelector").live('change', function () {
|
|
|
|
|
|
|
|
var profileId = $(this).val();
|
2011-12-12 04:22:10 +03:00
|
|
|
$("#existingSeries").find(".qualitySelector").each(function () {
|
2011-08-23 23:31:28 +03:00
|
|
|
$(this).val(profileId);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-09-19 19:18:03 +03:00
|
|
|
$(".addExistingButton").live('click', function () {
|
|
|
|
var button = $(this);
|
|
|
|
$(button).attr('disabled', 'disabled');
|
2011-08-23 23:31:28 +03:00
|
|
|
var root = $(this).parents(".existingSeries");
|
|
|
|
var title = $(this).siblings(".seriesLookup").val();
|
2011-09-09 06:52:25 +03:00
|
|
|
var seriesId = $(this).siblings(".seriesId").val();
|
2011-08-23 23:31:28 +03:00
|
|
|
var qualityId = $(this).siblings(".qualitySelector").val();
|
2012-09-20 18:37:40 +03:00
|
|
|
var date = $(this).siblings('.start-date').val();
|
2011-08-23 23:31:28 +03:00
|
|
|
|
|
|
|
var path = root.find(".seriesPathValue Label").text();
|
|
|
|
|
2012-01-13 19:54:20 +03:00
|
|
|
if (seriesId === 0 || $.trim(title).length === 0) {
|
2012-01-13 12:03:27 +03:00
|
|
|
$.gritter.add({
|
|
|
|
title: 'Failed',
|
|
|
|
text: 'Invalid Series Information for \'' + path + '\'',
|
2012-10-11 20:25:31 +03:00
|
|
|
icon: 'icon-minus-sign',
|
2012-01-13 12:03:27 +03:00
|
|
|
class_name: 'gritter-fail'
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-23 23:31:28 +03:00
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: addSeriesUrl,
|
2012-09-20 18:37:40 +03:00
|
|
|
data: jQuery.param({ path: path, seriesName: title, seriesId: seriesId, qualityProfileId: qualityId, startDate: date }),
|
2012-09-19 19:18:03 +03:00
|
|
|
error: function (req, status, error) {
|
|
|
|
$(button).removeAttr('disabled');
|
2011-08-23 23:31:28 +03:00
|
|
|
},
|
2012-02-03 10:08:50 +03:00
|
|
|
success: function() {
|
2011-08-23 23:31:28 +03:00
|
|
|
root.hide('highlight', 'fast');
|
2012-02-03 10:08:50 +03:00
|
|
|
if ($('.existingSeries').filter(":visible").length === 1)
|
|
|
|
reloadExistingSeries();
|
2011-08-23 23:31:28 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
function reloadExistingSeries() {
|
2012-02-22 10:46:09 +03:00
|
|
|
$('#existingSeries').html('<img src="../../Content/Images/ajax-loader.gif" />');
|
2011-12-19 03:07:41 +03:00
|
|
|
$.ajax({
|
|
|
|
url: existingSeriesUrl,
|
|
|
|
success: function( data ) {
|
2011-12-09 10:07:37 +03:00
|
|
|
$('#existingSeries').html(data);
|
2011-12-19 03:07:41 +03:00
|
|
|
}
|
2011-08-23 23:31:28 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-09-20 18:37:40 +03:00
|
|
|
$(".start-date-master").live('change', function () {
|
2012-09-19 09:06:09 +03:00
|
|
|
|
|
|
|
var date = $(this).val();
|
2012-09-20 18:37:40 +03:00
|
|
|
$("#existingSeries").find(".start-date").each(function () {
|
2012-09-19 09:06:09 +03:00
|
|
|
$(this).val(date);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-08-23 23:31:28 +03:00
|
|
|
//RootDir
|
2011-12-19 03:07:41 +03:00
|
|
|
//Delete RootDir
|
2012-10-11 20:25:31 +03:00
|
|
|
$(document).on('click', '.delete-root', function () {
|
|
|
|
var path = $(this).attr('data-path');
|
2011-12-19 03:07:41 +03:00
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: deleteRootDirUrl,
|
|
|
|
data: { Path: path },
|
|
|
|
success: function () {
|
|
|
|
refreshRoot();
|
|
|
|
$("#rootDirInput").val('');
|
|
|
|
}
|
2011-08-23 23:31:28 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#saveDir').live('click', saveRootDir);
|
|
|
|
|
|
|
|
function saveRootDir() {
|
|
|
|
var path = $("#rootDirInput").val();
|
2011-12-19 03:07:41 +03:00
|
|
|
|
2011-08-23 23:31:28 +03:00
|
|
|
if (path) {
|
2011-12-19 03:07:41 +03:00
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: saveRootDirUrl,
|
|
|
|
data: { Path: path },
|
|
|
|
success: function () {
|
|
|
|
refreshRoot();
|
|
|
|
$("#rootDirInput").val('');
|
|
|
|
}
|
2011-08-23 23:31:28 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function refreshRoot() {
|
2011-12-19 03:07:41 +03:00
|
|
|
$.ajax({
|
|
|
|
url: rootListUrl,
|
|
|
|
success: function (data) {
|
|
|
|
$('#rootDirs').html(data);
|
|
|
|
reloadAddNew();
|
|
|
|
reloadExistingSeries();
|
|
|
|
}
|
2011-08-23 23:31:28 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//AddNew
|
|
|
|
$('#saveNewSeries').live('click', function () {
|
2012-09-19 19:18:03 +03:00
|
|
|
$('#saveNewSeries').attr('disabled', 'disabled');
|
|
|
|
|
2011-08-23 23:31:28 +03:00
|
|
|
var seriesTitle = $("#newSeriesLookup").val();
|
2011-09-09 06:52:25 +03:00
|
|
|
var seriesId = $("#newSeriesId").val();
|
2011-08-23 23:31:28 +03:00
|
|
|
var qualityId = $("#qualityList").val();
|
|
|
|
var path = $('#newSeriesPath').val();
|
2012-09-20 18:37:40 +03:00
|
|
|
var date = $('#newStartDate').val();
|
2011-08-23 23:31:28 +03:00
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: addNewSeriesUrl,
|
2012-09-20 18:37:40 +03:00
|
|
|
data: jQuery.param({ path: path, seriesName: seriesTitle, seriesId: seriesId, qualityProfileId: qualityId, startDate: date }),
|
2011-08-23 23:31:28 +03:00
|
|
|
error: function (req, status, error) {
|
2012-09-19 19:18:03 +03:00
|
|
|
$('#saveNewSeries').removeAttr('disabled');
|
2011-08-23 23:31:28 +03:00
|
|
|
},
|
|
|
|
success: function () {
|
2012-09-19 19:18:03 +03:00
|
|
|
$('#saveNewSeries').removeAttr('disabled');
|
|
|
|
$("#newSeriesLookup").val('');
|
2012-09-20 18:37:40 +03:00
|
|
|
$('#newStartDate').val('');
|
2011-08-23 23:31:28 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
function reloadAddNew() {
|
2011-12-19 03:07:41 +03:00
|
|
|
$.ajax({
|
|
|
|
url: addNewUrl,
|
|
|
|
success: function (data) {
|
|
|
|
$('#addNewSeries').html(data);
|
|
|
|
}
|
2011-08-23 23:31:28 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-12 04:22:10 +03:00
|
|
|
//Watermark
|
|
|
|
$('#rootDirInput').livequery(function () {
|
2012-01-13 12:03:27 +03:00
|
|
|
$(this).watermark('Enter your new root folder path...');
|
2011-12-12 04:22:10 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
$('#newSeriesLookup').livequery(function () {
|
2012-01-13 12:03:27 +03:00
|
|
|
$(this).watermark('Title of the series you want to add...');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.existingSeriesContainer .seriesLookup').livequery(function () {
|
|
|
|
$(this).watermark('Please enter the series title...');
|
2011-12-12 04:22:10 +03:00
|
|
|
});
|