mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
storage form
This commit is contained in:
parent
07f78324fc
commit
5fc955d2a1
@ -1,9 +1,10 @@
|
|||||||
import React, { useContext } from "react";
|
import React, { useContext, useState, useEffect } from 'react';
|
||||||
import KeyValueTable from "./components/key-value-table";
|
|
||||||
import { ServerStatusContext } from '../utils/server-status-context';
|
import { ServerStatusContext } from '../utils/server-status-context';
|
||||||
import { Typography } from 'antd';
|
import { Typography, Switch, Input, Button } from 'antd';
|
||||||
import Link from 'next/link';
|
import {
|
||||||
|
postConfigUpdateToAPI,
|
||||||
|
API_S3_INFO,
|
||||||
|
} from './components/config/constants';
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
|
|
||||||
function Storage({ config }) {
|
function Storage({ config }) {
|
||||||
@ -11,66 +12,89 @@ function Storage({ config }) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.s3.enabled) {
|
const [endpoint, setEndpoint] = useState(config.s3.endpoint);
|
||||||
return (
|
const [accessKey, setAccessKey] = useState(config.s3.accessKey);
|
||||||
<div>
|
const [secret, setSecret] = useState(config.s3.secret);
|
||||||
<Title>External Storage</Title>
|
const [bucket, setBucket] = useState(config.s3.bucket);
|
||||||
<p>
|
const [region, setRegion] = useState(config.s3.region);
|
||||||
You are currently using the <Link href="/hardware-info">local storage of this Owncast server</Link> to store and distribute video.
|
const [acl, setAcl] = useState(config.s3.acl);
|
||||||
</p>
|
const [servingEndpoint, setServingEndpoint] = useState(config.s3.servingEndpoint);
|
||||||
<p>
|
const [enabled, setEnabled] = useState(config.s3.enabled);
|
||||||
Owncast can use S3-compatible external storage providers to offload the responsibility of disk and bandwidth utilization from your own server.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
function storageEnabledChanged(storageEnabled) {
|
||||||
Visit our <a href="https://owncast.online/docs/s3/">storage documentation</a> to learn how to configure this.
|
setEnabled(storageEnabled);
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = [
|
function endpointChanged(e) {
|
||||||
{
|
setEndpoint(e.target.value)
|
||||||
name: "Enabled",
|
}
|
||||||
value: config.s3.enabled.toString(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Endpoint",
|
|
||||||
value: config.s3.endpoint,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Access Key",
|
|
||||||
value: config.s3.accessKey,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Secret",
|
|
||||||
value: config.s3.secret,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Bucket",
|
|
||||||
value: config.s3.bucket,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Region",
|
|
||||||
value: config.s3.region,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const advanced = [
|
function accessKeyChanged(e) {
|
||||||
{
|
setAccessKey(e.target.value)
|
||||||
name: "ACL",
|
}
|
||||||
value: config.s3.acl
|
|
||||||
},
|
function secretChanged(e) {
|
||||||
{
|
setSecret(e.target.value)
|
||||||
name: "Serving Endpoint",
|
}
|
||||||
value: config.s3.servingEndpoint
|
|
||||||
},
|
function bucketChanged(e) {
|
||||||
];
|
setBucket(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function regionChanged(e) {
|
||||||
|
setRegion(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function aclChanged(e) {
|
||||||
|
setAcl(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function servingEndpointChanged(e) {
|
||||||
|
setServingEndpoint(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
const payload = {
|
||||||
|
value: {
|
||||||
|
enabled: enabled,
|
||||||
|
endpoint: endpoint,
|
||||||
|
accessKey: accessKey,
|
||||||
|
secret: secret,
|
||||||
|
bucket: bucket,
|
||||||
|
region: region,
|
||||||
|
acl: acl,
|
||||||
|
servingEndpoint: servingEndpoint,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
await postConfigUpdateToAPI({apiPath: API_S3_INFO, data: payload});
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const table = enabled ? (
|
||||||
|
<>
|
||||||
|
<br></br>
|
||||||
|
endpoint <Input defaultValue={endpoint} value={endpoint} onChange={endpointChanged} />
|
||||||
|
access key<Input label="Access key" defaultValue={accessKey} value={accessKey} onChange={accessKeyChanged} />
|
||||||
|
secret <Input label="Secret" defaultValue={secret} value={secret} onChange={secretChanged} />
|
||||||
|
bucket <Input label="Bucket" defaultValue={bucket} value={bucket} onChange={bucketChanged} />
|
||||||
|
region <Input label="Region" defaultValue={region} value={region} onChange={regionChanged} />
|
||||||
|
advanced<br></br>
|
||||||
|
acl <Input label="ACL" defaultValue={acl} value={acl} onChange={aclChanged} />
|
||||||
|
serving endpoint <Input label="Serving endpoint" defaultValue={servingEndpoint} value={servingEndpoint} onChange={servingEndpointChanged} />
|
||||||
|
<Button onClick={save}>Save</Button>
|
||||||
|
</>
|
||||||
|
): null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<KeyValueTable title="External Storage" data={data} />
|
<Title level={2}>Storage</Title>
|
||||||
<KeyValueTable title="Advanced options" data={advanced} />
|
Enabled:
|
||||||
|
<Switch checked={enabled} onChange={storageEnabledChanged} />
|
||||||
|
{ table }
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user