disable download mode for the moment

This commit is contained in:
tdurieux
2023-04-05 12:12:16 +02:00
parent d29d4281ab
commit e94a5f164a
5 changed files with 31 additions and 116 deletions
+3 -61
View File
@@ -13,14 +13,9 @@
name="anonymize" name="anonymize"
novalidate novalidate
> >
<h5 class="card-title">Anonymize a repository</h5> <h3 class="card-title mb-3">Anonymize your repository</h3>
<h6 class="card-subtitle mb-2 text-muted">
Fill the information to anonymize! It will only take 5min.
</h6>
<h2>Source</h2>
<!-- repoUrl --> <!-- repoUrl -->
<div class="form-group"> <div class="form-group mb-0">
<label for="repoUrl">Type the url of your repository</label>
<input <input
type="text" type="text"
class="form-control" class="form-control"
@@ -28,6 +23,7 @@
id="repoUrl" id="repoUrl"
ng-class="{'is-invalid': anonymize.repoUrl.$invalid}" ng-class="{'is-invalid': anonymize.repoUrl.$invalid}"
ng-model="repoUrl" ng-model="repoUrl"
placeholder="URL of your GitHub repository"
ng-model-options="{ debounce: {default: 1000, blur: 0, click: 0}, updateOn: 'default blur click' }" ng-model-options="{ debounce: {default: 1000, blur: 0, click: 0}, updateOn: 'default blur click' }"
ng-change="repoSelected()" ng-change="repoSelected()"
/> />
@@ -58,37 +54,6 @@
{{repoUrl}} is already anonymized {{repoUrl}} is already anonymized
</div> </div>
</div> </div>
<!-- select repo -->
<div class="form-group" ng-hide="repoUrl">
<label for="repositories">Or select one of your repository</label>
<div class="input-group mb-3">
<select
class="form-control"
id="repositories"
name="repositories"
ng-model="repoUrl"
ng-change="repoSelected()"
>
<option selected value="">None</option>
<option
ng-repeat="repo in repositories|orderBy:'fullName'"
value="https://github.com/{{ repo.fullName }}"
ng-bind="repo.fullName"
></option>
</select>
<div class="input-group-append">
<button
class="btn btn-outline-secondary"
ng-click="getRepositories(true)"
title="Refresh!"
data-toggle="tooltip"
data-placement="bottom"
>
<i class="fa fa-undo"></i>
</button>
</div>
</div>
</div>
<div ng-show="repoUrl"> <div ng-show="repoUrl">
<!-- Branch --> <!-- Branch -->
<div class="form-group"> <div class="form-group">
@@ -386,29 +351,6 @@
>Display Notebooks</label >Display Notebooks</label
> >
</div> </div>
<div class="form-group">
<label for="mode">Proxy mode</label>
<select
class="form-control"
id="mode"
name="mode"
ng-model="source.type"
>
<option value="GitHubStream" selected>Stream</option>
<option value="GitHubDownload">Download</option>
</select>
<small class="form-text text-muted"
>How the repository will be anonymized. Stream mode
will request the content on the flight. This is the
only option for repositories bigger than
{{site_options.MAX_REPO_SIZE * 1024| humanFileSize}}.
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> </div>
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
+6 -34
View File
@@ -999,9 +999,7 @@ angular
$scope.terms = ""; $scope.terms = "";
$scope.defaultTerms = ""; $scope.defaultTerms = "";
$scope.branches = []; $scope.branches = [];
$scope.repositories = [];
$scope.source = { $scope.source = {
type: "GitHubStream",
branch: "", branch: "",
commit: "", commit: "",
}; };
@@ -1079,17 +1077,6 @@ angular
} }
}); });
$scope.getRepositories = (force) => {
$http
.get("/api/user/all_repositories", {
params: { force: force === true ? "1" : "0" },
})
.then((res) => {
$scope.repositories = res.data;
});
};
$scope.getRepositories();
$scope.repoSelected = async () => { $scope.repoSelected = async () => {
$scope.terms = $scope.defaultTerms; $scope.terms = $scope.defaultTerms;
$scope.repoId = ""; $scope.repoId = "";
@@ -1176,14 +1163,6 @@ angular
resetValidity(); resetValidity();
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) {
$scope.anonymize.mode.$$element[0].disabled = true;
$scope.$apply(() => {
$scope.source.type = "GitHubStream";
checkSourceType();
});
}
if (!$scope.repoId) { if (!$scope.repoId) {
$scope.repoId = $scope.details.repo + "-" + generateRandomId(4); $scope.repoId = $scope.details.repo + "-" + generateRandomId(4);
} }
@@ -1453,7 +1432,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];
checkSourceType(); checkHasPage();
if (selected) { if (selected) {
$scope.source.commit = selected.commit; $scope.source.commit = selected.commit;
@@ -1464,22 +1443,15 @@ angular
} }
}); });
function checkSourceType() { function checkHasPage() {
if ($scope.source.type == "GitHubStream") { if ($scope.details && $scope.details.hasPage) {
$scope.options.page = false; $scope.anonymize.page.$$element[0].disabled = false;
//$scope.anonymize.page.$$element[0].disabled = true; if ($scope.details.pageSource.branch != $scope.source.branch) {
} else { $scope.anonymize.page.$$element[0].disabled = true;
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);
$scope.$watch("options.link", anonymize); $scope.$watch("options.link", anonymize);
+2 -2
View File
@@ -56,8 +56,8 @@ export default class Repository {
this._model = data; this._model = data;
switch (data.source.type) { switch (data.source.type) {
case "GitHubDownload": case "GitHubDownload":
this.source = new GitHubDownload(data.source, this); // this.source = new GitHubDownload(data.source, this);
break; // break;
case "GitHubStream": case "GitHubStream":
this.source = new GitHubStream(data.source, this); this.source = new GitHubStream(data.source, this);
break; break;
+19 -18
View File
@@ -468,28 +468,29 @@ router.post("/", async (req: express.Request, res: express.Response) => {
repo.owner = user.id; repo.owner = user.id;
updateRepoModel(repo, repoUpdate); updateRepoModel(repo, repoUpdate);
repo.source.type = "GitHubStream";
repo.source.accessToken = user.accessToken; repo.source.accessToken = user.accessToken;
repo.source.repositoryId = repository.model.id; repo.source.repositoryId = repository.model.id;
repo.source.repositoryName = repoUpdate.fullName; repo.source.repositoryName = repoUpdate.fullName;
if (repo.source.type == "GitHubDownload") { // if (repo.source.type === "GitHubDownload") {
// details.size is in kilobytes // // details.size is in kilobytes
if ( // if (
repository.size === undefined || // repository.size === undefined ||
repository.size > config.MAX_REPO_SIZE // repository.size > config.MAX_REPO_SIZE
) { // ) {
throw new AnonymousError("invalid_mode", { // throw new AnonymousError("invalid_mode", {
object: repository, // object: repository,
httpStatus: 400, // httpStatus: 400,
}); // });
} // }
} // }
if ( // if (
repository.size !== undefined && // repository.size !== undefined &&
repository.size < config.AUTO_DOWNLOAD_REPO_SIZE // repository.size < config.AUTO_DOWNLOAD_REPO_SIZE
) { // ) {
repo.source.type = "GitHubDownload"; // repo.source.type = "GitHubDownload";
} // }
repo.conference = repoUpdate.conference; repo.conference = repoUpdate.conference;
await repo.save(); await repo.save();
+1 -1
View File
@@ -91,7 +91,7 @@ export default class GitHubDownload extends GitHubBase implements SourceBase {
const that = this; const that = this;
async function updateProgress() { async function updateProgress() {
if (progress && that.repository.status) { if (progress && that.repository.status == RepositoryStatus.DOWNLOAD) {
await that.repository.updateStatus( await that.repository.updateStatus(
that.repository.status, that.repository.status,
progress.transferred.toString() progress.transferred.toString()