{this.props.children}
diff --git a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/plugin/pluginForm.jsx b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/plugin/pluginForm.jsx
index bb5f93c68..3581cb540 100644
--- a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/plugin/pluginForm.jsx
+++ b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/plugin/pluginForm.jsx
@@ -50,7 +50,7 @@ export default class PluginFormModal extends React.Component {
render() {
const {plugin, slotId, data} = this.props;
return (plugin &&
-
+
{this.props.plugin.caption}
diff --git a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/imageView.js b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/imageView.js
index e9e134dd8..cafe51a37 100644
--- a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/imageView.js
+++ b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/imageView.js
@@ -11,6 +11,8 @@ import {DumpActions} from '../../../actions/dumpActions';
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table';
import {Input} from 'react-bootstrap';
import ResultSelectActions from '../../../actions/resultSelectAction';
+import {UserStore} from '../../../stores/userStore';
+
var ImageView = React.createClass({
@@ -29,6 +31,7 @@ var ImageView = React.createClass({
componentWillMount: function() {
// Subscribe to the store.
SearchStore.listen(this._onChange);
+ ResultSelectActions.clear();
},
@@ -77,18 +80,37 @@ var ImageView = React.createClass({
formatOptions: function(cell, item){
let self = this;
- if (this.props.enableAdvancedSearch)
- return (
-
- {/* plugin-based result options*/}
-
-
-
- );
+ let isAdmin = UserStore.isAdmin();
+ let unindex = null;
+ let removeFiles = null;
+ if (this.props.enableAdvancedSearch) {
+ if (isAdmin) {
+ unindex = (
+ );
+
+ removeFiles = ();
+ }
+ return (
+ {unindex}
+ {removeFiles}
+
+
+ {/* plugin-based result options*/}
+
+
+
+ );
+ }
return ();
},
@@ -136,7 +158,8 @@ var ImageView = React.createClass({
bgColor: "rgb(163, 210, 216)",
onSelect: this.onRowSelect
};
- console.log("IMAGE LEVEL");
+ // TODO trigger this action elsewhere
+ ResultSelectActions.level("image");
return (
-
-
- {/* plugin-based result options */}
-
-
- );
+
+ let isAdmin = UserStore.isAdmin();
+ let unindex = null;
+ let removeFiles = null;
+ if (this.props.enableAdvancedSearch)
+ {
+ if (isAdmin) {
+ unindex = (
+ );
+
+ removeFiles = ();
+ }
+ }
+ if (this.props.enableAdvancedSearch)
+ return (
+ {unindex}
+ {removeFiles}
+ {/* plugin-based result options */}
+
+
);
+ return ();
+
},
handleSelect(item){
let {id} = item;
diff --git a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/serieView.js b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/serieView.js
index a2d8abfca..8d3594dea 100644
--- a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/serieView.js
+++ b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/serieView.js
@@ -6,6 +6,8 @@ import ConfirmModal from './confirmModal';
import PluginView from '../../plugin/pluginView.jsx';
import {Input} from 'react-bootstrap';
import ResultSelectActions from '../../../actions/resultSelectAction';
+import {UserStore} from '../../../stores/userStore';
+
var SeriesView = React.createClass({
getInitialState: function() {
@@ -22,6 +24,7 @@ var SeriesView = React.createClass({
componentWillMount: function() {
// Subscribe to the store.
SearchStore.listen(this._onChange);
+ ResultSelectActions.clear();
},
/**
@@ -59,16 +62,34 @@ var SeriesView = React.createClass({
formatOptions: function(cell, item){
let self = this;
- if (this.props.enableAdvancedSearch)
- return (
-
- {/* plugin-based result options */}
-
);
+ removeFiles = ();
+ }
+ return (
+
+ {unindex}
+ {removeFiles}
+
+ {/* plugin-based result options */}
+
-
- );
+
+ );
+
+ }
+
return ();
},
@@ -118,8 +139,13 @@ var SeriesView = React.createClass({
bgColor: "rgb(163, 210, 216)",
onSelect: this.onRowSelect
};
-
- return (
+
+
+ // TODO trigger this action elsewhere
+ ResultSelectActions.level("series");
+
+
+ return (
Number
diff --git a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/studyView.js b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/studyView.js
index 50b7af522..7eaa95b59 100644
--- a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/studyView.js
+++ b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/search/result/studyView.js
@@ -8,6 +8,9 @@ import PluginView from '../../plugin/pluginView.jsx';
import {Input} from 'react-bootstrap';
import ResultSelectActions from '../../../actions/resultSelectAction';
+import {UserStore} from '../../../stores/userStore';
+
+
var StudyView = React.createClass({
getInitialState: function() {
// We need this because refs are not updated in BootstrapTable.
@@ -23,6 +26,7 @@ var StudyView = React.createClass({
componentWillMount: function() {
// Subscribe to the store.
SearchStore.listen(this._onChange);
+ ResultSelectActions.clear();
},
/**
@@ -53,16 +57,30 @@ var StudyView = React.createClass({
formatOptions: function(cell, item){
let self = this;
- if (this.props.enableAdvancedSearch)
+ let isAdmin = UserStore.isAdmin();
+ let unindex = null;
+ let removeFiles = null;
+ if (this.props.enableAdvancedSearch) {
+
+ if (isAdmin) {
+ unindex = (
+ );
+
+ removeFiles = ();
+ }
return (
-
-
- {/* plugin-based result options */}
-
-
);
+ {unindex}
+ {removeFiles}
+ {/* plugin-based result options */}
+
+ );
+
+ }
return ();
},
@@ -106,12 +124,13 @@ var StudyView = React.createClass({
bgColor: "rgb(163, 210, 216)",
onSelect: this.onRowSelect
};
-
+ // TODO trigger this action elsewhere
+ ResultSelectActions.level("study");
return (
Date
- Description
+ Description
Institution
Modality
Options
diff --git a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/sidebar.js b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/sidebar.js
index c5799d28f..a37cf23e5 100644
--- a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/sidebar.js
+++ b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/components/sidebar.js
@@ -18,37 +18,34 @@ const Sidebar = React.createClass({
render() {
console.log("APP RENDER");
let menuItems = [
- {value: "search", caption: "Search"},
- {value: "management", caption: "Management"},
- {value: "indexer", caption: "Indexer"},
- {value: "about", caption: "About"}
+ {value: "search", caption: "Search", admin: false},
+ {value: "management", caption: "Management", admin: true},
+ {value: "indexer", caption: "Indexer", admin: true},
+ {value: "about", caption: "About", admin: false}
].concat(this.props.pluginMenuItems);
+ let isAdmin = UserStore.isAdmin();
+ console.log("Is admin: " + isAdmin)
let sidebarInstance = (
{
+
+
+
menuItems.map(function(e, i) {
const to = (e.isPlugin ? '/ext/' : '/') + e.value;
- return (-
- {e.caption}
-
);
+
+ let myKey = i ;//+ Math.floor((Math.random() * 100) + 1);
+ if (!e.admin || isAdmin)
+ return (-
+ {e.caption}
+
);
})
}
-
-
-
- {UserStore.getUsername()}
-
-
-
-
+
);
return sidebarInstance;
}
diff --git a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/stores/userStore.js b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/stores/userStore.js
index 1f433598b..f22f709e4 100644
--- a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/stores/userStore.js
+++ b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/js/stores/userStore.js
@@ -6,6 +6,10 @@ import $ from 'jquery';
import {UserActions} from '../actions/userActions';
import {Endpoints} from '../constants/endpoints';
+
+import DicoogleClient from 'dicoogle-client';
+
+
var UserStore = Reflux.createStore({
listenables: UserActions,
init: function () {
@@ -14,72 +18,134 @@ var UserStore = Reflux.createStore({
this._isLoggedIn = false;
this._username = "";
this._isAdmin = false;
+ this._roles = [];
+ this._token = '';
+
},
+ saveLocalStore: function(){
+ localStorage.setItem("user", JSON.stringify({
+ isAdmin: this._isAdmin,
+ 'username': this._username,
+ 'roles': this._roles,
+ 'token': this._token
+ }));
+
+
+ },
+ loadLocalStore: function(){
+ if (localStorage.token!=null)
+ {
+ console.log("loadLocalStore");
+ let user = JSON.parse(localStorage.getItem("user"));
+ this._isAdmin = user.isAdmin ;
+ this._username = user.username;
+ this._roles = user.roles;
+ this._token = user.token ;
+ this._isLoggedIn = true;
+ this.trigger({
+ isLoggedIn: this._isLoggedIn,
+ success: true
+ });
+ }
+
+ },
onLogin: function(user, pass){
console.log("onLogin");
var self = this;
var formData = {username: user, password: pass}; //Array
- $.ajax({
- url: Endpoints.base + "/login",
- type: "POST",
- dataType: 'json',
- data: formData,
- success: function(data, textStatus, jqXHR)
- {
- console.log(data);
- self._username = data.user;
- self._isAdmin = data.admin;
- self._isLoggedIn = true;
-
+ let dicoogleClient = DicoogleClient(Endpoints.base);
+ let errorCallBack = function()
+ {
self.trigger({
- isLoggedIn: self._isLoggedIn,
- success: true
+ failed: true
});
- },
- error: function (jqXHR, textStatus, errorThrown)
+
+ };
+ dicoogleClient.login(user, pass, function(errorCallBack, data){
+ if (data.token===undefined || data.token==null)
{
- //TODO: HANDLE LOGIN FAILED
- console.log("Login Failed");
- self.trigger({
- failed: true
- });
+ self.trigger({
+ failed: true
+ });
+ return ;
}
+ self._username = data.user;
+ self._isAdmin = data.admin;
+ self._token = data.token;
+ self._roles = data.roles;
+ self._isLoggedIn = true;
+ localStorage.token = self._token;
+ self.saveLocalStore();
+
+ console.log("Localstorage token: " + localStorage.token);
+ self.trigger({
+ isLoggedIn: self._isLoggedIn,
+ success: true
+ });
+
});
+
+
+
},
onIsLoggedIn: function(){
+
if(this._isLoggedIn === false)
{
- $.ajax({
- type: "GET",
- url: Endpoints.base + "/login",
- dataType: 'json',
- async: true,
- success: (result) => {
- /* if result is a JSon object */
- this._username = result.user;
- this._isAdmin = result.admin;
- this._isLoggedIn = true;
+ if (localStorage.token !=null) {
+ this.loadLocalStore();
+ this.trigger({
+ isLoggedIn: self._isLoggedIn,
+ success: true
+ });
+ }else{
+ console.log("Verify ajax");
+
+
+ $.ajax({
+ type: "GET",
+ url: Endpoints.base + "/login",
+ dataType: 'json',
+ async: true,
+ success: (result) => {
+ /* if result is a JSon object */
+ this._username = result.user;
+ this._isAdmin = result.admin;
+ this._isLoggedIn = true;
+
+ this.saveLocalStore();
setTimeout(() => {
- this.trigger({
+ this.trigger({
isLoggedIn: this._isLoggedIn,
success: true
- });
- }, 500)
+ });
+ }, 500)
},
- error: () => {
- this.trigger({
- isLoggedIn: this._isLoggedIn,
- success: true
- });
- }
+ error: () => {
+ this.trigger({
+ isLoggedIn: this._isLoggedIn,
+ success: false
+ });
+ }
});
+ }
+
+
+
} else {
//return this._isLoggedIn;
+ if (localStorage.token !==undefined) {
+ this.loadLocalStore();
+ this.trigger({
+ isLoggedIn: self._isLoggedIn,
+ success: true
+ });
+ }
this.trigger({
isLoggedIn: self._isLoggedIn,
success: true
@@ -87,9 +153,17 @@ var UserStore = Reflux.createStore({
}
},
+ onLogout: function() {
+ delete localStorage.token;
+ delete localStorage.user;
+ },
+
getUsername: function(){
return this._username;
},
+ isAdmin: function(){
+ return this._isAdmin;
+ },
getLogginState: function(){
return this._isLoggedIn;
}
diff --git a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/package.json b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/package.json
index 7b9bbd94c..c989cd96f 100644
--- a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/package.json
+++ b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/package.json
@@ -39,7 +39,7 @@
"dependencies": {
"bootstrap": "^3.3.2",
"core-js": "^2.0.3",
- "dicoogle-client": "^2.4.2",
+ "dicoogle-client": "^3.0.0-rc0",
"dicoogle-webcore": "../../../../../../../../../../../webcore",
"document-register-element": "^0.5.4",
"history": "^1.13.0",
diff --git a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/sass/modules/_topbar.scss b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/sass/modules/_topbar.scss
index 3e829df82..22045e9ee 100644
--- a/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/sass/modules/_topbar.scss
+++ b/dicoogle/src/main/java/pt/ua/dicoogle/server/web/webapp/WEB-INF/sass/modules/_topbar.scss
@@ -4,6 +4,7 @@
background: $blue1;
position:fixed;
z-index: 1001;
+ line-height: 50px;
}
.btn_drawer {
width: 50px;
@@ -24,4 +25,14 @@
font-size: 30px;
vertical-align: middle;
}
-}
\ No newline at end of file
+}
+
+.usernameLogin {
+ padding-right: 5px;
+}
+
+
+.buttonLogin {
+ padding-right: 10px;
+}
+
diff --git a/dicoogle/src/test/java/pt/ua/dicoogle/core/auth/TestRoles.java b/dicoogle/src/test/java/pt/ua/dicoogle/core/auth/TestRoles.java
new file mode 100644
index 000000000..343a8016b
--- /dev/null
+++ b/dicoogle/src/test/java/pt/ua/dicoogle/core/auth/TestRoles.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/
+ *
+ * This file is part of Dicoogle/dicoogle.
+ *
+ * Dicoogle/dicoogle is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Dicoogle/dicoogle is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Dicoogle. If not, see .
+ */
+package pt.ua.dicoogle.core.auth;
+
+import org.junit.Test;
+import pt.ua.dicoogle.server.users.*;
+import pt.ua.dicoogle.server.web.auth.Authentication;
+import pt.ua.dicoogle.server.web.auth.LoggedIn;
+
+/**
+ * Created by bastiao on 23/01/16.
+ */
+public class TestRoles {
+
+
+ //@Test
+ public void testRoles() {
+
+ UsersStruct users = UsersStruct.getInstance();
+ UsersXML usersXML = new UsersXML();
+ users = usersXML.getXML();
+ RolesXML rolesXML = new RolesXML();
+ RolesStruct rolesStruct = rolesXML.getXML();
+ System.out.println(rolesStruct.getRoles());
+ }
+
+ //@Test
+ public void testUserRoles() {
+
+ RolesXML rolesXML = new RolesXML();
+ RolesStruct rolesStruct = rolesXML.getXML();
+
+ UsersStruct users = UsersStruct.getInstance();
+ UsersXML usersXML = new UsersXML();
+ users = usersXML.getXML();
+ System.out.println(rolesStruct.getRoles());
+ for (User u : users.getUsers())
+ {
+ System.out.println(u.getUsername());
+ for (Role r : u.getRoles())
+ {
+ System.out.println(r);
+ }
+ }
+
+
+
+ }
+}
diff --git a/dicoogle/src/test/java/pt/ua/dicoogle/core/auth/TestUsers.java b/dicoogle/src/test/java/pt/ua/dicoogle/core/auth/TestUsers.java
new file mode 100644
index 000000000..459c6d0c0
--- /dev/null
+++ b/dicoogle/src/test/java/pt/ua/dicoogle/core/auth/TestUsers.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/
+ *
+ * This file is part of Dicoogle/dicoogle.
+ *
+ * Dicoogle/dicoogle is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Dicoogle/dicoogle is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Dicoogle. If not, see .
+ */
+package pt.ua.dicoogle.core.auth;
+
+import org.junit.*;
+import pt.ua.dicoogle.server.users.HashService;
+import pt.ua.dicoogle.server.users.User;
+import pt.ua.dicoogle.server.users.UsersStruct;
+import pt.ua.dicoogle.server.users.UsersXML;
+import pt.ua.dicoogle.server.web.auth.Authentication;
+import pt.ua.dicoogle.server.web.auth.LoggedIn;
+
+import static org.junit.Assert.assertEquals;
+import static pt.ua.dicoogle.server.web.servlets.webui.WebUIServlet.camelize;
+
+/**
+ * Created by bastiao on 23/01/16.
+ */
+public class TestUsers {
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void testUsers() {
+
+ UsersStruct users = UsersStruct.getInstance();
+ UsersXML usersXML = new UsersXML();
+ users = usersXML.getXML();
+
+ String username = "nat";
+ boolean admin = false;
+ String passPlainText = "123";
+ String passHash = HashService.getSHA1Hash(passPlainText); //password Hash
+ String hash = HashService.getSHA1Hash(username + admin + passHash);
+ System.out.println(hash);
+ System.out.println(passHash);
+ User u = new User("nat",hash, admin);
+ users.addUser(u);
+
+
+ for (String uu : users.getUsernames())
+ {
+ System.out.println(users.getUser(uu));
+ }
+
+ Authentication auth = Authentication.getInstance();
+ try {
+ LoggedIn loggedIn = auth.login("nat", "123");
+ System.out.println(loggedIn.getUserName());
+ System.out.println(loggedIn.isAdmin());
+ }
+ catch(Exception e)
+ {
+ System.out.println("Error in the test");
+ }
+
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 9ac3a9cdb..f06461ed3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
pt.ua.ieeta
dicoogle-all
- 2.3.0-SNAPSHOT
+ 2.3.0
pom
dicoogle-all
diff --git a/sdk-ext/pom.xml b/sdk-ext/pom.xml
index 675cf62e1..8c67136f5 100644
--- a/sdk-ext/pom.xml
+++ b/sdk-ext/pom.xml
@@ -10,7 +10,7 @@
pt.ua.ieeta
dicoogle-all
- 2.3.0-SNAPSHOT
+ 2.3.0
../pom.xml
diff --git a/sdk/pom.xml b/sdk/pom.xml
index f9c311832..65bd81789 100644
--- a/sdk/pom.xml
+++ b/sdk/pom.xml
@@ -10,7 +10,7 @@
pt.ua.ieeta
dicoogle-all
- 2.3.0-SNAPSHOT
+ 2.3.0
../pom.xml
diff --git a/webcore/package.json b/webcore/package.json
index 52ca76925..83afecc5d 100644
--- a/webcore/package.json
+++ b/webcore/package.json
@@ -31,7 +31,7 @@
"eslint": "^1.9.0"
},
"dependencies": {
- "dicoogle-client": "^2.4.1",
+ "dicoogle-client": "^3.0.0-rc0",
"events": "^1.1.0"
}
}