Revision 57542
Added by Michele Artini over 4 years ago
modules/dnet-orgs-database-application/trunk/src/main/resources/templates/user.html | ||
---|---|---|
1 |
<!doctype html> |
|
2 |
<html lang="en"> |
|
3 |
|
|
4 |
<head> |
|
5 |
<!-- Required meta tags --> |
|
6 |
<meta charset="utf-8"> |
|
7 |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
|
8 |
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"> |
|
9 |
<meta http-equiv="Pragma" content="no-cache"> |
|
10 |
<meta http-equiv="Expires" content="0"> |
|
11 |
|
|
12 |
<!-- Bootstrap CSS --> |
|
13 |
<link rel="stylesheet" href="resources/css/bootstrap.min.css" /> |
|
14 |
<!-- Icons CSS --> |
|
15 |
<link rel="stylesheet" href="resources/css/fontawesome-all.min.css"> |
|
16 |
|
|
17 |
<style type="text/css"> |
|
18 |
.table > tbody > tr > td { |
|
19 |
vertical-align: middle; |
|
20 |
} |
|
21 |
.card > .table { |
|
22 |
margin-bottom: 0 !important; |
|
23 |
} |
|
24 |
|
|
25 |
fieldset > legend { |
|
26 |
font-size: 1.2rem !important; |
|
27 |
} |
|
28 |
|
|
29 |
</style> |
|
30 |
|
|
31 |
|
|
32 |
<title>Organizations Database</title> |
|
33 |
|
|
34 |
</head> |
|
35 |
|
|
36 |
<body ng-app="orgs"> |
|
37 |
<nav class="navbar navbar-expand-lg navbar-dark bg-primary" ng-controller="userCtrl"> |
|
38 |
<a class="navbar-brand" href="#"> <img |
|
39 |
src="resources/images/openaire_logo_small.png" width="30" height="30" alt="OpenOrgs Database"> |
|
40 |
OpenOrgs Database |
|
41 |
</a> |
|
42 |
<button class="navbar-toggler" type="button" data-toggle="collapse" |
|
43 |
data-target="#navbarSupportedContent"> |
|
44 |
<span class="navbar-toggler-icon"></span> |
|
45 |
</button> |
|
46 |
|
|
47 |
<div class="collapse navbar-collapse w-100 order-1" id="navbarSupportedContent"> |
|
48 |
<ul class="navbar-nav mr-auto"> |
|
49 |
<li class="nav-item active"><a class="nav-link" href="#">Search</a></li> |
|
50 |
<li class="nav-item dropdown"><a |
|
51 |
class="nav-link dropdown-toggle" href="javascript:void(0)" id="navbarDropdown" |
|
52 |
role="button" data-toggle="dropdown">Browse</a> |
|
53 |
<div class="dropdown-menu"> |
|
54 |
<a class="dropdown-item" href="#!/countries">by country</a> <a |
|
55 |
class="dropdown-item" href="#!/types">by type</a> |
|
56 |
</div></li> |
|
57 |
<li class="nav-item"><a class="nav-link" href="#!/new">New</a></li> |
|
58 |
|
|
59 |
</ul> |
|
60 |
</div> |
|
61 |
|
|
62 |
<div class="navbar-collapse collapse w-100 order-2"> |
|
63 |
<ul class="navbar-nav ml-auto"> |
|
64 |
<li class="nav-item dropdown"> |
|
65 |
<a class="nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown">{{user}}</a> |
|
66 |
<div class="dropdown-menu"> |
|
67 |
<a class="dropdown-item" th:href="@{/logout}">Logout</a> |
|
68 |
</div> |
|
69 |
</li> |
|
70 |
<li class="nav-item"><a class="btn btn-outline-secondary" href="doc">API</a></li> |
|
71 |
</ul> |
|
72 |
</div> |
|
73 |
|
|
74 |
</nav> |
|
75 |
|
|
76 |
<div class="container-fluid small mt-4" ng-view></div> |
|
77 |
|
|
78 |
<script src="resources/js/jquery-3.4.1.min.js"></script> |
|
79 |
<script src="resources/js/popper.min.js"></script> |
|
80 |
<script src="resources/js/bootstrap.min.js"></script> |
|
81 |
<script src="resources/js/angular.min.js"></script> |
|
82 |
<script src="resources/js/angular-route.min.js"></script> |
|
83 |
<script src="resources/js/organizations.js"></script> |
|
84 |
</body> |
|
85 |
|
|
86 |
</html> |
modules/dnet-orgs-database-application/trunk/src/main/java/eu/dnetlib/organizations/repository/readonly/UserViewRepository.java | ||
---|---|---|
1 |
package eu.dnetlib.organizations.repository.readonly; |
|
2 |
|
|
3 |
import org.springframework.stereotype.Repository; |
|
4 |
|
|
5 |
import eu.dnetlib.organizations.model.view.UserView; |
|
6 |
|
|
7 |
@Repository |
|
8 |
public interface UserViewRepository extends ReadOnlyRepository<UserView, String> { |
|
9 |
|
|
10 |
} |
modules/dnet-orgs-database-application/trunk/src/main/java/eu/dnetlib/organizations/model/view/UserView.java | ||
---|---|---|
1 |
package eu.dnetlib.organizations.model.view; |
|
2 |
|
|
3 |
import java.io.Serializable; |
|
4 |
|
|
5 |
import javax.persistence.Column; |
|
6 |
import javax.persistence.Entity; |
|
7 |
import javax.persistence.Id; |
|
8 |
import javax.persistence.Table; |
|
9 |
|
|
10 |
import org.hibernate.annotations.Type; |
|
11 |
import org.hibernate.annotations.TypeDef; |
|
12 |
import org.hibernate.annotations.TypeDefs; |
|
13 |
|
|
14 |
import com.vladmihalcea.hibernate.type.array.StringArrayType; |
|
15 |
|
|
16 |
@Entity |
|
17 |
@Table(name = "users_view") |
|
18 |
@TypeDefs({ |
|
19 |
@TypeDef(name = "string-array", typeClass = StringArrayType.class) |
|
20 |
}) |
|
21 |
public class UserView implements Serializable { |
|
22 |
|
|
23 |
/** |
|
24 |
* |
|
25 |
*/ |
|
26 |
private static final long serialVersionUID = -3308680880727895075L; |
|
27 |
|
|
28 |
@Id |
|
29 |
@Column(name = "email") |
|
30 |
private String email; |
|
31 |
|
|
32 |
@Column(name = "valid") |
|
33 |
private boolean valid; |
|
34 |
|
|
35 |
@Column(name = "role") |
|
36 |
private String role; |
|
37 |
|
|
38 |
@Type(type = "string-array") |
|
39 |
@Column(name = "countries", columnDefinition = "text[]") |
|
40 |
private String[] countries; |
|
41 |
|
|
42 |
public String getEmail() { |
|
43 |
return email; |
|
44 |
} |
|
45 |
|
|
46 |
public void setEmail(final String email) { |
|
47 |
this.email = email; |
|
48 |
} |
|
49 |
|
|
50 |
public boolean isValid() { |
|
51 |
return valid; |
|
52 |
} |
|
53 |
|
|
54 |
public void setValid(final boolean valid) { |
|
55 |
this.valid = valid; |
|
56 |
} |
|
57 |
|
|
58 |
public String getRole() { |
|
59 |
return role; |
|
60 |
} |
|
61 |
|
|
62 |
public void setRole(final String role) { |
|
63 |
this.role = role; |
|
64 |
} |
|
65 |
|
|
66 |
public String[] getCountries() { |
|
67 |
return countries; |
|
68 |
} |
|
69 |
|
|
70 |
public void setCountries(final String[] countries) { |
|
71 |
this.countries = countries; |
|
72 |
} |
|
73 |
} |
modules/dnet-orgs-database-application/trunk/src/main/java/eu/dnetlib/organizations/controller/UserController.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import org.apache.commons.codec.digest.DigestUtils; |
7 | 7 |
import org.springframework.beans.factory.annotation.Autowired; |
8 |
import org.springframework.security.core.Authentication; |
|
9 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
10 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
8 |
import org.springframework.web.bind.annotation.GetMapping; |
|
9 |
import org.springframework.web.bind.annotation.PostMapping; |
|
11 | 10 |
import org.springframework.web.bind.annotation.RequestParam; |
12 | 11 |
import org.springframework.web.bind.annotation.RestController; |
13 | 12 |
|
14 | 13 |
import eu.dnetlib.organizations.model.User; |
14 |
import eu.dnetlib.organizations.model.view.UserView; |
|
15 | 15 |
import eu.dnetlib.organizations.repository.UserRepository; |
16 |
import eu.dnetlib.organizations.repository.readonly.UserViewRepository; |
|
16 | 17 |
import eu.dnetlib.organizations.utils.OpenOrgsConstants; |
17 | 18 |
|
18 | 19 |
@RestController |
... | ... | |
22 | 23 |
|
23 | 24 |
@Autowired |
24 | 25 |
private UserRepository userRepository; |
26 |
@Autowired |
|
27 |
private UserViewRepository userViewRepository; |
|
25 | 28 |
|
26 |
@RequestMapping(value = "/api/user/current", method = RequestMethod.GET) |
|
27 |
public UserInfo utente(final Authentication authentication) { |
|
28 |
return UserInfo.generate(authentication); |
|
29 |
} |
|
30 |
|
|
31 |
@RequestMapping(value = "/public_api/newUser", method = RequestMethod.POST) |
|
32 |
public Map<String, Integer> utente(final @RequestParam String email) { |
|
29 |
@PostMapping(value = "/public_api/newUser") |
|
30 |
public Map<String, Integer> newUser(final @RequestParam String email) { |
|
33 | 31 |
final Map<String, Integer> res = new HashMap<>(); |
34 | 32 |
if (userRepository.existsById(email)) { |
35 | 33 |
res.put("status", 2); |
... | ... | |
45 | 43 |
return res; |
46 | 44 |
} |
47 | 45 |
|
46 |
@GetMapping("/api/users") |
|
47 |
public Iterable<UserView> users() { |
|
48 |
return userViewRepository.findAll(); |
|
49 |
} |
|
50 |
|
|
48 | 51 |
} |
modules/dnet-orgs-database-application/trunk/src/main/java/eu/dnetlib/organizations/controller/HomeController.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
@GetMapping("/") |
12 | 12 |
public String home() { |
13 |
return "/user";
|
|
13 |
return "/home";
|
|
14 | 14 |
} |
15 | 15 |
|
16 | 16 |
@GetMapping("/login") |
modules/dnet-orgs-database-application/trunk/src/main/resources/sql/schema.sql | ||
---|---|---|
1 | 1 |
DROP VIEW organizations_view; |
2 | 2 |
DROP VIEW organizations_simple_view; |
3 |
DROP VIEW users_view; |
|
3 | 4 |
|
4 | 5 |
DROP TABLE IF EXISTS other_ids; |
5 | 6 |
DROP TABLE IF EXISTS other_names; |
... | ... | |
182 | 183 |
org.type, |
183 | 184 |
org.city, |
184 | 185 |
org.country; |
186 |
|
|
187 |
CREATE VIEW users_view AS SELECT |
|
188 |
u.email, |
|
189 |
u.valid, |
|
190 |
u.role, |
|
191 |
array_agg(uc.country) AS countries |
|
192 |
FROM |
|
193 |
users u |
|
194 |
LEFT OUTER JOIN user_countries uc ON (u.email = uc.email) |
|
195 |
GROUP BY u.email, u.valid, u.role |
|
196 |
ORDER BY u.email; |
|
197 |
|
|
198 |
|
|
185 | 199 |
|
modules/dnet-orgs-database-application/trunk/src/main/resources/static/resources/html/users.html | ||
---|---|---|
1 |
<table class="table table-sm table-hover col-sm-12 col-md-10 col-lg-8"> |
|
2 |
<thead class="thead-light"> |
|
3 |
<tr class="d-flex"> |
|
4 |
<th class="col-4">User</th> |
|
5 |
<th class="col-2 text-center">Valid</th> |
|
6 |
<th class="col-2 text-center">Role</th> |
|
7 |
<th class="col-3">Countries</th> |
|
8 |
<th class="col-1"></th> |
|
9 |
</tr> |
|
10 |
</thead> |
|
11 |
<tbody> |
|
12 |
<tr ng-repeat="u in users" class="d-flex"> |
|
13 |
<td class="col-4">{{u.email}}</td> |
|
14 |
<td class="col-2 text-center">{{u.valid}}</td> |
|
15 |
<td class="col-2 text-center">{{u.role}}</td> |
|
16 |
<td class="col-3">{{u.countries}}</td> |
|
17 |
<td class="col-1 text-right"><button type="button" class="btn btn-sm btn-outline-danger"><i class="fa fa-trash"></i></button></td> |
|
18 |
</tr> |
|
19 |
</tbody> |
|
20 |
</table> |
|
21 |
|
|
22 |
|
|
23 |
|
modules/dnet-orgs-database-application/trunk/src/main/resources/static/resources/js/organizations.js | ||
---|---|---|
12 | 12 |
.when('/metadata/:msg/:id', { templateUrl: 'resources/html/edit.html', controller: 'showMetadataCtrl' }) |
13 | 13 |
.when('/relations/:id', { templateUrl: 'resources/html/relations.html', controller: 'showRelationsCtrl' }) |
14 | 14 |
.when('/similarities/:id', { templateUrl: 'resources/html/similarities.html', controller: 'showSimilaritiesCtrl' }) |
15 |
.when('/users', { templateUrl: 'resources/html/users.html', controller: 'usersCtrl' }) |
|
15 | 16 |
.otherwise({ redirectTo: '/search' }); |
16 | 17 |
}); |
17 | 18 |
|
... | ... | |
27 | 28 |
}; |
28 | 29 |
}); |
29 | 30 |
|
30 |
orgsModule.controller('userCtrl', function ($scope, $http, $location) { |
|
31 |
$scope.user = ''; |
|
32 |
$http.get('api/user/current').then(function successCallback(res) { |
|
33 |
$scope.user = res.data.name; |
|
34 |
}, function errorCallback(res) { |
|
35 |
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')'); |
|
36 |
}); |
|
37 |
}); |
|
38 |
|
|
39 | 31 |
orgsModule.controller('newOrgCtrl', function ($scope, $http, $routeParams, $location) { |
40 | 32 |
$scope.org = { |
41 | 33 |
"id": "", |
... | ... | |
274 | 266 |
} |
275 | 267 |
}); |
276 | 268 |
|
269 |
|
|
270 |
|
|
271 |
orgsModule.controller('usersCtrl', function ($scope, $http) { |
|
272 |
$scope.users = []; |
|
273 |
$scope.vocabularies = {}; |
|
274 |
|
|
275 |
$http.get('api/vocabularies').then(function successCallback(res) { |
|
276 |
$scope.vocabularies = res.data; |
|
277 |
|
|
278 |
$http.get('api/users').then(function successCallback(res) { |
|
279 |
$scope.users = res.data; |
|
280 |
}, function errorCallback(res) { |
|
281 |
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')'); |
|
282 |
}); |
|
283 |
}, function errorCallback(res) { |
|
284 |
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')'); |
|
285 |
}); |
|
286 |
|
|
287 |
}); |
modules/dnet-orgs-database-application/trunk/src/main/resources/templates/403.html | ||
---|---|---|
17 | 17 |
<body> |
18 | 18 |
|
19 | 19 |
<div class="container"> |
20 |
<nav class="navbar navbar-expand-lg navbar-dark bg-primary" ng-controller="userCtrl">
|
|
20 |
<nav class="navbar navbar-expand-lg navbar-dark bg-primary"> |
|
21 | 21 |
<a class="navbar-brand" href="#"> |
22 | 22 |
<img src="resources/images/openaire_logo_small.png" width="30" height="30" alt="OpenOrgs Database"> OpenOrgs Database |
23 | 23 |
</a> |
24 | 24 |
</nav> |
25 |
|
|
26 |
|
|
25 |
|
|
27 | 26 |
<div class="card text-center" style="margin-top: 25px"> |
28 | 27 |
<div class="card-body"> |
29 | 28 |
<h5 class="card-title">403 - Access is denied</h5> |
30 | 29 |
<p class="card-text" th:inline="text">Hello '[[${#httpServletRequest.remoteUser}]]', you do not have permission to access this page.</p> |
31 | 30 |
</div> |
32 | 31 |
</div> |
33 |
|
|
34 |
|
|
35 | 32 |
</div> |
36 | 33 |
|
34 |
<script src="resources/js/jquery-3.4.1.min.js"></script> |
|
35 |
<script src="resources/js/popper.min.js"></script> |
|
37 | 36 |
<script src="resources/js/bootstrap.min.js"></script> |
38 | 37 |
|
39 | 38 |
</body> |
modules/dnet-orgs-database-application/trunk/src/main/resources/templates/login.html | ||
---|---|---|
21 | 21 |
<body> |
22 | 22 |
|
23 | 23 |
<div> |
24 |
<nav class="navbar navbar-expand-lg navbar-dark bg-primary" |
|
25 |
ng-controller="userCtrl"> |
|
26 |
<a class="navbar-brand" href="#"> <img |
|
27 |
src="resources/images/openaire_logo_small.png" width="30" |
|
28 |
height="30" alt="OpenOrgs Database"> OpenOrgs Database |
|
24 |
<nav class="navbar navbar-expand-lg navbar-dark bg-primary"> |
|
25 |
<a class="navbar-brand" href="#"> |
|
26 |
<img src="resources/images/openaire_logo_small.png" width="30" height="30" alt="OpenOrgs Database"> OpenOrgs Database |
|
29 | 27 |
</a> |
30 | 28 |
</nav> |
31 | 29 |
</div> |
... | ... | |
92 | 90 |
<script src="resources/js/jquery-3.4.1.min.js"></script> |
93 | 91 |
<script src="resources/js/popper.min.js"></script> |
94 | 92 |
<script src="resources/js/bootstrap.min.js"></script> |
93 |
|
|
95 | 94 |
<script> |
96 | 95 |
$('#tabList a').on('click', function (e) { |
97 | 96 |
e.preventDefault() |
modules/dnet-orgs-database-application/trunk/src/main/resources/templates/home.html | ||
---|---|---|
1 |
<!doctype html> |
|
2 |
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"> |
|
3 |
|
|
4 |
<head> |
|
5 |
<!-- Required meta tags --> |
|
6 |
<meta charset="utf-8"> |
|
7 |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
|
8 |
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"> |
|
9 |
<meta http-equiv="Pragma" content="no-cache"> |
|
10 |
<meta http-equiv="Expires" content="0"> |
|
11 |
|
|
12 |
<!-- Bootstrap CSS --> |
|
13 |
<link rel="stylesheet" href="resources/css/bootstrap.min.css" /> |
|
14 |
<!-- Icons CSS --> |
|
15 |
<link rel="stylesheet" href="resources/css/fontawesome-all.min.css"> |
|
16 |
|
|
17 |
<style type="text/css"> |
|
18 |
.table > tbody > tr > td { |
|
19 |
vertical-align: middle; |
|
20 |
} |
|
21 |
.card > .table { |
|
22 |
margin-bottom: 0 !important; |
|
23 |
} |
|
24 |
|
|
25 |
fieldset > legend { |
|
26 |
font-size: 1.2rem !important; |
|
27 |
} |
|
28 |
|
|
29 |
</style> |
|
30 |
|
|
31 |
|
|
32 |
<title>Organizations Database</title> |
|
33 |
|
|
34 |
</head> |
|
35 |
|
|
36 |
<body ng-app="orgs" sec:authorize="isAuthenticated()"> |
|
37 |
<nav class="navbar navbar-expand-lg navbar-dark bg-primary"> |
|
38 |
<a class="navbar-brand" href="#"> <img |
|
39 |
src="resources/images/openaire_logo_small.png" width="30" height="30" alt="OpenOrgs Database"> |
|
40 |
OpenOrgs Database |
|
41 |
</a> |
|
42 |
<button class="navbar-toggler" type="button" data-toggle="collapse" |
|
43 |
data-target="#navbarSupportedContent"> |
|
44 |
<span class="navbar-toggler-icon"></span> |
|
45 |
</button> |
|
46 |
|
|
47 |
<div class="collapse navbar-collapse w-100 order-1" id="navbarSupportedContent"> |
|
48 |
<ul class="navbar-nav mr-auto"> |
|
49 |
<li class="nav-item active"><a class="nav-link" href="#">Search</a></li> |
|
50 |
<li class="nav-item dropdown"> |
|
51 |
<a class="nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown">Browse</a> |
|
52 |
<div class="dropdown-menu"> |
|
53 |
<a class="dropdown-item" href="#!/countries">by country</a> <a |
|
54 |
class="dropdown-item" href="#!/types">by type</a> |
|
55 |
</div> |
|
56 |
</li> |
|
57 |
<li class="nav-item"><a class="nav-link" href="#!/new">New</a></li> |
|
58 |
</ul> |
|
59 |
</div> |
|
60 |
|
|
61 |
<div class="navbar-collapse collapse w-100 order-2"> |
|
62 |
<ul class="navbar-nav ml-auto"> |
|
63 |
<li class="nav-item dropdown" sec:authorize="hasRole('ROLE_SUPERUSER')"> |
|
64 |
<a class="nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown"><i class="fa fa-cog"></i></a> |
|
65 |
<div class="dropdown-menu dropdown-menu-right"> |
|
66 |
<a class="dropdown-item" href="#!/users">manage users</a> |
|
67 |
</div> |
|
68 |
</li> |
|
69 |
<li class="nav-item dropdown"> |
|
70 |
<a class="nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown"><i class="fa fa-user"></i></a> |
|
71 |
<div class="dropdown-menu dropdown-menu-right"> |
|
72 |
<p class="px-4 pt-2 text-muted small"> |
|
73 |
<b>Logged as:</b><br /><span sec:authentication="name"></span> |
|
74 |
<b>Role:</b><br /><span sec:authentication="principal.authorities"></span> |
|
75 |
</p> |
|
76 |
<div class="dropdown-divider"></div> |
|
77 |
<a class="dropdown-item" th:href="@{/logout}">Logout</a> |
|
78 |
</div> |
|
79 |
</li> |
|
80 |
<li class="nav-item"><a class="btn btn-outline-secondary" href="doc">API</a></li> |
|
81 |
</ul> |
|
82 |
</div> |
|
83 |
|
|
84 |
</nav> |
|
85 |
|
|
86 |
<div class="container-fluid small mt-4" ng-view></div> |
|
87 |
|
|
88 |
<script src="resources/js/jquery-3.4.1.min.js"></script> |
|
89 |
<script src="resources/js/popper.min.js"></script> |
|
90 |
<script src="resources/js/bootstrap.min.js"></script> |
|
91 |
<script src="resources/js/angular.min.js"></script> |
|
92 |
<script src="resources/js/angular-route.min.js"></script> |
|
93 |
<script src="resources/js/organizations.js"></script> |
|
94 |
</body> |
|
95 |
|
|
96 |
</html> |
Also available in: Unified diff
users management