diff --git a/public/partials/anonymize.htm b/public/partials/anonymize.htm
index 748f78e..9dc05e5 100644
--- a/public/partials/anonymize.htm
+++ b/public/partials/anonymize.htm
@@ -20,6 +20,7 @@
Fill the information to annoymize! It will only take 5min.
+
+
diff --git a/public/partials/header.htm b/public/partials/header.htm
index 880a741..440fd94 100644
--- a/public/partials/header.htm
+++ b/public/partials/header.htm
@@ -85,7 +85,7 @@
diff --git a/public/script/homeApp.js b/public/script/homeApp.js
index 8367b24..94e6f95 100644
--- a/public/script/homeApp.js
+++ b/public/script/homeApp.js
@@ -42,6 +42,11 @@ angular
controller: "faqController",
title: "FAQ - Anonymous GitHub",
})
+ .when("/profile", {
+ templateUrl: "/partials/profile.htm",
+ controller: "profileController",
+ title: "Profile - Anonymous GitHub",
+ })
.when("/claim", {
templateUrl: "/partials/claim.htm",
controller: "claimController",
@@ -124,6 +129,47 @@ angular
}
getSupportedFileTypes();
})
+ .controller("profileController", function($scope, $http) {
+ $scope.terms = "";
+ $scope.options = {
+ expirationMode: "remove",
+ update: false,
+ image: true,
+ pdf: true,
+ notebook: true,
+ loc: true,
+ link: true,
+ mode: "download",
+ };
+
+ function getDefault() {
+ $http.get("/api/user/default").then((res) => {
+ const data = res.data;
+ if (data.terms) {
+ $scope.terms = data.terms.join("\n");
+ }
+ $scope.option = Object.assign({}, $scope.option, data.options);
+ });
+ }
+ getDefault();
+
+ $scope.saveDefault = () => {
+ const params = {
+ terms: $scope.terms.trim().split("\n"),
+ options: $scope.options,
+ };
+ $http.post("/api/user/default", params).then(
+ () => {
+ getDefault();
+ },
+ (error) => {
+ $translate("ERRORS." + error.data.error).then((translation) => {
+ $scope.error = translation;
+ }, console.error);
+ }
+ );
+ };
+ })
.controller("claimController", function($scope, $location, $http) {
$scope.repoId = null;
$scope.repoUrl = null;
@@ -271,6 +317,7 @@ angular
$scope.repoUrl = "";
$scope.repoId = "";
$scope.terms = "";
+ $scope.defaultTerms = "";
$scope.branch = "";
$scope.branches = [];
@@ -292,6 +339,18 @@ angular
$scope.html_readme = "";
$scope.isUpdate = false;
+ function getDefault() {
+ $http.get("/api/user/default").then((res) => {
+ const data = res.data;
+ if (data.terms) {
+ $scope.defaultTerms = data.terms.join("\n");
+ }
+ $scope.options = Object.assign({}, $scope.options, data.options);
+ $scope.options.expirationDate = new Date($scope.options.expirationDate);
+ });
+ }
+ getDefault();
+
if ($routeParams.repoId && $routeParams.repoId != "") {
$scope.isUpdate = true;
$scope.repoId = $routeParams.repoId;
@@ -341,7 +400,7 @@ angular
$scope.getRepositories();
$scope.repoSelected = async () => {
- $scope.terms = "";
+ $scope.terms = $scope.defaultTerms;
$scope.repoId = "";
$scope.branch = "";
diff --git a/routes/user.js b/routes/user.js
index e254fca..3fc3540 100644
--- a/routes/user.js
+++ b/routes/user.js
@@ -22,6 +22,21 @@ router.get("/", async (req, res) => {
res.json({ username: req.user.profile.username, photo });
});
+router.get("/default", async (req, res) => {
+ const d = await db
+ .get("users")
+ .findOne({ username: req.user.username }, { projection: { default: 1 } });
+ res.json(d.default);
+});
+
+router.post("/default", async (req, res) => {
+ const d = req.body;
+ await db
+ .get("users")
+ .updateOne({ username: req.user.username }, { $set: { default: d } });
+ res.send("ok");
+});
+
router.get("/anonymized_repositories", async (req, res) => {
const repos = await db
.get("anonymized_repositories")