Bug Fix #54: Save proxy settings with ajax

This commit is contained in:
Gary Sharp
2014-07-07 13:49:38 +10:00
parent 5013fa27bd
commit 0b79140290
2 changed files with 85 additions and 12 deletions
@@ -521,7 +521,33 @@
<th style="width: 135px">&nbsp; <th style="width: 135px">&nbsp;
</th> </th>
<td> <td>
<input type="submit" class="button small" value="Save Proxy Settings" /> <button id="Config_System_Proxy_Save" type="button" class="button small">Save Proxy Settings</button>@AjaxHelpers.AjaxLoader()
<script>
$(function () {
var button = $('#Config_System_Proxy_Save');
button.click(function () {
var url = '@(Url.Action(MVC.API.System.UpdateProxySettings()))';
var data = {
ProxyAddress: $('#ProxyAddress').val(),
ProxyPort: $('#ProxyPort').val(),
ProxyUsername: $('#ProxyUsername').val(),
ProxyPassword: $('#ProxyPassword').val()
}
var ajaxLoading = button.next('.ajaxLoading').first().show();
$.getJSON(url, data, function (response, result) {
if (result != 'success' || response != 'OK') {
alert('Unable to change property "' + UpdatePropertyName + '":\n' + response);
ajaxLoading.hide();
} else {
ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
})
});
});
</script>
</td> </td>
</tr> </tr>
</table> </table>
@@ -1609,18 +1609,65 @@ WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>
WriteLiteral(" style=\"width: 135px\""); WriteLiteral(" style=\"width: 135px\"");
WriteLiteral(">&nbsp;\r\n </th>\r\n <td>\r\n <input"); WriteLiteral(">&nbsp;\r\n </th>\r\n <td>\r\n <button" +
"");
WriteLiteral(" type=\"submit\""); WriteLiteral(" id=\"Config_System_Proxy_Save\"");
WriteLiteral(" type=\"button\"");
WriteLiteral(" class=\"button small\""); WriteLiteral(" class=\"button small\"");
WriteLiteral(" value=\"Save Proxy Settings\""); WriteLiteral(">Save Proxy Settings</button>");
WriteLiteral(" />\r\n </td>\r\n </tr>\r\n </table>\r\n </div>\r\n");
#line 529 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" #line 524 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml"
Write(AjaxHelpers.AjaxLoader());
#line default
#line hidden
WriteLiteral("\r\n <script>\r\n $(function () {\r\n " +
" var button = $(\'#Config_System_Proxy_Save\');\r\n\r\n " +
" button.click(function () {\r\n var " +
"url = \'");
#line 530 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml"
Write(Url.Action(MVC.API.System.UpdateProxySettings()));
#line default
#line hidden
WriteLiteral(@"';
var data = {
ProxyAddress: $('#ProxyAddress').val(),
ProxyPort: $('#ProxyPort').val(),
ProxyUsername: $('#ProxyUsername').val(),
ProxyPassword: $('#ProxyPassword').val()
}
var ajaxLoading = button.next('.ajaxLoading').first().show();
$.getJSON(url, data, function (response, result) {
if (result != 'success' || response != 'OK') {
alert('Unable to change property ""' + UpdatePropertyName + '"":\n' + response);
ajaxLoading.hide();
} else {
ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
})
});
});
</script>
</td>
</tr>
</table>
</div>
");
#line 555 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml"
} }
} }
else else
@@ -1645,7 +1692,7 @@ WriteLiteral(">Address:\r\n </th>\r\n <td>\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 540 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" #line 566 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml"
Write(Html.DisplayFor(m => m.ProxyAddress)); Write(Html.DisplayFor(m => m.ProxyAddress));
@@ -1661,7 +1708,7 @@ WriteLiteral(">Port:\r\n </th>\r\n <td>\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 547 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" #line 573 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml"
Write(Html.DisplayFor(m => m.ProxyPort)); Write(Html.DisplayFor(m => m.ProxyPort));
@@ -1677,7 +1724,7 @@ WriteLiteral(">Username:\r\n </th>\r\n <td>\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 554 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" #line 580 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml"
Write(Html.DisplayFor(m => m.ProxyUsername)); Write(Html.DisplayFor(m => m.ProxyUsername));
@@ -1692,7 +1739,7 @@ WriteLiteral(">Password:\r\n </th>\r\n <td>*******
"</td>\r\n </tr>\r\n </table>\r\n </div>\r\n"); "</td>\r\n </tr>\r\n </table>\r\n </div>\r\n");
#line 565 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" #line 591 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml"
} }
@@ -1707,7 +1754,7 @@ WriteLiteral(">\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 567 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml" #line 593 "..\..\Areas\Config\Views\SystemConfig\Index.cshtml"
Write(Html.ActionLinkButton("Update Device Last Network Logons", MVC.API.System.UpdateLastNetworkLogonDates())); Write(Html.ActionLinkButton("Update Device Last Network Logons", MVC.API.System.UpdateLastNetworkLogonDates()));