diff --git a/public/partials/dashboard.htm b/public/partials/dashboard.htm index 5c3f262..244966d 100644 --- a/public/partials/dashboard.htm +++ b/public/partials/dashboard.htm @@ -155,7 +155,10 @@
Repository -
+
File -
+
Force update @@ -386,7 +392,7 @@ Remove @@ -398,7 +404,7 @@ class="dropdown-item" href="/w/{{repo.repoId}}/" target="_self" - ng-if="repo.options.page" + ng-if="repo.options.page && repo.status == 'ready'" > View Page diff --git a/public/script/app.js b/public/script/app.js index 4e23d0b..d3b56af 100644 --- a/public/script/app.js +++ b/public/script/app.js @@ -622,6 +622,27 @@ angular } getRepositories(); + function waitRepoToBeReady(repoId, callback) { + $http.get("/api/repo/" + repoId).then((res) => { + for (const repo of $scope.repositories) { + if (repo.repoId == repoId) { + repo.status = res.data.status; + break; + } + } + if ( + res.data.status == "ready" || + res.data.status == "error" || + res.data.status == "removed" || + res.data.status == "expired" + ) { + callback(res.data); + return; + } + setTimeout(() => waitRepoToBeReady(repoId), 2500); + }); + } + $scope.removeRepository = (repo) => { if ( confirm( @@ -636,12 +657,11 @@ angular $scope.toasts.push(toast); $http.delete(`/api/repo/${repo.repoId}`).then( () => { - setTimeout(() => { + waitRepoToBeReady(repo.repoId, () => { toast.title = `${repo.repoId} is removed.`; toast.body = `The repository ${repo.repoId} is removed.`; - getRepositories(); $scope.$apply(); - }, 5000); + }); }, (error) => { toast.title = `Error during the removal of ${repo.repoId}.`; @@ -663,12 +683,11 @@ angular $http.post(`/api/repo/${repo.repoId}/refresh`).then( () => { - setTimeout(() => { + waitRepoToBeReady(repo.repoId, () => { toast.title = `${repo.repoId} is refreshed.`; toast.body = `The repository ${repo.repoId} is refreshed.`; - getRepositories(); $scope.$apply(); - }, 5000); + }); }, (error) => { toast.title = `Error during the refresh of ${repo.repoId}.`;