fix: fix anonymization page

This commit is contained in:
tdurieux
2021-09-12 00:07:11 +02:00
parent 486ad634ca
commit f17454b919
2 changed files with 23 additions and 25 deletions
+4 -3
View File
@@ -395,9 +395,10 @@
will request the content on the flight. This is the will request the content on the flight. This is the
only option for repositories bigger than only option for repositories bigger than
{{site_options.MAX_REPO_SIZE * 1024| humanFileSize}}. {{site_options.MAX_REPO_SIZE * 1024| humanFileSize}}.
Download will download the repository the repository This repository is {{details.size * 8 *1024 |
on the anonymous.4open.science server, it is faster humanFileSize}}. Download will download the repository
and offer more features.</small the repository on the anonymous.4open.science server,
it is faster and offer more features.</small
> >
</div> </div>
</div> </div>
+19 -22
View File
@@ -864,7 +864,7 @@ angular
$scope.terms = $scope.defaultTerms; $scope.terms = $scope.defaultTerms;
$scope.repoId = ""; $scope.repoId = "";
$scope.source = { $scope.source = {
type: "GitHubDownload", type: "GitHubStream",
branch: "", branch: "",
commit: "", commit: "",
}; };
@@ -898,7 +898,7 @@ angular
} else { } else {
$scope.anonymize.commit.$$element[0].disabled = false; $scope.anonymize.commit.$$element[0].disabled = false;
} }
}) });
$scope.$watch("source.branch", async () => { $scope.$watch("source.branch", async () => {
const selected = $scope.branches.filter( const selected = $scope.branches.filter(
(f) => f.name == $scope.source.branch (f) => f.name == $scope.source.branch
@@ -919,15 +919,6 @@ angular
} }
}); });
$scope.$watch("options.mode", (v) => {
if (v == "GitHubStream") {
$scope.options.page = false;
$scope.anonymize.page.$$element[0].disabled = true;
} else {
$scope.anonymize.page.$$element[0].disabled = false;
}
});
$scope.getBranches = async (force) => { $scope.getBranches = async (force) => {
const o = parseGithubUrl($scope.repoUrl); const o = parseGithubUrl($scope.repoUrl);
const branches = await $http.get( const branches = await $http.get(
@@ -955,8 +946,12 @@ angular
const res = await $http.get(`/api/repo/${o.owner}/${o.repo}/`); const res = await $http.get(`/api/repo/${o.owner}/${o.repo}/`);
$scope.details = res.data; $scope.details = res.data;
if ($scope.details.size > $scope.site_options.MAX_REPO_SIZE) { if ($scope.details.size > $scope.site_options.MAX_REPO_SIZE) {
$scope.options.mode = "GitHubStream";
$scope.anonymize.mode.$$element[0].disabled = true; $scope.anonymize.mode.$$element[0].disabled = true;
$scope.$apply(() => {
$scope.source.type = "GitHubStream";
checkSourceType();
});
} }
$scope.repoId = $scope.details.repo + "-" + generateRandomId(4); $scope.repoId = $scope.details.repo + "-" + generateRandomId(4);
await $scope.getBranches(); await $scope.getBranches();
@@ -1186,12 +1181,7 @@ angular
const selected = $scope.branches.filter( const selected = $scope.branches.filter(
(f) => f.name == $scope.source.branch (f) => f.name == $scope.source.branch
)[0]; )[0];
if ($scope.details && $scope.details.hasPage) { checkSourceType();
$scope.anonymize.page.$$element[0].disabled = false;
if ($scope.details.pageSource.branch != $scope.source.branch) {
$scope.anonymize.page.$$element[0].disabled = true;
}
}
if (selected) { if (selected) {
$scope.source.commit = selected.commit; $scope.source.commit = selected.commit;
@@ -1202,14 +1192,21 @@ angular
} }
}); });
$scope.$watch("source.type", (v) => { function checkSourceType() {
if (v == "GitHubStream") { if ($scope.source.type == "GitHubStream") {
$scope.options.page = false; $scope.options.page = false;
$scope.anonymize.page.$$element[0].disabled = true; $scope.anonymize.page.$$element[0].disabled = true;
} else { } else {
$scope.anonymize.page.$$element[0].disabled = false; if ($scope.details && $scope.details.hasPage) {
$scope.anonymize.page.$$element[0].disabled = false;
if ($scope.details.pageSource.branch != $scope.source.branch) {
$scope.anonymize.page.$$element[0].disabled = true;
}
}
} }
}); }
$scope.$watch("source.type", checkSourceType);
$scope.$watch("terms", anonymize); $scope.$watch("terms", anonymize);
$scope.$watch("options.image", anonymize); $scope.$watch("options.image", anonymize);