From 7c7c09714ad3d33d98162a1f1814ffdd3b7fe8c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=8A=BC?= Date: Sat, 22 Nov 2014 19:38:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E7=AE=80=E5=8C=96=E4=BA=86=E9=A1=B5=E9=9D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controllers/ProjectsController.php | 3 +- .../app/views/projects/publish.blade.php | 62 +++++++------------ 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/publisher/app/controllers/ProjectsController.php b/publisher/app/controllers/ProjectsController.php index 8395fa4..5cdacde 100644 --- a/publisher/app/controllers/ProjectsController.php +++ b/publisher/app/controllers/ProjectsController.php @@ -120,8 +120,7 @@ public function dopublish() public function queryStatus() { - $ids = Input::get('sync_svr',array()); - array_push($ids, intval(Input::get('upd_prj'))); + $ids = Input::get('ids',array()); $tasks = Tasks::whereIn("id",$ids)->get(); $return = array(); foreach ($tasks as $row) { diff --git a/publisher/app/views/projects/publish.blade.php b/publisher/app/views/projects/publish.blade.php index 6dd4806..616b97f 100644 --- a/publisher/app/views/projects/publish.blade.php +++ b/publisher/app/views/projects/publish.blade.php @@ -177,14 +177,29 @@ alert(_data.msg); return false; } - setTimeout(function(){update_task_status(_data.tasks);},3000); + var _task_ids = new Array; + //绑定显示元素和任务之间的关系 + if(typeof(_data.tasks.upd_prj) != 'undefined') + { + $("#show_update_status").addClass("task_id_"+_data.tasks.upd_prj); + _task_ids.push(parseInt(_data.tasks.upd_prj)); + } + if(typeof(_data.tasks.sync_svr) != 'undefined') + { + for(var _key in _data.tasks.sync_svr) + { + $(".server_"+_key).find("td:eq(4)").addClass("task_id_"+_data.tasks.sync_svr[_key]); + _task_ids.push(parseInt(_data.tasks.sync_svr[_key])); + } + } + setTimeout(function(){update_task_status(_task_ids);},3000); },'json'); } }); var update_task_status = function(_tasks){ var __tasks = _tasks; - $.post("/projects/querystatus",_tasks,function(_return){ + $.post("/projects/querystatus",{ids:_tasks},function(_return){ var _done_tasks = new Array; for(var _key in _return) { @@ -198,55 +213,24 @@ break; case 'success': _class = 'uk-icon-check-circle-o'; - _done_tasks.push(parseInt(_key)); break; case 'failed': _class = 'uk-icon-times-circle-o'; - _done_tasks.push(parseInt(_key)); break; } - if(typeof(__tasks.upd_prj) != 'undefined' && __tasks.upd_prj == _key) - { - $("#show_update_status").empty().append($("").attr('class', _class)); - } - else - { - if(__tasks.sync_svr != 'undefined') - { - for(var __key in __tasks.sync_svr) - { - if(__tasks.sync_svr[__key] == _key) - { - $(".server_"+__key).find("td:eq(4)").empty().append($("").attr('class', _class)); - break; - } - } - } - } - } - console.log(_done_tasks); - console.log(__tasks); - if(typeof(__tasks.upd_prj) != 'undefined' && -1 != $.inArray(__tasks.upd_prj, _done_tasks)) - { - delete __tasks.upd_prj; - } - if(typeof(__tasks.sync_svr) != 'undefined') - { - for(var __key in __tasks.sync_svr) + $(".task_id_"+_key).empty().append($("").attr('class', _class)); + if(_return[_key] == 'success' || _return[_key] == 'failed') { - if( -1 != $.inArray(__tasks.sync_svr[__key], _done_tasks)) + //从__tasks里面删除 + _index = $.inArray(parseInt(_key), __tasks); + if(_index != -1) { - delete __tasks.sync_svr[__key]; + __tasks.splice(_index,1); } } - if($.isEmptyObject(__tasks.sync_svr)) - { - delete __tasks.sync_svr; - } } if(!$.isEmptyObject(__tasks)) { - console.log(__tasks); setTimeout(function(){update_task_status(__tasks);},3000); } },'json');