@@ -104,7 +104,7 @@ <h5>Aggregation <i class="fa fa-calculator"></i>
104
104
< h5 > Topology < i class ="fa fa-sitemap "> </ i >
105
105
< input type ="checkbox " id ="mod-topology " style ="margin-right: 10px; float: left; ">
106
106
</ h5 >
107
- < div style ="display: inline-block; ">
107
+ < div style ="display: inline-block; white-space: nowrap; ">
108
108
< label style ="display: inline-block; align-items: center; margin-bottom: 10px; ">
109
109
< input type ="checkbox " id ="mod-fully " value ='Fully ' style ="margin-right: 10px; " checked > Fully
110
110
</ label >
@@ -114,7 +114,9 @@ <h5>Topology <i class="fa fa-sitemap"></i>
114
114
< label style ="display: inline-block; align-items: center; margin-bottom: 10px; ">
115
115
< input type ="checkbox " id ="mod-star " value ='Star ' style ="margin-right: 10px; margin-left: 10px; "> Star
116
116
</ label >
117
- < input type ="number " id ="mod-topology-nodes " placeholder ="Nº nodes " min ="0 " value ="3 " style ="display: inline; width: 40%; margin-left: 10px; ">
117
+ < input type ="number " id ="mod-topology-nodes " placeholder ="Nodes " oninput ="greaterthan0(this) " style ="display: inline; width: 15%; margin-left: 10px; ">
118
+ < input type ="number " id ="mod-topology-increment " placeholder ="Increment " oninput ="greaterthan0(this) " style ="display: inline; width: 21%; margin-left: 0px; ">
119
+ < input type ="number " id ="mod-topology-iterations " placeholder ="Iterations " oninput ="greaterthan0(this) " style ="display: inline; width: 20%; margin-left: 0px; ">
118
120
</ div >
119
121
< hr >
120
122
< h5 > Dataset < i class ="fa fa-database "> </ i >
@@ -265,7 +267,7 @@ <h5 class="step-title">Topology generation</h5>
265
267
< option > Random</ option >
266
268
</ select >
267
269
< input type ="number " class ="form-control " id ="predefined-topology-nodes "
268
- placeholder ="Number of nodes " min ="0 " value ="3 " style ="display: inline; width: 40% ">
270
+ placeholder ="Number of nodes " min ="1 " value ="3 " oninput =" greaterthan0(this) " style ="display: inline; width: 40% ">
269
271
< i id ="networkTopologyRandom " class ="fa fa-refresh "> </ i >
270
272
</ div >
271
273
</ div >
@@ -1063,8 +1065,12 @@ <h5 class="step-title">Schema of deployment</h5>
1063
1065
// Step 4
1064
1066
if ( data [ "topology" ] === "Custom" ) {
1065
1067
document . getElementById ( "custom-topology-btn" ) . checked = true ;
1068
+ document . getElementById ( "custom-topology-btn" ) . click ( ) ;
1069
+ document . getElementById ( "predefined-topology-select" ) . value = "Fully" ;
1070
+ document . getElementById ( "predefined-topology-nodes" ) . value = 3 ;
1066
1071
} else {
1067
1072
document . getElementById ( "predefined-topology-btn" ) . checked = true ;
1073
+ document . getElementById ( "predefined-topology-btn" ) . click ( ) ;
1068
1074
document . getElementById ( "predefined-topology-select" ) . value = data [ "topology" ] ;
1069
1075
document . getElementById ( "predefined-topology-nodes" ) . value = data [ "n_nodes" ] ;
1070
1076
}
@@ -1685,6 +1691,7 @@ <h5 class="step-title">Schema of deployment</h5>
1685
1691
scenarioStorage . replaceScenario ( ) ;
1686
1692
1687
1693
clearFields ( ) ;
1694
+ updateModelOptions ( ) ;
1688
1695
updateScenariosPosition ( true ) ;
1689
1696
1690
1697
document . getElementById ( "new-btn" ) . style . display = "none" ;
@@ -1774,7 +1781,6 @@ <h5 class="step-title">Schema of deployment</h5>
1774
1781
//Show next scenario
1775
1782
scenarioStorage . actual_scenario = scenarioStorage . actual_scenario + 1 ;
1776
1783
setScenarioData ( scenarioStorage . scenariosList [ scenarioStorage . actual_scenario ] ) ;
1777
- updateModelOptions ( ) ;
1778
1784
updateScenariosPosition ( ) ;
1779
1785
1780
1786
if ( scenarioStorage . actual_scenario == scenarioStorage . scenariosList . length - 1 ) {
@@ -1793,7 +1799,6 @@ <h5 class="step-title">Schema of deployment</h5>
1793
1799
scenarioStorage . actual_scenario = scenarioStorage . actual_scenario - 1 ;
1794
1800
var actual_scenario = scenarioStorage . scenariosList [ scenarioStorage . actual_scenario ] ;
1795
1801
setScenarioData ( actual_scenario ) ;
1796
- updateModelOptions ( ) ;
1797
1802
updateScenariosPosition ( ) ;
1798
1803
1799
1804
if ( scenarioStorage . actual_scenario == 0 ) {
@@ -1805,7 +1810,7 @@ <h5 class="step-title">Schema of deployment</h5>
1805
1810
</ script >
1806
1811
1807
1812
< script >
1808
- //Scenario generataion
1813
+ //User inputs
1809
1814
1810
1815
function atLeastOneChecked ( checkboxIds ) {
1811
1816
return checkboxIds . some ( function ( id ) {
@@ -1821,6 +1826,17 @@ <h5 class="step-title">Schema of deployment</h5>
1821
1826
}
1822
1827
}
1823
1828
1829
+ function greaterthan0 ( input ) {
1830
+ value = parseInt ( input . value )
1831
+ if ( value < 1 && ! isNaN ( value ) ) {
1832
+ input . value = 1 ;
1833
+ }
1834
+ }
1835
+ </ script >
1836
+
1837
+ < script >
1838
+ //Scenario generataion
1839
+
1824
1840
// Show the modal
1825
1841
document . getElementById ( "open-gen-modal-btn" ) . addEventListener ( "click" , function ( ) {
1826
1842
$ ( '#gen-modal' ) . modal ( 'show' ) ;
@@ -1878,53 +1894,77 @@ <h5 class="step-title">Schema of deployment</h5>
1878
1894
return ;
1879
1895
}
1880
1896
1897
+ var increment = parseInt ( document . getElementById ( "mod-topology-increment" ) . value ) ;
1898
+ var iterations = parseInt ( document . getElementById ( "mod-topology-iterations" ) . value ) ;
1899
+ var nodes = parseInt ( document . getElementById ( "mod-topology-nodes" ) . value ) ;
1900
+
1901
+ //Default value for nodes
1902
+ if ( isNaN ( nodes ) ) {
1903
+ nodes = 3 ;
1904
+ }
1905
+
1906
+ //Default iterations value
1907
+ if ( isNaN ( iterations ) ) {
1908
+ iterations = 1 ;
1909
+ increment = 0 ;
1910
+ }
1911
+
1881
1912
//Generate scenarios with all aggregation methods selected
1882
- for ( var it1 = 0 ; it1 < aggregation_methods . length ; it1 ++ ) {
1883
- var aggregation_checkbox = document . getElementById ( aggregation_methods [ it1 ] ) ;
1884
- if ( aggregation_checkbox . checked ) {
1885
- document . getElementById ( "aggregationSelect" ) . value = aggregation_checkbox . value ;
1886
-
1887
- //Generate topologys
1888
- //Selected topology
1889
- for ( var it2 = 0 ; it2 < topologys . length ; it2 ++ ) {
1890
- var topology_checkbox = document . getElementById ( topologys [ it2 ] ) ;
1891
- if ( topology_checkbox . checked ) {
1892
- document . getElementById ( "predefined-topology-select" ) . value = topology_checkbox . value ;
1893
- document . getElementById ( "predefined-topology-nodes" ) . value = document . getElementById ( "mod-topology-nodes" ) . value ;
1894
- document . getElementById ( "networkTopologyRandom" ) . click ( ) ;
1895
-
1896
- //Generate datasets
1897
- //Selected dataset
1898
- for ( var it3 = 0 ; it3 < datasets . length ; it3 ++ ) {
1899
- var dataset_checkbox = document . getElementById ( datasets [ it3 ] ) ;
1900
- if ( dataset_checkbox . checked ) {
1901
- document . getElementById ( "datasetSelect" ) . value = dataset_checkbox . value ;
1902
- document . getElementById ( "modelSelect" ) . value = updateModelOptions ( ) ;
1903
-
1904
- //Generate attacks
1905
- //Selected attack
1906
- for ( var it4 = 0 ; it4 < attacks . length ; it4 ++ ) {
1907
- var attacks_checkbox = document . getElementById ( attacks [ it4 ] ) ;
1908
- if ( attacks_checkbox . checked ) {
1909
- document . getElementById ( "poisoning-attack-select" ) . value = attacks_checkbox . value ;
1910
-
1911
- //Set scenario title
1912
- document . getElementById ( "scenario-title" ) . value = document . getElementById ( "aggregationSelect" ) . value + "_" +
1913
- document . getElementById ( "predefined-topology-select" ) . value + "_nodes" +
1914
- document . getElementById ( "predefined-topology-nodes" ) . value + "_" +
1915
- document . getElementById ( "datasetSelect" ) . value + "_" + document . getElementById ( "poisoning-attack-select" ) . value ;
1916
-
1917
-
1918
- //Save generated scenario
1919
- scenarioStorage . saveScenario ( ) ;
1920
- scenarioStorage . actual_scenario = scenarioStorage . scenariosList . length - 1 ;
1913
+ for ( var it0 = 0 ; it0 < iterations ; it0 ++ ) {
1914
+ for ( var it1 = 0 ; it1 < aggregation_methods . length ; it1 ++ ) {
1915
+ var aggregation_checkbox = document . getElementById ( aggregation_methods [ it1 ] ) ;
1916
+ if ( aggregation_checkbox . checked ) {
1917
+ document . getElementById ( "aggregationSelect" ) . value = aggregation_checkbox . value ;
1918
+
1919
+ //Generate topologys
1920
+ //Selected topology
1921
+ for ( var it2 = 0 ; it2 < topologys . length ; it2 ++ ) {
1922
+ var topology_checkbox = document . getElementById ( topologys [ it2 ] ) ;
1923
+ if ( topology_checkbox . checked ) {
1924
+ document . getElementById ( "predefined-topology-select" ) . value = topology_checkbox . value ;
1925
+
1926
+ // Node increment TODO number of times to increment
1927
+ if ( it2 != 0 ) {
1928
+ }
1929
+
1930
+ document . getElementById ( "predefined-topology-nodes" ) . value = nodes ;
1931
+ document . getElementById ( "networkTopologyRandom" ) . click ( ) ;
1932
+
1933
+ //Generate datasets
1934
+ //Selected dataset
1935
+ for ( var it3 = 0 ; it3 < datasets . length ; it3 ++ ) {
1936
+ var dataset_checkbox = document . getElementById ( datasets [ it3 ] ) ;
1937
+ if ( dataset_checkbox . checked ) {
1938
+ document . getElementById ( "datasetSelect" ) . value = dataset_checkbox . value ;
1939
+ document . getElementById ( "modelSelect" ) . value = updateModelOptions ( ) ;
1940
+
1941
+ //Generate attacks
1942
+ //Selected attack
1943
+ for ( var it4 = 0 ; it4 < attacks . length ; it4 ++ ) {
1944
+ var attacks_checkbox = document . getElementById ( attacks [ it4 ] ) ;
1945
+ if ( attacks_checkbox . checked ) {
1946
+ document . getElementById ( "poisoning-attack-select" ) . value = attacks_checkbox . value ;
1947
+
1948
+ //Set scenario title
1949
+ document . getElementById ( "scenario-title" ) . value = document . getElementById ( "aggregationSelect" ) . value + "_" +
1950
+ document . getElementById ( "predefined-topology-select" ) . value + "_nodes" +
1951
+ document . getElementById ( "predefined-topology-nodes" ) . value + "_" +
1952
+ document . getElementById ( "datasetSelect" ) . value + "_" + document . getElementById ( "poisoning-attack-select" ) . value ;
1953
+
1954
+
1955
+ //Save generated scenario
1956
+ scenarioStorage . saveScenario ( ) ;
1957
+ scenarioStorage . actual_scenario = scenarioStorage . scenariosList . length - 1 ;
1958
+ }
1921
1959
}
1922
1960
}
1923
1961
}
1924
1962
}
1925
1963
}
1926
1964
}
1927
1965
}
1966
+ // Increment nodes
1967
+ nodes = nodes + increment ;
1928
1968
}
1929
1969
1930
1970
//Show buttons
0 commit comments