|
1793 | 1793 | fields: { |
1794 | 1794 | vlanrange: { |
1795 | 1795 | label: 'label.vlan.vni.range', |
1796 | | - /* select: function(args) { |
1797 | | - var items = []; |
1798 | | - if(args.context.physicalNetworks[0].vlan != null && args.context.physicalNetworks[0].vlan.length > 0) { |
1799 | | - var vlanranges = args.context.physicalNetworks[0].vlan.split(";"); |
1800 | | - for(var i = 0; i < vlanranges.length ; i++) { |
1801 | | - items.push({id: vlanranges[i], description: vlanranges[i]}); |
1802 | | - } |
1803 | | - } |
1804 | | - args.response.success({data: items}); |
1805 | | - },*/ |
1806 | 1796 | validation: { |
1807 | 1797 | required: true |
1808 | 1798 | } |
1809 | 1799 | }, |
1810 | | - account: { |
1811 | | - label: 'label.account', |
1812 | | - validation: { |
1813 | | - required: true |
| 1800 | + scope: { |
| 1801 | + label: 'label.scope', |
| 1802 | + docID: 'helpGuestNetworkZoneScope', |
| 1803 | + select: function(args) { |
| 1804 | + var array1 = []; |
| 1805 | + |
| 1806 | + array1.push({ |
| 1807 | + id: 'account-specific', |
| 1808 | + description: 'label.account' |
| 1809 | + }); |
| 1810 | + array1.push({ |
| 1811 | + id: 'project-specific', |
| 1812 | + description: 'label.project' |
| 1813 | + }); |
| 1814 | + |
| 1815 | + args.response.success({ |
| 1816 | + data: array1 |
| 1817 | + }); |
| 1818 | + |
| 1819 | + args.$select.change(function() { |
| 1820 | + var $form = $(this).closest('form'); |
| 1821 | + |
| 1822 | + if ($(this).val() == "account-specific") { |
| 1823 | + $form.find('.form-item[rel=domainId]').css('display', 'inline-block'); |
| 1824 | + $form.find('.form-item[rel=account]').css('display', 'inline-block'); |
| 1825 | + $form.find('.form-item[rel=projectId]').hide(); |
| 1826 | + } else if ($(this).val() == "project-specific") { |
| 1827 | + $form.find('.form-item[rel=domainId]').css('display', 'inline-block'); |
| 1828 | + $form.find('.form-item[rel=account]').hide(); |
| 1829 | + $form.find('.form-item[rel=projectId]').css('display', 'inline-block'); |
| 1830 | + } |
| 1831 | + |
| 1832 | + if (args.context.projects != null && args.context.projects.length > 0) { |
| 1833 | + $form.find('.form-item[rel=domainId]').hide(); |
| 1834 | + $form.find('.form-item[rel=account]').hide(); |
| 1835 | + $form.find('.form-item[rel=projectId]').hide(); |
| 1836 | + } |
| 1837 | + }); |
| 1838 | + }, |
| 1839 | + isHidden: function(args) { |
| 1840 | + if(args.context.projects != null && args.context.projects.length > 0) |
| 1841 | + return true; |
| 1842 | + else |
| 1843 | + return false; |
1814 | 1844 | } |
1815 | 1845 | }, |
1816 | | - domainid: { |
| 1846 | + domainId: { |
1817 | 1847 | label: 'label.domain', |
1818 | 1848 | validation: { |
1819 | 1849 | required: true |
|
1836 | 1866 | } |
1837 | 1867 | }); |
1838 | 1868 | } |
| 1869 | + }, |
| 1870 | + account: { |
| 1871 | + label: 'label.account', |
| 1872 | + validation: { |
| 1873 | + required: true |
| 1874 | + }, |
| 1875 | + dependsOn: 'domainId', |
| 1876 | + select: function (args) { |
| 1877 | + $.ajax({ |
| 1878 | + url: createURL('listAccounts&domainid=' + args.domainId), |
| 1879 | + data: { |
| 1880 | + listAll: true |
| 1881 | + }, |
| 1882 | + success: function (json) { |
| 1883 | + args.response.success({ |
| 1884 | + data: $.map(json.listaccountsresponse.account, function (account) { |
| 1885 | + return { |
| 1886 | + id: account.name, |
| 1887 | + description: account.name |
| 1888 | + }; |
| 1889 | + }) |
| 1890 | + }); |
| 1891 | + } |
| 1892 | + }); |
| 1893 | + } |
| 1894 | + }, |
| 1895 | + projectId: { |
| 1896 | + label: 'label.project', |
| 1897 | + validation: { |
| 1898 | + required: true |
| 1899 | + }, |
| 1900 | + dependsOn: 'domainId', |
| 1901 | + select: function(args) { |
| 1902 | + var items = []; |
| 1903 | + $.ajax({ |
| 1904 | + url: createURL("listProjects&domainid=" + args.domainId), |
| 1905 | + dataType: "json", |
| 1906 | + async: false, |
| 1907 | + success: function(json) { |
| 1908 | + projectObjs = json.listprojectsresponse.project; |
| 1909 | + $(projectObjs).each(function() { |
| 1910 | + items.push({ |
| 1911 | + id: this.id, |
| 1912 | + description: this.name |
| 1913 | + }); |
| 1914 | + }); |
| 1915 | + } |
| 1916 | + }); |
| 1917 | + args.response.success({ |
| 1918 | + data: items |
| 1919 | + }); |
| 1920 | + } |
1839 | 1921 | } |
1840 | 1922 | } |
1841 | 1923 | }, |
1842 | 1924 | action: function (args) { |
1843 | 1925 | var data = { |
1844 | 1926 | physicalnetworkid: args.context.physicalNetworks[0].id, |
1845 | | - vlanrange: args.data.vlanrange, |
1846 | | - domainid: args.data.domainid, |
1847 | | - account: args.data.account |
| 1927 | + vlanrange: args.data.vlanrange |
1848 | 1928 | }; |
| 1929 | + |
| 1930 | + var $form = args.$form; |
| 1931 | + |
| 1932 | + if (($form.find('.form-item[rel=domainId]').css("display") != "none") && (args.data.domainId != null && args.data.domainId.length > 0)) { |
| 1933 | + $.extend(data, { |
| 1934 | + domainid: args.data.domainId |
| 1935 | + }) |
| 1936 | + } |
| 1937 | + |
| 1938 | + if (($form.find('.form-item[rel=account]').css("display") != "none") && (args.data.account != null && args.data.account.length > 0)) { |
| 1939 | + $.extend(data, { |
| 1940 | + account: args.data.account |
| 1941 | + }) |
| 1942 | + } |
| 1943 | + |
| 1944 | + if (($form.find('.form-item[rel=projectId]').css("display") != "none") && (args.data.projectId != null && args.data.projectId.length > 0)) { |
| 1945 | + $.extend(data, { |
| 1946 | + projectid: args.data.projectId |
| 1947 | + }) |
| 1948 | + } |
| 1949 | + |
1849 | 1950 | $.ajax({ |
1850 | 1951 | url: createURL('dedicateGuestVlanRange'), |
1851 | 1952 | data: data, |
|
18718 | 18819 | ucsmanagerid: args.context.ucsManagers[0].id |
18719 | 18820 | }, |
18720 | 18821 | success: function (json) { |
18721 | | - //for testing only (begin) |
18722 | | - /* |
18723 | | - json = { |
18724 | | - "refreshucsbladesresponse": { |
18725 | | - "count": 7, |
18726 | | - "ucsblade": [ |
18727 | | - { |
18728 | | - "id": "6c6a2d2c-575e-41ac-9782-eee51b0b80f8", |
18729 | | - "ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a", |
18730 | | - "bladedn": "sys/chassis-1/blade-5" |
18731 | | - }, |
18732 | | - { |
18733 | | - "id": "d371d470-a51f-489c-aded-54a63dfd76c7", |
18734 | | - "ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a", |
18735 | | - "bladedn": "sys/chassis-1/blade-6" |
18736 | | - }, |
18737 | | - { |
18738 | | - "id": "c0f64591-4a80-4083-bb7b-576220b436a2", |
18739 | | - "ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a", |
18740 | | - "bladedn": "sys/chassis-1/blade-7" |
18741 | | - }, |
18742 | | - { |
18743 | | - "id": "74b9b69a-cb16-42f5-aad6-06391ebdd759", |
18744 | | - "ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a", |
18745 | | - "bladedn": "sys/chassis-1/blade-1" |
18746 | | - }, |
18747 | | - { |
18748 | | - "id": "713a5adb-0136-484f-9acb-d9203af497be", |
18749 | | - "ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a", |
18750 | | - "bladedn": "sys/chassis-1/blade-2" |
18751 | | - }, |
18752 | | - { |
18753 | | - "id": "da633578-21cb-4678-9eb4-981a53198b41", |
18754 | | - "ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a", |
18755 | | - "bladedn": "sys/chassis-1/blade-4" |
18756 | | - }, |
18757 | | - { |
18758 | | - "id": "3d491c6e-f0b6-40b0-bf6e-f89efdd73c30", |
18759 | | - "ucsmanagerid": "9a34c186-12fa-4bbc-af04-5f1a2bf7ae4a", |
18760 | | - "bladedn": "sys/chassis-1/blade-3" |
18761 | | - } |
18762 | | - ] |
18763 | | - } |
18764 | | - }; |
18765 | | - */ |
18766 | | - //for testing only (end) |
18767 | | - |
18768 | | - /* |
18769 | | - var item = json.refreshucsbladesresponse.ucsblade[0]; |
18770 | | - addExtraPropertiesToUcsBladeObject(item); |
18771 | | - args.response.success({ |
18772 | | - data: item |
18773 | | - }); |
18774 | | - */ |
18775 | 18822 | $(window).trigger('cloudStack.fullRefresh'); |
18776 | 18823 | } |
18777 | 18824 | }); |
|
0 commit comments