clean cache button
This commit is contained in:
parent
3a3f24135d
commit
ae7b483c90
|
@ -162,6 +162,16 @@ public class AdminController extends AbstractDnetController {
|
|||
}
|
||||
}
|
||||
|
||||
@GetMapping("/api/clearCache")
|
||||
public List<String> clearCache(final Authentication authentication) {
|
||||
if (UserInfo.isSuperAdmin(authentication)) {
|
||||
dbUtils.clearCache();
|
||||
return Arrays.asList("All caches are cleared");
|
||||
} else {
|
||||
throw new RuntimeException("User not authorized");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/api/restartSuggestionsImport")
|
||||
public List<String> restartSuggestionsImport(final Authentication authentication) {
|
||||
if (UserInfo.isSuperAdmin(authentication)) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
@ -330,6 +331,13 @@ public class DatabaseUtils {
|
|||
return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(VocabularyTerm.class), name);
|
||||
}
|
||||
|
||||
@CacheEvict(value = {
|
||||
"vocs", "countries_for_user"
|
||||
}, allEntries = true)
|
||||
public void clearCache() {
|
||||
log.info("All caches cleaned");
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveUser(@RequestBody final UserView userView) {
|
||||
final User user = userRepository.findById(userView.getEmail()).orElseThrow(() -> new RuntimeException("User not found"));
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
<table class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 20%">Command</th>
|
||||
<th style="width: 80%">Status</th>
|
||||
<th style="width: 30%">Command</th>
|
||||
<th style="width: 70%">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -25,6 +25,10 @@
|
|||
<td><button class="btn btn-sm btn-link" ng-click="restartSuggestionsImport()" ng-disabled="suggestionImportMessage">Restart the import of the suggestions</button></td>
|
||||
<td>{{suggestionImportMessage}}<span ng-show="suggestionImportMessage"> - to see the current import execution <a href="#!/lastImport">click here</a></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button class="btn btn-sm btn-link" ng-click="clearCache()" ng-disabled="cacheMessage">Clear all caches</button></td>
|
||||
<td>{{cacheMessage}}<span ng-show="cacheMessage"></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -813,6 +813,7 @@ orgsModule.controller('utilsCtrl', function ($scope, $http) {
|
|||
$scope.consistencyCheckMessage = '';
|
||||
$scope.invalidSuggestedCountriesMessage = '';
|
||||
$scope.suggestionImportMessage = '';
|
||||
$scope.cacheMessage = '';
|
||||
|
||||
$scope.refreshFulltextIndex = function() {
|
||||
$scope.fulltextIndexMessage = '...';
|
||||
|
@ -833,6 +834,12 @@ orgsModule.controller('utilsCtrl', function ($scope, $http) {
|
|||
$scope.suggestionImportMessage = '...';
|
||||
call_http_get($http, 'api/restartSuggestionsImport', function(res) { $scope.suggestionImportMessage = res.data[0]; });
|
||||
}
|
||||
|
||||
$scope.clearCache = function() {
|
||||
$scope.cacheMessage = '...';
|
||||
call_http_get($http, 'api/clearCache', function(res) { $scope.cacheMessage = res.data[0]; });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -42,6 +42,11 @@ fieldset > legend { font-size : 1.2rem !important; }
|
|||
color: gray !important;
|
||||
text-decoration: line-through !important;
|
||||
}
|
||||
|
||||
.btn-link {
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue