aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author无闻 <joe2010xtmf@163.com>2014-04-29 17:47:16 -0400
committer无闻 <joe2010xtmf@163.com>2014-04-29 17:47:16 -0400
commit0d6856dbe73c8041451743946fb324663350a687 (patch)
treecbbc1490f3a50760861ae6b9b78fd7d8fc905c21
parent2401e68d7ed7d53425293ad32d231542d03bbef3 (diff)
parent494e5fd40c6c6f035c9d7a7e2737259afcb8424c (diff)
downloadgitea-0d6856dbe73c8041451743946fb324663350a687.tar.gz
gitea-0d6856dbe73c8041451743946fb324663350a687.zip
Merge pull request #143 from tsigo/rs-install-default-hosts
Install: Set the default host string based on database type
-rw-r--r--public/js/app.js15
-rw-r--r--templates/install.tmpl2
2 files changed, 16 insertions, 1 deletions
diff --git a/public/js/app.js b/public/js/app.js
index b7b5deb83b..30e9d5d0bb 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -468,6 +468,9 @@ function initRepository() {
function initInstall() {
// database type change
(function () {
+ var mysql_default = '127.0.0.1:3306'
+ var postgres_default = '127.0.0.1:5432'
+
$('#install-database').on("change", function () {
var val = $(this).val();
if (val != "SQLite3") {
@@ -475,6 +478,18 @@ function initInstall() {
$('.sqlite-setting').addClass("hide");
if (val == "PostgreSQL") {
$('.pgsql-setting').removeClass("hide");
+
+ // Change the host value to the Postgres default, but only
+ // if the user hasn't already changed it from the MySQL
+ // default.
+ if ($('#database-host').val() == mysql_default) {
+ $('#database-host').val(postgres_default);
+ }
+ } else if (val == 'MySQL') {
+ $('.pgsql-setting').addClass("hide");
+ if ($('#database-host').val() == postgres_default) {
+ $('#database-host').val(mysql_default);
+ }
} else {
$('.pgsql-setting').addClass("hide");
}
diff --git a/templates/install.tmpl b/templates/install.tmpl
index 8fe678e509..eb6327d205 100644
--- a/templates/install.tmpl
+++ b/templates/install.tmpl
@@ -21,7 +21,7 @@
<div class="form-group">
<label class="col-md-3 control-label">Host: </label>
<div class="col-md-8">
- <input name="host" class="form-control" placeholder="Type database server host" value="{{.host}}">
+ <input name="host" id="database-host" class="form-control" placeholder="Type database server host" value="{{.host}}">
</div>
</div>