Updated Branches: refs/heads/ui-dedicatedresources-refactoring 22ddc3fa0 -> 63b398e93
UI: fix nested api for dedicating pod/cluster/host Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/63b398e9 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/63b398e9 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/63b398e9 Branch: refs/heads/ui-dedicatedresources-refactoring Commit: 63b398e93056123070d87b4f2c297667638cefc9 Parents: 22ddc3f Author: Isaac Chiang <isaacchi...@gmail.com> Authored: Thu Jul 18 10:27:50 2013 +0800 Committer: Isaac Chiang <isaacchi...@gmail.com> Committed: Thu Jul 18 10:27:50 2013 +0800 ---------------------------------------------------------------------- ui/scripts/system.js | 139 ++++++++++++++++----------------- ui/scripts/ui/widgets/listView.js | 22 +++--- 2 files changed, 81 insertions(+), 80 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63b398e9/ui/scripts/system.js ---------------------------------------------------------------------- diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 18c3df4..a677d91 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -9454,51 +9454,49 @@ podId = json.createpodresponse.pod.id; //EXPLICIT DEDICATION - if(args.$form.find('.form-item[rel=isDedicated]').find('input[type=checkbox]').is(':Checked')== true){ + if(args.$form.find('.form-item[rel=isDedicated]') + .find('input[type=checkbox]').is(':Checked')== true){ + var array2 = []; + if(args.data.accountId != "") array2.push("&account=" +todb(args.data.accountId)); if(podId != null){ - $.ajax({ - url:createURL("dedicatePod&podId=" +podId +"&domainId=" +args.data.domainId + array2.join("")), - dataType:"json", - success:function(json){ + $.ajax({ + url:createURL("dedicatePod&podId=" + + podId + + "&domainId=" + + args.data.domainId + + array2.join("")), + dataType:"json", + success:function(json){ var jid = json.dedicatepodresponse.jobid; - args.response.success({ - _custom: - { jobId: jid - }, - notification: { - poll: pollAsyncJobResult + args.response.success({ + _custom:{ + jobId: jid }, - - data:item - }); - - }, - - error:function(json){ - - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } - }); - - } - } - else { - args.response.success({data: item}); + notification: { + poll: pollAsyncJobResult, + // FIXME: should use label tag + desc: "Dedicate Pod" + }, + data:item + }); + }, + error:function(json){ + args.response.error(parseXMLHttpResponse(XMLHttpResponse)); + } + }); + } } - + args.response.success({data: item}); }, error: function(XMLHttpResponse) { var errorMsg = parseXMLHttpResponse(XMLHttpResponse); args.response.error(errorMsg); } - }); - - }, notification: { @@ -10421,18 +10419,22 @@ if(clusterId != null){ $.ajax({ - url:createURL("dedicateCluster&clusterId=" +clusterId +"&domainId=" +args.data.domainId + array2.join("")), + url:createURL("dedicateCluster&clusterId=" + + clusterId +"&domainId=" + + args.data.domainId + + array2.join("")), dataType:"json", success:function(json){ var jid = json.dedicateclusterresponse.jobid; args.response.success({ - _custom: - { jobId: jid + _custom: { + jobId: jid }, notification: { - poll: pollAsyncJobResult + poll: pollAsyncJobResult, + // FIXME: should use label tag + desc: 'Dedicate Cluster' }, - data:$.extend(item, {state:'Enabled'}) }); @@ -10442,9 +10444,8 @@ } }); } - } else { - args.response.success({data: item}); } + args.response.success({data: item}); }, error: function(XMLHttpResponse) { var errorMsg = parseXMLHttpResponse(XMLHttpResponse); @@ -11513,50 +11514,47 @@ var array2 = []; if(args.$form.find('.form-item[rel=isDedicated]').find('input[type=checkbox]').is(':Checked')== true){ + if(args.data.accountId != "") array2.push("&account=" +todb(args.data.accountId)); - - if(hostId != null){ - $.ajax({ - url:createURL("dedicateHost&hostId=" +hostId +"&domainId=" +args.data.domainId + array2.join("")), - dataType:"json", - success:function(json){ - var jid = json.dedicatehostresponse.jobid; - args.response.success({ - _custom: - { jobId: jid - }, - notification: { - poll: pollAsyncJobResult - }, - - data:item - - }); - - }, + if(hostId != null){ + $.ajax({ + url:createURL("dedicateHost&hostId=" + + hostId + + "&domainId=" + + args.data.domainId + + array2.join("")), + dataType:"json", + success:function(json) { + var jid = json.dedicatehostresponse.jobid; + args.response.success({ + _custom: { + jobId: jid + }, + notification: { + poll: pollAsyncJobResult, + // FIXME: should use label tag + desc: "Dedicate Host" + }, + data:item + }); - error:function(json){ - args.response.error(parseXMLHttpResponse(XMLHttpResponse)); - } - }); - } - } - else { - args.response.success({data: item}); + }, + error:function(json){ + args.response.error(parseXMLHttpResponse(XMLHttpResponse)); + } + }); + } } - + args.response.success({data: item}); }, - error: function(XMLHttpResponse) { var errorMsg = parseXMLHttpResponse(XMLHttpResponse); args.response.error(errorMsg); } - }); }, - notification: { poll: function(args){ args.complete({ @@ -11564,7 +11562,6 @@ }); } }, - messages: { notification: function(args) { return 'label.add.host'; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63b398e9/ui/scripts/ui/widgets/listView.js ---------------------------------------------------------------------- diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js index bc68a72..283d5de 100644 --- a/ui/scripts/ui/widgets/listView.js +++ b/ui/scripts/ui/widgets/listView.js @@ -182,6 +182,8 @@ // Disable any clicking/actions for row $instanceRow.bind('click', function() { return false; }); + if(args.notification) notification = args.notification; + notification._custom = args._custom; if (additional && additional.success) additional.success(args); @@ -246,25 +248,27 @@ {}, // Error - function(args) { + function(errorArgs) { if (!isHeader) { if ($instanceRow.data('list-view-new-item')) { // For create forms $instanceRow.remove(); } else { // For standard actions - replaceItem( - $instanceRow, - $.extend($instanceRow.data('json-obj'), args.data), - args.actionFilter ? - args.actionFilter : - $instanceRow.data('list-view-action-filter') - ); + if(!args.notification) { + replaceItem( + $instanceRow, + $.extend($instanceRow.data('json-obj'), errorArgs.data), + errorArgs.actionFilter ? + errorArgs.actionFilter : + $instanceRow.data('list-view-action-filter') + ); + } } } if (options.error) { - options.error(args); + options.error(errorArgs); } } );