|
5612 | 5612 | }); |
5613 | 5613 | } |
5614 | 5614 | } |
5615 | | - }, |
5616 | | - |
5617 | | - // Enable swift |
5618 | | - enableSwift: { |
5619 | | - label: 'label.enable.swift', |
5620 | | - isHeader: true, |
5621 | | - addRow: false, |
5622 | | - preFilter: function(args) { |
5623 | | - var swiftEnableConfiguration = false; |
5624 | | - $.ajax({ |
5625 | | - url: createURL('listConfigurations'), |
5626 | | - data: { |
5627 | | - name: 'swift.enable' |
5628 | | - }, |
5629 | | - async: false, |
5630 | | - success: function(json) { |
5631 | | - swiftEnableConfiguration = json.listconfigurationsresponse.configuration[0].value == 'true' ? true : false; |
5632 | | - } |
5633 | | - }); |
5634 | | - |
5635 | | - var havingSwift = false; |
5636 | | - $.ajax({ |
5637 | | - url: createURL("listImageStores"), |
5638 | | - data: { |
5639 | | - provider: 'Swift' |
5640 | | - }, |
5641 | | - async: false, |
5642 | | - success: function(json) { |
5643 | | - var items = json.listimagestoreresponse.imagestore; |
5644 | | - if (items != null && items.length > 0) |
5645 | | - havingSwift = true; |
5646 | | - } |
5647 | | - }); |
5648 | | - |
5649 | | - if(swiftEnableConfiguration == true && havingSwift == false) |
5650 | | - return true; |
5651 | | - else |
5652 | | - return false; |
5653 | | - }, |
5654 | | - messages: { |
5655 | | - notification: function(args) { |
5656 | | - return 'label.enable.swift'; |
5657 | | - } |
5658 | | - }, |
5659 | | - createForm: { |
5660 | | - desc: 'confirm.enable.swift', |
5661 | | - fields: { |
5662 | | - url: { |
5663 | | - label: 'label.url', |
5664 | | - validation: { |
5665 | | - required: true |
5666 | | - } |
5667 | | - }, |
5668 | | - account: { |
5669 | | - label: 'label.account' |
5670 | | - }, |
5671 | | - username: { |
5672 | | - label: 'label.username' |
5673 | | - }, |
5674 | | - key: { |
5675 | | - label: 'label.key' |
5676 | | - } |
5677 | | - } |
5678 | | - }, |
5679 | | - action: function(args) { |
5680 | | - $.ajax({ |
5681 | | - url: createURL('addSwift'), |
5682 | | - data: { |
5683 | | - url: args.data.url, |
5684 | | - account: args.data.account, |
5685 | | - username: args.data.username, |
5686 | | - key: args.data.key |
5687 | | - }, |
5688 | | - success: function(json) { |
5689 | | - args.response.success(); |
5690 | | - |
5691 | | - cloudStack.dialog.notice({ |
5692 | | - message: 'message.after.enable.swift' |
5693 | | - }); |
5694 | | - }, |
5695 | | - error: function(json) { |
5696 | | - args.response.error(parseXMLHttpResponse(json)); |
5697 | | - } |
5698 | | - }); |
5699 | | - } |
5700 | | - }, |
5701 | | - |
5702 | | - enableS3: { |
5703 | | - label: 'label.enable.s3', |
5704 | | - isHeader: true, |
5705 | | - addRow: false, |
5706 | | - |
5707 | | - preFilter: function(args) { |
5708 | | - var s3EnableConfiguration = false; |
5709 | | - $.ajax({ |
5710 | | - url: createURL('listConfigurations'), |
5711 | | - data: { |
5712 | | - name: 's3.enable' |
5713 | | - }, |
5714 | | - async: false, |
5715 | | - success: function(json) { |
5716 | | - s3EnableConfiguration = json.listconfigurationsresponse.configuration[0].value == 'true' ? true : false; |
5717 | | - } |
5718 | | - }); |
5719 | | - |
5720 | | - var havingS3 = false; |
5721 | | - $.ajax({ |
5722 | | - url: createURL("listImageStores"), |
5723 | | - data: { |
5724 | | - provider: 'S3' |
5725 | | - }, |
5726 | | - async: false, |
5727 | | - success: function(json) { |
5728 | | - var items = json.listimagestoreresponse.imagestore; |
5729 | | - if (items != null && items.length > 0) { |
5730 | | - havingS3 = true; |
5731 | | - } |
5732 | | - } |
5733 | | - }); |
5734 | | - |
5735 | | - if(s3EnableConfiguration == true && havingS3 == false) |
5736 | | - return true; |
5737 | | - else |
5738 | | - return false; |
5739 | | - }, |
5740 | | - |
5741 | | - messages: { |
5742 | | - notification: function(args) { |
5743 | | - return 'label.enable.s3'; |
5744 | | - } |
5745 | | - }, |
5746 | | - |
5747 | | - createForm: { |
5748 | | - desc: 'confirm.enable.s3', |
5749 | | - fields: { |
5750 | | - accesskey: { |
5751 | | - label: 'label.s3.access_key', |
5752 | | - validation: { |
5753 | | - required: true |
5754 | | - } |
5755 | | - }, |
5756 | | - secretkey: { |
5757 | | - label: 'label.s3.secret_key', |
5758 | | - validation: { |
5759 | | - required: true |
5760 | | - } |
5761 | | - }, |
5762 | | - bucket: { |
5763 | | - label: 'label.s3.bucket', |
5764 | | - validation: { |
5765 | | - required: true |
5766 | | - } |
5767 | | - }, |
5768 | | - endpoint: { |
5769 | | - label: 'label.s3.endpoint' |
5770 | | - }, |
5771 | | - usehttps: { |
5772 | | - label: 'label.s3.use_https', |
5773 | | - isEditable: true, |
5774 | | - isBoolean: true, |
5775 | | - isChecked: true, |
5776 | | - converter: cloudStack.converters.toBooleanText |
5777 | | - }, |
5778 | | - connectiontimeout: { |
5779 | | - label: 'label.s3.connection_timeout' |
5780 | | - }, |
5781 | | - maxerrorretry: { |
5782 | | - label: 'label.s3.max_error_retry' |
5783 | | - }, |
5784 | | - sockettimeout: { |
5785 | | - label: 'label.s3.socket_timeout' |
5786 | | - } |
5787 | | - } |
5788 | | - }, |
5789 | | - action: function(args) { |
5790 | | - $.ajax({ |
5791 | | - url: createURL('addS3'), |
5792 | | - data: { |
5793 | | - accesskey: args.data.accesskey, |
5794 | | - secretkey: args.data.secretkey, |
5795 | | - bucket: args.data.bucket, |
5796 | | - endpoint: args.data.endpoint, |
5797 | | - usehttps: (args.data.usehttps != null && args.data.usehttps == 'on' ? 'true' : 'false'), |
5798 | | - connectiontimeout: args.data.connectiontimeout, |
5799 | | - maxerrorretry: args.data.maxerrorretry, |
5800 | | - sockettimeout: args.data.sockettimeout |
5801 | | - }, |
5802 | | - success: function(json) { |
5803 | | - args.response.success(); |
5804 | | - |
5805 | | - cloudStack.dialog.notice({ |
5806 | | - message: 'message.after.enable.s3' |
5807 | | - }); |
5808 | | - }, |
5809 | | - error: function(json) { |
5810 | | - args.response.error(parseXMLHttpResponse(json)); |
5811 | | - } |
5812 | | - }); |
5813 | | - } |
5814 | 5615 | } |
5815 | 5616 | }, |
5816 | 5617 |
|
|
0 commit comments