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

@ -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){}});