diff --git a/public/css/style.css b/public/css/style.css index 4895052..f72ea9a 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -211,7 +211,7 @@ a.black_border:hover { background-color: #ffffff; padding: 8px 6px; margin: 0; - border-bottom: 1px solid #dddddd ; + border-bottom: 1px solid #dddddd; border-radius: 0; } @@ -314,3 +314,13 @@ loc .lang { float: left; height: 100%; } + +.rounded-circle.fa { + display: inline-block; + font-size: 75px; + height: 140px; + width: 140px; + border: 4px solid; + line-height: 140px; + text-align: center; +} diff --git a/public/i18n/locale-en.json b/public/i18n/locale-en.json index 76fa3ed..a12d0db 100644 --- a/public/i18n/locale-en.json +++ b/public/i18n/locale-en.json @@ -7,11 +7,11 @@ "repo_is_updating": "Anonymous GitHub is still processing the repository, it can take several minutes.", "repoUrl_not_defined": "The repository url needs to be defined.", "repoId_already_used": "The repository id is already used.", - "invalid_repoId": "The format of the repository id is invalid", - "branch_not_specified": "The branch is not specified", - "options_not_provided": "options_not_provided", - "invalid_terms_format": "invalid_terms_format", - "unable_to_anonymize": "unable_to_anonymize", + "invalid_repoId": "The format of the repository id is invalid.", + "branch_not_specified": "The branch is not specified.", + "options_not_provided": "Anonimization options are mendatory.", + "invalid_terms_format": "Terms are in an invalid format.", + "unable_to_anonymize": "An error happened during the anonimization proccess. Please try later or report the issue.", "non_supported_mode": "The selected anonymization mode is invalid, only download and stream are supported.", "invalid_path": "The provided path is invalid or missing.", "file_not_found": "The requested file is not found.", diff --git a/public/partials/status.htm b/public/partials/status.htm new file mode 100644 index 0000000..66d2053 --- /dev/null +++ b/public/partials/status.htm @@ -0,0 +1,116 @@ +
+

Status of

+ +
+

Progress

+ +

+ The current status of your repository. The repository will take few + minutes to get ready depending on the size of the repository. + Visit the FAQ for more information. +

+ +
+
+ {{repo.status | title}} +
+
+
+ +
+ +
+

Support the project

+ +
+
+ + +

Contribute

+

+ Collabore to the Anonymous GitHub by implementing new features and + fixing bugs. Contribution likes supporting new file format or + improving the deployment are more than welcome. +

+

+ Go to GitHub » +

+
+ +
+ + +

Feedback

+

+ Feedback is also really valuable for the project. It helps to project + to identify bugs, missing feature and define priorities for the + project. +

+

+ Create an issue » +

+
+ +
+ + +

Finance

+

+ You can also help the project by supporting financiarly the project. + The server costs around 25$ per month. Any help to support the cost + would be gradly appriciated. +

+

+ GitHub Sponsor » + Ko-fi » +

+
+
+
+ +
+ +
+ Go to the anonymized repository + Go to the anonymized Gh-page +
+
diff --git a/public/script/homeApp.js b/public/script/homeApp.js index 431d254..8367b24 100644 --- a/public/script/homeApp.js +++ b/public/script/homeApp.js @@ -28,6 +28,11 @@ angular controller: "anonymizeController", title: "Anonymize - Anonymous GitHub", }) + .when("/status/:repoId", { + templateUrl: "/partials/status.htm", + controller: "statusController", + title: "Repository status - Anonymous GitHub", + }) .when("/404", { templateUrl: "/partials/404.htm", title: "Page not found - Anonymous GitHub", @@ -218,6 +223,43 @@ angular return false; }; }) + .controller("statusController", function($scope, $http, $routeParams) { + $scope.repoId = $routeParams.repoId; + $scope.repo = null; + $scope.progress = 0; + $scope.getStatus = () => { + $http + .get("/api/repo/" + $scope.repoId, { + repoId: $scope.repoId, + repoUrl: $scope.repoUrl, + }) + .then( + (res) => { + $scope.repo = res.data; + if ($scope.repo.status == "ready") { + $scope.progress = 100; + } else if ($scope.repo.status == "queue") { + $scope.progress = 0; + } else if ($scope.repo.status == "downloaded") { + $scope.progress = 50; + } else if ($scope.repo.status == "downloading") { + $scope.progress = 25; + } else if ($scope.repo.status == "preparing") { + $scope.progress = 10; + } else if ($scope.repo.status == "anonimizing") { + $scope.progress = 75; + } + if ($scope.repo.status != "ready") { + setTimeout($scope.getStatus, 1000); + } + }, + (err) => { + $scope.error = err.data; + } + ); + }; + $scope.getStatus(); + }) .controller("anonymizeController", function( $scope, $http, @@ -505,7 +547,7 @@ angular await $http.post("/api/repo/", newRepo, { headers: { "Content-Type": "application/json" }, }); - window.location.href = "/r/" + $scope.repoId; + window.location.href = "/status/" + $scope.repoId; } catch (error) { if (error.data) { $translate("ERRORS." + error.data.error).then((translation) => { @@ -530,7 +572,7 @@ angular await $http.post("/api/repo/" + newRepo.repoId, newRepo, { headers: { "Content-Type": "application/json" }, }); - window.location.href = "/r/" + $scope.repoId; + window.location.href = "/status/" + $scope.repoId; } catch (error) { if (error.data) { displayErrorMessage(error.data.error); diff --git a/routes/repositoy.js b/routes/repositoy.js index d266ce3..15b38d4 100644 --- a/routes/repositoy.js +++ b/routes/repositoy.js @@ -112,13 +112,15 @@ router.post("/:repoId/", async (req, res) => { ); repoConfig = await repoUtils.getConfig(repoUpdate.repoId); + await repoUtils.updateStatus(repoConfig, "preparing"); + res.send("ok"); + await githubUtils.downloadRepoAndAnonymize(repoConfig); await repoUtils.updateStatus(repoConfig, "ready"); - - return res.send("ok"); } catch (error) { console.error(error); + await repoUtils.updateStatus(repoConfig, "error", error); return res.status(500).json({ error }); } }); @@ -320,17 +322,17 @@ router.post("/", async (req, res) => { }, { upsert: true } ); + res.send("ok"); try { await githubUtils.downloadRepoAndAnonymize(data); await repoUtils.updateStatus(repoConfig, "ready"); } catch (error) { console.error(error); - await repoUtils.updateStatus(repoConfig, "error"); + await repoUtils.updateStatus(repoConfig, "error", "unable_to_anonymize"); return res .status(500) .json({ error: "unable_to_anonymize", message: error.message }); } - res.send("ok"); }); module.exports = router; diff --git a/utils/github.js b/utils/github.js index ed39a59..5b422a6 100644 --- a/utils/github.js +++ b/utils/github.js @@ -51,6 +51,7 @@ module.exports.downloadRepoAndAnonymize = async (repoConfig) => { return true; } else if (repoConfig.options.mode == "stream") { // in stream mode only download the list of file from github + await repoUtils.updateStatus(repoConfig, "downloading"); await fileUtils.getFileList({ repoConfig }); await repoUtils.updateStatus(repoConfig, "ready"); return true; diff --git a/utils/repository.js b/utils/repository.js index 206b9e3..93147fb 100644 --- a/utils/repository.js +++ b/utils/repository.js @@ -139,11 +139,19 @@ module.exports.downloadRepoZip = async (repoConfig, target) => { }); }; -module.exports.updateStatus = async (repoConfig, status) => { +module.exports.updateStatus = async (repoConfig, status, errorMessage) => { repoConfig.status = status; + repoConfig.errorMessage = errorMessage; + const update = { $set: { status } }; + if (!errorMessage) { + update["$unset"] = { errorMessage: "" }; + } else { + update["$set"].errorMessage = errorMessage; + } + await db .get("anonymized_repositories") - .updateOne({ repoId: repoConfig.repoId }, { $set: { status } }); + .updateOne({ repoId: repoConfig.repoId }, update); }; module.exports.downloadOriginalRepo = async (repoConfig, destination) => {