Skip to content

Commit

Permalink
[BACKLOG-7157] Error messages and style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Morrise committed May 16, 2016
1 parent 3682f74 commit c375a93
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 17 deletions.
Expand Up @@ -22,6 +22,7 @@

package org.pentaho.di.ui.repo;

import com.sun.xml.ws.client.ClientTransportException;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.pentaho.di.core.database.DatabaseMeta;
Expand All @@ -31,6 +32,7 @@
import org.pentaho.di.core.plugins.PluginInterface;
import org.pentaho.di.core.plugins.PluginRegistry;
import org.pentaho.di.core.plugins.RepositoryPluginType;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.repository.AbstractRepository;
import org.pentaho.di.repository.RepositoriesMeta;
import org.pentaho.di.repository.Repository;
Expand All @@ -48,6 +50,8 @@
public class RepositoryConnectController {

public static final String DEFAULT_URL = "defaultUrl";
public static final String ERROR_MESSAGE = "errorMessage";
public static final String ERROR_401 = "401";

private static Class<?> PKG = RepositoryConnectController.class;
private static LogChannelInterface log =
Expand Down Expand Up @@ -159,19 +163,20 @@ public String getDatabases() {
return list.toString();
}

public boolean connectToRepository() {
public String connectToRepository() {
return connectToRepository( currentRepository );
}

public boolean connectToRepository( String username, String password ) {
public String connectToRepository( String username, String password ) {
return connectToRepository( currentRepository, username, password );
}

public boolean connectToRepository( RepositoryMeta repositoryMeta ) {
public String connectToRepository( RepositoryMeta repositoryMeta ) {
return connectToRepository( repositoryMeta, null, null );
}

public boolean connectToRepository( RepositoryMeta repositoryMeta, String username, String password ) {
public String connectToRepository( RepositoryMeta repositoryMeta, String username, String password ) {
JSONObject jsonObject = new JSONObject();
try {
Repository repository =
pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class );
Expand All @@ -180,24 +185,37 @@ public boolean connectToRepository( RepositoryMeta repositoryMeta, String userna
if ( spoon != null ) {
spoon.setRepository( repository );
}
return true;
jsonObject.put( "success", true );
} catch ( KettleException ke ) {
if ( ke.getMessage().contains( ERROR_401 ) ) {
jsonObject.put( ERROR_MESSAGE, BaseMessages.getString( PKG, "RepositoryConnection.Error.InvalidCredentials" ) );
} else {
jsonObject.put( ERROR_MESSAGE, BaseMessages.getString( PKG, "RepositoryConnection.Error.InvalidServer" ) );
}
jsonObject.put( "success", false );
log.logError( "Unable to connect to repository", ke );
}
return false;
return jsonObject.toString();
}

public boolean deleteRepository( String name ) {
RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( name );
int index = repositoriesMeta.indexOfRepository( repositoryMeta );
repositoriesMeta.removeRepository( index );
save();
if ( index != -1 ) {
if ( spoon != null && spoon.getRepositoryName().equals( repositoryMeta.getName() ) ) {
spoon.closeRepository();
}
repositoriesMeta.removeRepository( index );
save();
}
return true;
}

public void addDatabase( DatabaseMeta databaseMeta ) {
repositoriesMeta.addDatabase( databaseMeta );
save();
if ( databaseMeta != null ) {
repositoriesMeta.addDatabase( databaseMeta );
save();
}
}

public boolean setDefaultRepository( String name ) {
Expand Down
Expand Up @@ -121,10 +121,11 @@ private void renderConnectDropdown() {
if ( repositoriesMeta != null ) {
for ( int i = 0; i < repositoriesMeta.nrRepositories(); i++ ) {
MenuItem item = new MenuItem( connectionMenu, SWT.CHECK );
item.setText( repositoriesMeta.getRepository( i ).getName() );
if ( spoon.rep != null && spoon.rep.getName().equals( repositoriesMeta.getRepository( i ).getName() ) ) {
item.setSelection( true );
continue;
}
item.setText( repositoriesMeta.getRepository( i ).getName() );
item.addSelectionListener( new SelectionAdapter() {
@Override public void widgetSelected( SelectionEvent selectionEvent ) {
String repoName = ( (MenuItem) selectionEvent.widget ).getText();
Expand Down
Expand Up @@ -166,7 +166,9 @@ private void open( RepositoryMeta repositoryMeta ) {
DatabaseDialog databaseDialog = new DatabaseDialog( shell, new DatabaseMeta() );
databaseDialog.open();
DatabaseMeta databaseMeta = databaseDialog.getDatabaseMeta();
controller.addDatabase( databaseMeta );
if ( databaseMeta != null ) {
controller.addDatabase( databaseMeta );
}
return true;
}
};
Expand Down
Expand Up @@ -6,3 +6,6 @@ RepositoryConnectMenu.ErrorLoadingRepositories=An error has occurred while loadi

RepositoryDialog.Dialog.Tile=Help for Repository Connection
RepositoryDialog.Dialog.Header=Repository Connection

RepositoryConnection.Error.InvalidCredentials=Sorry, we didn't recognize those connection details. Please check the user name and password and try again.
RepositoryConnection.Error.InvalidServer=You don't seem to be getting a connection to the server. Please check the path you're using and make sure the server is up and running.
57 changes: 56 additions & 1 deletion plugins/repositories-plugin/src/main/resources/web/css/style.css
Expand Up @@ -231,6 +231,7 @@ button.invisible {
}

#btnHelp {
cursor: pointer;
margin: 8px 0px 0px 4px;
}

Expand Down Expand Up @@ -441,7 +442,7 @@ table#repoMngTable td {
}

#table-scroll {
height:380px;
height:300px;
overflow:auto;
}

Expand Down Expand Up @@ -547,3 +548,57 @@ hr {
position: relative;
top: 8px;
}

.error-message-icon {
width: 32px;
height: 28px;
float: left;
margin-top: 15px;
margin-left: 15px;
}

.error-message {
border: 1px solid #f3E085;
background-color: #fcf8e3;
width: 580px;
height: 63px;
border-radius: 5px;
position: absolute;
top: 10px;
left: 23px;
}

.error-message-text {
width: 460px;
float: left;
margin-top: 13px;
margin-left: 15px;
text-align: left;
font-size: 14px;
}

.error-message-close {
width: 14px;
height: 14px;
float: right;
margin-right: 10px;
margin-top: 10px;
}

.error-message.ng-hide {
top: -63px;
opacity: 0;
}

.error-message.ng-hide-remove,
.error-message.ng-hide-add {
display: block !important;
}

.error-message.ng-hide-remove {
transition: all linear 600ms;
}

.error-message.ng-hide-add {
transition: all linear 600ms;
}
Expand Up @@ -326,7 +326,11 @@ define(
}

$scope.connect = function() {
if (loginToRepository(this.model.username, this.model.password)) {
this.model.hasError = false;
var response = JSON.parse(loginToRepository(this.model.username, this.model.password));
this.model.errorMessage = response.errorMessage;
this.model.hasError = response.success == false;
if (response.success == true) {
close();
}
}
Expand Down
Expand Up @@ -80,6 +80,8 @@ define( [
});

repoConnectionApp.service("repositoryConnectModel", function() {
this.hasError = false;
this.errorMessage = "";
this.username = "";
this.password = "";
});
Expand Down
Expand Up @@ -7,9 +7,9 @@
<div ng-repeat="database in databases" class="db_list_items" ng-class="{active : database == selectedDatabase}" ng-click="selectDatabase(database)">{{database.name}}</div>
</div>
<div>
<button id="delete" class="right margin_left_10 secondary" ng-class="{invisible : !model.selectedDatabase || model.databases.length == 0}"
<button id="delete" class="right margin_left_10 secondary" ng-class="{invisible : !selectedDatabase || databases.length == 0}"
type="button" ng-click="deleteConnection()">Delete</button>
<button id="edit" class="right margin_left_10 secondary" ng-class="{invisible : !model.selectedDatabase || model.databases.length == 0}"
<button id="edit" class="right margin_left_10 secondary" ng-class="{invisible : !selectedDatabase || databases.length == 0}"
type="button" ng-click="editConnection()">Edit</button>
<button id="new" class="right secondary" type="button" ng-click="createNewConnection()">New</button>
</div>
Expand Down
@@ -1,9 +1,21 @@
<div class="error-message" ng-show="model.hasError">
<div class="error-message-icon">
<img src="images/caution.svg" />
</div>
<div class="error-message-text">
{{model.errorMessage}}
</div>
<div class="error-message-close" ng-click="model.hasError=false">
<img src="images/close_notif.svg" />
</div>
</div>
<div class="main_div">
<div class="header" style="margin-bottom:37px;margin-top:77px;">
<img id="pentaho-img" alt="" src="images/u135.png" />
</div>
<div class="title_text" style="margin-bottom:34px;">Repository Connection</div>
<div class="middle_div2">
<form>
<div style="margin-bottom:18px;">
<label for="userName" class="margin_bottom_5 block text_left">User Name</label>
<input set-focus id="userName" class="block repo_conn_txt" type="text" ng-model="model.username" />
Expand All @@ -13,7 +25,8 @@
<input id="password" class="block repo_conn_txt" type="password" ng-model="model.password" />
</div>
<div>
<button id="connect" class="standard" type="button" ng-disabled="!canConnect()" ng-click="connect()">Connect</button>
<button id="connect" class="standard" type="submit" ng-disabled="!canConnect()" ng-click="connect()">Connect</button>
</div>
</form>
</div>
</div>
@@ -1,4 +1,5 @@
<div class="main_div">
<div class="title_text margin_bottom_30">Repository Manager</div>
<div id="table-wrapper" class="margin_bottom_20 table_border">
<div id="table-scroll">
<table id="repoMngTable">
Expand Down

0 comments on commit c375a93

Please sign in to comment.