On 09/11/2014 04:23 AM, Aline Manera wrote:
On 09/10/2014 09:02 AM, Hongliang Wang wrote:
> Added APIs to kimchi.api.js.
>
> Signed-off-by: Hongliang Wang <hlwang(a)linux.vnet.ibm.com>
> ---
> ui/js/src/kimchi.api.js | 49
> +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
>
> diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
> index 5fc456d..393962b 100644
> --- a/ui/js/src/kimchi.api.js
> +++ b/ui/js/src/kimchi.api.js
> @@ -1130,5 +1130,54 @@ var kimchi = {
> kimchi.message.error(data.responseJSON.reason);
> }
> });
> + },
> +
> + /**
> + * Add a volume to a given storage pool by URL.
> + */
> + downloadVolumeToSP: function(settings, suc, err) {
> + var url = settings['url'];
> + var name = settings['name'];
> + var sp = encodeURIComponent(settings['sp']);
> + kimchi.requestJSON({
> + url : kimchi.url + 'storagepools/' + sp +
> '/storagevolumes',
> + type : 'POST',
> + data : JSON.stringify({
> + name: name,
> + url: url
> + }),
> + contentType : 'application/json',
> + dataType : 'json',
> + success : suc,
> + error : err
> + });
> + },
> +
> + makeTaskTrackFunc: function(task) {
> + return function(suc, err, progress) {
> + var onTaskResponse = function(result) {
> + var taskStatus = result['status'];
> + switch(taskStatus) {
> + case 'running':
> + progress && progress(result);
> + setTimeout(trackTask, 200);
> + break;
> + case 'finished':
> + suc(result);
> + break;
> + case 'failed':
> + err(result);
> + break;
> + default:
> + break;
> + }
> + };
> +
> + var trackTask = function() {
> + kimchi.getTask(task, onTaskResponse, err);
> + };
> +
> + trackTask();
> + };
A recently code merged already created a function like above
(trackTask) - you can use it.
ACK.
> }
> };