fix repo update

This commit is contained in:
tdurieux
2021-04-21 22:58:18 +02:00
parent a32945bf67
commit fbc7952d62
2 changed files with 50 additions and 39 deletions

View File

@@ -113,7 +113,7 @@
{{$index + 1}}
</th>
<td class="align-middle">
<a href="/r/{{repo.repoId}}" target="__self"
<a href="/r/{{repo.repoId}}"
>{{repo.repoId}}</a
>
</td>
@@ -185,7 +185,6 @@
<a
class="dropdown-item"
href="/anonymize/{{repo.repoId}}"
target="_self"
>
<i class="fa fa-edit" aria-hidden="true"></i> Edit
</a>
@@ -218,7 +217,6 @@
<a
class="dropdown-item"
href="/r/{{repo.repoId}}/"
target="_self"
>
<i class="fa fa-eye" aria-hidden="true"></i> View Repo
</a>

View File

@@ -591,13 +591,15 @@ angular
link: true,
mode: "download",
};
$scope.options.expirationDate.setDate(90);
$scope.options.expirationDate.setDate(
$scope.options.expirationDate.getDate() + 90
);
$scope.anonymize_readme = "";
$scope.readme = "";
$scope.html_readme = "";
$scope.isUpdate = false;
function getDefault() {
function getDefault(cb) {
$http.get("/api/user/default").then((res) => {
const data = res.data;
if (data.terms) {
@@ -607,44 +609,55 @@ angular
$scope.options.expirationDate = new Date(
$scope.options.expirationDate
);
$scope.options.expirationDate.setDate(
$scope.options.expirationDate.getDate() + 90
);
if (cb) cb();
});
}
getDefault();
getDefault(() => {
if ($routeParams.repoId && $routeParams.repoId != "") {
$scope.isUpdate = true;
$scope.repoId = $routeParams.repoId;
$http.get("/api/repo/" + $scope.repoId).then(
async (res) => {
$scope.repoUrl = "https://github.com/" + res.data.fullName;
if ($routeParams.repoId && $routeParams.repoId != "") {
$scope.isUpdate = true;
$scope.repoId = $routeParams.repoId;
$http.get("/api/repo/" + $scope.repoId).then(
async (res) => {
$scope.repoUrl = "https://github.com/" + res.data.fullName;
$scope.terms = res.data.terms.join("\n");
$scope.branch = res.data.branch;
$scope.options = res.data.options;
$scope.conference = res.data.conference;
if (res.data.options.expirationDate) {
$scope.options.expirationDate = new Date(
res.data.options.expirationDate
);
} else {
$scope.options.expirationDate = new Date();
$scope.options.expirationDate.setDate(
$scope.options.expirationDate.getDate() + 90
);
}
$scope.terms = res.data.terms.join("\n");
$scope.branch = res.data.branch;
$scope.options = res.data.options;
$scope.conference = res.data.conference;
$scope.options.expirationDate = new Date(
res.data.options.expirationDate
);
$scope.details = (await $http.get(
`/api/repo/${res.data.fullName}/`
)).data;
$scope.details = (await $http.get(
`/api/repo/${res.data.fullName}/`
)).data;
await getReadme();
await $scope.getBranches();
anonymize();
$scope.$apply();
},
(err) => {
$location.url("/404");
}
);
$scope.$watch("anonymize", () => {
$scope.anonymize.repoId.$$element[0].disabled = true;
$scope.anonymize.repoUrl.$$element[0].disabled = true;
$scope.anonymize.repositories.$$element[0].disabled = true;
});
}
await getReadme();
await $scope.getBranches();
anonymize();
$scope.$apply();
},
(err) => {
$location.url("/404");
}
);
$scope.$watch("anonymize", () => {
$scope.anonymize.repoId.$$element[0].disabled = true;
$scope.anonymize.repoUrl.$$element[0].disabled = true;
$scope.anonymize.repositories.$$element[0].disabled = true;
});
}
});
$scope.repositories = [];
@@ -936,7 +949,7 @@ angular
$scope.$on("$routeUpdate", function(event, current, old) {
$scope.filePath = $routeParams.path || "";
$scope.paths = $scope.filePath.split("/");
updateContent();
});