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

View File

@@ -395,9 +395,10 @@
will request the content on the flight. This is the
only option for repositories bigger than
{{site_options.MAX_REPO_SIZE * 1024| humanFileSize}}.
Download will download the repository the repository
on the anonymous.4open.science server, it is faster
and offer more features.</small
This repository is {{details.size * 8 *1024 |
humanFileSize}}. Download will download the repository
the repository on the anonymous.4open.science server,
it is faster and offer more features.</small
>
</div>
</div>

View File

@@ -864,7 +864,7 @@ angular
$scope.terms = $scope.defaultTerms;
$scope.repoId = "";
$scope.source = {
type: "GitHubDownload",
type: "GitHubStream",
branch: "",
commit: "",
};
@@ -898,7 +898,7 @@ angular
} else {
$scope.anonymize.commit.$$element[0].disabled = false;
}
})
});
$scope.$watch("source.branch", async () => {
const selected = $scope.branches.filter(
(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) => {
const o = parseGithubUrl($scope.repoUrl);
const branches = await $http.get(
@@ -955,8 +946,12 @@ angular
const res = await $http.get(`/api/repo/${o.owner}/${o.repo}/`);
$scope.details = res.data;
if ($scope.details.size > $scope.site_options.MAX_REPO_SIZE) {
$scope.options.mode = "GitHubStream";
$scope.anonymize.mode.$$element[0].disabled = true;
$scope.$apply(() => {
$scope.source.type = "GitHubStream";
checkSourceType();
});
}
$scope.repoId = $scope.details.repo + "-" + generateRandomId(4);
await $scope.getBranches();
@@ -1186,12 +1181,7 @@ angular
const selected = $scope.branches.filter(
(f) => f.name == $scope.source.branch
)[0];
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;
}
}
checkSourceType();
if (selected) {
$scope.source.commit = selected.commit;
@@ -1202,14 +1192,21 @@ angular
}
});
$scope.$watch("source.type", (v) => {
if (v == "GitHubStream") {
function checkSourceType() {
if ($scope.source.type == "GitHubStream") {
$scope.options.page = false;
$scope.anonymize.page.$$element[0].disabled = true;
} 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("options.image", anonymize);