Skip to content

Commit b2be65e

Browse files
committed
Make "Port" field optional
1 parent 33248bb commit b2be65e

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
if ( !file_exists($autoload_file = MPG_ABS_PATH . '/vendor/autoload.php') ) {
4-
die('Install dependencies with `composer install` to run this script successfully.');
4+
die('Run `composer install` to complete ' . MPG_APP_NAME . ' installation.');
55
}
66

77
$loader = require_once $autoload_file;

source/Controllers/LoginController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ public function processFormData() : array {
3838

3939
if ( isset($_POST['port']) && !empty($_POST['port']) ) {
4040
$_SESSION['mpg']['mongodb_port'] = $_POST['port'];
41-
} else {
42-
$errors[] = 'Port';
4341
}
4442

4543
if ( isset($_POST['database']) && !empty($_POST['database']) ) {

source/Helpers/MongoDBHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ private static function createClient() : Client {
5050
}
5151

5252
$clientUri .= $_SESSION['mpg']['mongodb_host'];
53-
$clientUri .= ':' . $_SESSION['mpg']['mongodb_port'];
53+
54+
if ( isset($_SESSION['mpg']['mongodb_port']) ) {
55+
$clientUri .= ':' . $_SESSION['mpg']['mongodb_port'];
56+
}
57+
// When it's not defined: port defaults to 27017.
5458

5559
if ( isset($_SESSION['mpg']['mongodb_database']) ) {
5660
$clientUri .= '/' . $_SESSION['mpg']['mongodb_database'];

static/js/mpg.login.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ MPG.eventListeners.addLoginButton = function() {
6060

6161
document.getElementById('mpg-login-button').addEventListener('click', function(_event) {
6262

63-
if ( document.querySelector('input[name="host"]').value === ''
64-
|| document.querySelector('input[name="port"]').value === '' )
65-
{
63+
if ( document.querySelector('input[name="host"]').value === '' ) {
64+
6665
document.querySelector('.card').classList.add('apply-shake');
66+
6767
}
6868

6969
});

views/login.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<div class="input-group-prepend">
8080
<span class="input-group-text"><i class="fa fa-filter"></i></span>
8181
</div>
82-
<input type="number" class="form-control" placeholder="Port" name="port" required>
82+
<input type="number" class="form-control" placeholder="Port" name="port">
8383
</div>
8484

8585
<div class="input-group form-group">

0 commit comments

Comments
 (0)