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

View File

@@ -13,14 +13,9 @@
name="anonymize"
novalidate
>
<h5 class="card-title">Anonymize a repository</h5>
<h6 class="card-subtitle mb-2 text-muted">
Fill the information to anonymize! It will only take 5min.
</h6>
<h2>Source</h2>
<h3 class="card-title mb-3">Anonymize your repository</h3>
<!-- repoUrl -->
<div class="form-group">
<label for="repoUrl">Type the url of your repository</label>
<div class="form-group mb-0">
<input
type="text"
class="form-control"
@@ -28,6 +23,7 @@
id="repoUrl"
ng-class="{'is-invalid': anonymize.repoUrl.$invalid}"
ng-model="repoUrl"
placeholder="URL of your GitHub repository"
ng-model-options="{ debounce: {default: 1000, blur: 0, click: 0}, updateOn: 'default blur click' }"
ng-change="repoSelected()"
/>
@@ -58,37 +54,6 @@
{{repoUrl}} is already anonymized
</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">
<!-- Branch -->
<div class="form-group">
@@ -386,29 +351,6 @@
>Display Notebooks</label
>
</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 class="form-group">
<div class="form-check">

View File

@@ -999,9 +999,7 @@ angular
$scope.terms = "";
$scope.defaultTerms = "";
$scope.branches = [];
$scope.repositories = [];
$scope.source = {
type: "GitHubStream",
branch: "",
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.terms = $scope.defaultTerms;
$scope.repoId = "";
@@ -1176,14 +1163,6 @@ angular
resetValidity();
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.anonymize.mode.$$element[0].disabled = true;
$scope.$apply(() => {
$scope.source.type = "GitHubStream";
checkSourceType();
});
}
if (!$scope.repoId) {
$scope.repoId = $scope.details.repo + "-" + generateRandomId(4);
}
@@ -1453,7 +1432,7 @@ angular
const selected = $scope.branches.filter(
(f) => f.name == $scope.source.branch
)[0];
checkSourceType();
checkHasPage();
if (selected) {
$scope.source.commit = selected.commit;
@@ -1464,22 +1443,15 @@ angular
}
});
function checkSourceType() {
if ($scope.source.type == "GitHubStream") {
$scope.options.page = false;
//$scope.anonymize.page.$$element[0].disabled = true;
} else {
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;
}
function checkHasPage() {
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);
$scope.$watch("options.link", anonymize);

View File

@@ -56,8 +56,8 @@ export default class Repository {
this._model = data;
switch (data.source.type) {
case "GitHubDownload":
this.source = new GitHubDownload(data.source, this);
break;
// this.source = new GitHubDownload(data.source, this);
// break;
case "GitHubStream":
this.source = new GitHubStream(data.source, this);
break;

View File

@@ -468,28 +468,29 @@ router.post("/", async (req: express.Request, res: express.Response) => {
repo.owner = user.id;
updateRepoModel(repo, repoUpdate);
repo.source.type = "GitHubStream";
repo.source.accessToken = user.accessToken;
repo.source.repositoryId = repository.model.id;
repo.source.repositoryName = repoUpdate.fullName;
if (repo.source.type == "GitHubDownload") {
// details.size is in kilobytes
if (
repository.size === undefined ||
repository.size > config.MAX_REPO_SIZE
) {
throw new AnonymousError("invalid_mode", {
object: repository,
httpStatus: 400,
});
}
}
if (
repository.size !== undefined &&
repository.size < config.AUTO_DOWNLOAD_REPO_SIZE
) {
repo.source.type = "GitHubDownload";
}
// if (repo.source.type === "GitHubDownload") {
// // details.size is in kilobytes
// if (
// repository.size === undefined ||
// repository.size > config.MAX_REPO_SIZE
// ) {
// throw new AnonymousError("invalid_mode", {
// object: repository,
// httpStatus: 400,
// });
// }
// }
// if (
// repository.size !== undefined &&
// repository.size < config.AUTO_DOWNLOAD_REPO_SIZE
// ) {
// repo.source.type = "GitHubDownload";
// }
repo.conference = repoUpdate.conference;
await repo.save();

View File

@@ -91,7 +91,7 @@ export default class GitHubDownload extends GitHubBase implements SourceBase {
const that = this;
async function updateProgress() {
if (progress && that.repository.status) {
if (progress && that.repository.status == RepositoryStatus.DOWNLOAD) {
await that.repository.updateStatus(
that.repository.status,
progress.transferred.toString()