mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Show local vs. external message on storage config page
This commit is contained in:
parent
83de63b1e8
commit
8e907eb8f3
@ -1,12 +1,21 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from "react";
|
||||||
import { SERVER_CONFIG, fetchData, FETCH_INTERVAL } from './utils/apis';
|
import { SERVER_CONFIG, fetchData, FETCH_INTERVAL } from "./utils/apis";
|
||||||
import KeyValueTable from './components/key-value-table';
|
import KeyValueTable from "./components/key-value-table";
|
||||||
|
|
||||||
function Storage({ config }) {
|
function Storage({ config }) {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!config.s3.enabled) {
|
||||||
|
return (
|
||||||
|
<h3>
|
||||||
|
Local storage is being used. Enable external S3 storage if you want
|
||||||
|
to use it.
|
||||||
|
</h3>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
name: "Enabled",
|
name: "Enabled",
|
||||||
@ -36,31 +45,30 @@ function Storage({ config }) {
|
|||||||
return <KeyValueTable title="External Storage" data={data} />;
|
return <KeyValueTable title="External Storage" data={data} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ServerConfig() {
|
export default function ServerConfig() {
|
||||||
const [config, setConfig] = useState();
|
const [config, setConfig] = useState();
|
||||||
|
|
||||||
const getInfo = async () => {
|
const getInfo = async () => {
|
||||||
try {
|
try {
|
||||||
const result = await fetchData(SERVER_CONFIG);
|
const result = await fetchData(SERVER_CONFIG);
|
||||||
console.log("viewers result", result)
|
console.log("viewers result", result);
|
||||||
|
|
||||||
setConfig({ ...result });
|
setConfig({ ...result });
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setConfig({ ...config, message: error.message });
|
setConfig({ ...config, message: error.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let getStatusIntervalId = null;
|
let getStatusIntervalId = null;
|
||||||
|
|
||||||
getInfo();
|
getInfo();
|
||||||
getStatusIntervalId = setInterval(getInfo, FETCH_INTERVAL);
|
getStatusIntervalId = setInterval(getInfo, FETCH_INTERVAL);
|
||||||
|
|
||||||
// returned function will be called on component unmount
|
// returned function will be called on component unmount
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(getStatusIntervalId);
|
clearInterval(getStatusIntervalId);
|
||||||
}
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -80,6 +88,5 @@ export default function ServerConfig() {
|
|||||||
<Storage config={config} />
|
<Storage config={config} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user