diff --git a/publisher/app/controllers/ProjectsController.php b/publisher/app/controllers/ProjectsController.php index 38cee1f..8395fa4 100644 --- a/publisher/app/controllers/ProjectsController.php +++ b/publisher/app/controllers/ProjectsController.php @@ -118,6 +118,18 @@ public function dopublish() return Response::json(array("result"=>true,'msg' => '','tasks' => $task_ids)); } + public function queryStatus() + { + $ids = Input::get('sync_svr',array()); + array_push($ids, intval(Input::get('upd_prj'))); + $tasks = Tasks::whereIn("id",$ids)->get(); + $return = array(); + foreach ($tasks as $row) { + $return[$row->id] = $row->status; + } + return Response::json($return); + } + public function getSrclog() { //TODO 根据用户权限判断 diff --git a/publisher/app/routes.php b/publisher/app/routes.php index 95c2085..efbb2b3 100644 --- a/publisher/app/routes.php +++ b/publisher/app/routes.php @@ -24,6 +24,8 @@ Route::get('projects/publish',array('before' => 'auth', 'uses' => 'ProjectsController@publish')); Route::get('projects/srclog',array('before' => 'auth', 'uses' => 'ProjectsController@getSrclog')); Route::post('projects/dopublish',array('before' => 'auth', 'uses' => 'ProjectsController@dopublish')); +Route::post('projects/querystatus',array('before' => 'auth', 'uses' => 'ProjectsController@queryStatus')); + Route::any('servers/add',array('before' => 'auth', 'uses' => 'ServersController@addServers')); Route::any('servers/edit',array('before' => 'auth', 'uses' => 'ServersController@editServers')); diff --git a/publisher/app/views/projects/publish.blade.php b/publisher/app/views/projects/publish.blade.php index bde2361..6dd4806 100644 --- a/publisher/app/views/projects/publish.blade.php +++ b/publisher/app/views/projects/publish.blade.php @@ -17,8 +17,10 @@ 当前版本{{{ $project->current_version }}} 备注{{{ $project->comments }}} 操作 - -  已经选择版本: + + +  已经选择版本:-- +  更新情况:-- @@ -93,7 +95,7 @@ thisbtn.attr("disabled","disabled").html("载入中..."); //清理所有已经载入的页 lastlog = ''; - version_log_box.html(''); + version_log_box.empty(); load_log_data(function(){thisbtn.removeAttr("disabled").html("版本选择");}); }); @@ -170,14 +172,86 @@ { //提交 $.post($("#publish_form").attr("action"),$("#publish_form").serialize(),function(_data){ - //状态,提示信息 - //设定项目update的任务号 - //设定每个服务器更新的任务号 - //启动轮询 + if(!_data.result) + { + alert(_data.msg); + return false; + } + setTimeout(function(){update_task_status(_data.tasks);},3000); },'json'); } }); +var update_task_status = function(_tasks){ + var __tasks = _tasks; + $.post("/projects/querystatus",_tasks,function(_return){ + var _done_tasks = new Array; + for(var _key in _return) + { + var _class = ''; + switch(_return[_key]) + { + case 'created': + continue; + case 'execute': + _class = 'uk-icon-spinner uk-icon-spin'; + 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) + { + if( -1 != $.inArray(__tasks.sync_svr[__key], _done_tasks)) + { + delete __tasks.sync_svr[__key]; + } + } + if($.isEmptyObject(__tasks.sync_svr)) + { + delete __tasks.sync_svr; + } + } + if(!$.isEmptyObject(__tasks)) + { + console.log(__tasks); + setTimeout(function(){update_task_status(__tasks);},3000); + } + },'json'); +} + //查询任务完成情况 @stop