From 5fc955d2a148acb34837a1007472f69c76013115 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sun, 31 Jan 2021 19:45:26 -0800 Subject: [PATCH 1/2] storage form --- web/pages/config-storage.tsx | 140 ++++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 58 deletions(-) diff --git a/web/pages/config-storage.tsx b/web/pages/config-storage.tsx index 6c1f5e3d0..e46713350 100644 --- a/web/pages/config-storage.tsx +++ b/web/pages/config-storage.tsx @@ -1,9 +1,10 @@ -import React, { useContext } from "react"; -import KeyValueTable from "./components/key-value-table"; +import React, { useContext, useState, useEffect } from 'react'; import { ServerStatusContext } from '../utils/server-status-context'; -import { Typography } from 'antd'; -import Link from 'next/link'; - +import { Typography, Switch, Input, Button } from 'antd'; +import { + postConfigUpdateToAPI, + API_S3_INFO, +} from './components/config/constants'; const { Title } = Typography; function Storage({ config }) { @@ -11,66 +12,89 @@ function Storage({ config }) { return null; } - if (!config.s3.enabled) { - return ( -
- External Storage -

- You are currently using the local storage of this Owncast server to store and distribute video. -

-

- Owncast can use S3-compatible external storage providers to offload the responsibility of disk and bandwidth utilization from your own server. -

+ const [endpoint, setEndpoint] = useState(config.s3.endpoint); + const [accessKey, setAccessKey] = useState(config.s3.accessKey); + const [secret, setSecret] = useState(config.s3.secret); + const [bucket, setBucket] = useState(config.s3.bucket); + const [region, setRegion] = useState(config.s3.region); + const [acl, setAcl] = useState(config.s3.acl); + const [servingEndpoint, setServingEndpoint] = useState(config.s3.servingEndpoint); + const [enabled, setEnabled] = useState(config.s3.enabled); -

- Visit our storage documentation to learn how to configure this. -

-
- ); + function storageEnabledChanged(storageEnabled) { + setEnabled(storageEnabled); } - const data = [ - { - 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, - }, - ]; + function endpointChanged(e) { + setEndpoint(e.target.value) + } - const advanced = [ - { - name: "ACL", - value: config.s3.acl - }, - { - name: "Serving Endpoint", - value: config.s3.servingEndpoint - }, - ]; + function accessKeyChanged(e) { + setAccessKey(e.target.value) + } + + function secretChanged(e) { + setSecret(e.target.value) + } + + 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 ? ( + <> +

+ endpoint + access key + secret + bucket + region + advanced

+ acl + serving endpoint + + + ): null; return ( <> - - + Storage + Enabled: + + { table } ); } From 3290297eedc9fdbadf950a588eeb67a1134dcbbe Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sun, 31 Jan 2021 20:06:38 -0800 Subject: [PATCH 2/2] Force build on any branch --- web/.github/workflows/build-next.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/web/.github/workflows/build-next.yml b/web/.github/workflows/build-next.yml index d35c03938..d9d713f0f 100644 --- a/web/.github/workflows/build-next.yml +++ b/web/.github/workflows/build-next.yml @@ -1,11 +1,5 @@ name: Build admin app -on: - push: - branches: - - master - pull_request: - branches: master - +on: [push, pull_request] jobs: run: name: npm run build