From f17454b9195033b233971d7786ddc2ff48429960 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Sun, 12 Sep 2021 00:07:11 +0200 Subject: [PATCH] fix: fix anonymization page --- public/partials/anonymize.htm | 7 +++--- public/script/app.js | 41 ++++++++++++++++------------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/public/partials/anonymize.htm b/public/partials/anonymize.htm index 773b53f..357a770 100644 --- a/public/partials/anonymize.htm +++ b/public/partials/anonymize.htm @@ -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. diff --git a/public/script/app.js b/public/script/app.js index b3a321c..71a00fa 100644 --- a/public/script/app.js +++ b/public/script/app.js @@ -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);