You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by je...@apache.org on 2015/01/22 01:31:11 UTC

git commit: updated refs/heads/volume-upload to d79c371

Repository: cloudstack
Updated Branches:
  refs/heads/volume-upload 818f9cfcc -> d79c3714d


volume-upload: UI > storage > volumes > add new action "Upload Volume from Local" in header of listView.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d79c3714
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d79c3714
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d79c3714

Branch: refs/heads/volume-upload
Commit: d79c3714d2ae1d310e74923ebf5394dd401bbfcd
Parents: 818f9cf
Author: Jessica Wang <je...@apache.org>
Authored: Wed Jan 21 16:30:12 2015 -0800
Committer: Jessica Wang <je...@apache.org>
Committed: Wed Jan 21 16:30:12 2015 -0800

----------------------------------------------------------------------
 ui/scripts/storage.js | 142 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 141 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d79c3714/ui/scripts/storage.js
----------------------------------------------------------------------
diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js
index 6585e1a..c754e3c 100644
--- a/ui/scripts/storage.js
+++ b/ui/scripts/storage.js
@@ -376,7 +376,147 @@
                             notification: {
                                 poll: pollAsyncJobResult
                             }
-                        }
+                        },
+                                                
+                        uploadVolumefromLocal: {
+                            isHeader: true,
+                            label: 'Upload Volume from Local',
+                            preFilter: function(args) {
+                                return !args.context.instances;
+                            },
+                            messages: {
+                                notification: function() {
+                                    return 'Upload Volume from Local';
+                                }
+                            },
+                            createForm: {
+                                title: 'Upload Volume from Local',
+                                fileUpload: {
+                                    getURL: function(args) {
+                                        args.data = args.formData;
+                                        
+                                        var data = {
+                                            name: args.data.name,
+                                            zoneId: args.data.availabilityZone,
+                                            format: args.data.format,
+                                            url: args.data.url
+                                        };
+
+                                        if (args.data.checksum != null && args.data.checksum.length > 0) {
+                                            $.extend(data, {
+                                                checksum: args.data.checksum
+                                            });
+                                        }
+                                        
+                                        $.ajax({
+                                            url: createURL('getUploadParamsForVolume'),
+                                            data: data,
+                                            async: false,
+                                            success: function(json) {
+                                                var uploadparams = json.postuploadvolumeresponse.getuploadparams; //son.postuploadvolumeresponse.getuploadparams is an object, not an array of object.
+                                                var volumeId = uploadparams.id;
+
+                                                args.response.success({
+                                                    url: uploadparams.postURL,
+                                                    data: {
+                                                        signature: uploadparams.signature,
+                                                        expires: uploadparams.timeout,
+                                                        metadata: uploadparams.metadata
+                                                    }
+                                                });
+                                                
+                                                cloudStack.dialog.notice({
+                                                    message: "This volume file has been uploaded. Please check its status at Stroage menu > Volumes > " + args.data.name + " > Status field."
+                                                });
+                                            }
+                                        });
+                                    },
+                                    postUpload: function(args) {
+                                        console.log("postUpload() is hit");
+                                        // Called when upload is done to do 
+                                        // verification checks;
+                                        // i.e., poll the server to verify successful upload
+                                        //
+                                        // success() will close the dialog and call standard action
+                                        // error() will keep dialog open if user wants to re-submit
+                                        args.response.success();
+                                    }
+                                },                                
+                                fields: {
+                                    volumeFileUpload: {
+                                        label: 'local file',
+                                        isFileUpload: true
+                                    },
+                                    name: {
+                                        label: 'label.name',
+                                        validation: {
+                                            required: true
+                                        },
+                                        docID: 'helpUploadVolumeName'
+                                    },
+                                    availabilityZone: {
+                                        label: 'label.availability.zone',
+                                        docID: 'helpUploadVolumeZone',
+                                        select: function(args) {
+                                            $.ajax({
+                                                url: createURL("listZones&available=true"),
+                                                dataType: "json",
+                                                async: true,
+                                                success: function(json) {
+                                                    var zoneObjs = json.listzonesresponse.zone;
+                                                    args.response.success({
+                                                        descriptionField: 'name',
+                                                        data: zoneObjs
+                                                    });
+                                                }
+                                            });
+                                        }
+                                    },
+                                    format: {
+                                        label: 'label.format',
+                                        docID: 'helpUploadVolumeFormat',
+                                        select: function(args) {
+                                            var items = [];
+                                            items.push({
+                                                id: 'RAW',
+                                                description: 'RAW'
+                                            });
+                                            items.push({
+                                                id: 'VHD',
+                                                description: 'VHD'
+                                            });
+                                            items.push({
+                                                id: 'VHDX',
+                                                description: 'VHDX'
+                                            });
+                                            items.push({
+                                                id: 'OVA',
+                                                description: 'OVA'
+                                            });
+                                            items.push({
+                                                id: 'QCOW2',
+                                                description: 'QCOW2'
+                                            });
+                                            args.response.success({
+                                                data: items
+                                            });
+                                        }
+                                    },
+                                    checksum: {
+                                        docID: 'helpUploadVolumeChecksum',
+                                        label: 'label.md5.checksum'
+                                    }
+                                }
+                            },
+
+                            action: function(args) {
+                                return; //createForm.fileUpload.getURL() has executed the whole action. Therefore, nothing needs to be done here.
+                            },
+
+                            notification: {
+                                poll: pollAsyncJobResult
+                            }
+                        }                        
                     },
 
                     advSearchFields: {