CLOUDSTACK-1065: cloudstack UI - regions menu - implement create region action.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8b15988a Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8b15988a Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8b15988a Branch: refs/heads/marvin_refactor Commit: 8b15988a01d9737e49c77d6d41f7943e1a7f471f Parents: e9cc875 Author: Jessica Wang <[email protected]> Authored: Tue Mar 19 13:14:29 2013 -0700 Committer: Prasanna Santhanam <[email protected]> Committed: Sun Mar 31 22:01:09 2013 +0530 ---------------------------------------------------------------------- ui/scripts/regions.js | 57 ++++++++++++++----------------------------- 1 files changed, 19 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b15988a/ui/scripts/regions.js ---------------------------------------------------------------------- diff --git a/ui/scripts/regions.js b/ui/scripts/regions.js index 8839dec..917b761 100644 --- a/ui/scripts/regions.js +++ b/ui/scripts/regions.js @@ -27,8 +27,10 @@ args.response.success({ data: regions ? regions : [ - { id: -1, name: _l('label.no.data') } - ] + { id: -1, name: '(Default)' } + ], + activeRegionID: cloudStack.context.users.regionid ? + cloudStack.context.users.regionid : 1 }); } }); @@ -53,34 +55,34 @@ fields: { id: { label: 'label.id', validation: { required: true } }, name: { label: 'label.name', validation: { required: true } }, - endpoint: { label: 'label.endpoint', validation: { required: true } } + endpoint: { label: 'label.endpoint', validation: { required: true } } } }, - action: function(args) { - var data = { + action: function(args) { + var data = { id: args.data.id, name: args.data.name, endpoint: args.data.endpoint - }; - + }; + $.ajax({ url: createURL('addRegion'), data: data, - success: function(json) { + success: function(json) { var item = json.addregionresponse.region; - args.response.success({data: item}); - $(window).trigger('cloudStack.refreshRegions'); + args.response.success({data: item}); + //$(window).trigger('cloudStack.refreshRegions'); }, error: function(json) { args.response.error(parseXMLHttpResponse(json)); } }); - }, + }, notification: { poll: function(args) { args.complete(); } - } + } } }, dataProvider: function(args) { @@ -104,15 +106,9 @@ edit: { label: 'label.edit.region', action: function(args) { - var data = { - id: args.context.regions[0].id, - name: args.data.name, - endpoint: args.data.endpoint - }; - $.ajax({ url: createURL('updateRegion'), - data: data, + data: args.data, success: function(json) { args.response.success(); $(window).trigger('cloudStack.refreshRegions'); @@ -128,22 +124,7 @@ messages: { notification: function() { return 'label.remove.region'; }, confirm: function() { return 'message.remove.region'; } - }, - preAction: function(args) { - var region = args.context.regions[0]; - - /* e.g. - region.endpoint == "http://localhost:8080/client/" - document.location.href == "http://localhost:8080/client/#" - */ - /* - if(document.location.href.indexOf(region.endpoint) != -1) { - cloudStack.dialog.notice({ message: _l('You can not remove the region that you are currently in.') }); - return false; - } - */ - return true; - }, + }, action: function(args) { var region = args.context.regions[0]; @@ -166,11 +147,11 @@ title: 'label.details', fields: [ { - id: { label: 'label.id' } + name: { label: 'label.name', isEditable: true }, }, { - name: { label: 'label.name', isEditable: true }, - endpoint: { label: 'label.endpoint', isEditable: true } + endpoint: { label: 'label.endpoint', isEditable: true }, + id: { label: 'label.id', isEditable: true } } ], dataProvider: function(args) {
