check suggested countries
This commit is contained in:
parent
6ee176ff89
commit
dc7dddfb37
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
@ -145,4 +146,18 @@ public class AdminController extends AbstractDnetController {
|
|||
throw new RuntimeException("User not authorized");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/api/verifyCountriesInSuggestions")
|
||||
public List<String> verifyCountriesInSuggestions(final Authentication authentication) {
|
||||
if (UserInfo.isSuperAdmin(authentication)) {
|
||||
final List<String> list = dbUtils.invalidCountriesInSuggestions();
|
||||
if (list.isEmpty()) {
|
||||
return Arrays.asList("All countries are valid");
|
||||
} else {
|
||||
return Arrays.asList("Invalid countries in suggestions: " + StringUtils.join(list, ", "));
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("User not authorized");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -536,4 +536,10 @@ public class DatabaseUtils {
|
|||
return makeRelation(masterId, otherId, RelationType.Merges);
|
||||
}
|
||||
|
||||
public List<String> invalidCountriesInSuggestions() {
|
||||
final String sql =
|
||||
" select distinct t.oa_country from tmp_dedup_events t left outer join countries c on (t.oa_country = c.val) where c.val is null order by t.oa_country";
|
||||
return jdbcTemplate.queryForList(sql, String.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label">Read only</label>
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" type="checkbox" ng-model="sysconf.readonly" />
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" ng-model="sysconf.readonly" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
|
|
|
@ -1,6 +1,27 @@
|
|||
<h4>System utilities</h4>
|
||||
<br />
|
||||
|
||||
<table class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 20%">Command</th>
|
||||
<th style="width: 80%">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><button class="btn btn-sm btn-link" ng-click="refreshFulltextIndex()" ng-disabled="fulltextIndexMessage">Rebuild fulltext index</button></td>
|
||||
<td>{{fulltextIndexMessage}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button class="btn btn-sm btn-link" ng-click="performConsistencyCheck()" ng-disabled="consistencyCheckMessage">Perform consistency check</button></td>
|
||||
<td>{{consistencyCheckMessage}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button class="btn btn-sm btn-link" ng-click="verifyCountriesInSuggestions()" ng-disabled="invalidSuggestedCountriesMessage">Verify countries in suggestions</button></td>
|
||||
<td>{{invalidSuggestedCountriesMessage}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<button class="btn btn-sm btn-primary" ng-click="refreshFulltextIndex()">Rebuild fulltext index</button>
|
||||
<button class="btn btn-sm btn-primary" ng-click="performConsistencyCheck()">Perform consistency check</button>
|
||||
|
|
|
@ -808,13 +808,24 @@ orgsModule.controller('lastImportCtrl', function ($scope, $http) {
|
|||
});
|
||||
|
||||
orgsModule.controller('utilsCtrl', function ($scope, $http) {
|
||||
|
||||
$scope.fulltextIndexMessage = '';
|
||||
$scope.consistencyCheckMessage = '';
|
||||
$scope.invalidSuggestedCountriesMessage = '';
|
||||
|
||||
$scope.refreshFulltextIndex = function() {
|
||||
call_http_get($http, 'api/refreshFulltextIndex', function(res) { alert(res.data[0]); });
|
||||
$scope.fulltextIndexMessage = '...';
|
||||
call_http_get($http, 'api/refreshFulltextIndex', function(res) { $scope.fulltextIndexMessage = res.data[0]; });
|
||||
}
|
||||
|
||||
$scope.performConsistencyCheck = function() {
|
||||
call_http_get($http, 'api/performConsistencyCheck', function(res) { alert(res.data[0]); });
|
||||
$scope.consistencyCheckMessage = '...';
|
||||
call_http_get($http, 'api/performConsistencyCheck', function(res) { $scope.consistencyCheckMessage = res.data[0]; });
|
||||
}
|
||||
|
||||
$scope.verifyCountriesInSuggestions = function() {
|
||||
$scope.invalidSuggestedCountriesMessage = '...';
|
||||
call_http_get($http, 'api/verifyCountriesInSuggestions', function(res) { $scope.invalidSuggestedCountriesMessage = res.data[0]; });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue