Skip to content

Commit

Permalink
ui changes
Browse files Browse the repository at this point in the history
  • Loading branch information
VictoriqueMoe committed Aug 19, 2024
1 parent 6160d48 commit ab09e64
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
9 changes: 7 additions & 2 deletions src/controllers/secure/BucketView.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { Controller } from "@tsed/di";
import { Controller, Inject } from "@tsed/di";
import { Get, Hidden, View } from "@tsed/schema";
import { Authorize } from "@tsed/passport";
import type { CustomUserInfoModel } from "../../model/auth/CustomUserInfoModel";
import { Req } from "@tsed/common";
import type { Request } from "express";
import { BucketService } from "../../services/BucketService.js";

@Controller("/bucket")
@Hidden()
export class BucketView {
public constructor(@Inject() private bucketService: BucketService) {}

@Get()
@View("/secure/files.ejs")
@Authorize("bucketAuthProvider")
public showBucketPage(@Req() req: Request): unknown {
public async showBucketPage(@Req() req: Request): Promise<unknown> {
const bucket = await this.bucketService.getBucket();
return {
user: req.user as CustomUserInfoModel,
bucket,
};
}
}
20 changes: 13 additions & 7 deletions src/public/secure/files.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
<div class="row">
<div class="col-md-12">
<div class="card border-primary mb-3">
<div class="card-header">Current Entries</div>
<div class="card-header">Current Entries
<% if(typeof bucket !== "undefined"){ %>
for bucket: <%- bucket.bucketToken -%>
<% } %>
</div>
<div class="card-body">
<table class="table submissionsTable datatables display nowrap" data-type="entries">
<thead>
Expand All @@ -54,7 +58,8 @@
</div>
</div>
</div>
<div class="row mt-4" <% if(!user.email) { %> style="display:none;" <% } %> >
<div class="row mt-4"
<% if(user.email) { %>>
<div class="col-md-12">
<div class="card border-primary mb-3">
<div class="card-header">Blocked Ips</div>
Expand All @@ -71,6 +76,7 @@
</div>
</div>
</div>
<% } %>
</div>
</div>
<!--modals-->
Expand Down Expand Up @@ -187,12 +193,12 @@
const url = row.url;
const ext = url.match(/\.(mp4|ogg|webm)$/)?.[1];
let filename = data || `${row.fileName}`; // filename here is originalFileName. but hidden files do not have it, so get the filename on disk
if(ext && !data){
filename+=`.${ext}`;
if (ext && !data) {
filename += `.${ext}`;
}
if(url.match(/\.(jpeg|jpg|gif|png|webp)$/) != null){
if (url.match(/\.(jpeg|jpg|gif|png|webp)$/) != null) {
return `<span class="text-primary" data-bs-toggle="tooltip" data-bs-html="true" data-bs-title="<img src='${url}' />">${filename}</span>`;
}else if(url.match(/\.(mp4|ogg|webm)$/) != null){
} else if (url.match(/\.(mp4|ogg|webm)$/) != null) {
let type = `video/${ext}`;
const videoTag = `<video width='320' height='240' autoplay><source src='${url}' type='${type}'></video>`;
return `<span class="text-primary" data-bs-toggle="tooltip" data-bs-html="true" data-bs-title="${videoTag}">${filename}</span>`;
Expand Down Expand Up @@ -338,7 +344,7 @@
reloadTable(["entries", "ips"]);
}
},
<% } %>
<% } %>
{
extend: "selectedSingle",
text: "Details",
Expand Down
14 changes: 9 additions & 5 deletions src/public/snippets/navbar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
<a class="nav-link" id="statsNav" href="/admin/stats">Statistics</a>
</li>
<% if(user.email) { %>
<li class="nav-item">
<a class="nav-link" id="userNav" href="/admin/user">User</a>
</li>
<li class="nav-item">
<a class="nav-link" id="userNav" href="/admin/user">User</a>
</li>
<% } %>
<li class="nav-item">
<a class="nav-link" href="/rest/auth/logout">Logout</a>
<a class="nav-link" href="/rest/auth/logout">
<% if(typeof bucket === "undefined"){ %>Logout
<% }else{ %>Close bucket
<% } %>
</a>
</li>
</ul>
</div>
</div>
</nav>
</nav>

0 comments on commit ab09e64

Please sign in to comment.