Skip to content
Browse files

accounts page (editing etc)

cql queries
  • Loading branch information...
1 parent b2f69b7 commit 06e6ac5754239e092af41e0433334198df26390a @tomekkup committed Jan 4, 2013
Showing with 925 additions and 204 deletions.
  1. +2 −2 README.md
  2. +12 −0 build.xml
  3. +0 −14 pom.xml
  4. +10 −17 src/main/frontend/source/class/helenos/Application.js
  5. +0 −3 src/main/frontend/source/class/helenos/components/Header.js
  6. +1 −1 src/main/frontend/source/class/helenos/components/SchemaPane.js
  7. +1 −1 src/main/frontend/source/class/helenos/components/menu/KeyspaceContextMenu.js
  8. +62 −83 src/main/frontend/source/class/helenos/components/tab/AccountsEditorPage.js
  9. +6 −4 src/main/frontend/source/class/helenos/components/tab/ConnectionsEditorPage.js
  10. +90 −0 src/main/frontend/source/class/helenos/components/tab/browse/AbstractPage.js
  11. +3 −4 .../frontend/source/class/helenos/components/tab/browse/{AbstractBrowsePage.js → AbstractPageOLD.js}
  12. +60 −0 src/main/frontend/source/class/helenos/components/tab/browse/CqlPage.js
  13. +198 −0 src/main/frontend/source/class/helenos/components/tab/browse/CqlPageOLD.js
  14. +29 −23 src/main/frontend/source/class/helenos/components/tab/browse/PredicatePage.js
  15. +198 −0 src/main/frontend/source/class/helenos/components/tab/browse/PredicatePageOLD.js
  16. +10 −1 src/main/frontend/source/class/helenos/theme/Appearance.js
  17. +5 −5 src/main/frontend/source/class/helenos/theme/Color.js
  18. +1 −2 src/main/frontend/source/class/helenos/theme/Decoration.js
  19. +7 −1 src/main/frontend/source/class/helenos/theme/Font.js
  20. +18 −10 src/main/frontend/source/class/helenos/ui/treevirtual/ResultsTree.js
  21. +8 −8 src/main/frontend/source/class/helenos/util/GuiObserver.js
  22. +27 −0 src/main/frontend/source/class/helenos/util/RpcActionsProvider.js
  23. BIN src/main/frontend/source/resource/helenos/Black_and_white_384x75.png
  24. BIN src/main/frontend/source/resource/helenos/White_on_black_background_384x75.png
  25. BIN src/main/frontend/source/resource/helenos/logo.png
  26. BIN src/main/frontend/source/resource/helenos/logobw.png
  27. BIN src/main/frontend/source/resource/helenos/logoold.png
  28. +1 −1 src/main/frontend/source/resource/welcome.html
  29. +38 −9 src/main/java/tomekkup/helenos/dao/AccountDao.java
  30. +30 −0 src/main/java/tomekkup/helenos/dozer/converters/SimpleGrantedAuthorityConverter.java
  31. +9 −4 src/main/java/tomekkup/helenos/service/AccountsProvider.java
  32. +24 −5 src/main/java/tomekkup/helenos/service/impl/AccountsProviderImpl.java
  33. +1 −1 src/main/java/tomekkup/helenos/service/impl/StandardQueryProviderImpl.java
  34. +5 −5 src/main/java/tomekkup/helenos/{dao/model/Account.java → types/qx/QxAccount.java}
  35. +65 −0 src/main/java/tomekkup/helenos/types/qx/QxPasswordChangeRequest.java
  36. +4 −0 src/main/resources/xml-bean-mappings.xml
View
4 README.md
@@ -18,10 +18,10 @@ Helenos is a web based GUI Cassandra client that helps you to explore data and m
## Gallery
-
-
[Picasa album](https://picasaweb.google.com/tomekkuprowski/Helenos)
+Click here for [preview on Youtube](http://www.youtube.com)
+
## Twitter
You can track my tweets to keep up with new releases [Tweeter] (https://twitter.com/tomekkup)
View
12 build.xml
@@ -12,6 +12,18 @@
"environment" : {
"qx.app.version" : "${HELENOS_VERSION}"
}
+ },
+ "lint-withver" : {
+ "extend" : ["lint"],
+ "environment" : {
+ "qx.app.version" : "${HELENOS_VERSION}"
+ }
+ },
+ "clean-withver" : {
+ "extend" : ["clean"],
+ "environment" : {
+ "qx.app.version" : "${HELENOS_VERSION}"
+ }
}
}
}
View
14 pom.xml
@@ -276,20 +276,6 @@
<artifactId>exec-maven-plugin</artifactId>
<version>${maven.plugin.exec.version}</version>
<executions>
- <!--
- <execution>
- <id>clean-frontend</id>
- <phase>clean</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>python</executable>
- <workingDirectory>src/main/frontend</workingDirectory>
- <commandlineArgs>generate.py clean</commandlineArgs>
- </configuration>
- </execution>
- -->
<execution>
<id>build-frontend</id>
<phase>prepare-package</phase>
View
27 src/main/frontend/source/class/helenos/Application.js
@@ -23,19 +23,6 @@ qx.Class.define("helenos.Application",
{
_loginBox : null,
- shake : {duration: 1000, keyFrames : {
- 0 : {translate: "0px"},
- 10 : {translate: "-10px"},
- 20 : {translate: "10px"},
- 30 : {translate: "-10px"},
- 40 : {translate: "10px"},
- 50 : {translate: "-10px"},
- 60 : {translate: "10px"},
- 70 : {translate: "-10px"},
- 80 : {translate: "10px"},
- 90 : {translate: "-10px"},
- 100 : {translate: "0px"}
- }},
/**
* @lint ignoreUndefined(silverbluetheme)
*/
@@ -58,15 +45,21 @@ qx.Class.define("helenos.Application",
// support additional cross-browser console. Press F7 to toggle visibility
qx.log.appender.Console;
}
- // register root
- helenos.util.GuiObserver.registerRoot(this.getRoot());
// ask for credentials
- this.initLoginBox();
+ //this.initLoginBox();
+ this.initLoginBoxFAKE();
+ },
+
+ initLoginBoxFAKE : function() {
+ this.checkCredentials('admin', '123', function(foo1, foo2){
+ qx.core.Init.getApplication().getRoot().add(new helenos.components.TopComposite(), {edge : 0});
+ }, this);
},
initLoginBox : function() {
this._loginBox = new dialog.Login({
- "text" : 'Please sign in',
+ "text" : 'Enter your credentials...',
+ "image" : "helenos/logobw.png",
checkCredentials : this.checkCredentials
});
View
3 src/main/frontend/source/class/helenos/components/Header.js
@@ -6,9 +6,6 @@ License:
Authors:
Tomek Kuprowski (tomekkuprowski at gmail dot com)
************************************************************************ */
-/*
-#asset(qx/icon/${qx.icontheme}/16/devices/network-wired.png)
-*/
qx.Class.define("helenos.components.Header",
{
extend : qx.ui.container.Composite,
View
2 src/main/frontend/source/class/helenos/components/SchemaPane.js
@@ -97,7 +97,7 @@ qx.Class.define("helenos.components.SchemaPane",
"message" : '<h3>Create new keyspace</h3>',
"formData" : formData,
"allowCancel" : true,
- "callback" : function(context, result) {
+ "callback" : function(result) {
if (result != null) {
helenos.util.RpcActionsProvider.createKeyspace(result);
helenos.util.GuiObserver.refreshSchemaTree();
View
2 src/main/frontend/source/class/helenos/components/menu/KeyspaceContextMenu.js
@@ -134,7 +134,7 @@ qx.Class.define('helenos.components.menu.KeyspaceContextMenu',
'value' : ''
}
};
- dialog.Dialog.form('<h4>Create new column family</h4>', formData, function(context, result) {
+ dialog.Dialog.form('<h4>Create new column family</h4>', formData, function(result) {
if (result != null) {
result['keyspaceName'] = ksName;
helenos.util.RpcActionsProvider.createColumnFamily(result);
View
145 src/main/frontend/source/class/helenos/components/tab/AccountsEditorPage.js
@@ -74,8 +74,8 @@ qx.Class.define("helenos.components.tab.AccountsEditorPage",
this.__deleteButton.addListener('execute', this.__onDeleteAccount, this);
this.__deleteButton.setEnabled(false);
- this.__editButton = new qx.ui.form.Button('Edit', 'icon/16/actions/edit-cut.png');
- this.__editButton.addListener('execute', this.__onEditAccount, this);
+ this.__editButton = new qx.ui.form.Button('Reset password', 'icon/16/actions/edit-cut.png');
+ this.__editButton.addListener('execute', this.__onEditPasswdAccount, this);
this.__editButton.setEnabled(false);
pane.add(this.__addButton);
@@ -88,110 +88,87 @@ qx.Class.define("helenos.components.tab.AccountsEditorPage",
* @lint ignoreUndefined(dialog)
*/
__onAddAccount : function(e) {
- var formData = {
- 'username' : {
- 'type' : 'textfield',
- 'label' : 'Username (unique)',
- 'value' : '',
- 'validation' : {
- 'required' : true
- }
- },
- 'password1' : {
- 'type' : 'passwordfield',
- 'label' : 'Password',
- 'value' : '',
- 'validation' : {
- 'required' : true
- }
+ var formData =
+ {
+ 'username' :
+ {
+ 'type' : "TextField",
+ 'label' : "User Name",
+ 'value' : "",
+ "validation" : {
+ "required" : true
+ }
},
- 'password2' : {
- 'type' : 'passwordfield',
- 'label' : 'Repeat password',
- 'value' : '',
+ 'password' :
+ {
+ 'type' : "passwordfield",
+ 'label' : "Password",
+ 'value' : "",
'validation' : {
- 'required' : true
+ "required" : true
}
},
- 'authorities' :
+ 'authority' :
{
- 'type' : "combobox",
- 'label' : "Authorities",
+ 'type' : "SelectBox",
+ 'label' : "Authority",
'value' : "ROLE_USER",
- 'height' : 120,
'options' : [
{
- 'label' : "ROLE_USER", 'value' : "ROLE_USER"
+ 'label' : "ROLE_USER",
+ 'value' : "ROLE_USER"
},
- {
- 'label' : "ROLE_ADMIN", 'value' : "ROLE_ADMIN"
+{
+ 'label' : "ROLE_ADMIN",
+ 'value' : "ROLE_ADMIN"
}
]
- },
- 'enabled' :
- {
- 'type' : 'checkbox',
- 'label' : 'Enabled',
- 'value' : true
}
};
- (new dialog.Form({
- "message" : '<h3>Create new account</h3>',
- "formData" : formData,
- "allowCancel" : true,
- "callback" : function(context, result) {
- if (result != null) {
- helenos.util.RpcActionsProvider.storeAccount(result);
- context._reloadAccountsTable();
- }
- },
- "context" : this
- })).set({
- width : 350
- }).show();
+
+ var _this = this;
+ dialog.Dialog.form("<h3>Add account</h3>",formData, function( result )
+ {
+ result['enabled'] = true;
+ result['authorities'] = [result['authority']];
+ result['authority'] = undefined;
+ helenos.util.RpcActionsProvider.createAccount(result);
+ _this._reloadAccountsTable();
+ }, _this);
},
/**
* @lint ignoreUndefined(dialog)
*/
- __onEditAccount : function(e) {
- var alias = this.__getSelectedAlias();
- var cc = helenos.util.RpcActionsProvider.getAccountByAlias(alias);
- var formData = {
- 'hosts' : {
- 'type' : 'TextField',
- 'label' : 'Hosts (comma separated)',
- 'value' : cc.hosts,
+ __onEditPasswdAccount : function(e) {
+ var username = this.__getSelectedUsername();
+ var formData =
+ {
+ 'password1' :
+ {
+ 'type' : "passwordfield",
+ 'label' : "Password",
+ 'value' : "",
'validation' : {
- 'required' : true
- }
+ "required" : true
+ }
},
- 'clusterName' :
+ 'password2' :
{
- 'type' : 'TextField',
- 'label' : 'Cluster name',
- 'value' : cc.clusterName,
+ 'type' : "passwordfield",
+ 'label' : "Repeat password",
+ 'value' : "",
'validation' : {
- 'required' : true
+ "required" : true
}
}
};
- (new dialog.Form({
- "message" : '<h3>Edit account</h3>',
- "formData" : formData,
- "allowCancel" : true,
- "callback" : function(context, result) {
- if (result != null) {
- result['alias'] = cc.alias;
- result['active'] = cc.active;
- helenos.util.RpcActionsProvider.storeAccount(result);
- context._reloadAccountsTable();
- }
- },
- "context" : this
- })).set({
- width : 550
- }).show();
+ dialog.Dialog.form("<h3>Reset password for: " + username + "</h3>",formData, function( result )
+ {
+ result['username'] = username;
+ helenos.util.RpcActionsProvider.saveNewPasword(result);
+ }, this);
+
},
/**
@@ -202,12 +179,14 @@ qx.Class.define("helenos.components.tab.AccountsEditorPage",
var selectedRow = selectionModel.getSelectedRanges()[0].minIndex;
var username = this.__accountsTable.getTableModel().getValue(0, selectedRow);
+
+ var _this = this;
dialog.Dialog.confirm(this.tr('are.you.sure'), function(ret) {
if (ret == true) {
helenos.util.RpcActionsProvider.deleteAccount(username);
this._reloadAccountsTable();
}
- }, this);
+ }, _this);
},
@@ -216,7 +195,7 @@ qx.Class.define("helenos.components.tab.AccountsEditorPage",
this.__accountsTable.getTableModel().reloadData();
},
- __getSelectedAlias : function() {
+ __getSelectedUsername : function() {
var selectedRow = this.__accountsTable.getSelectionModel().getSelectedRanges()[0].minIndex;
return this.__accountsTable.getTableModel().getValue(0, selectedRow);
},
View
10 src/main/frontend/source/class/helenos/components/tab/ConnectionsEditorPage.js
@@ -119,15 +119,16 @@ qx.Class.define("helenos.components.tab.ConnectionsEditorPage",
}
}
};
+ var _this = this;
(new dialog.Form({
"message" : '<h3>Create new connection</h3>',
"formData" : formData,
"allowCancel" : true,
- "callback" : function(context, result) {
+ "callback" : function(result) {
if (result != null) {
result['active'] = false;
helenos.util.RpcActionsProvider.storeConnection(result);
- context._reloadConnectionsTable();
+ _this._reloadConnectionsTable();
}
},
"context" : this
@@ -159,16 +160,17 @@ qx.Class.define("helenos.components.tab.ConnectionsEditorPage",
}
}
};
+ var _this = this;
(new dialog.Form({
"message" : '<h3>Edit connection</h3>',
"formData" : formData,
"allowCancel" : true,
- "callback" : function(context, result) {
+ "callback" : function(result) {
if (result != null) {
result['alias'] = cc.alias;
result['active'] = cc.active;
helenos.util.RpcActionsProvider.storeConnection(result);
- context._reloadConnectionsTable();
+ _this._reloadConnectionsTable();
}
},
"context" : this
View
90 src/main/frontend/source/class/helenos/components/tab/browse/AbstractPage.js
@@ -0,0 +1,90 @@
+/* ************************************************************************
+Copyright:
+ 2012 Tomek Kuprowski
+License:
+ GPLv2: http://www.gnu.org/licences/gpl.html
+Authors:
+ Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ ************************************************************************ */
+/*
+#asset(qx/icon/${qx.icontheme}/16/actions/system-search.png)
+#asset(qx/icon/${qx.icontheme}/16/places/folder-open.png)
+*/
+qx.Class.define("helenos.components.tab.browse.AbstractPage",
+{
+ extend : helenos.components.tab.AbstractCloseablePage,
+
+ construct : function(ksName, cfName)
+ {
+ this.base(arguments);
+ this._cfDef = helenos.util.RpcActionsProvider.describeColumnFamily(ksName, cfName);
+
+ this.set({
+ layout : new qx.ui.layout.Grow(),
+ label : (ksName + ' : ' + cfName),
+ icon : this._getIconPath()
+ });
+
+ this._manager = new qx.ui.form.validation.Manager();
+ this.__buildMainPane();
+ },
+
+ members : {
+
+ _cfDef : null,
+ _manager : null,
+ _resultsTree : null,
+
+ _getSplitPaneOrientation : function() {
+ throw new Error('_getSplitPaneOrientation is abstract');
+ },
+
+ _buildCriteriaComponent : function() {
+ throw new Error('_buildCriteriaComponent is abstract');
+ },
+
+ _getIconPath : function() {
+ throw new Error('_getIconPath is abstract');
+ },
+
+ _performSearch : function() {
+ throw new Error('_performSearch is abstract');
+ },
+
+ __buildMainPane : function() {
+ var pane = new qx.ui.splitpane.Pane(this._getSplitPaneOrientation());
+ pane.add(this._getCriteriaPane(),0);
+ pane.add(this._getResultsPane(), 1);
+ this.add(pane);
+ },
+
+ _getCriteriaPane : function() {
+ throw new Error('_getCriteriaPane is abstract');
+ },
+
+ _getResultsPane : function() {
+ this._resultsTree = new helenos.ui.treevirtual.ResultsTree();
+
+ var tablePane = new qx.ui.core.scroll.ScrollPane().set({allowGrowX : true, allowGrowY : true});
+ tablePane.add(this._resultsTree);
+
+ var resultView = new qx.ui.container.Composite(new qx.ui.layout.VBox(1));
+ resultView.add(tablePane, {flex : 1});
+ return resultView;
+ },
+
+ _getSearchButton : function() {
+ var button = new qx.ui.form.Button('Search', 'icon/16/actions/system-search.png');
+ button.addListener("execute", this._performValidation, this);
+ return button;
+ },
+
+ _performValidation : function(e) {
+ this._manager.validate();
+ if (this._manager.isValid()) {
+ var data = this._performSearch();
+ this._resultsTree.setData(data);
+ }
+ }
+ }
+});
View
7 ...mponents/tab/browse/AbstractBrowsePage.js → .../components/tab/browse/AbstractPageOLD.js
@@ -10,8 +10,9 @@ Authors:
#asset(qx/icon/${qx.icontheme}/16/actions/system-search.png)
#asset(qx/icon/${qx.icontheme}/16/places/folder-open.png)
*/
-qx.Class.define("helenos.components.tab.browse.AbstractBrowsePage",
+qx.Class.define("helenos.components.tab.browse.AbstractPageOLD",
{
+ /*
extend : helenos.components.tab.AbstractCloseablePage,
construct : function(ksName, cfName)
@@ -28,7 +29,6 @@ qx.Class.define("helenos.components.tab.browse.AbstractBrowsePage",
});
this._resultView = new qx.ui.container.Composite(new qx.ui.layout.VBox(8));
- //this._rajCB = new qx.ui.form.CheckBox('Parse results to JSON');
var pane = new qx.ui.splitpane.Pane("horizontal");
pane.add(this._getCriteriaPane(),0);
@@ -44,7 +44,6 @@ qx.Class.define("helenos.components.tab.browse.AbstractBrowsePage",
_resultView : null,
_manager : null,
- //_rajCB : null,
_getCriteriaPane : function() {
var components = this._getCriteriaComponents();
@@ -137,5 +136,5 @@ qx.Class.define("helenos.components.tab.browse.AbstractBrowsePage",
node.add(new qx.ui.tree.TreeFile(data));
}
}
- }
+ }*/
});
View
60 src/main/frontend/source/class/helenos/components/tab/browse/CqlPage.js
@@ -0,0 +1,60 @@
+/* ************************************************************************
+Copyright:
+ 2012 Tomek Kuprowski
+License:
+ GPLv2: http://www.gnu.org/licences/gpl.html
+Authors:
+ Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ ************************************************************************ */
+qx.Class.define("helenos.components.tab.browse.CqlPage",
+{
+ extend : helenos.components.tab.browse.AbstractPage,
+
+ construct : function(ksName, cfName)
+ {
+ this.base(arguments, ksName, cfName);
+ },
+
+ members :
+ {
+ _getSplitPaneOrientation : function() {
+ return 'vertical';
+ },
+
+ _getIconPath : function() {
+ return 'helenos/query-16.png';
+ },
+
+ _performSearch : function(e) {
+ var queryStr = this._queryArea.getValue();
+ return helenos.util.RpcActionsProvider.queryCql(this._cfDef, queryStr);
+ },
+
+ _getCriteriaPane : function() {
+ this._queryArea = new qx.ui.form.TextArea('SELECT * FROM ' + this._cfDef.name);
+ this._queryArea.set({
+ padding : 6,
+ wrap : true,
+ height : 120,
+ appearance : 'cql-textarea'
+ });
+
+ var queryGB = new helenos.ui.GroupBoxV('Query');
+ queryGB.add(this._queryArea, {
+ flex : 1
+ });
+
+ var buttonPane = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, 'left'));
+ buttonPane.add(this._getSearchButton());
+
+ var container = new qx.ui.container.Composite(new qx.ui.layout.VBox(3, 'top'));
+ container.setAppearance('criteria-pane');
+ container.add(queryGB, {
+ flex : 1
+ });
+ container.add(buttonPane);
+
+ return container;
+ }
+ }
+});
View
198 src/main/frontend/source/class/helenos/components/tab/browse/CqlPageOLD.js
@@ -0,0 +1,198 @@
+/* ************************************************************************
+Copyright:
+ 2012 Tomek Kuprowski
+License:
+ GPLv2: http://www.gnu.org/licences/gpl.html
+Authors:
+ Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ ************************************************************************ */
+qx.Class.define("helenos.components.tab.browse.CqlPageOLD",
+{
+ /*
+ extend : helenos.components.tab.browse.AbstractBrowsePage,
+
+ construct : function(ksName)
+ {
+ this.base(arguments, ksName, null);
+ this.set({
+ icon : 'helenos/query-16.png'
+ });
+ },
+
+ members :
+ {
+ __keyModeRBG : null,
+ __columnsByRBG : null,
+
+ __keyFromTF : null,
+ __keyToTF : null,
+ __keyMode : 'predicate',
+ __keysLimitTF : null,
+
+ __nameStartTF : null,
+ __nameEndTF : null,
+ __sNameTF : null,
+
+ __columnNamesTF : null,
+ __rangeColNamesCP : null,
+ __rangeFromToCP : null,
+ __reversedCB : null,
+ __colsLimitTF : null,
+
+ _tree : null,
+
+ _performSearch : function(e) {
+ var keyFrom = this.__keyFromTF.getValue();
+ var keyTo = this.__keyToTF.getValue();
+ var sName = (this.__sNameTF == null ? null : this.__sNameTF.getValue());
+
+ var nameStart, nameEnd, reversed, columnNames;
+ if (this.__columnsByRBG.getSelection()[0].getLabel() == 'range') {
+ nameStart = this.__nameStartTF.getValue();
+ nameEnd = this.__nameEndTF.getValue();
+ reversed = this.__reversedCB.getValue();
+ } else {
+ columnNames = this.__columnNamesTF.getValue().split(',');
+ }
+ var result;
+ if (this.__keyMode == 'predicate') {
+ result = helenos.util.RpcActionsProvider.queryPredicate(this._cfDef, keyFrom, keyTo, columnNames, nameStart, nameEnd, sName, reversed);
+ } else {
+ result = helenos.util.RpcActionsProvider.queryKeyRange(this._cfDef, keyFrom, keyTo, columnNames, nameStart, nameEnd, sName, reversed);
+ }
+ this._resultView.removeAll();
+ this._resultView.add(this._getResultComponent(result), {flex: 1});
+ },
+
+ _getResultComponent : function(result) {
+ this._tree = new helenos.ui.treevirtual.ResultsTree(result);
+
+ var tablePane = new qx.ui.core.scroll.ScrollPane().set({allowGrowX : true, allowGrowY : true});
+
+ tablePane.add(this._tree);
+ return tablePane;
+ },
+
+ _getCriteriaComponents : function() {
+ var ret = new Array();
+
+ ret.push(this.__getKeysGB());
+ ret.push(this.__getColumnsGB());
+
+ return ret;
+ },
+
+ __getColumnsGB : function() {
+ var columnsGB = new helenos.ui.GroupBoxV('Columns');
+
+ if (this._cfDef.columnType == 'Super') {
+ this.__nameStartTF = new helenos.ui.TextField(this._cfDef.subComparatorType.className);
+ this.__nameEndTF = new helenos.ui.TextField(this._cfDef.subComparatorType.className);
+ } else {
+ this.__nameStartTF = new helenos.ui.TextField(this._cfDef.comparatorType.className);
+ this.__nameEndTF = new helenos.ui.TextField(this._cfDef.comparatorType.className);
+ }
+
+ columnsGB.add(this.__getRangeFromToBox());
+ columnsGB.add(this.__getRangeColNamesBox());
+
+ if (this._cfDef.columnType == 'Super') {
+ this.__sNameTF = new helenos.ui.TextField(this._cfDef.comparatorType.className);
+ columnsGB.add(new qx.ui.basic.Label('Super column name:'));
+ columnsGB.add(this.__sNameTF);
+ }
+
+ columnsGB.add(new qx.ui.basic.Label('Columns mode:'));
+ columnsGB.add(this.__getRangeModeBG());
+
+ return columnsGB;
+ },
+
+ __getKeysGB : function() {
+ this.__keyFromTF = new helenos.ui.TextField(this._cfDef.keyValidationClass);
+ this.__keyToTF = new helenos.ui.TextField(this._cfDef.keyValidationClass);
+ this.__keyToTF.setEnabled(false);
+
+ var keysGB = new helenos.ui.GroupBoxV('Keys');
+ keysGB.add(new qx.ui.basic.Label('From:'));
+ keysGB.add(this.__keyFromTF);
+ keysGB.add(new qx.ui.basic.Label('To:'));
+ keysGB.add(this.__keyToTF);
+
+ keysGB.add(new qx.ui.basic.Label('Key mode:'));
+ keysGB.add(this.__getKeyModeBG());
+
+ return keysGB;
+ },
+
+ __getRangeModeBG : function() {
+ var byNameBT = new qx.ui.form.RadioButton('name');
+ var byRangeBT = new qx.ui.form.RadioButton('range');
+
+ this.__columnsByRBG = new qx.ui.form.RadioButtonGroup(new qx.ui.layout.HBox(8));
+ this.__columnsByRBG.add(byNameBT);
+ this.__columnsByRBG.add(byRangeBT);
+ this.__columnsByRBG.setSelection([byRangeBT]);
+ this.__columnsByRBG.addListener("changeSelection", this._onRangeModeToggled, this);
+ return this.__columnsByRBG;
+ },
+
+ __getKeyModeBG : function() {
+ var predicateBT = new qx.ui.form.RadioButton('predicate');
+ var keyRangeBT = new qx.ui.form.RadioButton('key range');
+
+ this.__keyModeRBG = new qx.ui.form.RadioButtonGroup(new qx.ui.layout.HBox(5));
+ this.__keyModeRBG.add(predicateBT);
+ this.__keyModeRBG.add(keyRangeBT);
+ this.__keyModeRBG.setSelection([predicateBT]);
+ this.__keyModeRBG.addListener("changeSelection", this._onKeyModeToggled, this);
+ return this.__keyModeRBG;
+ },
+
+ __getRangeFromToBox : function() {
+ this.__rangeFromToCP = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({padding : 0});
+
+ this.__colsLimitTF = new qx.ui.form.TextField().set({filter : /[0-9]/, value : '10'});
+
+ this.__rangeFromToCP.add(new qx.ui.basic.Label('From:'));
+ this.__rangeFromToCP.add(this.__nameStartTF);
+ this.__rangeFromToCP.add(new qx.ui.basic.Label('To:'));
+ this.__rangeFromToCP.add(this.__nameEndTF);
+ this.__rangeFromToCP.add(new qx.ui.basic.Label('Limit:'));
+ this.__rangeFromToCP.add(this.__colsLimitTF);
+
+ this.__reversedCB = new qx.ui.form.CheckBox('Reversed');
+ this.__rangeFromToCP.add(this.__reversedCB);
+
+ return this.__rangeFromToCP;
+ },
+
+ __getRangeColNamesBox : function() {
+ this.__rangeColNamesCP = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({padding : 0, visibility : 'excluded'});
+
+ this.__columnNamesTF = new qx.ui.form.TextArea().set({placeholder : 'comma separated columns list'});
+ this.__rangeColNamesCP.add(new qx.ui.basic.Label('Column names:'));
+ this.__rangeColNamesCP.add(this.__columnNamesTF);
+
+ return this.__rangeColNamesCP;
+ },
+
+ _onRangeModeToggled : function(e) {
+ var selectedBtnLabel = e.getData()[0].getLabel();
+ if (selectedBtnLabel == 'name') {
+ this.__rangeFromToCP.setVisibility('excluded');
+ this.__rangeColNamesCP.setVisibility('visible');
+ } else {
+ this.__rangeFromToCP.setVisibility('visible');
+ this.__rangeColNamesCP.setVisibility('excluded');
+ }
+ },
+
+ _onKeyModeToggled : function(e) {
+ var selectedBtnLabel = e.getData()[0].getLabel();
+ this.__keyToTF.resetValue();
+ this.__keyToTF.setEnabled(selectedBtnLabel != 'predicate');
+ this.__keyMode = selectedBtnLabel;
+ }
+ }*/
+});
View
52 src/main/frontend/source/class/helenos/components/tab/browse/PredicatePage.js
@@ -8,14 +8,11 @@ Authors:
************************************************************************ */
qx.Class.define("helenos.components.tab.browse.PredicatePage",
{
- extend : helenos.components.tab.browse.AbstractBrowsePage,
+ extend : helenos.components.tab.browse.AbstractPage,
construct : function(ksName, cfName)
{
this.base(arguments, ksName, cfName);
- this.set({
- icon : 'icon/16/apps/office-spreadsheet.png'
- });
},
members :
@@ -40,6 +37,15 @@ qx.Class.define("helenos.components.tab.browse.PredicatePage",
_tree : null,
+ _getSplitPaneOrientation : function() {
+ return 'horizontal';
+ },
+
+ _getIconPath : function() {
+ return 'icon/16/apps/office-spreadsheet.png';
+ },
+
+
_performSearch : function(e) {
var keyFrom = this.__keyFromTF.getValue();
var keyTo = this.__keyToTF.getValue();
@@ -53,34 +59,34 @@ qx.Class.define("helenos.components.tab.browse.PredicatePage",
} else {
columnNames = this.__columnNamesTF.getValue().split(',');
}
- var result;
+
if (this.__keyMode == 'predicate') {
- result = helenos.util.RpcActionsProvider.queryPredicate(this._cfDef, keyFrom, keyTo, columnNames, nameStart, nameEnd, sName, reversed);
+ return helenos.util.RpcActionsProvider.queryPredicate(this._cfDef, keyFrom, keyTo, columnNames, nameStart, nameEnd, sName, reversed);
} else {
- result = helenos.util.RpcActionsProvider.queryKeyRange(this._cfDef, keyFrom, keyTo, columnNames, nameStart, nameEnd, sName, reversed);
+ return helenos.util.RpcActionsProvider.queryKeyRange(this._cfDef, keyFrom, keyTo, columnNames, nameStart, nameEnd, sName, reversed);
}
- this._resultView.removeAll();
- this._resultView.add(this._getResultComponent(result), {flex: 1});
},
- _getResultComponent : function(result) {
- this._tree = new helenos.ui.treevirtual.ResultsTree(result);
+ _getCriteriaPane : function() {
+ var widgets = new Array();
+ widgets.push(this.__getKeysGB());
+ widgets.push(this.__getColumnsGB());
- var tablePane = new qx.ui.core.scroll.ScrollPane().set({allowGrowX : true, allowGrowY : true});
+ var container = new qx.ui.container.Composite(new qx.ui.layout.VBox(7).set({alignX : 'left'}));
+ container.setAppearance('criteria-pane');
- tablePane.add(this._tree);
- return tablePane;
- },
-
- _getCriteriaComponents : function() {
- var ret = new Array();
-
- ret.push(this.__getKeysGB());
- ret.push(this.__getColumnsGB());
+ for (var i = 0; i < widgets.length; i++) {
+ container.add(widgets[i]);
+ }
+ container.add(this._getSearchButton());
- return ret;
+ var pane = new qx.ui.container.Scroll();
+ pane.setWidth(180);
+ pane.add(container);
+ return pane;
},
-
+
+
__getColumnsGB : function() {
var columnsGB = new helenos.ui.GroupBoxV('Columns');
View
198 src/main/frontend/source/class/helenos/components/tab/browse/PredicatePageOLD.js
@@ -0,0 +1,198 @@
+/* ************************************************************************
+Copyright:
+ 2012 Tomek Kuprowski
+License:
+ GPLv2: http://www.gnu.org/licences/gpl.html
+Authors:
+ Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ ************************************************************************ */
+qx.Class.define("helenos.components.tab.browse.PredicatePageOLD",
+{
+ /*
+ extend : helenos.components.tab.browse.AbstractBrowsePage,
+
+ construct : function(ksName, cfName)
+ {
+ this.base(arguments, ksName, cfName);
+ this.set({
+ icon : 'icon/16/apps/office-spreadsheet.png'
+ });
+ },
+
+ members :
+ {
+ __keyModeRBG : null,
+ __columnsByRBG : null,
+
+ __keyFromTF : null,
+ __keyToTF : null,
+ __keyMode : 'predicate',
+ __keysLimitTF : null,
+
+ __nameStartTF : null,
+ __nameEndTF : null,
+ __sNameTF : null,
+
+ __columnNamesTF : null,
+ __rangeColNamesCP : null,
+ __rangeFromToCP : null,
+ __reversedCB : null,
+ __colsLimitTF : null,
+
+ _tree : null,
+
+ _performSearch : function(e) {
+ var keyFrom = this.__keyFromTF.getValue();
+ var keyTo = this.__keyToTF.getValue();
+ var sName = (this.__sNameTF == null ? null : this.__sNameTF.getValue());
+
+ var nameStart, nameEnd, reversed, columnNames;
+ if (this.__columnsByRBG.getSelection()[0].getLabel() == 'range') {
+ nameStart = this.__nameStartTF.getValue();
+ nameEnd = this.__nameEndTF.getValue();
+ reversed = this.__reversedCB.getValue();
+ } else {
+ columnNames = this.__columnNamesTF.getValue().split(',');
+ }
+ var result;
+ if (this.__keyMode == 'predicate') {
+ result = helenos.util.RpcActionsProvider.queryPredicate(this._cfDef, keyFrom, keyTo, columnNames, nameStart, nameEnd, sName, reversed);
+ } else {
+ result = helenos.util.RpcActionsProvider.queryKeyRange(this._cfDef, keyFrom, keyTo, columnNames, nameStart, nameEnd, sName, reversed);
+ }
+ this._resultView.removeAll();
+ this._resultView.add(this._getResultComponent(result), {flex: 1});
+ },
+
+ _getResultComponent : function(result) {
+ this._tree = new helenos.ui.treevirtual.ResultsTree(result);
+
+ var tablePane = new qx.ui.core.scroll.ScrollPane().set({allowGrowX : true, allowGrowY : true});
+
+ tablePane.add(this._tree);
+ return tablePane;
+ },
+
+ _getCriteriaComponents : function() {
+ var ret = new Array();
+
+ ret.push(this.__getKeysGB());
+ ret.push(this.__getColumnsGB());
+
+ return ret;
+ },
+
+ __getColumnsGB : function() {
+ var columnsGB = new helenos.ui.GroupBoxV('Columns');
+
+ if (this._cfDef.columnType == 'Super') {
+ this.__nameStartTF = new helenos.ui.TextField(this._cfDef.subComparatorType.className);
+ this.__nameEndTF = new helenos.ui.TextField(this._cfDef.subComparatorType.className);
+ } else {
+ this.__nameStartTF = new helenos.ui.TextField(this._cfDef.comparatorType.className);
+ this.__nameEndTF = new helenos.ui.TextField(this._cfDef.comparatorType.className);
+ }
+
+ columnsGB.add(this.__getRangeFromToBox());
+ columnsGB.add(this.__getRangeColNamesBox());
+
+ if (this._cfDef.columnType == 'Super') {
+ this.__sNameTF = new helenos.ui.TextField(this._cfDef.comparatorType.className);
+ columnsGB.add(new qx.ui.basic.Label('Super column name:'));
+ columnsGB.add(this.__sNameTF);
+ }
+
+ columnsGB.add(new qx.ui.basic.Label('Columns mode:'));
+ columnsGB.add(this.__getRangeModeBG());
+
+ return columnsGB;
+ },
+
+ __getKeysGB : function() {
+ this.__keyFromTF = new helenos.ui.TextField(this._cfDef.keyValidationClass);
+ this.__keyToTF = new helenos.ui.TextField(this._cfDef.keyValidationClass);
+ this.__keyToTF.setEnabled(false);
+
+ var keysGB = new helenos.ui.GroupBoxV('Keys');
+ keysGB.add(new qx.ui.basic.Label('From:'));
+ keysGB.add(this.__keyFromTF);
+ keysGB.add(new qx.ui.basic.Label('To:'));
+ keysGB.add(this.__keyToTF);
+
+ keysGB.add(new qx.ui.basic.Label('Key mode:'));
+ keysGB.add(this.__getKeyModeBG());
+
+ return keysGB;
+ },
+
+ __getRangeModeBG : function() {
+ var byNameBT = new qx.ui.form.RadioButton('name');
+ var byRangeBT = new qx.ui.form.RadioButton('range');
+
+ this.__columnsByRBG = new qx.ui.form.RadioButtonGroup(new qx.ui.layout.HBox(8));
+ this.__columnsByRBG.add(byNameBT);
+ this.__columnsByRBG.add(byRangeBT);
+ this.__columnsByRBG.setSelection([byRangeBT]);
+ this.__columnsByRBG.addListener("changeSelection", this._onRangeModeToggled, this);
+ return this.__columnsByRBG;
+ },
+
+ __getKeyModeBG : function() {
+ var predicateBT = new qx.ui.form.RadioButton('predicate');
+ var keyRangeBT = new qx.ui.form.RadioButton('key range');
+
+ this.__keyModeRBG = new qx.ui.form.RadioButtonGroup(new qx.ui.layout.HBox(5));
+ this.__keyModeRBG.add(predicateBT);
+ this.__keyModeRBG.add(keyRangeBT);
+ this.__keyModeRBG.setSelection([predicateBT]);
+ this.__keyModeRBG.addListener("changeSelection", this._onKeyModeToggled, this);
+ return this.__keyModeRBG;
+ },
+
+ __getRangeFromToBox : function() {
+ this.__rangeFromToCP = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({padding : 0});
+
+ this.__colsLimitTF = new qx.ui.form.TextField().set({filter : /[0-9]/, value : '10'});
+
+ this.__rangeFromToCP.add(new qx.ui.basic.Label('From:'));
+ this.__rangeFromToCP.add(this.__nameStartTF);
+ this.__rangeFromToCP.add(new qx.ui.basic.Label('To:'));
+ this.__rangeFromToCP.add(this.__nameEndTF);
+ this.__rangeFromToCP.add(new qx.ui.basic.Label('Limit:'));
+ this.__rangeFromToCP.add(this.__colsLimitTF);
+
+ this.__reversedCB = new qx.ui.form.CheckBox('Reversed');
+ this.__rangeFromToCP.add(this.__reversedCB);
+
+ return this.__rangeFromToCP;
+ },
+
+ __getRangeColNamesBox : function() {
+ this.__rangeColNamesCP = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({padding : 0, visibility : 'excluded'});
+
+ this.__columnNamesTF = new qx.ui.form.TextArea().set({placeholder : 'comma separated columns list'});
+ this.__rangeColNamesCP.add(new qx.ui.basic.Label('Column names:'));
+ this.__rangeColNamesCP.add(this.__columnNamesTF);
+
+ return this.__rangeColNamesCP;
+ },
+
+ _onRangeModeToggled : function(e) {
+ var selectedBtnLabel = e.getData()[0].getLabel();
+ if (selectedBtnLabel == 'name') {
+ this.__rangeFromToCP.setVisibility('excluded');
+ this.__rangeColNamesCP.setVisibility('visible');
+ } else {
+ this.__rangeFromToCP.setVisibility('visible');
+ this.__rangeColNamesCP.setVisibility('excluded');
+ }
+ },
+
+ _onKeyModeToggled : function(e) {
+ var selectedBtnLabel = e.getData()[0].getLabel();
+ this.__keyToTF.resetValue();
+ this.__keyToTF.setEnabled(selectedBtnLabel != 'predicate');
+ this.__keyMode = selectedBtnLabel;
+ }
+ }*/
+});
View
11 src/main/frontend/source/class/helenos/theme/Appearance.js
@@ -17,7 +17,7 @@ qx.Theme.define("helenos.theme.Appearance",
return {
font : "bold",
textColor : "#E8E8E8",
- padding : [ 8, 12 ],
+ padding : [ 6 ],
decorator : "app-header-black"
};
}
@@ -41,6 +41,15 @@ qx.Theme.define("helenos.theme.Appearance",
}
},
+ 'cql-textarea' : {
+ style : function(states) {
+ return {
+ textColor : '#265515',
+ font : 'cql'
+ }
+ }
+ },
+
'groupbox/frame' : {
style : function(states) {
return {
View
10 src/main/frontend/source/class/helenos/theme/Color.js
@@ -8,10 +8,10 @@ Authors:
************************************************************************ */
qx.Theme.define("helenos.theme.Color",
{
- extend : qx.theme.simple.Color,
+ extend : qx.theme.simple.Color,
- colors :
- {
- "background" : "#f0f3f9"
- }
+ colors :
+ {
+ "background" : "#f0f3f9"
+ }
});
View
3 src/main/frontend/source/class/helenos/theme/Decoration.js
@@ -16,8 +16,7 @@ qx.Theme.define('helenos.theme.Decoration',
{
decorator : qx.ui.decoration.Background,
style : {
- backgroundImage : 'helenos/background.jpg',
- backgroundRepeat : 'repeat-x'
+ backgroundColor : "#1e1b1b"
}
}
}
View
8 src/main/frontend/source/class/helenos/theme/Font.js
@@ -12,5 +12,11 @@ qx.Theme.define("helenos.theme.Font",
fonts :
{
-}
+ "cql" :
+ {
+ size : 14,
+ family : [ "Courier New" ],
+ bold : true
+ }
+ }
});
View
28 src/main/frontend/source/class/helenos/ui/treevirtual/ResultsTree.js
@@ -11,17 +11,23 @@ qx.Class.define("helenos.ui.treevirtual.ResultsTree",
extend : qx.ui.treevirtual.TreeVirtual,
include : [helenos.ui.table.MZeroClipboardCtxHandler],
- construct : function(data)
+ construct : function()
{
this.base(arguments, ["Name", "Value", "Clock", "TTL"]);
- this.set({alwaysShowOpenCloseSymbol : true, useTreeLines : true, statusBarVisible : false});
+ this.set({
+ alwaysShowOpenCloseSymbol : true,
+ useTreeLines : true,
+ statusBarVisible : false
+ });
var resizeBehavior = this.getTableColumnModel().getBehavior();
- resizeBehavior.set(1, { width:"1*", minWidth:200 });
+ resizeBehavior.set(1, {
+ width:"1*",
+ minWidth:200
+ });
+ resizeBehavior.setWidth(2, 140);
resizeBehavior.setWidth(3, 60);
- this.setData(data);
-
this.setContextMenuHandler(0, this.contextMenuHandler);
this.setContextMenuHandler(1, this.contextMenuHandler);
this.setContextMenuHandler(2, this.contextMenuHandler);
@@ -35,18 +41,20 @@ qx.Class.define("helenos.ui.treevirtual.ResultsTree",
return
}
var dataModel = this.getDataModel();
-
+ dataModel.clearData();
var i;
for(i = 0; i < data.length; i++) {
var row = data[i];
var branch = dataModel.addBranch(null, row.key, true, false, 'helenos/key.png');
var j;
for (j = 0; j < row.columns.length; j++) {
var col = row.columns[j];
- var leaf = dataModel.addLeaf(branch, col.name, 'helenos/isctf.png');
- dataModel.setColumnData(leaf, 1, col.value);
- dataModel.setColumnData(leaf, 2, col.clock);
- dataModel.setColumnData(leaf, 3, col.ttl);
+ if (col.name != 'KEY') {
+ var leaf = dataModel.addLeaf(branch, col.name, 'helenos/isctf.png');
+ dataModel.setColumnData(leaf, 1, col.value);
+ dataModel.setColumnData(leaf, 2, col.clock);
+ dataModel.setColumnData(leaf, 3, col.ttl);
+ }
}
}
dataModel.setData();
View
16 src/main/frontend/source/class/helenos/util/GuiObserver.js
@@ -12,22 +12,15 @@ qx.Class.define("helenos.util.GuiObserver",
{
__tabbedPane : null,
__schemaPane : null,
- __root : null,
shutdownApp : function() {
- qx.core.Assert.assertNotNull(this.__root,'root not registered yet');
-
- var handler = this.__root.fadeOut(750);
+ var handler = qx.core.Init.getApplication().getRoot().fadeOut(750);
handler.addListener('end', function(e) {
qx.core.ObjectRegistry.shutdown();
window.location.reload();
}, this);
},
- registerRoot : function(component) {
- this.__root = component;
- },
-
registerTabbedPane : function(pane) {
this.__tabbedPane = pane;
},
@@ -70,6 +63,13 @@ qx.Class.define("helenos.util.GuiObserver",
this._addPageToTab(cfPage);
},
+ showBrowseByCqlQueryTab : function(keyspaceName, columnFamilyName) {
+ qx.core.Assert.assertNotNull(this.__tabbedPane,'tabbed pane not registered yet');
+ var cqlPage = new helenos.components.tab.browse.CqlPage(keyspaceName, columnFamilyName);
+
+ this._addPageToTab(cqlPage);
+ },
+
refreshSchemaTree : function() {
qx.core.Assert.assertNotNull(this.__schemaPane,'cluster pane not registered yet');
this.__schemaPane.refreshSchemaTree();
View
27 src/main/frontend/source/class/helenos/util/RpcActionsProvider.js
@@ -38,6 +38,21 @@ qx.Class.define('helenos.util.RpcActionsProvider', {
return rpc.callSync('getConnectionByAlias', alias);
},
+ saveNewPasword : function(passwordBean) {
+ var rpc = new helenos.util.Rpc(this._ACCOUNT);
+ return rpc.callSync('saveNewPassword', passwordBean);
+ },
+
+ createAccount : function(account) {
+ var rpc = new helenos.util.Rpc(this._ACCOUNT);
+ return rpc.callSync('createAccount', account);
+ },
+
+ loadUserByUsername : function(username) {
+ var rpc = new helenos.util.Rpc(this._ACCOUNT);
+ return rpc.callSync('loadUserByUsername', username);
+ },
+
deleteConnection : function(alias) {
var rpc = new helenos.util.Rpc(this._CLUSTERCONNECTION);
return rpc.callSync('delete', alias);
@@ -135,6 +150,18 @@ qx.Class.define('helenos.util.RpcActionsProvider', {
return rpc.callSync('createKeyspace', formData);
},
+ queryCql : function(cfDef, queryStr) {
+ var query = {};
+ query.keyClass = this.__findParamClass(cfDef.keyValidationClass);
+ query.nameClass = this.__findParamClass(cfDef.comparatorType.className);
+ query.keyspace = cfDef.keyspaceName;
+ query.columnFamily = cfDef.name;
+ query.query = queryStr;
+
+ var rpc = new helenos.util.Rpc(this._STANDARDQUERY);
+ return rpc.callSync('cql', query);
+ },
+
queryPredicate : function(cfDef, keyFrom, keyTo, columnNames, nameStart, nameEnd, sName, reversed ) {
var query = {};
View
BIN src/main/frontend/source/resource/helenos/Black_and_white_384x75.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/main/frontend/source/resource/helenos/White_on_black_background_384x75.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/main/frontend/source/resource/helenos/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/main/frontend/source/resource/helenos/logobw.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN src/main/frontend/source/resource/helenos/logoold.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 src/main/frontend/source/resource/welcome.html
@@ -20,7 +20,7 @@
<section>
<div id="title">
- <h1>Helenos</h1>
+ <h1>Helenos</h1>
<p>Cassandra web console</p>
<hr>
<span class="credits left">Project maintained by <a href="https://github.com/tomekkup">tomekkup</a></span>
View
47 src/main/java/tomekkup/helenos/dao/AccountDao.java
@@ -1,6 +1,6 @@
package tomekkup.helenos.dao;
-import tomekkup.helenos.dao.model.Account;
+import tomekkup.helenos.types.qx.QxAccount;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
@@ -22,6 +22,7 @@
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
+import tomekkup.helenos.types.qx.QxPasswordChangeRequest;
/**
* ********************************************************
@@ -63,19 +64,44 @@ private void ensureDefaultCreds() {
try {
loadUserByUsername("admin");
} catch (UsernameNotFoundException e) {
- String encodedPasswd = passwordEncoder.encodePassword("admin", saltSource.getSalt(new Account("admin")));
- Account user = new Account("admin", encodedPasswd, new SimpleGrantedAuthority(ROLE_ADMIN), true);
+ String encodedPasswd = encodePasswd("admin", "admin");
+ QxAccount user = new QxAccount("admin", encodedPasswd, new SimpleGrantedAuthority(ROLE_ADMIN), true);
user.addAuthority(new SimpleGrantedAuthority(ROLE_USER));
store(user);
}
}
- public void store(Account user) {
+ private String encodePasswd(String username, String passwd) {
+ return passwordEncoder.encodePassword(passwd, saltSource.getSalt(new QxAccount(username)));
+ }
+
+ private void encodePasswd(QxAccount user) {
+ user.setPassword(passwordEncoder.encodePassword(user.getPassword(), saltSource.getSalt(new QxAccount(user.getUsername()))));
+ }
+
+ public void createAccount(QxAccount user) {
+ encodePasswd(user);
+ store(user);
+ }
+
+ public void store(QxAccount user) {
jdbcTemplate.update(queriesProperties.getProperty("user.merge"), prepareParameterSource(user));
}
- public List<Account> loadAll() {
+ public void saveNewPassword(QxPasswordChangeRequest pcr) throws IllegalStateException {
+ if(!pcr.getPassword1().equals(pcr.getPassword2())) {
+ throw new IllegalStateException("both passwords must equal");
+ }
+ if(!StringUtils.hasText(pcr.getPassword2())) {
+ throw new IllegalStateException("password can not be empty");
+ }
+ QxAccount account = (QxAccount)loadUserByUsername(pcr.getUsername());
+ account.setPassword(encodePasswd(pcr.getUsername(), pcr.getPassword1()));
+ this.store(account);
+ }
+
+ public List<QxAccount> loadAll() {
return jdbcTemplate.query(queriesProperties.getProperty("user.select.star"), new MapSqlParameterSource(), new UserMapper());
}
@@ -84,18 +110,21 @@ public long getAccountsCount() {
}
public void delete(String username) {
+ if (username.toLowerCase().equals("admin")) {
+ throw new IllegalArgumentException("admin account can not be removed");
+ }
jdbcTemplate.update(queriesProperties.getProperty("user.delete"), new MapSqlParameterSource("username", username));
}
- private SqlParameterSource prepareParameterSource(Account user) {
+ private SqlParameterSource prepareParameterSource(QxAccount user) {
return new MapSqlParameterSource(user.toParametersMap());
}
- private static final class UserMapper implements RowMapper<Account> {
+ private static final class UserMapper implements RowMapper<QxAccount> {
@Override
- public Account mapRow(ResultSet rs, int rowNum) throws SQLException {
- Account user = new Account();
+ public QxAccount mapRow(ResultSet rs, int rowNum) throws SQLException {
+ QxAccount user = new QxAccount();
user.setUsername(rs.getString("USERNAME"));
user.setPassword(rs.getString("PASSWORD"));
user.setEnabled(rs.getBoolean("ENABLED"));
View
30 src/main/java/tomekkup/helenos/dozer/converters/SimpleGrantedAuthorityConverter.java
@@ -0,0 +1,30 @@
+package tomekkup.helenos.dozer.converters;
+
+import org.dozer.CustomConverter;
+import org.dozer.MappingException;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+
+/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
+ *
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
+ */
+public class SimpleGrantedAuthorityConverter implements CustomConverter {
+
+ @Override
+ public Object convert(Object existingDestinationFieldValue, Object sourceFieldValue, Class<?> destinationClass, Class<?> sourceClass) {
+ if (sourceFieldValue == null) {
+ return null;
+ }
+ if (!(sourceFieldValue instanceof String)) {
+ throw new MappingException("Converter " + this.getClass().toString() + " used incorrectly. Arguments passed in were:"
+ + existingDestinationFieldValue + " and " + sourceFieldValue);
+ }
+
+ return new SimpleGrantedAuthority((String)sourceFieldValue);
+ }
+}
View
13 src/main/java/tomekkup/helenos/service/AccountsProvider.java
@@ -1,7 +1,8 @@
package tomekkup.helenos.service;
-import tomekkup.helenos.dao.model.Account;
+import tomekkup.helenos.types.qx.QxAccount;
import java.util.List;
+import tomekkup.helenos.types.qx.QxPasswordChangeRequest;
/**
* ********************************************************
@@ -14,13 +15,17 @@
*/
public interface AccountsProvider {
- List<Account> loadAll();
+ List<QxAccount> loadAll();
long getAccountsCount();
void delete(String username);
- void store(Account account);
+ void store(QxAccount account);
- Account loadUserByUsername(String username);
+ void createAccount(QxAccount account) throws IllegalStateException;
+
+ void saveNewPassword(QxPasswordChangeRequest pcr) throws IllegalStateException;
+
+ QxAccount loadUserByUsername(String username);
}
View
29 src/main/java/tomekkup/helenos/service/impl/AccountsProviderImpl.java
@@ -1,11 +1,14 @@
package tomekkup.helenos.service.impl;
import tomekkup.helenos.dao.AccountDao;
-import tomekkup.helenos.dao.model.Account;
+import tomekkup.helenos.types.qx.QxAccount;
import tomekkup.helenos.service.AccountsProvider;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;
+import org.springframework.util.Assert;
+import tomekkup.helenos.types.qx.QxPasswordChangeRequest;
/**
* ********************************************************
@@ -31,7 +34,7 @@ public void setAccountDao(AccountDao accountDao) {
}
@Override
- public List<Account> loadAll() {
+ public List<QxAccount> loadAll() {
return accountDao.loadAll();
}
@@ -46,12 +49,28 @@ public void delete(String username) {
}
@Override
- public void store(Account account) {
+ public void store(QxAccount account) {
accountDao.store(account);
}
@Override
- public Account loadUserByUsername(String username) {
- return (Account) accountDao.loadUserByUsername(username);
+ public void saveNewPassword(QxPasswordChangeRequest pcr) throws IllegalStateException {
+ accountDao.saveNewPassword(pcr);
+ }
+
+ @Override
+ public void createAccount(QxAccount account) throws IllegalStateException {
+ try {
+ loadUserByUsername(account.getUsername());
+ } catch(UsernameNotFoundException e) {
+ accountDao.createAccount(account);
+ return;
+ }
+ throw new IllegalStateException("account with this name already exists");
+ }
+
+ @Override
+ public QxAccount loadUserByUsername(String username) {
+ return (QxAccount) accountDao.loadUserByUsername(username);
}
}
View
2 src/main/java/tomekkup/helenos/service/impl/StandardQueryProviderImpl.java
@@ -48,7 +48,7 @@
}
@Override
- public <K, N> List<Slice<K,N>> cql(tomekkup.helenos.types.qx.query.CqlQuery<K, N> query) {
+ public <K, N> List<Slice<K,N>> cql(@JsonRpcParam("query") tomekkup.helenos.types.qx.query.CqlQuery<K, N> query) {
CqlQuery<K,N,String> cqlQuery = new CqlQuery<K, N, String>(getKeyspace(query.getKeyspace()), getSerializer(query.getKeyClass()), getSerializer(query.getNameClass()), StringSerializer.get());
cqlQuery.setQuery(query.getQuery());
QueryResult<CqlRows<K, N, String>> qr = cqlQuery.execute();
View
10 ...a/tomekkup/helenos/dao/model/Account.java → .../tomekkup/helenos/types/qx/QxAccount.java
@@ -1,4 +1,4 @@
-package tomekkup.helenos.dao.model;
+package tomekkup.helenos.types.qx;
import java.util.ArrayList;
import java.util.Collection;
@@ -16,23 +16,23 @@
*
* @author tomek
*/
-public class Account implements UserDetails {
+public class QxAccount implements UserDetails {
private Collection<SimpleGrantedAuthority> authorities = new HashSet<SimpleGrantedAuthority>();
private String username;
private String password;
private boolean enabled;
- public Account() {
+ public QxAccount() {
super();
}
- public Account(String username) {
+ public QxAccount(String username) {
this();
setUsername(username);
}
- public Account(String username, String password, SimpleGrantedAuthority authority, boolean enabled) {
+ public QxAccount(String username, String password, SimpleGrantedAuthority authority, boolean enabled) {
this(username);
setPassword(password);
addAuthority(authority);
View
65 src/main/java/tomekkup/helenos/types/qx/QxPasswordChangeRequest.java
@@ -0,0 +1,65 @@
+package tomekkup.helenos.types.qx;
+
+/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
+ *
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
+ */
+public class QxPasswordChangeRequest {
+
+ public QxPasswordChangeRequest() {
+
+ }
+
+ private String username;
+ private String password1;
+ private String password2;
+
+ /**
+ * @return the username
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @param username the username to set
+ */
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ /**
+ * @return the password1
+ */
+ public String getPassword1() {
+ return password1;
+ }
+
+ /**
+ * @param password1 the password1 to set
+ */
+ public void setPassword1(String password1) {
+ this.password1 = password1;
+ }
+
+ /**
+ * @return the password2
+ */
+ public String getPassword2() {
+ return password2;
+ }
+
+ /**
+ * @param password2 the password2 to set
+ */
+ public void setPassword2(String password2) {
+ this.password2 = password2;
+ }
+
+
+}
View
4 src/main/resources/xml-bean-mappings.xml
@@ -10,6 +10,10 @@
<class-a>java.nio.HeapByteBuffer</class-a>
<class-b>java.lang.String</class-b>
</converter>
+ <converter type="tomekkup.helenos.dozer.converters.SimpleGrantedAuthorityConverter" >
+ <class-a>java.lang.String</class-a>
+ <class-b>org.springframework.security.core.authority.SimpleGrantedAuthority</class-b>
+ </converter>
</custom-converters>
</configuration>

0 comments on commit 06e6ac5

Please sign in to comment.
Something went wrong with that request. Please try again.