CC-2848: Misc bugs from demo service

- Handling concurrency issue playlist section and show(canlendar) section
This commit is contained in:
James 2011-11-10 15:35:27 -05:00
parent 17016e5d40
commit b04b7ff010
10 changed files with 317 additions and 72 deletions

View file

@ -52,7 +52,9 @@ function changeCueIn(event) {
}
$.post(url, {format: "json", cueIn: cueIn, pos: pos}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
if(json.response.error) {
showError(span, json.response.error);
return;
@ -79,7 +81,9 @@ function changeCueOut(event) {
}
$.post(url, {format: "json", cueOut: cueOut, pos: pos}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
if(json.response.error) {
showError(span, json.response.error);
return;
@ -106,6 +110,9 @@ function changeFadeIn(event) {
}
$.post(url, {format: "json", fadeIn: fadeIn, pos: pos}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
if(json.response.error) {
return;
}
@ -130,6 +137,9 @@ function changeFadeOut(event) {
}
$.post(url, {format: "json", fadeOut: fadeOut, pos: pos}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
if(json.response.error) {
return;
}
@ -192,7 +202,9 @@ function openFadeEditor(event) {
highlightActive(this);
$.get(url, {format: "json", pos: pos}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
$("#crossfade_"+(pos)+"-"+(pos+1))
.empty()
.append(json.html)
@ -228,7 +240,9 @@ function openCueEditor(event) {
highlightActive(li);
$.get(url, {format: "json", pos: pos}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
$("#cues_"+pos)
.empty()
.append(json.html)
@ -245,7 +259,10 @@ function redrawDataTablePage() {
}
function setSPLContent(json) {
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
if(json.message) {
alert(json.message);
return;
@ -329,6 +346,9 @@ function moveSPLItem(event, ui) {
}
function noOpenPL(json) {
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
$("#side_playlist")
.empty()
.append(json.html);
@ -364,6 +384,9 @@ function createPlaylistMetaForm(json) {
data = $("#side_playlist form").serialize();
$.post(url, data, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
openDiffSPL(json);
//redraw the library list
redrawDataTablePage();
@ -398,6 +421,9 @@ function deleteSPL() {
url = '/Playlist/delete-active/format/json';
$.post(url, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
noOpenPL(json);
//redraw the library list
redrawDataTablePage();
@ -405,7 +431,9 @@ function deleteSPL() {
}
function openDiffSPL(json) {
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
$("#side_playlist")
.empty()
.append(json.html);
@ -428,6 +456,9 @@ function editName() {
url = '/Playlist/set-playlist-name';
$.post(url, {format: "json", name: input.val()}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
input.addClass('element_hidden');
nameElement.text(json.playlistName);
redrawDataTablePage();
@ -460,6 +491,9 @@ function setUpSPL() {
var url = '/Playlist/set-playlist-fades';
$.get(url, {format: "json"}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
$("#spl_fade_in_main").find("span")
.empty()
.append(json.fadeIn);
@ -491,7 +525,11 @@ function setUpSPL() {
url = '/Playlist/set-playlist-description';
$.post(url, {format: "json", description: description}, function(json){
textarea.val(json.playlistDescription);
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}else{
textarea.val(json.playlistDescription);
}
});
});
@ -501,7 +539,11 @@ function setUpSPL() {
url = '/Playlist/set-playlist-description';
$.post(url, {format: "json"}, function(json){
textarea.val(json.playlistDescription);
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}else{
textarea.val(json.playlistDescription);
}
});
});
@ -520,6 +562,9 @@ function setUpSPL() {
}
$.post(url, {format: "json", fadeIn: fadeIn}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
if(json.response.error) {
return;
}
@ -543,6 +588,9 @@ function setUpSPL() {
}
$.post(url, {format: "json", fadeOut: fadeOut}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
if(json.response.error) {
return;
}
@ -571,6 +619,13 @@ function setUpSPL() {
$("#spl_sortable" ).bind( "drop", addSPLItem);
}
// Alert the error and reload the page
// this function is used to resolve concurrency issue
function alertPlaylistErrorAndReload(){
alert("The Playlist doesn't exist anymore!");
window.location.reload();
}
$(document).ready(function() {
var currentlyOpenedSplId;
setUpSPL();

View file

@ -60,6 +60,10 @@ function findHosts(request, callback) {
}
function beginEditShow(data){
if(data.show_error == true){
alertShowErrorAndReload();
return false;
}
$("#add-show-form")
.empty()
.append(data.newForm);
@ -310,7 +314,7 @@ function setAddShowEvents() {
.append(json.newForm);
setAddShowEvents();
scheduleRefetchEvents();
scheduleRefetchEvents(json);
}
});
});
@ -432,6 +436,14 @@ $(document).ready(function() {
//setAddShowEvents();
});
//Alert the error and reload the page
//this function is used to resolve concurrency issue
function alertShowErrorAndReload(){
alert("The show instance doesn't exist anymore!");
window.location.reload();
}
$(window).resize(function(){
var windowWidth = $(this).width();
// margin on showform are 16 px on each side

View file

@ -4,7 +4,10 @@
*
*/
function scheduleRefetchEvents() {
function scheduleRefetchEvents(json) {
if(json.show_error == true){
alert("The show instance doesn't exist anymore!")
}
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
}
@ -282,7 +285,6 @@ function eventRender(event, element, view) {
}
function eventAfterRender( event, element, view ) {
$(element)
.jjmenu("click",
[{get:"/Schedule/make-context-menu/format/json/id/#id#"}],
@ -301,6 +303,9 @@ function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui
$.post(url,
{day: dayDelta, min: minuteDelta, showInstanceId: event.id},
function(json){
if(json.show_error == true){
alertShowErrorAndReload();
}
if(json.error) {
alert(json.error);
revertFunc();
@ -316,12 +321,15 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie
$.post(url,
{day: dayDelta, min: minuteDelta, showInstanceId: event.id},
function(json){
if(json.show_error == true){
alertShowErrorAndReload();
}
if(json.error) {
alert(json.error);
revertFunc();
}
scheduleRefetchEvents();
scheduleRefetchEvents(json);
});
}
@ -430,6 +438,13 @@ function addQtipToSCIcons(ele){
}
}
//Alert the error and reload the page
//this function is used to resolve concurrency issue
function alertShowErrorAndReload(){
alert("The show instance doesn't exist anymore!");
window.location.reload();
}
$(document).ready(function(){
setInterval( "checkSCUploadStatus()", 5000 );
})

View file

@ -74,6 +74,9 @@ function setScheduleDialogEvents(dialog) {
$.post(url,
{format: "json", groupId: groupId},
function(json){
if(json.show_error == true){
alertShowErrorAndReload();
}
var dialog = $("#schedule_playlist_dialog");
setScheduleDialogHtml(json);
@ -103,7 +106,9 @@ function dtDrawCallback() {
}
function makeScheduleDialog(dialog, json) {
if(json.show_error == true){
alertShowErrorAndReload();
}
dialog.find('#schedule_playlists').dataTable( {
"bProcessing": true,
"bServerSide": true,
@ -151,6 +156,9 @@ function makeScheduleDialog(dialog, json) {
$.post(url,
{plId: pl_id, search: search},
function(json){
if(json.show_error == true){
alertShowErrorAndReload();
}
var dialog = $("#schedule_playlist_dialog");
setScheduleDialogHtml(json);
@ -171,7 +179,7 @@ function confirmCancelShow(show_instance_id){
var url = "/Schedule/cancel-current-show/id/"+show_instance_id;
$.ajax({
url: url,
success: function(data){scheduleRefetchEvents();}
success: function(data){scheduleRefetchEvents(data);}
});
}
}
@ -181,6 +189,12 @@ function uploadToSoundCloud(show_instance_id){
var url = "/Schedule/upload-to-sound-cloud";
var span = $(window.triggerElement).find(".recording");
$.post(url,
{id: show_instance_id, format: "json"},
function(json){
scheduleRefetchEvents(json);
});
if(span.length == 0){
span = $(window.triggerElement).find(".soundcloud");
span.removeClass("soundcloud")
@ -189,13 +203,6 @@ function uploadToSoundCloud(show_instance_id){
span.removeClass("recording")
.addClass("progress");
}
$.post(url,
{id: show_instance_id, format: "json"},
function(){
scheduleRefetchEvents();
});
}
//used by jjmenu
@ -208,6 +215,9 @@ function getId() {
//end functions used by jjmenu
function buildContentDialog(json){
if(json.show_error == true){
alertShowErrorAndReload();
}
var dialog = $(json.dialog);
var viewportwidth;
@ -263,7 +273,9 @@ function buildContentDialog(json){
function buildScheduleDialog(json){
var dialog;
if(json.show_error == true){
alertShowErrorAndReload();
}
if(json.error) {
alert(json.error);
return;
@ -289,9 +301,6 @@ function buildScheduleDialog(json){
checkShowLength();
}
function buildEditDialog(json){
}
/**
* Use user preference for time scale; defaults to month if preference was never set
@ -381,6 +390,13 @@ function createFullCalendar(data){
});
}
//Alert the error and reload the page
//this function is used to resolve concurrency issue
function alertShowErrorAndReload(){
alert("The show instance doesn't exist anymore!");
window.location.reload();
}
$(window).load(function() {
$.ajax({ url: "/Api/calendar-init/format/json", dataType:"json", success:createFullCalendar
, error:function(jqXHR, textStatus, errorThrown){}});