Skip to content

Commit

Permalink
Merge branch 'check_cn'
Browse files Browse the repository at this point in the history
  • Loading branch information
yoichiro committed Aug 12, 2014
2 parents c429ece + d98d1eb commit ad1551f
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 62 deletions.
2 changes: 1 addition & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "ChromeMyAdmin",
"short_name": "MyAdmin",
"description": "This application provides you 'MySQL GUI Admin console' windows.",
"version": "2.0.0",
"version": "2.1.0",
"author": "Yoichiro Tanaka",
"app": {
"background": {
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/scripts/window/controllers/error_dialog_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ chromeMyAdmin.controller("ErrorDialogController", ["$scope", "mySQLClientService
$scope.message1 = "Fatal error occurred. Go back to login screen.";
$scope.message2 = data.reason;
} else {
$scope.title = "Error";
$scope.title = data.title || "Error";
$scope.message1 = data.message;
$scope.message2 = data.reason;
}
Expand Down
57 changes: 17 additions & 40 deletions app/scripts/window/controllers/login_form_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,6 @@ chromeMyAdmin.controller("LoginFormController", ["$scope", "$timeout", "mySQLCli

// Private methods

var showErrorMessage = function(message) {
$scope.safeApply(function() {
$scope.errorMessage = message;
});
};

var hideMessage = function() {
$scope.safeApply(function() {
$scope.successMessage = "";
$scope.errorMessage = "";
});
};

var showSuccessMessage = function(message) {
$scope.safeApply(function() {
$scope.successMessage = message;
});
};

var onConnected = function(initialHandshakeRequest) {
$scope.safeApply(function() {
var connectionInfo = {
Expand All @@ -55,35 +36,29 @@ chromeMyAdmin.controller("LoginFormController", ["$scope", "$timeout", "mySQLCli
$scope.password = favorite.password;
$scope.useSSL = favorite.useSSL || "no";
$scope.caCert = favorite.caCert;
$scope.checkCN = favorite.checkCN || "yes";
});
});
$scope.$on(Events.LOGIN, function(event, data) {
doConnect();
});
};

var showAboutMe = function() {
var manifest = chrome.runtime.getManifest();
var aboutMe = manifest.name + " version " + manifest.version;
aboutMe += " (C) " + manifest.author + " 2014, all rights reserved.";
$scope.aboutMe = aboutMe;
};

var doConnect = function() {
hideMessage();
if (isUseSSLConnection()) {
mySQLClientService.loginWithSSL(
$scope.hostName,
Number($scope.portNumber),
$scope.userName,
$scope.password,
$scope.caCert
$scope.caCert,
isCheckCN()
).then(function(initialHandshakeRequest) {
identityKeepService.set(
$scope.hostName, $scope.portNumber, $scope.userName, $scope.password);
onConnected(initialHandshakeRequest);
}, function(reason) {
showErrorMessage("Connection failed: " + reason);
$scope.showErrorDialog("Connection failed.", reason);
mySQLClientService.logout();
});
} else {
Expand All @@ -97,7 +72,7 @@ chromeMyAdmin.controller("LoginFormController", ["$scope", "$timeout", "mySQLCli
$scope.hostName, $scope.portNumber, $scope.userName, $scope.password);
onConnected(initialHandshakeRequest);
}, function(reason) {
showErrorMessage("Connection failed: " + reason);
$scope.showErrorDialog("Connection failed.", reason);
mySQLClientService.logout();
});
}
Expand All @@ -107,35 +82,37 @@ chromeMyAdmin.controller("LoginFormController", ["$scope", "$timeout", "mySQLCli
return $scope.useSSL === "yes";
};

var isCheckCN = function() {
return $scope.checkCN === "yes";
};

// Public methods

$scope.initialize = function() {
$scope.successMessage = "";
$scope.errorMessage = "";
$scope.portNumber = 3306;
$scope.useSSL = "no";
$scope.checkCN = "yes";
assignEventHandlers();
showAboutMe();
};

$scope.connect = function() {
doConnect();
};

$scope.doTestConnection = function() {
hideMessage();
if (isUseSSLConnection()) {
mySQLClientService.loginWithSSL(
$scope.hostName,
Number($scope.portNumber),
$scope.userName,
$scope.password,
$scope.caCert
$scope.caCert,
isCheckCN()
).then(function(initialHandshakeRequest) {
showSuccessMessage("Connection was successfully.");
$scope.showCustomErrorDialog("Test connection", "Connection was successfully.", "");
mySQLClientService.logout();
}, function(reason) {
showErrorMessage("Connection failed: " + reason);
$scope.showCustomErrorDialog("Test connection", "Connection failed.", reason);
mySQLClientService.logout();
});
} else {
Expand All @@ -145,10 +122,10 @@ chromeMyAdmin.controller("LoginFormController", ["$scope", "$timeout", "mySQLCli
$scope.userName,
$scope.password
).then(function(initialHandshakeRequest) {
showSuccessMessage("Connection was successfully.");
$scope.showCustomErrorDialog("Test connection", "Connection was successfully.", "");
mySQLClientService.logout();
}, function(reason) {
showErrorMessage("Connection failed: " + reason);
$scope.showCustomErrorDialog("Test connection", "Connection failed.", reason);
mySQLClientService.logout();
});
}
Expand All @@ -169,7 +146,7 @@ chromeMyAdmin.controller("LoginFormController", ["$scope", "$timeout", "mySQLCli
$scope.addFavorite = function() {
var name = $scope.name || $scope.hostName;
if (name) {
favoriteService.set(name, $scope.hostName, Number($scope.portNumber), $scope.userName, $scope.password, $scope.useSSL, $scope.caCert);
favoriteService.set(name, $scope.hostName, Number($scope.portNumber), $scope.userName, $scope.password, $scope.useSSL, $scope.caCert, $scope.checkCN);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ chromeMyAdmin.controller("windowTitlePanelController", ["$scope", "mySQLClientSe
};

var resetTitleText = function() {
$scope.titleText = "";
$scope.titleText = getAboutMe();
};

var getAboutMe = function() {
var manifest = chrome.runtime.getManifest();
var aboutMe = manifest.name + " version " + manifest.version;
aboutMe += " (C) " + manifest.author + " 2014, all rights reserved.";
return aboutMe;
};

var onConnectionChanged = function(info) {
Expand Down
9 changes: 9 additions & 0 deletions app/scripts/window/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ chromeMyAdmin.run(["$rootScope", "Events", "ErrorLevel", "mySQLClientService", "
});
};

$rootScope.showCustomErrorDialog = function(title, message, reason) {
$rootScope.$broadcast(Events.SHOW_ERROR_DIALOG, {
errorLevel: ErrorLevel.ERROR,
title: title,
message: message,
reason: reason
});
};

$rootScope.notifyConnectionChanged = function(connectionInfo) {
$rootScope.$broadcast(Events.CONNECTION_CHANGED, connectionInfo);
};
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/window/services/favorite_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ chromeMyAdmin.factory("favoriteService", ["$rootScope", "$q", "Events", function
};

return {
set: function(name, hostName, port, userName, password, useSSL, caCert) {
set: function(name, hostName, port, userName, password, useSSL, caCert, checkCN) {
var deferred = $q.defer();
chrome.storage.sync.get("favorites", function(items) {
var favorites = items.favorites || {};
Expand All @@ -29,6 +29,7 @@ chromeMyAdmin.factory("favoriteService", ["$rootScope", "$q", "Events", function
favorite.password = password;
favorite.useSSL = useSSL;
favorite.caCert = caCert;
favorite.checkCN = checkCN;
favorites[name] = favorite;
chrome.storage.sync.set({favorites: favorites}, function() {
$rootScope.$broadcast(Events.FAVORITES_CHANGED, favorites);
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/window/services/mysql_client_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ chromeMyAdmin.factory("mySQLClientService", ["$q", "$rootScope", function($q, $r
);
return deferred.promise;
},
loginWithSSL: function(hostName, portNumber, userName, password, ca) {
loginWithSSL: function(hostName, portNumber, userName, password, ca, checkCN) {
$rootScope.showMainStatusMessage("Logging in to MySQL server with SSL...");
$rootScope.showProgressBar();
var deferred = $q.defer();
Expand All @@ -240,6 +240,7 @@ chromeMyAdmin.factory("mySQLClientService", ["$q", "$rootScope", function($q, $r
userName,
password,
ca,
checkCN,
function(initialHandshakeRequest, result) {
$rootScope.hideProgressBar();
if (result.isSuccess()) {
Expand Down
5 changes: 4 additions & 1 deletion app/styles/window.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ body {
.windowTitlePanel div.titleText {
margin-top: 0;
margin-left: 10px;
-webkit-user-select: none;
-webkit-app-region: drag;
cursor: default;
}

.navbar-fixed-top {
Expand Down Expand Up @@ -117,7 +120,7 @@ body {
}

.loginPanel .form-group {
margin-bottom: 12px;
/* margin-bottom: 15px; */
}

.loginPanel .form-group textarea {
Expand Down
24 changes: 11 additions & 13 deletions app/templates/login_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@
<textarea class="form-control" ng-model="caCert"></textarea>
</div>
</div>
<div class="form-group" ng-show="isCACertificateVisible()">
<label for="loginFormCheckCN" class="col-sm-4 control-label">Check CN</label>
<div class="col-sm-8">
<label class="radio-inline">
<input type="radio" ng-model="checkCN" value="no" /> No<br />
</label>
<label class="radio-inline">
<input type="radio" ng-model="checkCN" value="yes" /> Yes<br />
</label>
</div>
</div>
</form>
<div class="clearfix">
<div class="btn-group pull-right">
Expand All @@ -56,18 +67,5 @@
<button type="button" class="btn btn-primary" ng-click="connect()" ng-disabled="!canConnect()">Connect</button>
</div>
</div>
<div class="loginPanelAlertBlock">
<div ng-show="isErrorMessageVisible()">
<div class="alert alert-danger">
<strong>Error:</strong> {{errorMessage}}
</div>
</div>
<div ng-show="isSuccessMessageVisible()">
<div class="alert alert-success">
<strong>Success:</strong> {{successMessage}}
</div>
</div>
</div>
</div>
<div class="aboutMe">{{aboutMe}}</div>
</div>
2 changes: 1 addition & 1 deletion app/window.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script type="text/javascript" src="scripts/lib/sha1.js"></script>
<!-- endbuild -->
<script type="text/javascript" src="scripts/lib/forge.min.js"></script>
<script type="text/javascript" src="scripts/lib/mysql_js_driver_1.6.0.min.js"></script>
<script type="text/javascript" src="scripts/lib/mysql_js_driver_1.7.0.min.js"></script>

<script type="text/javascript" src="scripts/lib/ace-builds/src-min-noconflict/ace.js"></script>
<!-- build:js scripts/lib/ui-ace.min.js -->
Expand Down

0 comments on commit ad1551f

Please sign in to comment.