mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-06 05:38:09 +02:00
fix: fix action menu in the admin
This commit is contained in:
@@ -245,6 +245,64 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="d-flex">
|
||||||
|
<div class="dropdown">
|
||||||
|
<button
|
||||||
|
class="btn black_border dropdown-toggle btn-sm"
|
||||||
|
type="button"
|
||||||
|
id="dropdownMenuButton"
|
||||||
|
data-toggle="dropdown"
|
||||||
|
aria-haspopup="true"
|
||||||
|
aria-expanded="false"
|
||||||
|
>
|
||||||
|
Actions
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||||
|
<a class="dropdown-item" href="#" ng-click="removeCache(repo)">
|
||||||
|
<i class="fas fa-trash-alt"></i> Remove Cache
|
||||||
|
</a>
|
||||||
|
<a class="dropdown-item" href="/anonymize/{{repo.repoId}}">
|
||||||
|
<i class="far fa-edit" aria-hidden="true"></i> Edit
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
class="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
ng-show="repo.status == 'ready' || repo.status == 'error'"
|
||||||
|
ng-click="updateRepository(repo)"
|
||||||
|
>
|
||||||
|
<i class="fas fa-sync"></i> Force update
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
class="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
ng-show="repo.status == 'removed'"
|
||||||
|
ng-click="updateRepository(repo)"
|
||||||
|
>
|
||||||
|
<i class="fas fa-check-circle"></i>
|
||||||
|
Enable
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
class="dropdown-item"
|
||||||
|
href="#"
|
||||||
|
ng-show="repo.status == 'ready'"
|
||||||
|
ng-click="removeRepository(repo)"
|
||||||
|
>
|
||||||
|
<i class="fas fa-trash-alt"></i> Remove
|
||||||
|
</a>
|
||||||
|
<a class="dropdown-item" href="/r/{{repo.repoId}}/">
|
||||||
|
<i class="fa fa-eye" aria-hidden="true"></i> View Repo
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
class="dropdown-item"
|
||||||
|
href="/w/{{repo.repoId}}/"
|
||||||
|
target="_self"
|
||||||
|
ng-if="repo.options.page && repo.status == 'ready'"
|
||||||
|
>
|
||||||
|
<i class="fas fa-globe"></i> View Page
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
class="col-12 d-flex px-0 py-3 border-bottom color-border-secondary"
|
class="col-12 d-flex px-0 py-3 border-bottom color-border-secondary"
|
||||||
|
|||||||
+60
-1
@@ -39,13 +39,37 @@ angular
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.updateRepository = (repo) => {
|
||||||
|
const toast = {
|
||||||
|
title: `Refreshing ${repo.repoId}...`,
|
||||||
|
date: new Date(),
|
||||||
|
body: `The repository ${repo.repoId} is going to be refreshed.`,
|
||||||
|
};
|
||||||
|
$scope.toasts.push(toast);
|
||||||
|
repo.s;
|
||||||
|
|
||||||
|
$http.post(`/api/repo/${repo.repoId}/refresh`).then(
|
||||||
|
(res) => {
|
||||||
|
if (res.data.status == "ready") {
|
||||||
|
toast.title = `${repo.repoId} is refreshed.`;
|
||||||
|
} else {
|
||||||
|
toast.title = `Refreshing of ${repo.repoId}.`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
toast.title = `Error during the refresh of ${repo.repoId}.`;
|
||||||
|
toast.body = error.body;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
function getRepositories() {
|
function getRepositories() {
|
||||||
$http.get("/api/admin/repos", { params: $scope.query }).then(
|
$http.get("/api/admin/repos", { params: $scope.query }).then(
|
||||||
(res) => {
|
(res) => {
|
||||||
$scope.total = res.data.total;
|
$scope.total = res.data.total;
|
||||||
$scope.totalPage = Math.ceil(res.data.total / $scope.query.limit);
|
$scope.totalPage = Math.ceil(res.data.total / $scope.query.limit);
|
||||||
$scope.repositories = res.data.results;
|
$scope.repositories = res.data.results;
|
||||||
$scope.$apply();
|
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@@ -172,6 +196,41 @@ angular
|
|||||||
getUser($routeParams.username);
|
getUser($routeParams.username);
|
||||||
getUserRepositories($routeParams.username);
|
getUserRepositories($routeParams.username);
|
||||||
|
|
||||||
|
$scope.removeCache = (repo) => {
|
||||||
|
$http.delete("/api/admin/repos/" + repo.repoId).then(
|
||||||
|
(res) => {
|
||||||
|
$scope.$apply();
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.updateRepository = (repo) => {
|
||||||
|
const toast = {
|
||||||
|
title: `Refreshing ${repo.repoId}...`,
|
||||||
|
date: new Date(),
|
||||||
|
body: `The repository ${repo.repoId} is going to be refreshed.`,
|
||||||
|
};
|
||||||
|
$scope.toasts.push(toast);
|
||||||
|
repo.s;
|
||||||
|
|
||||||
|
$http.post(`/api/repo/${repo.repoId}/refresh`).then(
|
||||||
|
(res) => {
|
||||||
|
if (res.data.status == "ready") {
|
||||||
|
toast.title = `${repo.repoId} is refreshed.`;
|
||||||
|
} else {
|
||||||
|
toast.title = `Refreshing of ${repo.repoId}.`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
toast.title = `Error during the refresh of ${repo.repoId}.`;
|
||||||
|
toast.body = error.body;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
let timeClear = null;
|
let timeClear = null;
|
||||||
$scope.$watch(
|
$scope.$watch(
|
||||||
"query",
|
"query",
|
||||||
|
|||||||
+5
-2
@@ -196,7 +196,7 @@ export default class Repository {
|
|||||||
const newCommit = branches.filter((f) => f.name == branch.name)[0]
|
const newCommit = branches.filter((f) => f.name == branch.name)[0]
|
||||||
?.commit;
|
?.commit;
|
||||||
if (branch.commit == newCommit && this.status == "ready") {
|
if (branch.commit == newCommit && this.status == "ready") {
|
||||||
console.log(`${this._model.repoId} is up to date`);
|
console.log(`[UPDATE] ${this._model.repoId} is up to date`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._model.source.commit = newCommit;
|
this._model.source.commit = newCommit;
|
||||||
@@ -370,7 +370,10 @@ export default class Repository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get originalCachePath() {
|
get originalCachePath() {
|
||||||
return join(this._model.repoId, "original") + (process.platform === "win32" ? "\\" : "/");
|
return (
|
||||||
|
join(this._model.repoId, "original") +
|
||||||
|
(process.platform === "win32" ? "\\" : "/")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get status() {
|
get status() {
|
||||||
|
|||||||
+15
-7
@@ -139,17 +139,25 @@ router.get("/repos", async (req, res) => {
|
|||||||
status.push({ status: "download" });
|
status.push({ status: "download" });
|
||||||
}
|
}
|
||||||
const skipIndex = (page - 1) * limit;
|
const skipIndex = (page - 1) * limit;
|
||||||
|
const [total, results] = await Promise.all([
|
||||||
|
AnonymizedRepositoryModel.find(
|
||||||
|
{
|
||||||
|
$and: query,
|
||||||
|
},
|
||||||
|
{ originalFiles: 0 }
|
||||||
|
).countDocuments(),
|
||||||
|
AnonymizedRepositoryModel.find({ $and: query }, { originalFiles: 0 })
|
||||||
|
.skip(skipIndex)
|
||||||
|
.sort(sort)
|
||||||
|
.limit(limit)
|
||||||
|
.exec(),
|
||||||
|
]);
|
||||||
res.json({
|
res.json({
|
||||||
query: { $and: query },
|
query: { $and: query },
|
||||||
page,
|
page,
|
||||||
total: await AnonymizedRepositoryModel.find({
|
total,
|
||||||
$and: query,
|
|
||||||
}).countDocuments(),
|
|
||||||
sort,
|
sort,
|
||||||
results: await AnonymizedRepositoryModel.find({ $and: query })
|
results,
|
||||||
.sort(sort)
|
|
||||||
.limit(limit)
|
|
||||||
.skip(skipIndex),
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user