- create default values for starter fields
- add starter api urls - try and add TS types for initial components and objects - cleanup status indicator on layout header - create custom textfield for config form editing
This commit is contained in:
@@ -19,6 +19,9 @@ export const STREAMKEY_CHANGE = `${API_LOCATION}changekey`;
|
||||
// Current server config
|
||||
export const SERVER_CONFIG = `${API_LOCATION}serverconfig`;
|
||||
|
||||
// Base url to update config settings
|
||||
export const SERVER_CONFIG_UPDATE_URL = `${API_LOCATION}config`;
|
||||
|
||||
// Get viewer count over time
|
||||
export const VIEWERS_OVER_TIME = `${API_LOCATION}viewersOverTime`;
|
||||
|
||||
@@ -67,6 +70,12 @@ interface FetchOptions {
|
||||
};
|
||||
|
||||
export async function fetchData(url: string, options?: FetchOptions) {
|
||||
// TEMP
|
||||
export const TEMP_UPDATER_API = LOGS_ALL;
|
||||
|
||||
const GITHUB_RELEASE_URL = "https://api.github.com/repos/owncast/owncast/releases/latest";
|
||||
|
||||
export async function fetchData(url: string, options?: object) {
|
||||
const {
|
||||
data,
|
||||
method = 'GET',
|
||||
@@ -105,6 +114,7 @@ export async function fetchData(url: string, options?: FetchOptions) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
export async function getGithubRelease() {
|
||||
try {
|
||||
const response = await fetch(GITHUB_RELEASE_URL);
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import { STATUS, fetchData, FETCH_INTERVAL, SERVER_CONFIG } from './apis';
|
||||
import { UpdateArgs } from '../types/config-section';
|
||||
|
||||
export const initialServerConfigState = {
|
||||
streamKey: '',
|
||||
@@ -63,11 +64,20 @@ const ServerStatusProvider = ({ children }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const setConfigField = ({ fieldName, value }) => {
|
||||
const updatedConfig = {
|
||||
const setConfigField = ({ fieldName, value, path }: UpdateArgs) => {
|
||||
const updatedConfig = path ?
|
||||
{
|
||||
...config,
|
||||
[path]: {
|
||||
...config[path],
|
||||
[fieldName]: value,
|
||||
},
|
||||
} :
|
||||
{
|
||||
...config,
|
||||
[fieldName]: value,
|
||||
};
|
||||
|
||||
setConfig(updatedConfig);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user