Skip to content

Commit 8343f1b

Browse files
author
mreishman
committed
add server chlogic changes
1 parent a087184 commit 8343f1b

File tree

5 files changed

+177
-78
lines changed

5 files changed

+177
-78
lines changed

core/html/changelog.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
Bug Fixes
1515
<ul>
1616
<li>
17-
Fixed issue with errors not displaying correctly when poll fails.
17+
Fixed issue with errors not displaying correctly when poll fails
1818
</li>
1919
<li>
2020
Changed archive to dropdown from button
2121
</li>
22+
<li>
23+
Fixed bug where adding a new server would show dropdown inputs as text field inputs
24+
</li>
2225
</ul>
2326
</li>
2427
</ul>

core/js/watchlist.js

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,91 @@ var countOfAddedFiles = 0;
33
var countOfClicks = 0;
44
var locationInsert = "newRowLocationForWatchList";
55

6+
function generateTypeSelect(value)
7+
{
8+
returnText = "";
9+
returnText += "<option value=\"local\"";
10+
if(value === "local")
11+
{
12+
returnText += " selected ";
13+
}
14+
returnText += ">Local</option>";
15+
returnText += "<option value=\"external\"";
16+
if(value === "external")
17+
{
18+
returnText += " selected ";
19+
}
20+
returnText += " >External</option>";
21+
return returnText;
22+
}
23+
24+
function generateGitTypeSelect(value)
25+
{
26+
returnText = "";
27+
returnText += "<option value=\"github\"";
28+
if(value === "github")
29+
{
30+
returnText += " selected ";
31+
}
32+
returnText += ">GitHub</option>";
33+
returnText += "<option value=\"gitlab\"";
34+
if(value === "gitlab")
35+
{
36+
returnText += " selected ";
37+
}
38+
returnText += " >GitLab</option>";
39+
return returnText;
40+
}
41+
42+
function generateTrueFalseSelect(value)
43+
{
44+
returnText = "";
45+
returnText += "<option value=\"true\"";
46+
if(value === "true")
47+
{
48+
returnText += " selected ";
49+
}
50+
returnText += ">True</option>";
51+
returnText += "<option value=\"false\"";
52+
if(value === "false")
53+
{
54+
returnText += " selected ";
55+
}
56+
returnText += " >False</option>";
57+
return returnText;
58+
}
59+
660
function addRowFunction()
761
{
862
countOfWatchList++;
963
countOfClicks++;
10-
var documentUpdateText = "<li class='watchFolderGroups' id='rowNumber"+countOfWatchList+"'><span class='leftSpacingserverNames' > Name: </span> <input class='inputWidth300' type='text' name='watchListKey" + countOfWatchList + "' >";
64+
let item = $("#hiddenWatchlistFormBlank").html();
65+
item = item.replace(/{{i}}/g, countOfWatchList);
66+
item = item.replace(/{{key}}/g, "");
1167
for(var i = 0; i < numberOfSubRows; i++)
1268
{
13-
documentUpdateText += " <input style='display: none;' type='text' name='watchListItem"+countOfWatchList+"-"+(i+1)+"-Name' value="+arrayOfKeysNonEnc[i]+">";
69+
let find = "{{"+countOfWatchList+"-"+(i+1)+"}}";
70+
let replaceString = new RegExp(find, 'g');
71+
1472
if(arrayOfKeysNonEnc[i] === "type")
1573
{
16-
documentUpdateText += " <br> <span class='leftSpacingserverNames' > "+arrayOfKeysNonEnc[i]+": </span>";
17-
documentUpdateText += " <select class='inputWidth300' name='watchListItem" + countOfWatchList + "-" + (i+1) + "' >";
18-
documentUpdateText += " <option value=\"local\" selected >Local</option>";
19-
documentUpdateText += " <option value=\"external\" >External</option>";
20-
documentUpdateText += " </select>";
74+
item = item.replace(replaceString, generateTypeSelect("local"));
2175
}
2276
else if(arrayOfKeysNonEnc[i] === "gitType")
2377
{
24-
documentUpdateText += " <br> <span class='leftSpacingserverNames' > "+arrayOfKeysNonEnc[i]+": </span>";
25-
documentUpdateText += " <select class='inputWidth300' name='watchListItem" + countOfWatchList + "-" + (i+1) + "' >";
26-
documentUpdateText += " <option value=\"github\" selected>GitHub</option>";
27-
documentUpdateText += " <option value=\"gitlab\" >GitLab</option>";
28-
documentUpdateText += " </select>";
78+
item = item.replace(replaceString, generateGitTypeSelect("github"));
2979
}
3080
else if(arrayOfKeysNonEnc[i] === "Archive")
3181
{
32-
documentUpdateText += " <br> <span class='leftSpacingserverNames' > "+arrayOfKeysNonEnc[i]+": </span>";
33-
documentUpdateText += " <select class='inputWidth300' name='watchListItem" + countOfWatchList + "-" + (i+1) + "' >";
34-
documentUpdateText += " <option value=\"true\" >True</option>";
35-
documentUpdateText += " <option value=\"false\" selected >False</option>";
36-
documentUpdateText += " </select>";
82+
item = item.replace(replaceString, generateTrueFalseSelect("false"));
3783
}
3884
else
3985
{
40-
documentUpdateText += "<br> <span class='leftSpacingserverNames' > "+arrayOfKeysNonEnc[i]+": </span> <input class='inputWidth300' type='text' name='watchListItem" + countOfWatchList + "-" + (i+1) + "' >"
86+
item = item.replace(replaceString, "");
4187
}
4288
}
43-
documentUpdateText += '<br> <input style="display: none" type="text" name="watchListItem'+countOfWatchList+'-0" value="'+numberOfSubRows+'"> '
44-
documentUpdateText += " <span class='leftSpacingserverNames' ></span> <a class='mainLinkClass' onclick='deleteRowFunction("+ countOfWatchList +", true)'>Remove</a><span> | </span><a class='mainLinkClass' onclick='testConnection(dataForWatchFolder"+countOfWatchList+");' >Check Connection</a></li><div style='display:inline-block;' id='newRowLocationForWatchList"+countOfClicks+"'></div>";
45-
document.getElementById(locationInsert).outerHTML += documentUpdateText;
89+
item += "<div style=\"display: inline-block;\" id=\"newRowLocationForWatchList"+countOfClicks+"\"></div>";
90+
document.getElementById(locationInsert).outerHTML += item;
4691
document.getElementById('numberOfRows').value = countOfWatchList;
4792
countOfAddedFiles++;
4893
locationInsert = "newRowLocationForWatchList"+countOfClicks;

core/php/functions/watchlistFunctions.php

Lines changed: 100 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
<?php
22

3-
function generateWatchlistBlock($defaultArray, $arrayKeys, $key, $item, $i)
3+
function generateWatchlistBlock($defaultArray, $arrayKeys, $key = "{{key}}", $item = array(), $i = "{{i}}")
44
{
5-
$stringToReturn = "
6-
<script type=\"text/javascript\">
7-
var dataForWatchFolder" . $i . " = " . json_encode($item) . ";
8-
</script>
5+
$stringToReturn = "";
6+
if(!empty($item))
7+
{
8+
$stringToReturn .= "
9+
<script type=\"text/javascript\">
10+
var dataForWatchFolder" . $i . " = " . json_encode($item) . ";
11+
</script>";
12+
}
13+
$stringToReturn .= "
914
<li class=\"watchFolderGroups\" id=\"rowNumber" . $i . "\" >
1015
<span class=\"leftSpacingserverNames\" > Name: </span>
1116
<input class='inputWidth300' type='text' name='watchListKey" . $i . "' value='" . $key . "'>";
1217
$j = 0;
1318
foreach($defaultArray as $key2 => $item2)
1419
{
20+
$varValue = "REPLACE";
21+
if(!empty($item))
22+
{
23+
$varValue = "";
24+
if(isset($item[$key2]))
25+
{
26+
$varValue = $item[$key2];
27+
}
28+
}
1529
$j++;
1630
$stringToReturn .= "
1731
<br>
@@ -20,69 +34,100 @@ function generateWatchlistBlock($defaultArray, $arrayKeys, $key, $item, $i)
2034
if($key2 === "type")
2135
{
2236
$stringToReturn .= "
23-
<select class='inputWidth300' name='watchListItem" . $i . "-" . $j . "' >
24-
<option value=\"local\" ";
25-
if($item[$key2] === "local")
26-
{
27-
$stringToReturn .= " selected ";
28-
}
29-
$stringToReturn .= " >Local</option>
30-
<option value=\"external\" ";
31-
if($item[$key2] === "external")
32-
{
33-
$stringToReturn .= " selected ";
34-
}
35-
$stringToReturn .= ">External</option>
36-
</select>";
37+
<select class='inputWidth300' name='watchListItem" . $i . "-" . $j . "' >";
38+
if(!empty($item))
39+
{
40+
$stringToReturn .= "
41+
<option value=\"local\" ";
42+
if($varValue === "local")
43+
{
44+
$stringToReturn .= " selected ";
45+
}
46+
$stringToReturn .= " >Local</option>
47+
<option value=\"external\" ";
48+
if($varValue === "external")
49+
{
50+
$stringToReturn .= " selected ";
51+
}
52+
$stringToReturn .= ">External</option>";
53+
}
54+
else
55+
{
56+
$stringToReturn .= "{{" . $i . "-" . $j . "}}";
57+
}
58+
$stringToReturn .= "</select>";
3759
}
3860
elseif($key2 === "gitType")
3961
{
40-
$stringToReturn .= "
41-
<select class='inputWidth300' name='watchListItem" . $i . "-" . $j . "' >
42-
<option value=\"github\" ";
43-
if($item[$key2] === "github")
44-
{
45-
$stringToReturn .= " selected ";
46-
}
47-
$stringToReturn .= " >GitHub</option>
48-
<option value=\"gitlab\" ";
49-
if($item[$key2] === "gitlab")
50-
{
51-
$stringToReturn .= "selected";
52-
}
53-
$stringToReturn .= ">GitLab</option>
54-
</select>";
62+
$stringToReturn .= "
63+
<select class='inputWidth300' name='watchListItem" . $i . "-" . $j . "' >";
64+
if(!empty($item))
65+
{
66+
$stringToReturn .= "
67+
<option value=\"github\" ";
68+
if($varValue === "github")
69+
{
70+
$stringToReturn .= " selected ";
71+
}
72+
$stringToReturn .= " >GitHub</option>
73+
<option value=\"gitlab\" ";
74+
if($varValue === "gitlab")
75+
{
76+
$stringToReturn .= "selected";
77+
}
78+
$stringToReturn .= ">GitLab</option>";
79+
}
80+
else
81+
{
82+
$stringToReturn .= "{{" . $i . "-" . $j . "}}";
83+
}
84+
$stringToReturn .= "</select>";
5585
}
5686
elseif($key2 === "Archive")
5787
{
58-
$value = "false";
59-
if(isset($item[$key2]))
88+
$stringToReturn .= "
89+
<select class='inputWidth300' name='watchListItem" . $i . "-" . $j . "' >";
90+
if(!empty($item))
6091
{
61-
$value = (string)$item[$key2];
62-
}
63-
$stringToReturn .= "
64-
<select class='inputWidth300' name='watchListItem" . $i . "-" . $j . "' >
65-
<option value=\"true\" ";
66-
if($value === "true")
67-
{
68-
$stringToReturn .= " selected ";
69-
}
70-
$stringToReturn .= " >True</option>
71-
<option value=\"false\" ";
72-
if($value === "false")
73-
{
74-
$stringToReturn .= " selected ";
75-
}
76-
$stringToReturn .= " >False</option>
77-
</select>";
92+
$value = "false";
93+
if(isset($varValue))
94+
{
95+
$value = (string)$varValue;
96+
}
97+
$stringToReturn .= "
98+
<option value=\"true\" ";
99+
if($value === "true")
100+
{
101+
$stringToReturn .= " selected ";
102+
}
103+
$stringToReturn .= " >True</option>
104+
<option value=\"false\" ";
105+
if($value === "false")
106+
{
107+
$stringToReturn .= " selected ";
108+
}
109+
$stringToReturn .= " >False</option>";
110+
}
111+
else
112+
{
113+
$stringToReturn .= "{{" . $i . "-" . $j . "}}";
114+
}
115+
$stringToReturn .= "</select>";
78116
}
79117
else
80118
{
81119
$stringToReturn .= "
82120
<input class='inputWidth300' type='text' name='watchListItem" . $i . "-" . $j . "' value='";
83-
if(isset($item[$key2]))
121+
if(!empty($item))
122+
{
123+
if($varValue !== "")
124+
{
125+
$stringToReturn .= "$varValue";
126+
}
127+
}
128+
else
84129
{
85-
$stringToReturn .= "$item[$key2]";
130+
$stringToReturn .= "{{" . $i . "-" . $j . "}}";
86131
}
87132
$stringToReturn .= "'>";
88133
}

core/php/templateFiles/watchList.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<script type="text/javascript">
100100
var arrayOfKeysNonEnc = <?php echo json_encode(array_keys($defaultArray)); ?>;
101101
var numberOfSubRows = <?php echo count(array_keys($defaultArray)); ?>;
102-
var countOfWatchList = <?php echo count(array_keys($config['serverWatchList'])); ?>;
102+
var countOfWatchList = <?php echo count(array_keys($config['watchList'])); ?>;
103103
</script>
104104
<li><h2>Your Watch List: </h2></li>
105105
<?php
@@ -118,6 +118,9 @@
118118
</ul>
119119
</div>
120120
<div id="hidden" style="display: none">
121+
<span id="hiddenWatchlistFormBlank">
122+
<?php echo generateWatchlistBlock($defaultArray, $arrayKeys); ?>
123+
</span>
121124
<input id="numberOfRows" type="text" name="numberOfRows" value="<?php echo $i;?>">
122125
<input id="watchListNormal" type="text" name="watchListNormal" value="true" >
123126
</div>

core/php/templateFiles/watchListServer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@
9797
</ul>
9898
</div>
9999
<div id="hidden" style="display: none">
100+
<span id="hiddenWatchlistFormBlank">
101+
<?php echo generateWatchlistBlock($defaultArray, $arrayKeys); ?>
102+
</span>
100103
<input id="numberOfRows" type="text" name="numberOfRows" value="<?php echo $i;?>">
101104
<input id="watchListServer" type="text" name="watchListServer" value="true" >
102105
</div>

0 commit comments

Comments
 (0)