Skip to content

Commit

Permalink
autorestart corpus when using permalinks (closes #440)
Browse files Browse the repository at this point in the history
  • Loading branch information
boogheta committed Mar 7, 2022
1 parent e5e694a commit 4289c3d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
39 changes: 32 additions & 7 deletions hyphe_frontend/app/js/service_hyphe_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

angular.module('hyphe.service_hyphe_api', [])

.factory('api', ['config', '$http', 'corpus', '$location', function(config, $http, corpus, $location) {
.factory('api', ['config', '$http', 'corpus', '$location', '$timeout', function(config, $http, corpus, $location, $timeout) {
var surl = config.get('serverURL')
if (!surl) {
console.error('[Error] NO SERVER URL SPECIFIED. Please check front end config file.')
Expand Down Expand Up @@ -802,17 +802,42 @@ angular.module('hyphe.service_hyphe_api', [])
// Success
function(response){
var target = (response.data[0] || {}).result
if (pseudo_route === API.STATUS_GET && target && target.corpus && target.corpus.name && corpus.getName() !== target.corpus.name) {
corpus.setName(target.corpus.name);
window.location.reload();
}
if(target !== undefined){
if(target && target.corpus && target.corpus.corpus_id && target.corpus.status != "ready" && $location.path()!=='/admin') {
// Corpus shut down
$location.path('/login')
if (pseudo_route !== API.CORPUS_START) {
ns.startCorpus({
id: corpus.getId(),
password: ""
}, function(){
$timeout(function() {
buildApiCall(pseudo_route, params)(settings, successCallback, errorCallback);
}, 1000);
},function(data, status, headers, conf){
$location.path('/login')
})
} else $location.path('/login') // Corpus shut down
} else {
// console.log('[OK]', response.data)
successCallback(target, response.data[0])
}
// console.log('[OK]', response.data)
successCallback(target, response.data[0])
} else {
if(response.data[0] && response.data[0].message && response.data[0].message.status && response.data[0].message.status != "ready" && $location.path()!=='/admin') {
// Corpus shut down
$location.path('/login')
if (pseudo_route !== API.CORPUS_START) {
ns.startCorpus({
id: corpus.getId(),
password: ""
}, function(){
$timeout(function() {
buildApiCall(pseudo_route, params)(settings, successCallback, errorCallback);
}, 1000);
},function(data, status, headers, conf){
$location.path('/login')
})
} else $location.path('/login') // Corpus shut down
} else {
console.error('[Error: API call: unexpected response] Response:', response.data)
errorCallback(response.data, response.status, response.headers, response.config)
Expand Down
1 change: 1 addition & 0 deletions hyphe_frontend/app/views/manageTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ angular.module('hyphe.manageTagsController', [])
}

// Init
api.globalStatus({})
loadInWebentities()

// Functions
Expand Down
2 changes: 1 addition & 1 deletion hyphe_frontend/app/views/monitorCrawls.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ angular.module('hyphe.monitorcrawlsController', [])
}
}


$scope.focusOnJob = function(job){
if (!job || !job._id) return
$location.search({'id': job._id})
Expand Down Expand Up @@ -196,6 +195,7 @@ angular.module('hyphe.monitorcrawlsController', [])
}

// Initialization
api.globalStatus({})
updateLastCrawlJobs()
if ($location.search().id) {
$scope.focusedJobId = $location.search().id
Expand Down
3 changes: 1 addition & 2 deletions hyphe_frontend/app/views/prospect.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ angular.module('hyphe.prospectController', [])
$scope.settingsChanged = difference
}



$scope.loadWebentities = function(query){

// Get filtering settings
Expand Down Expand Up @@ -450,6 +448,7 @@ angular.module('hyphe.prospectController', [])
$scope.dynamicWebentities = new DynamicWebentities()

// Init
api.globalStatus({})
$scope.applySettings()

$scope.$on('$locationChangeStart', function(event, newUrl) {
Expand Down

0 comments on commit 4289c3d

Please sign in to comment.