improve download button

This commit is contained in:
tdurieux
2021-08-12 16:01:48 +02:00
parent 1c06512241
commit 4d2defa630
3 changed files with 50 additions and 21 deletions

View File

@@ -78,8 +78,8 @@ input,
button {
outline: none;
}
*:hover,
*:active {
input:hover,
input:active {
box-shadow: none !important;
}
@@ -326,7 +326,7 @@ a:hover {
cursor: default;
}
.paths {
.status-bar {
background-color: var(--main-bg-color);
padding: 8px 6px;
margin: 0;
@@ -334,6 +334,15 @@ a:hover {
border-radius: 0;
}
.paths {
padding: 0;
margin: 0;
background-color: initial;
border: none;
border-radius: 0;
align-items: center;
}
.paths a {
color: var(--color);
}
@@ -507,3 +516,4 @@ loc .lang {
rgb(23 26 49) 100%
);
}

View File

@@ -4,24 +4,29 @@
<tree class="files" file="files"></tree>
</div>
<div class="col-md h-100 overflow-auto p-0 d-flex flex-column">
<nav aria-label="repository menu">
<ol class="breadcrumb shadow paths">
<div class="d-flex align-content-between status-bar shadow">
<ol class="flex-grow-1 breadcrumb paths">
<li class="breadcrumb-item" ng-repeat="p in paths" ng-bind="p">
Loading...
</li>
</ol>
<a ng-href="{{url}}" target="__self" class="btn btn-primary"
>Download file</a
>
<a
ng-href="/api/repo/{{repoId}}/zip"
target="__self"
class="btn btn-primary"
>Download Repository</a
>
</nav>
<div class="">
<a
ng-if="options.download"
ng-href="{{url}}"
target="__self"
class="btn btn-outline-primary btn-sm"
>Download file</a
>
<a
ng-if="options.download"
ng-href="/api/repo/{{repoId}}/zip"
target="__self"
class="btn btn-outline-primary btn-sm"
>Download Repository</a
>
</div>
</div>
<div class="align-items-stretch h-100 w-100 overflow-auto">
<ng-include src="'./partials/pageView.htm'"></ng-include>
</div>

View File

@@ -50,12 +50,26 @@ router.get(
router.get(
"/:repoId/options",
async (req: express.Request, res: express.Response) => {
const repo = await getRepo(req, res);
if (!repo) return;
try {
const repo = await getRepo(req, res, { nocheck: true });
let redirectURL = null;
if (
repo.status == "expired" &&
repo.options.expirationMode == "redirect" &&
repo.source.url
) {
redirectURL = repo.source.url;
} else {
repo.check();
}
await repo.updateIfNeeded();
res.json(repo.options);
res.json({
url: redirectURL,
download: !!config.ENABLE_DOWNLOAD,
});
} catch (error) {
handleError(error, res);
}