Skip to content

Commit e874017

Browse files
committed
bug fixes
1 parent 8ea629a commit e874017

File tree

8 files changed

+65
-8
lines changed

8 files changed

+65
-8
lines changed

portal/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"generate-api": "npx acts-util-apilib",
8-
"start-dev": "webpack serve --open"
8+
"start-dev": "webpack serve --open",
9+
"build": "npx webpack --config webpack.config.production.js && (cd dist && ln -s ../static static && zip -j -r -9 odfs-portal-release.zip bundle.js static env.js && rm static)"
910
},
1011
"keywords": [],
1112
"author": "Amir Czwink",

portal/src/APIService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* */
1818
import { API } from "../dist/api";
1919
import { APIServiceBase, HTTPService, Injectable, OAuth2TokenManager } from "acfrontend";
20-
import { CONFIG_BACKEND, CONFIG_BACKENDPORT, CONFIG_OIDC } from "./config";
20+
import { CONFIG_BACKEND, CONFIG_OIDC } from "./config";
2121
import { SCOPE_FILES_WRITE } from "./definitions";
2222

2323
@Injectable
@@ -27,7 +27,7 @@ export class APIService extends API
2727
{
2828
super( req => this.base.SendRequest(req) );
2929

30-
this.base = new APIServiceBase(httpService, CONFIG_BACKEND, CONFIG_BACKENDPORT, "http");
30+
this.base = new APIServiceBase(httpService, CONFIG_BACKEND.host, CONFIG_BACKEND.port, CONFIG_BACKEND.protocol);
3131

3232
oAuth2TokenManager.tokenIssued.Subscribe(x => this.accessToken = x.accessToken);
3333
}

portal/src/config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818

1919
import { OAuth2Config } from "acfrontend";
2020

21-
export const CONFIG_BACKEND = process.env.ODFS_BACKEND!;
22-
export const CONFIG_BACKENDPORT = parseInt(process.env.ODFS_BACKEND_PORT!);
21+
export const CONFIG_BACKEND = {
22+
host: process.env.ODFS_BACKEND_HOST!,
23+
port: parseInt(process.env.ODFS_BACKEND_PORT!),
24+
protocol: process.env.ODFS_BACKEND_PROTOCOL! as "http" | "https",
25+
};
2326

2427
export const CONFIG_OIDC: OAuth2Config = {
2528
flow: "authorizationCode",

portal/src/file-explorer/content/VideoStreamComponent.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import { Component, FormField, Injectable, JSX_CreateElement, JSX_Fragment, ProgressSpinner, RouteParamProperty, Select } from "acfrontend";
2020
import { APIService } from "../../APIService";
2121
import { StreamingRequestResultDTO } from "../../../dist/api";
22-
import { CONFIG_BACKEND, CONFIG_BACKENDPORT } from "../../config";
22+
import { CONFIG_BACKEND } from "../../config";
2323

2424
@Injectable
2525
export class VideoStreamComponent extends Component
@@ -37,6 +37,8 @@ export class VideoStreamComponent extends Component
3737
{
3838
if(this.data === null)
3939
return <ProgressSpinner />;
40+
if(this.data.options.length === 0)
41+
return "This video can't be viewed!";
4042

4143
const sel = this.data.options[this.selectedIndex];
4244
return <>
@@ -55,7 +57,7 @@ export class VideoStreamComponent extends Component
5557
private GetSelectedVideoURL()
5658
{
5759
const sel = this.data!.options[this.selectedIndex];
58-
return `http://${CONFIG_BACKEND}:${CONFIG_BACKENDPORT}/stream?blobId=${sel.blobId}&streamingKey=${this.data!.streamingKey}`;
60+
return `${CONFIG_BACKEND.protocol}://${CONFIG_BACKEND.host}:${CONFIG_BACKEND.port}/stream?blobId=${sel.blobId}&streamingKey=${this.data!.streamingKey}`;
5961
}
6062

6163
private async LoadPoster()

portal/static/index.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
1010
</head>
1111
<body>
12+
<script src="./env.js"></script>
1213
<script src="./bundle.js"></script>
1314
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
1415
</body>

portal/webpack.config.production.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
mode: 'production',
5+
entry: "./src/app.ts",
6+
7+
output: {
8+
filename: 'bundle.js',
9+
path: path.resolve(__dirname, 'dist'),
10+
},
11+
12+
resolve: {
13+
extensions: [".ts", ".tsx", ".js"],
14+
},
15+
16+
module: {
17+
rules: [
18+
{
19+
test: /\.ts(x?)$/,
20+
exclude: /node_modules/,
21+
use: [
22+
{
23+
loader: "ts-loader"
24+
}
25+
]
26+
},
27+
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
28+
{
29+
enforce: "pre",
30+
test: /\.js$/,
31+
loader: "source-map-loader"
32+
}
33+
]
34+
},
35+
};

service/src/data-access/FileVersionsController.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface FileVersion
2727

2828
@Injectable
2929
export class FileVersionsController
30-
{
30+
{
3131
constructor(private dbConnMgr: DBConnectionsManager)
3232
{
3333
}
@@ -43,6 +43,18 @@ export class FileVersionsController
4343
});
4444
}
4545

46+
public async ClearByPrefix(fileId: number, titlePrefix: string)
47+
{
48+
const conn = await this.dbConnMgr.CreateAnyConnectionQueryExecutor();
49+
await conn.DeleteRows("files_versions", "fileId = ? AND title LIKE ?", fileId, titlePrefix + "%");
50+
}
51+
52+
public async Delete(fileId: number, title: string)
53+
{
54+
const conn = await this.dbConnMgr.CreateAnyConnectionQueryExecutor();
55+
await conn.DeleteRows("files_versions", "fileId = ? AND title = ?", fileId, title);
56+
}
57+
4658
public async QueryVersions(fileId: number)
4759
{
4860
const conn = await this.dbConnMgr.CreateAnyConnectionQueryExecutor();

service/src/services/ThumbnailService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export class ThumbnailService
6565
const mediaInfo = await this.ffProbeService.AnalyzeMediaFile(mediaFilePath);
6666
await this.blobsController.WriteMetaData(blobId, "av", JSON.stringify(mediaInfo));
6767

68+
await this.fileVersionsController.ClearByPrefix(fileId, "thumb_");
69+
await this.fileVersionsController.Delete(fileId, "preview");
70+
6871
if(!mediaType.startsWith("audio/"))
6972
{
7073
const isImage = mediaType.startsWith("image/");

0 commit comments

Comments
 (0)