Skip to content

Commit

Permalink
Hiding the two Cautious sections that are not used for the moment and…
Browse files Browse the repository at this point in the history
… adding the possibility to change the number of pages as startpages. #229
  • Loading branch information
2LaMa committed Oct 18, 2019
1 parent 9a7d61b commit 87a79b0
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 57 deletions.
30 changes: 22 additions & 8 deletions hyphe_frontend/app/views/settings.html
Expand Up @@ -89,12 +89,26 @@ <h3 style="margin:0px">CRAWLING</h3>
</md-input-container>

<div layout = "column">
<dt style="margin-bottom: 18px">Startpages mode</dt>
<div flex="50" ng-repeat="item in allStartpagesMode">
<md-checkbox ng-checked="ed_defaultStartpagesMode.includes(item)" ng-click="toggle(item, ed_defaultStartpagesMode)" aria-label="StartPagesCheckbox">
{{item}}
<dt style="margin-bottom: 18px">What pages to use as startpages of the WebEntity ?</dt>
<div flex="50">
<md-checkbox ng-model="startpages_homepage" aria-label="StartPagesCheckbox">
The Homepage of the WebEntity
</md-checkbox>
</div>
<div flex="50">
<md-checkbox ng-model="startpages_prefixes" aria-label="prefixes-Checkbox">
The prefixes of the WebEntity
</md-checkbox>
</div>

<div flex="50">
<md-checkbox ng-model="startpages_pages" aria-label="pages-n-Checkbox">
The most cited know pages of the WebEntity :

This comment has been minimized.

Copy link
@boogheta

boogheta Oct 18, 2019

Member

knowN

This comment has been minimized.

Copy link
@boogheta

boogheta Oct 18, 2019

Member

and no space before : in english :) (as well as for ? above)

</md-checkbox>
<md-input-container style="width:60px ; margin:0px; height:33px">
<input ng-disabled="!startpages_pages" type="number" min="0" max="50" ng-model="nbOfPages" aria-label="nbOfPagesAsStartpages">

This comment has been minimized.

Copy link
@boogheta

boogheta Oct 18, 2019

Member

min should be 1 and let's use a constant scope value for max

</md-input-container>
</div>
</div>
</dl>
</md-content>
Expand Down Expand Up @@ -122,7 +136,7 @@ <h3 style="margin:0px">PROXY</h3>
</div>

<!-- Cautious Crawl -->
<div flex="50" flex-xs="100" flex-gt-sm="33" layout="column" style="padding: 4px">
<div flex="50" flex-xs="100" flex-gt-sm="33" layout="column" style="padding: 4px" ng-show="false">
<md-content style="padding: 8px" md-colors="{'background': 'default-background-100'}" flex="grow">
<h3 style="margin:0px">CAUTIOUS CRAWL</h3>
<dl class="key-value-pairs">
Expand All @@ -148,7 +162,7 @@ <h3 style="margin:0px">CAUTIOUS CRAWL</h3>
</div>

<!-- CAUTIOUS DOMAINS -->
<div flex="50" flex-xs="100" flex-gt-sm="33" layout="column" style="padding: 4px">
<div flex="50" flex-xs="100" flex-gt-sm="33" layout="column" style="padding: 4px" ng-show="false">
<md-content style="padding: 8px" md-colors="{'background': 'default-background-100'}" flex="grow">
<h3 style="margin:0px">CAUTIOUS DOMAINS</h3>

Expand Down Expand Up @@ -238,7 +252,7 @@ <h3 style="margin:0px">PROXY</h3>
</div>

<!-- Cautious Crawl -->
<div flex="50" flex-xs="100" flex-gt-sm="33" layout="column" style="padding: 4px">
<div flex="50" flex-xs="100" flex-gt-sm="33" layout="column" style="padding: 4px" ng-show="false">
<md-content style="padding: 8px" md-colors="{'background': 'default-background-100'}" flex="grow">
<h3 style="margin:0px">CAUTIOUS CRAWL</h3>
<dl class="key-value-pairs">
Expand All @@ -258,7 +272,7 @@ <h3 style="margin:0px">CAUTIOUS CRAWL</h3>
</div>

<!-- CAUTIOUS DOMAINS -->
<div flex="50" flex-xs="100" flex-gt-sm="33" layout="column" style="padding: 4px">
<div flex="50" flex-xs="100" flex-gt-sm="33" layout="column" style="padding: 4px" ng-show = "false">
<md-content style="padding: 8px" md-colors="{'background': 'default-background-100'}" flex="grow">
<h3 style="margin:0px">CAUTIOUS DOMAINS</h3>

Expand Down
141 changes: 92 additions & 49 deletions hyphe_frontend/app/views/settings.js
Expand Up @@ -13,23 +13,23 @@ angular.module('hyphe.settingsController', [])
$scope.loading = true
$scope.destroying = false
$scope.resetting = false;
$scope.allStartpagesMode = ['homepage', 'prefixes', 'pages-5'];
$scope.saving = false;



$scope.destroy = function(){
if (confirm('Are you sure you want to PERMANENTLY destroy this corpus?')) {
$scope.destroying = true
$scope.status = {message: 'Destroying corpus'};
api.destroyCorpus({
id:corpus.getId()
}, function(){
$location.path('/project/'+$scope.corpusId+'/');
}, function(){
$scope.status = {message: "Error destroying project", background:'danger'};
})
}
if (confirm('Are you sure you want to PERMANENTLY destroy this corpus?')) {
$scope.destroying = true
$scope.status = {message: 'Destroying corpus'};
api.destroyCorpus({
id:corpus.getId()
}, function(){
$location.path('/project/'+$scope.corpusId+'/');
}, function(){
$scope.status = {message: "Error destroying project", background:'danger'};
})
}
}

$scope.resetCorpus = function(){
if (confirm('Are you sure you want to reset this corpus?')) {
Expand All @@ -55,60 +55,91 @@ angular.module('hyphe.settingsController', [])
$scope.status = {message:'max depth must be comprised between 0 and ' + $scope.maxmax_depth, background:'danger'}
return false;
}

if ($scope.nbOfPages < 0 || $scope.nbOfPages > 50){
$scope.status = {message:'Please enter a valid number of pages as Startpages (between 0 and 9)', background:'danger'}

This comment has been minimized.

Copy link
@boogheta

boogheta Oct 18, 2019

Member

min 1 and use a constant from scope for max

return false;
}

return true;
}

$scope.toggle = function(item, list){
var index = list.indexOf(item);
if (index > -1){
list.splice(index, 1);
$scope.toggle = function(item, list, replace){
var toggle = false;
for (var index = 0; index < list.length; index++) {
if ((list[index].startsWith("pages") && item.startsWith("pages")) || list[index] === item) {
console.log(item)
list.splice(index, 1);
toggle = true;
}
}
else{
if (!toggle || replace) {
console.log('iciaussi?')
list.push(item);
}
};

This comment has been minimized.

Copy link
@boogheta

boogheta Oct 18, 2019

Member

Function not used anymore



$scope.editSettings = function(save){
if (save && checkValid()) {


if (save) {
$scope.saving = true;
var modifiedOptions = {

//construction of the array of startpages mode
$scope.ed_defaultStartpagesMode = [];
if ($scope.startpages_homepage) {
console.log($scope.startpages_homepage)

This comment has been minimized.

Copy link
@boogheta

boogheta Oct 18, 2019

Member

logging forgotten

$scope.ed_defaultStartpagesMode.push('homepage');
}
if ($scope.startpages_prefixes) {
$scope.ed_defaultStartpagesMode.push('prefixes');
}
if ($scope.startpages_pages) {
$scope.ed_defaultStartpagesMode.push('pages-' + $scope.nbOfPages);
}
if (checkValid()) {

var modifiedOptions = {
"max_depth": $scope.ed_max_depth,
"defaultStartpagesMode" : $scope.ed_defaultStartpagesMode,
"proxy" : {
"port" : $scope.ed_proxy_port,
"host" : $scope.ed_proxy_host
"defaultStartpagesMode": $scope.ed_defaultStartpagesMode,
"proxy": {
"port": $scope.ed_proxy_port,
"host": $scope.ed_proxy_host
},
"phantom" : {
"timeout" : $scope.ed_timeout,
"ajax_timeout" : $scope.ed_ajax_timeout,
"idle_timeout" : $scope.ed_idle_timeout,
"whitelist_domains" : $scope.ed_whitelist
"phantom": {
"timeout": $scope.ed_timeout,
"ajax_timeout": $scope.ed_ajax_timeout,
"idle_timeout": $scope.ed_idle_timeout,
"whitelist_domains": $scope.ed_whitelist
},
"follow_redirects" : $scope.ed_follow_redirects,
"defaultCreationRule" : $scope.ed_defaultCreationRule
};

$scope.status = {message:'Saving new settings'};

api.setCorpusOptions({
id: $scope.corpusId,
options: modifiedOptions
}, function (options) {
$scope.options = options;
$scope.status = {};
$scope.saving = false;
console.log("Settings successfully updated");
},function(){
$scope.status = {message:'Could not save new settings.', background:'danger'}
"follow_redirects": $scope.ed_follow_redirects,
"defaultCreationRule": $scope.ed_defaultCreationRule
};

$scope.status = {message: 'Saving new settings'};

api.setCorpusOptions({
id: $scope.corpusId,
options: modifiedOptions
}, function (options) {
$scope.options = options;
$scope.status = {};
$scope.saving = false;
console.log("Settings successfully updated");
}, function () {
$scope.status = {message: 'Could not save new settings.', background: 'danger'}
$scope.saving = false;
console.error("Settings could not be updated");
});
} else {
$scope.saving = false;
console.error("Settings could not be updated");
});
} else {
$scope.saving = false;
if (save && !checkValid()) return;
if (save && !checkValid()) return;

This comment has been minimized.

Copy link
@boogheta

boogheta Oct 18, 2019

Member

Since you changed the "if save and checkvalid" from above into "if save" only, save is always false inside this else and this condition is never true. You should move the return as a "if !checkvalid" above instead

}
}
$scope.ed_max_depth = $scope.options.max_depth;
$scope.ed_defaultStartpagesMode = $scope.options.defaultStartpagesMode.slice();
console.log($scope.ed_defaultStartpagesMode);

This comment has been minimized.

Copy link
@boogheta

boogheta Oct 18, 2019

Member

one more log forgotten

$scope.ed_proxy_host = $scope.options.proxy.host+"";
$scope.ed_proxy_port = $scope.options.proxy.port+0;
$scope.ed_timeout = $scope.options.phantom.timeout+0;
Expand All @@ -117,7 +148,19 @@ angular.module('hyphe.settingsController', [])
$scope.ed_whitelist = $scope.options.phantom.whitelist_domains.slice();
$scope.ed_follow_redirects = $scope.options.follow_redirects.slice();
$scope.ed_defaultCreationRule = $scope.options.defaultCreationRule+"";
$scope.startpages_homepage = $scope.options.defaultStartpagesMode.includes('homepage');
$scope.startpages_prefixes = $scope.options.defaultStartpagesMode.includes('prefixes');
$scope.startpages_pages = $scope.options.defaultStartpagesMode.some(x => x.startsWith('pages'))
$scope.corpusSettingsEditMode = !$scope.corpusSettingsEditMode;

//define the current number of most cited pages as start pages
for (var i=0; i<$scope.options.defaultStartpagesMode.length; i++){
if ($scope.ed_defaultStartpagesMode[i].startsWith('pages')){
$scope.nbOfPages = parseInt($scope.ed_defaultStartpagesMode[i].slice(-1));
console.log($scope.nbOfPages)

This comment has been minimized.

Copy link
@boogheta

boogheta Oct 18, 2019

Member

And yet another one ;)

return;

This comment has been minimized.

Copy link
@boogheta

boogheta Oct 18, 2019

Member

there's no impact in this case since we're reaching the end of the function, but this return is dangerous and should rather be a break

}
}
};


Expand Down

0 comments on commit 87a79b0

Please sign in to comment.