mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-24 22:14:18 +00:00
🧹 Reformat code
This commit is contained in:
parent
70fe072b5e
commit
809d86758c
50 changed files with 207 additions and 194 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { Route, Switch } from "react-router"
|
import { Route, Switch } from "react-router"
|
||||||
import PageLogin from "./routes/PageLogin"
|
import PageLogin from "./routes/PageLogin"
|
||||||
import PageRepositories from "./routes/PageRepositories"
|
import PageRepositories from "./routes/PageRepositories"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import Style from "./Button.module.css"
|
import Style from "./Button.module.css"
|
||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
import make_icon from "../../utils/make_icon"
|
import make_icon from "../../utils/make_icon"
|
||||||
|
|
|
@ -22,7 +22,7 @@ export default function ButtonSidebar({ icon, children, to, className, ...props
|
||||||
path: to,
|
path: to,
|
||||||
strict: true,
|
strict: true,
|
||||||
exact: true,
|
exact: true,
|
||||||
});
|
})
|
||||||
|
|
||||||
if(match) {
|
if(match) {
|
||||||
className = classNames(Style.Active, className)
|
className = classNames(Style.Active, className)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import Style from "./ButtonSmallX.module.css"
|
import Style from "./ButtonSmallX.module.css"
|
||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
import { faTimes } from "@fortawesome/free-solid-svg-icons"
|
import { faTimes } from "@fortawesome/free-solid-svg-icons"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, {useState} from "react"
|
import React, { useState } from "react"
|
||||||
import Style from "./InputWithIcon.module.css"
|
import Style from "./InputWithIcon.module.css"
|
||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
import make_icon from "../../utils/make_icon"
|
import make_icon from "../../utils/make_icon"
|
||||||
|
@ -17,7 +17,7 @@ import make_icon from "../../utils/make_icon"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function InputWithIcon({ icon, className, ...props }) {
|
export default function InputWithIcon({ icon, className, ...props }) {
|
||||||
const [isFocused, setFocused] = useState(false);
|
const [isFocused, setFocused] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(Style.InputWithIcon, isFocused ? Style.Focused : null, className)}>
|
<div className={classNames(Style.InputWithIcon, isFocused ? Style.Focused : null, className)}>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { faSpinner } from "@fortawesome/free-solid-svg-icons"
|
import { faSpinner } from "@fortawesome/free-solid-svg-icons"
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React from "react"
|
||||||
import Style from "./Radio.module.css"
|
import Style from "./Radio.module.css"
|
||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A radio button.
|
* A radio button.
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,7 +15,10 @@ import classNames from "classnames"
|
||||||
*/
|
*/
|
||||||
export default function TextArea({ resize, children, className, ...props }) {
|
export default function TextArea({ resize, children, className, ...props }) {
|
||||||
return (
|
return (
|
||||||
<textarea className={classNames(Style.TextArea, resize ? Style.TextAreaResizable : Style.TextAreaNoResize, className)} {...props}>
|
<textarea
|
||||||
|
className={classNames(Style.TextArea, resize
|
||||||
|
? Style.TextAreaResizable
|
||||||
|
: Style.TextAreaNoResize, className)} {...props}>
|
||||||
{children}
|
{children}
|
||||||
</textarea>
|
</textarea>
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,7 +16,7 @@ import Style from "./FormLabel.module.css"
|
||||||
export default function FormLabel({ children, text, htmlFor }) {
|
export default function FormLabel({ children, text, htmlFor }) {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<label htmlFor={htmlFor} className={Style.LabelText} >
|
<label htmlFor={htmlFor} className={Style.LabelText}>
|
||||||
{text}
|
{text}
|
||||||
</label>
|
</label>
|
||||||
<div className={Style.LabelContent}>
|
<div className={Style.LabelContent}>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useState } from "react"
|
import React, { useState } from "react"
|
||||||
import BoxFull from "../base/BoxFull"
|
import BoxFull from "../base/BoxFull"
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
import { faAt, faClock, faPlus } from "@fortawesome/free-solid-svg-icons"
|
import { faClock, faPlus } from "@fortawesome/free-solid-svg-icons"
|
||||||
import InputWithIcon from "../base/InputWithIcon"
|
import InputWithIcon from "../base/InputWithIcon"
|
||||||
import FormInline from "../base/FormInline"
|
import FormInline from "../base/FormInline"
|
||||||
import Style from "./BoxConditionDatetime.module.css"
|
import Style from "./BoxConditionDatetime.module.css"
|
||||||
|
@ -26,7 +26,7 @@ const INVALID_USER_CHARACTERS = /[^0-9TZ:+-]/g
|
||||||
export default function BoxConditionDatetime({ ...props }) {
|
export default function BoxConditionDatetime({ ...props }) {
|
||||||
const [datetime, setDatetime] = useState("")
|
const [datetime, setDatetime] = useState("")
|
||||||
const [ba, setBa] = useState(false)
|
const [ba, setBa] = useState(false)
|
||||||
const {addCondition} = useRepositoryEditor()
|
const { addCondition } = useRepositoryEditor()
|
||||||
|
|
||||||
const onInputChange = event => {
|
const onInputChange = event => {
|
||||||
let text = event.target.value
|
let text = event.target.value
|
||||||
|
@ -38,7 +38,7 @@ export default function BoxConditionDatetime({ ...props }) {
|
||||||
const onButtonClick = e => {
|
const onButtonClick = e => {
|
||||||
const naive = new Date(datetime)
|
const naive = new Date(datetime)
|
||||||
if(naive.toString() === "Invalid Date") {
|
if(naive.toString() === "Invalid Date") {
|
||||||
console.debug("Refusing to add condition: ", naive , " is an Invalid Date.")
|
console.debug("Refusing to add condition: ", naive, " is an Invalid Date.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const aware = convertToLocalISODate(naive)
|
const aware = convertToLocalISODate(naive)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { useState } from "react"
|
import React, { useState } from "react"
|
||||||
import BoxFull from "../base/BoxFull"
|
import BoxFull from "../base/BoxFull"
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
import { faHashtag, faPlus } from "@fortawesome/free-solid-svg-icons"
|
import { faHashtag, faPlus } from "@fortawesome/free-solid-svg-icons"
|
||||||
import InputWithIcon from "../base/InputWithIcon"
|
import InputWithIcon from "../base/InputWithIcon"
|
||||||
import FormInline from "../base/FormInline"
|
import FormInline from "../base/FormInline"
|
||||||
|
@ -24,7 +24,7 @@ const INVALID_HASHTAG_CHARACTERS = /([^a-z0-9_\u00c0-\u00d6\u00d8-\u00f6\u00f8-\
|
||||||
*/
|
*/
|
||||||
export default function BoxConditionHashtag({ ...props }) {
|
export default function BoxConditionHashtag({ ...props }) {
|
||||||
const [hashtag, setHashtag] = useState("")
|
const [hashtag, setHashtag] = useState("")
|
||||||
const {addCondition} = useRepositoryEditor()
|
const { addCondition } = useRepositoryEditor()
|
||||||
|
|
||||||
const onInputChange = event => {
|
const onInputChange = event => {
|
||||||
let text = event.target.value
|
let text = event.target.value
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
import React, { useCallback, useState, useRef, useMemo, useEffect } from "react"
|
import React, { useCallback, useEffect, useState } from "react"
|
||||||
import BoxFull from "../base/BoxFull"
|
import BoxFull from "../base/BoxFull"
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
import { faMapPin, faPlus } from "@fortawesome/free-solid-svg-icons"
|
import { faMapPin, faPlus } from "@fortawesome/free-solid-svg-icons"
|
||||||
import FormInline from "../base/FormInline"
|
|
||||||
import Style from "./BoxConditionMap.module.css"
|
import Style from "./BoxConditionMap.module.css"
|
||||||
import ButtonIconOnly from "../base/ButtonIconOnly"
|
import ButtonIconOnly from "../base/ButtonIconOnly"
|
||||||
import { MapContainer, Marker, TileLayer } from "react-leaflet"
|
import { MapContainer, TileLayer } from "react-leaflet"
|
||||||
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
|
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
|
||||||
import Condition from "../../utils/Condition"
|
import Condition from "../../utils/Condition"
|
||||||
|
|
||||||
|
|
||||||
const STARTING_POSITION = {lat: 41.89309, lng: 12.48289}
|
const STARTING_POSITION = { lat: 41.89309, lng: 12.48289 }
|
||||||
const STARTING_ZOOM = 3
|
const STARTING_ZOOM = 3
|
||||||
|
|
||||||
// FIXME: this only works correctly at the equator!
|
// FIXME: this only works correctly at the equator!
|
||||||
/**
|
/**
|
||||||
* https://wiki.openstreetmap.org/wiki/Zoom_levels
|
* https://wiki.openstreetmap.org/wiki/Zoom_levels
|
||||||
*/
|
*/
|
||||||
const MPIXEL = [
|
const MPIXEL = [
|
||||||
156412,
|
156412,
|
||||||
78206,
|
78206,
|
||||||
|
@ -53,25 +52,27 @@ export default function BoxConditionMap({ ...props }) {
|
||||||
const [position, setPosition] = useState(STARTING_POSITION)
|
const [position, setPosition] = useState(STARTING_POSITION)
|
||||||
const [zoom, setZoom] = useState(STARTING_ZOOM)
|
const [zoom, setZoom] = useState(STARTING_ZOOM)
|
||||||
const [map, setMap] = useState(null)
|
const [map, setMap] = useState(null)
|
||||||
const {addCondition} = useRepositoryEditor()
|
const { addCondition } = useRepositoryEditor()
|
||||||
|
|
||||||
const onMove = useCallback(
|
const onMove = useCallback(
|
||||||
() => {
|
() => {
|
||||||
setPosition(map.getCenter())
|
setPosition(map.getCenter())
|
||||||
},
|
},
|
||||||
[map]
|
[map],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onZoom = useCallback(
|
const onZoom = useCallback(
|
||||||
() => {
|
() => {
|
||||||
setZoom(map.getZoom())
|
setZoom(map.getZoom())
|
||||||
},
|
},
|
||||||
[map]
|
[map],
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if(map === null) return
|
if(map === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
map.on("move", onMove)
|
map.on("move", onMove)
|
||||||
map.on("zoom", onZoom)
|
map.on("zoom", onZoom)
|
||||||
|
@ -80,7 +81,7 @@ export default function BoxConditionMap({ ...props }) {
|
||||||
map.off("zoom", onZoom)
|
map.off("zoom", onZoom)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[map]
|
[map],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onButtonClick = () => {
|
const onButtonClick = () => {
|
||||||
|
@ -90,7 +91,7 @@ export default function BoxConditionMap({ ...props }) {
|
||||||
|
|
||||||
addCondition(new Condition(
|
addCondition(new Condition(
|
||||||
"COORDINATES",
|
"COORDINATES",
|
||||||
`< ${radius} ${position.lat} ${position.lng}`
|
`< ${radius} ${position.lat} ${position.lng}`,
|
||||||
))
|
))
|
||||||
setPosition(STARTING_POSITION)
|
setPosition(STARTING_POSITION)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { useState } from "react"
|
import React, { useState } from "react"
|
||||||
import BoxFull from "../base/BoxFull"
|
import BoxFull from "../base/BoxFull"
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
import { faAt, faPlus } from "@fortawesome/free-solid-svg-icons"
|
import { faAt, faPlus } from "@fortawesome/free-solid-svg-icons"
|
||||||
import InputWithIcon from "../base/InputWithIcon"
|
import InputWithIcon from "../base/InputWithIcon"
|
||||||
import FormInline from "../base/FormInline"
|
import FormInline from "../base/FormInline"
|
||||||
|
@ -23,7 +23,7 @@ const INVALID_USER_CHARACTERS = /[^a-zA-Z0-9]/g
|
||||||
*/
|
*/
|
||||||
export default function BoxConditionUser({ ...props }) {
|
export default function BoxConditionUser({ ...props }) {
|
||||||
const [user, setUser] = useState("")
|
const [user, setUser] = useState("")
|
||||||
const {addCondition} = useRepositoryEditor()
|
const { addCondition } = useRepositoryEditor()
|
||||||
|
|
||||||
const onInputChange = event => {
|
const onInputChange = event => {
|
||||||
let text = event.target.value
|
let text = event.target.value
|
||||||
|
|
|
@ -12,7 +12,7 @@ import useRepositoryEditor from "../../hooks/useRepositoryEditor"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function BoxConditions({ ...props }) {
|
export default function BoxConditions({ ...props }) {
|
||||||
const {conditions} = useRepositoryEditor()
|
const { conditions } = useRepositoryEditor()
|
||||||
|
|
||||||
const badges = conditions.map((cond, pos) => <ConditionBadge key={pos} {...cond}/>)
|
const badges = conditions.map((cond, pos) => <ConditionBadge key={pos} {...cond}/>)
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import CurrentServer from "./CurrentServer"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function BoxLoggedIn({ ...props }) {
|
export default function BoxLoggedIn({ ...props }) {
|
||||||
const {logout} = useContext(ContextUser)
|
const { logout } = useContext(ContextUser)
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -27,10 +27,12 @@ export default function BoxLoggedIn({ ...props }) {
|
||||||
You are currently logged in at <CurrentServer/> as <LoggedInUser/>.
|
You are currently logged in at <CurrentServer/> as <LoggedInUser/>.
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button color={"Red"} onClick={() => {
|
<Button
|
||||||
|
color={"Red"} onClick={() => {
|
||||||
logout()
|
logout()
|
||||||
history.push("/login")
|
history.push("/login")
|
||||||
}} icon={faSignOutAlt}>Logout</Button>
|
}} icon={faSignOutAlt}
|
||||||
|
>Logout</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</BoxFull>
|
</BoxFull>
|
||||||
|
|
|
@ -22,12 +22,12 @@ export default function BoxLogin({ ...props }) {
|
||||||
const [password, setPassword] = useState("password")
|
const [password, setPassword] = useState("password")
|
||||||
const [working, setWorking] = useState(false)
|
const [working, setWorking] = useState(false)
|
||||||
const [error, setError] = useState(null)
|
const [error, setError] = useState(null)
|
||||||
const {login} = useContext(ContextUser)
|
const { login } = useContext(ContextUser)
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
|
|
||||||
const doLogin = async () => {
|
const doLogin = async () => {
|
||||||
if(working) {
|
if(working) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setWorking(true)
|
setWorking(true)
|
||||||
|
@ -67,10 +67,10 @@ export default function BoxLogin({ ...props }) {
|
||||||
/>
|
/>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
{error ?
|
{error ?
|
||||||
<FormAlert color={"Red"}>
|
<FormAlert color={"Red"}>
|
||||||
{error.toString()}
|
{error.toString()}
|
||||||
</FormAlert>
|
</FormAlert>
|
||||||
: null}
|
: null}
|
||||||
<FormButton
|
<FormButton
|
||||||
onClick={doLogin}
|
onClick={doLogin}
|
||||||
icon={faArrowRight}
|
icon={faArrowRight}
|
||||||
|
|
|
@ -15,9 +15,9 @@ import ContextUser from "../../contexts/ContextUser"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function BoxRepositoriesActive({ repositories, refresh, ...props }) {
|
export default function BoxRepositoriesActive({ repositories, refresh, ...props }) {
|
||||||
const {user} = useContext(ContextUser)
|
const { user } = useContext(ContextUser)
|
||||||
|
|
||||||
let contents;
|
let contents
|
||||||
if(repositories.length > 0) {
|
if(repositories.length > 0) {
|
||||||
contents = repositories.map(repo => (
|
contents = repositories.map(repo => (
|
||||||
<RepositorySummaryBase
|
<RepositorySummaryBase
|
||||||
|
|
|
@ -15,9 +15,9 @@ import { faSearch } from "@fortawesome/free-solid-svg-icons"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function BoxRepositoriesArchived({ repositories, refresh, ...props }) {
|
export default function BoxRepositoriesArchived({ repositories, refresh, ...props }) {
|
||||||
const {user} = useContext(ContextUser)
|
const { user } = useContext(ContextUser)
|
||||||
|
|
||||||
let contents;
|
let contents
|
||||||
if(repositories.length > 0) {
|
if(repositories.length > 0) {
|
||||||
contents = repositories.map(repo => (
|
contents = repositories.map(repo => (
|
||||||
<RepositorySummaryBase
|
<RepositorySummaryBase
|
||||||
|
|
|
@ -34,7 +34,12 @@ export default function BoxRepositoryCreate({ ...props }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoxFull header={"Create repository"} {...props}>
|
<BoxFull header={"Create repository"} {...props}>
|
||||||
<FormLabelled onSubmit={e => {e.preventDefault(); save()}}>
|
<FormLabelled
|
||||||
|
onSubmit={e => {
|
||||||
|
e.preventDefault()
|
||||||
|
save()
|
||||||
|
}}
|
||||||
|
>
|
||||||
<FormLabel htmlFor={"repo-name"} text={"Repository name"}>
|
<FormLabel htmlFor={"repo-name"} text={"Repository name"}>
|
||||||
<InputWithIcon
|
<InputWithIcon
|
||||||
id={"repo-name"}
|
id={"repo-name"}
|
||||||
|
@ -63,28 +68,28 @@ export default function BoxRepositoryCreate({ ...props }) {
|
||||||
</label>
|
</label>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
{error ?
|
{error ?
|
||||||
<FormAlert color={"Red"}>
|
<FormAlert color={"Red"}>
|
||||||
{error.toString()}
|
{error.toString()}
|
||||||
</FormAlert>
|
</FormAlert>
|
||||||
: null}
|
: null}
|
||||||
{id ?
|
{id ?
|
||||||
<Button
|
<Button
|
||||||
style={{"gridColumn": "1 / 3"}}
|
style={{ "gridColumn": "1 / 3" }}
|
||||||
icon={faPencilAlt}
|
icon={faPencilAlt}
|
||||||
color={"Green"}
|
color={"Green"}
|
||||||
onClick={e => goToOnSuccess(save, history, "/repositories")}
|
onClick={e => goToOnSuccess(save, history, "/repositories")}
|
||||||
>
|
>
|
||||||
Edit repository
|
Edit repository
|
||||||
</Button>
|
</Button>
|
||||||
:
|
:
|
||||||
<Button
|
<Button
|
||||||
style={{"gridColumn": "1 / 3"}}
|
style={{ "gridColumn": "1 / 3" }}
|
||||||
icon={faPlus}
|
icon={faPlus}
|
||||||
color={"Green"}
|
color={"Green"}
|
||||||
onClick={e => goToOnSuccess(save, history, "/repositories")}
|
onClick={e => goToOnSuccess(save, history, "/repositories")}
|
||||||
>
|
>
|
||||||
Create repository
|
Create repository
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
|
|
||||||
</FormLabelled>
|
</FormLabelled>
|
||||||
|
|
|
@ -15,7 +15,7 @@ import ContextServer from "../../contexts/ContextServer"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function BoxSetServer({ ...props }) {
|
export default function BoxSetServer({ ...props }) {
|
||||||
const {server, setServer} = useContext(ContextServer);
|
const { server, setServer } = useContext(ContextServer)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoxFull header={"Choose server"} {...props}>
|
<BoxFull header={"Choose server"} {...props}>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useContext } from "react"
|
import React, { useContext } from "react"
|
||||||
import Style from "./ConditionBadge.module.css"
|
import Style from "./ConditionBadge.module.css"
|
||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
import ButtonSmallX from "../base/ButtonSmallX"
|
import ButtonSmallX from "../base/ButtonSmallX"
|
||||||
import { faAt, faClock, faGlobe, faHashtag, faMapPin } from "@fortawesome/free-solid-svg-icons"
|
import { faAt, faClock, faGlobe, faHashtag, faMapPin } from "@fortawesome/free-solid-svg-icons"
|
||||||
import ContextRepositoryEditor from "../../contexts/ContextRepositoryEditor"
|
import ContextRepositoryEditor from "../../contexts/ContextRepositoryEditor"
|
||||||
|
@ -36,7 +36,7 @@ export default function ConditionBadge({ ...condition }) {
|
||||||
const { id, type, content } = condition
|
const { id, type, content } = condition
|
||||||
const color = CONDITION_COLORS[type]
|
const color = CONDITION_COLORS[type]
|
||||||
const icon = CONDITION_ICONS[type]
|
const icon = CONDITION_ICONS[type]
|
||||||
const {removeRawCondition} = useContext(ContextRepositoryEditor)
|
const { removeRawCondition } = useContext(ContextRepositoryEditor)
|
||||||
|
|
||||||
let displayedContent = content
|
let displayedContent = content
|
||||||
if(type === 3) {
|
if(type === 3) {
|
||||||
|
@ -65,10 +65,12 @@ export default function ConditionBadge({ ...condition }) {
|
||||||
{displayedContent}
|
{displayedContent}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ButtonSmallX onClick={() => {
|
<ButtonSmallX
|
||||||
console.debug(`Removing Condition: `, condition)
|
onClick={() => {
|
||||||
removeRawCondition(condition)
|
console.debug(`Removing Condition: `, condition)
|
||||||
}}/>
|
removeRawCondition(condition)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useContext } from "react"
|
import React, { useContext } from "react"
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
import { faGlobe } from "@fortawesome/free-solid-svg-icons"
|
import { faGlobe } from "@fortawesome/free-solid-svg-icons"
|
||||||
import ContextServer from "../../contexts/ContextServer"
|
import ContextServer from "../../contexts/ContextServer"
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import ContextServer from "../../contexts/ContextServer"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function CurrentServer({ ...props }) {
|
export default function CurrentServer({ ...props }) {
|
||||||
const {server} = useContext(ContextServer);
|
const { server } = useContext(ContextServer)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<b {...props}>
|
<b {...props}>
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"a b"
|
"a b";
|
||||||
;
|
|
||||||
grid-template-columns: 250px 1fr;
|
grid-template-columns: 250px 1fr;
|
||||||
|
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import ContextUser from "../../contexts/ContextUser"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function LoggedInUser({ ...props }) {
|
export default function LoggedInUser({ ...props }) {
|
||||||
const {user} = useContext(ContextUser);
|
const { user } = useContext(ContextUser)
|
||||||
|
|
||||||
if(!user) {
|
if(!user) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, {useContext} from "react"
|
import React, { useContext } from "react"
|
||||||
import Style from "./Logo.module.css"
|
import Style from "./Logo.module.css"
|
||||||
import LogoDark from "../../media/LogoDark.png"
|
import LogoDark from "../../media/LogoDark.png"
|
||||||
import LogoLight from "../../media/LogoLight.png"
|
import LogoLight from "../../media/LogoLight.png"
|
||||||
|
@ -19,9 +19,9 @@ import classNames from "classnames"
|
||||||
export default function Logo({ className, ...props }) {
|
export default function Logo({ className, ...props }) {
|
||||||
// I have no idea why IntelliJ is complaining about this line
|
// I have no idea why IntelliJ is complaining about this line
|
||||||
// It's perfectly fine!
|
// It's perfectly fine!
|
||||||
const {theme} = useContext(ContextTheme)
|
const { theme } = useContext(ContextTheme)
|
||||||
|
|
||||||
let logo;
|
let logo
|
||||||
if(theme === "ThemeDark") {
|
if(theme === "ThemeDark") {
|
||||||
logo = LogoDark
|
logo = LogoDark
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useContext } from "react"
|
import React, { useContext } from "react"
|
||||||
import Style from "./RepositorySummaryBase.module.css"
|
import Style from "./RepositorySummaryBase.module.css"
|
||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
import Button from "../base/Button"
|
import Button from "../base/Button"
|
||||||
import { faArchive, faPencilAlt, faTrash } from "@fortawesome/free-solid-svg-icons"
|
import { faArchive, faPencilAlt, faTrash } from "@fortawesome/free-solid-svg-icons"
|
||||||
import { useHistory } from "react-router"
|
import { useHistory } from "react-router"
|
||||||
|
@ -29,13 +29,13 @@ import ContextUser from "../../contexts/ContextUser"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function RepositorySummaryBase(
|
export default function RepositorySummaryBase(
|
||||||
{ id, refresh, owner, icon, name, start, end, is_active, canDelete, canEdit, canArchive, className, ...props }
|
{ id, refresh, owner, icon, name, start, end, is_active, canDelete, canEdit, canArchive, className, ...props },
|
||||||
) {
|
) {
|
||||||
const {fetchDataAuth} = useContext(ContextUser)
|
const { fetchDataAuth } = useContext(ContextUser)
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
const {fetchNow: archiveThis} = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, {"close": true})
|
const { fetchNow: archiveThis } = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, { "close": true })
|
||||||
const {fetchNow: unarchiveThis} = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, {"open": true})
|
const { fetchNow: unarchiveThis } = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, { "open": true })
|
||||||
const {fetchNow: deletThis} = useData(fetchDataAuth, "DELETE", `/api/v1/repositories/${id}`)
|
const { fetchNow: deletThis } = useData(fetchDataAuth, "DELETE", `/api/v1/repositories/${id}`)
|
||||||
|
|
||||||
const onEditClick = event => {
|
const onEditClick = event => {
|
||||||
history.push(`/repositories/${id}/edit`)
|
history.push(`/repositories/${id}/edit`)
|
||||||
|
@ -79,32 +79,32 @@ export default function RepositorySummaryBase(
|
||||||
</div>
|
</div>
|
||||||
<div className={Style.Right}>
|
<div className={Style.Right}>
|
||||||
{canDelete ?
|
{canDelete ?
|
||||||
<Button
|
<Button
|
||||||
color={"Red"}
|
color={"Red"}
|
||||||
icon={faTrash}
|
icon={faTrash}
|
||||||
onClick={onDeleteClick}
|
onClick={onDeleteClick}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
: null}
|
: null}
|
||||||
{canEdit ?
|
{canEdit ?
|
||||||
<Button
|
<Button
|
||||||
color={"Yellow"}
|
color={"Yellow"}
|
||||||
icon={faPencilAlt}
|
icon={faPencilAlt}
|
||||||
onClick={onEditClick}
|
onClick={onEditClick}
|
||||||
>
|
>
|
||||||
Edit
|
Edit
|
||||||
</Button>
|
</Button>
|
||||||
: null}
|
: null}
|
||||||
{canArchive ?
|
{canArchive ?
|
||||||
<Button
|
<Button
|
||||||
color={"Grey"}
|
color={"Grey"}
|
||||||
icon={faArchive}
|
icon={faArchive}
|
||||||
onClick={is_active ? onArchiveClick : onUnarchiveClick}
|
onClick={is_active ? onArchiveClick : onUnarchiveClick}
|
||||||
>
|
>
|
||||||
{is_active ? "Archive" : "Unarchive"}
|
{is_active ? "Archive" : "Unarchive"}
|
||||||
</Button>
|
</Button>
|
||||||
: null}
|
: null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
"a b"
|
"a b"
|
||||||
"a c"
|
"a c"
|
||||||
"a d"
|
"a d"
|
||||||
"a e"
|
"a e";
|
||||||
;
|
|
||||||
grid-template-columns: auto 1fr;
|
grid-template-columns: auto 1fr;
|
||||||
grid-template-rows: 5px 1fr 1fr 5px;
|
grid-template-rows: 5px 1fr 1fr 5px;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, {useContext} from "react"
|
import React, { useContext } from "react"
|
||||||
import Select from "../base/Select"
|
import Select from "../base/Select"
|
||||||
import ContextTheme from "../../contexts/ContextTheme"
|
import ContextTheme from "../../contexts/ContextTheme"
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import ContextTheme from "../../contexts/ContextTheme"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function SelectTheme({ ...props }) {
|
export default function SelectTheme({ ...props }) {
|
||||||
const {theme, setTheme} = useContext(ContextTheme);
|
const { theme, setTheme } = useContext(ContextTheme)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select value={theme} onChange={e => setTheme(e.target.value)} {...props}>
|
<Select value={theme} onChange={e => setTheme(e.target.value)} {...props}>
|
||||||
|
|
|
@ -17,7 +17,7 @@ import ContextUser from "../../contexts/ContextUser"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function Sidebar({ className, ...props }) {
|
export default function Sidebar({ className, ...props }) {
|
||||||
const {user} = useContext(ContextUser)
|
const { user } = useContext(ContextUser)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside className={classNames(Style.Sidebar, className)} {...props}>
|
<aside className={classNames(Style.Sidebar, className)} {...props}>
|
||||||
|
@ -30,7 +30,7 @@ export default function Sidebar({ className, ...props }) {
|
||||||
<ButtonSidebar to={"/alerts"} icon={faExclamationTriangle}>Alerts</ButtonSidebar>
|
<ButtonSidebar to={"/alerts"} icon={faExclamationTriangle}>Alerts</ButtonSidebar>
|
||||||
<ButtonSidebar to={"/settings"} icon={faCog}>Settings</ButtonSidebar>
|
<ButtonSidebar to={"/settings"} icon={faCog}>Settings</ButtonSidebar>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
:
|
:
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<ButtonSidebar to={"/login"} icon={faKey}>Login</ButtonSidebar>
|
<ButtonSidebar to={"/login"} icon={faKey}>Login</ButtonSidebar>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
@ -38,7 +38,7 @@ export default function Sidebar({ className, ...props }) {
|
||||||
{
|
{
|
||||||
process.env.NODE_ENV === "development" ?
|
process.env.NODE_ENV === "development" ?
|
||||||
<ButtonSidebar to={"/sandbox"} icon={faWrench}>Sandbox</ButtonSidebar>
|
<ButtonSidebar to={"/sandbox"} icon={faWrench}>Sandbox</ButtonSidebar>
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
</aside>
|
</aside>
|
||||||
)
|
)
|
||||||
|
|
|
@ -75,7 +75,7 @@ export default function GlobalServer({ children }) {
|
||||||
}, [server])
|
}, [server])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextServer.Provider value={{server, setServer, fetchData}}>
|
<ContextServer.Provider value={{ server, setServer, fetchData }}>
|
||||||
{children}
|
{children}
|
||||||
</ContextServer.Provider>
|
</ContextServer.Provider>
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,7 +14,7 @@ export default function GlobalTheme({ children }) {
|
||||||
const [theme, setTheme] = useLocalStorageState("theme", "ThemeDark")
|
const [theme, setTheme] = useLocalStorageState("theme", "ThemeDark")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextTheme.Provider value={{theme, setTheme}}>
|
<ContextTheme.Provider value={{ theme, setTheme }}>
|
||||||
{children}
|
{children}
|
||||||
</ContextTheme.Provider>
|
</ContextTheme.Provider>
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import ContextUser from "../../contexts/ContextUser"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function GlobalUser({ children }) {
|
export default function GlobalUser({ children }) {
|
||||||
const {fetchData} = useContext(ContextServer)
|
const { fetchData } = useContext(ContextServer)
|
||||||
const [user, setUser] = useLocalStorageState("login", null)
|
const [user, setUser] = useLocalStorageState("login", null)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +79,7 @@ export default function GlobalUser({ children }) {
|
||||||
}, [setUser])
|
}, [setUser])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextUser.Provider value={{user, login, logout, fetchDataAuth}}>
|
<ContextUser.Provider value={{ user, login, logout, fetchDataAuth }}>
|
||||||
{children}
|
{children}
|
||||||
</ContextUser.Provider>
|
</ContextUser.Provider>
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,15 +14,15 @@ import useData from "../../hooks/useData"
|
||||||
|
|
||||||
|
|
||||||
export default function RepositoryEditor({
|
export default function RepositoryEditor({
|
||||||
id = null,
|
id = null,
|
||||||
name,
|
name,
|
||||||
is_active: isActive,
|
is_active: isActive,
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
conditions,
|
conditions,
|
||||||
evaluation_mode: evaluationMode,
|
evaluation_mode: evaluationMode,
|
||||||
className,
|
className,
|
||||||
}) {
|
}) {
|
||||||
/** The repository name. */
|
/** The repository name. */
|
||||||
const [_name, setName] = useState(name ?? "")
|
const [_name, setName] = useState(name ?? "")
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ export default function RepositoryEditor({
|
||||||
/** The operator the conditions should be evaluated with. */
|
/** The operator the conditions should be evaluated with. */
|
||||||
const [_evaluationMode, setEvaluationMode] = useState(evaluationMode ?? 0)
|
const [_evaluationMode, setEvaluationMode] = useState(evaluationMode ?? 0)
|
||||||
|
|
||||||
const {user, fetchDataAuth} = useContext(ContextUser)
|
const { user, fetchDataAuth } = useContext(ContextUser)
|
||||||
|
|
||||||
const method = id ? "PUT" : "POST"
|
const method = id ? "PUT" : "POST"
|
||||||
const path = id ? `/api/v1/repositories/${id}` : `/api/v1/repositories/`
|
const path = id ? `/api/v1/repositories/${id}` : `/api/v1/repositories/`
|
||||||
|
@ -61,7 +61,7 @@ export default function RepositoryEditor({
|
||||||
"owner": user,
|
"owner": user,
|
||||||
"start": _start,
|
"start": _start,
|
||||||
}
|
}
|
||||||
const {error, loading, fetchNow} = useData(fetchDataAuth, method, path, body)
|
const { error, loading, fetchNow } = useData(fetchDataAuth, method, path, body)
|
||||||
|
|
||||||
const save = useCallback(
|
const save = useCallback(
|
||||||
() => {
|
() => {
|
||||||
|
@ -73,7 +73,7 @@ export default function RepositoryEditor({
|
||||||
}
|
}
|
||||||
fetchNow()
|
fetchNow()
|
||||||
},
|
},
|
||||||
[id, body, fetchNow]
|
[id, body, fetchNow],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ export default function RepositoryEditor({
|
||||||
setRawConditions(conditions)
|
setRawConditions(conditions)
|
||||||
setEvaluationMode(evaluationMode)
|
setEvaluationMode(evaluationMode)
|
||||||
},
|
},
|
||||||
[name, isActive, start, end, conditions, evaluationMode]
|
[name, isActive, start, end, conditions, evaluationMode],
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ export default function RepositoryEditor({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for duplicates
|
// Check for duplicates
|
||||||
let duplicate = null;
|
let duplicate = null
|
||||||
for(const oldCond of _conditions) {
|
for(const oldCond of _conditions) {
|
||||||
if(newCond.type === oldCond.type && newCond.content === oldCond.content) {
|
if(newCond.type === oldCond.type && newCond.content === oldCond.content) {
|
||||||
duplicate = oldCond
|
duplicate = oldCond
|
||||||
|
@ -119,21 +119,23 @@ export default function RepositoryEditor({
|
||||||
console.debug("Adding ", newCond, " to the Repository Conditions")
|
console.debug("Adding ", newCond, " to the Repository Conditions")
|
||||||
appendRawCondition(newCond)
|
appendRawCondition(newCond)
|
||||||
},
|
},
|
||||||
[_conditions]
|
[_conditions],
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextRepositoryEditor.Provider value={{
|
<ContextRepositoryEditor.Provider
|
||||||
id,
|
value={{
|
||||||
name: _name, setName,
|
id,
|
||||||
isActive: _isActive, setActive,
|
name: _name, setName,
|
||||||
start: _start, setStart,
|
isActive: _isActive, setActive,
|
||||||
end: _end, setEnd,
|
start: _start, setStart,
|
||||||
conditions: _conditions, addCondition, appendRawCondition, removeRawCondition, spliceRawCondition,
|
end: _end, setEnd,
|
||||||
evaluationMode: _evaluationMode, setEvaluationMode,
|
conditions: _conditions, addCondition, appendRawCondition, removeRawCondition, spliceRawCondition,
|
||||||
error, loading,
|
evaluationMode: _evaluationMode, setEvaluationMode,
|
||||||
revert, save,
|
error, loading,
|
||||||
}}>
|
revert, save,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<div className={classNames(Style.RepositoryEditor, className)}>
|
<div className={classNames(Style.RepositoryEditor, className)}>
|
||||||
<BoxConditionMap className={Style.SearchByZone}/>
|
<BoxConditionMap className={Style.SearchByZone}/>
|
||||||
<BoxConditionHashtag className={Style.SearchByHashtags}/>
|
<BoxConditionHashtag className={Style.SearchByHashtags}/>
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
"b d"
|
"b d"
|
||||||
"b e"
|
"b e"
|
||||||
"b f"
|
"b f"
|
||||||
"b g"
|
"b g";
|
||||||
;
|
|
||||||
grid-template-columns: 400px 1fr;
|
grid-template-columns: 400px 1fr;
|
||||||
grid-template-rows: auto auto auto 1fr auto;
|
grid-template-rows: auto auto auto 1fr auto;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {createContext} from "react";
|
import { createContext } from "react"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {createContext} from "react";
|
import { createContext } from "react"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {createContext} from "react";
|
import { createContext } from "react"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +14,6 @@ import {createContext} from "react";
|
||||||
const ContextTheme = createContext({
|
const ContextTheme = createContext({
|
||||||
isSet: false,
|
isSet: false,
|
||||||
theme: "ThemeDark",
|
theme: "ThemeDark",
|
||||||
setTheme: () => console.error("Trying to setTheme while outside a ContextTheme.Provider!")
|
setTheme: () => console.error("Trying to setTheme while outside a ContextTheme.Provider!"),
|
||||||
})
|
})
|
||||||
export default ContextTheme
|
export default ContextTheme
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {createContext} from "react";
|
import { createContext } from "react"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,10 +14,10 @@ export default function useArrayState(def) {
|
||||||
newSingle => {
|
newSingle => {
|
||||||
console.debug("Appending ", newSingle, " to ArrayState")
|
console.debug("Appending ", newSingle, " to ArrayState")
|
||||||
setValue(
|
setValue(
|
||||||
oldArray => [...oldArray, newSingle]
|
oldArray => [...oldArray, newSingle],
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
[]
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
const spliceValue = useCallback(
|
const spliceValue = useCallback(
|
||||||
|
@ -28,21 +28,21 @@ export default function useArrayState(def) {
|
||||||
// TODO: Hope this doesn't break anything...
|
// TODO: Hope this doesn't break anything...
|
||||||
oldArray.splice(position, 1)
|
oldArray.splice(position, 1)
|
||||||
return oldArray
|
return oldArray
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
[]
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
const removeValue = useCallback(
|
const removeValue = useCallback(
|
||||||
remValue => {
|
remValue => {
|
||||||
console.debug("Removing ", remValue, " from ArrayState")
|
console.debug("Removing ", remValue, " from ArrayState")
|
||||||
setValue(
|
setValue(
|
||||||
oldArray => oldArray.filter(item => JSON.stringify(item) !== JSON.stringify(remValue))
|
oldArray => oldArray.filter(item => JSON.stringify(item) !== JSON.stringify(remValue)),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
[]
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
return {value, setValue, appendValue, spliceValue, removeValue}
|
return { value, setValue, appendValue, spliceValue, removeValue }
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import { useCallback, useEffect, useState } from "react"
|
import { useCallback, useState } from "react"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,15 +28,17 @@ export default function useData(fetchData, method, path, body, init) {
|
||||||
const _data = await fetchData(method, path, body, init)
|
const _data = await fetchData(method, path, body, init)
|
||||||
console.debug(`Displaying data of ${method} ${path}: `, _data)
|
console.debug(`Displaying data of ${method} ${path}: `, _data)
|
||||||
setData(_data)
|
setData(_data)
|
||||||
} catch(e) {
|
}
|
||||||
|
catch(e) {
|
||||||
console.debug(`Displaying error of ${method} ${path}: `, e)
|
console.debug(`Displaying error of ${method} ${path}: `, e)
|
||||||
setError(e)
|
setError(e)
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
console.debug(`Stopping loading of ${method} ${path}...`)
|
console.debug(`Stopping loading of ${method} ${path}...`)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[fetchData, method, path, body, init]
|
[fetchData, method, path, body, init],
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,8 +54,8 @@ export default function useData(fetchData, method, path, body, init) {
|
||||||
|
|
||||||
await load()
|
await load()
|
||||||
},
|
},
|
||||||
[load]
|
[load],
|
||||||
)
|
)
|
||||||
|
|
||||||
return {data, error, loading, fetchNow}
|
return { data, error, loading, fetchNow }
|
||||||
}
|
}
|
|
@ -12,16 +12,18 @@ import { useEffect } from "react"
|
||||||
* @param init - Additional `init` parameters to pass to `fetch`.
|
* @param init - Additional `init` parameters to pass to `fetch`.
|
||||||
*/
|
*/
|
||||||
export default function useDataImmediately(fetchData, method, path, body, init) {
|
export default function useDataImmediately(fetchData, method, path, body, init) {
|
||||||
const {data, error, loading, fetchNow} = useData(fetchData, method, path, body, init)
|
const { data, error, loading, fetchNow } = useData(fetchData, method, path, body, init)
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if(!(loading || data || error)) {
|
if(!(
|
||||||
|
loading || data || error
|
||||||
|
)) {
|
||||||
fetchNow()
|
fetchNow()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[data, error, loading, fetchNow]
|
[data, error, loading, fetchNow],
|
||||||
)
|
)
|
||||||
|
|
||||||
return {data, error, loading, fetchNow}
|
return { data, error, loading, fetchNow }
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default function useLocalStorageState(key, def) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [value, setValue] = useState(load());
|
const [value, setValue] = useState(load())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a value to the {@link localStorage}.
|
* Save a value to the {@link localStorage}.
|
||||||
|
@ -43,7 +43,7 @@ export default function useLocalStorageState(key, def) {
|
||||||
console.warn(`Can't save ${key}; localStorage doesn't seem to be available...`)
|
console.warn(`Can't save ${key}; localStorage doesn't seem to be available...`)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[key]
|
[key],
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@ export default function useLocalStorageState(key, def) {
|
||||||
setValue(value)
|
setValue(value)
|
||||||
save(value)
|
save(value)
|
||||||
},
|
},
|
||||||
[save]
|
[save],
|
||||||
)
|
)
|
||||||
|
|
||||||
return [value, setAndSave]
|
return [value, setAndSave]
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"a"
|
"a"
|
||||||
"b"
|
"b";
|
||||||
;
|
|
||||||
|
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"a"
|
"a"
|
||||||
"b"
|
"b";
|
||||||
;
|
|
||||||
grid-template-rows: auto 1fr;
|
grid-template-rows: auto 1fr;
|
||||||
|
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
|
|
|
@ -6,17 +6,14 @@ import RepositoryEditor from "../components/providers/RepositoryEditor"
|
||||||
import useDataImmediately from "../hooks/useDataImmediately"
|
import useDataImmediately from "../hooks/useDataImmediately"
|
||||||
import ContextUser from "../contexts/ContextUser"
|
import ContextUser from "../contexts/ContextUser"
|
||||||
import BoxAlert from "../components/base/BoxAlert"
|
import BoxAlert from "../components/base/BoxAlert"
|
||||||
import RepositorySummaryBase from "../components/interactive/RepositorySummaryBase"
|
|
||||||
import { faSearch } from "@fortawesome/free-solid-svg-icons"
|
|
||||||
import Loading from "../components/base/Loading"
|
import Loading from "../components/base/Loading"
|
||||||
import BoxFull from "../components/base/BoxFull"
|
|
||||||
|
|
||||||
|
|
||||||
export default function PageEdit({ id, className, ...props }) {
|
export default function PageEdit({ id, className, ...props }) {
|
||||||
const {fetchDataAuth} = useContext(ContextUser)
|
const { fetchDataAuth } = useContext(ContextUser)
|
||||||
const {data, error} = useDataImmediately(fetchDataAuth, "GET", `/api/v1/repositories/${id}`)
|
const { data, error } = useDataImmediately(fetchDataAuth, "GET", `/api/v1/repositories/${id}`)
|
||||||
|
|
||||||
let contents;
|
let contents
|
||||||
if(error) {
|
if(error) {
|
||||||
contents = <BoxAlert color={"Red"}>{error.toString()}</BoxAlert>
|
contents = <BoxAlert color={"Red"}>{error.toString()}</BoxAlert>
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@ import Loading from "../components/base/Loading"
|
||||||
|
|
||||||
|
|
||||||
export default function PageRepositories({ children, className, ...props }) {
|
export default function PageRepositories({ children, className, ...props }) {
|
||||||
const {fetchDataAuth} = useContext(ContextUser)
|
const { fetchDataAuth } = useContext(ContextUser)
|
||||||
const {data, error, fetchNow: refresh} = useDataImmediately(fetchDataAuth, "GET", "/api/v1/repositories/")
|
const { data, error, fetchNow: refresh } = useDataImmediately(fetchDataAuth, "GET", "/api/v1/repositories/")
|
||||||
|
|
||||||
let contents;
|
let contents
|
||||||
if(error) {
|
if(error) {
|
||||||
contents = <BoxAlert color={"Red"}>{error}</BoxAlert>
|
contents = <BoxAlert color={"Red"}>{error}</BoxAlert>
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"a"
|
"a"
|
||||||
"b"
|
"b";
|
||||||
;
|
|
||||||
|
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Redirect } from "react-router"
|
||||||
|
|
||||||
|
|
||||||
export default function PageRoot() {
|
export default function PageRoot() {
|
||||||
const {state} = useContext(ContextUser)
|
const { state } = useContext(ContextUser)
|
||||||
|
|
||||||
if(!state) {
|
if(!state) {
|
||||||
return <Redirect to={"/login"}/>
|
return <Redirect to={"/login"}/>
|
||||||
|
|
|
@ -17,13 +17,15 @@ export default function convertToLocalISODate(date) {
|
||||||
const naive = date.toISOString()
|
const naive = date.toISOString()
|
||||||
|
|
||||||
// Find the local timezone
|
// Find the local timezone
|
||||||
const tz = - new Date().getTimezoneOffset()
|
const tz = -new Date().getTimezoneOffset()
|
||||||
|
|
||||||
// Convert the timezone to hours
|
// Convert the timezone to hours
|
||||||
const tzHours = Math.abs(Math.floor(tz / 60)).toString().padStart(2, "0")
|
const tzHours = Math.abs(Math.floor(tz / 60)).toString().padStart(2, "0")
|
||||||
|
|
||||||
// Find the minutes
|
// Find the minutes
|
||||||
const tzMinutes = (tz % 60).toString().padStart(2, "0")
|
const tzMinutes = (
|
||||||
|
tz % 60
|
||||||
|
).toString().padStart(2, "0")
|
||||||
|
|
||||||
// Replace the naive part with the aware part
|
// Replace the naive part with the aware part
|
||||||
return naive.replace("Z", `${tz < 0 ? "-" : "+"}${tzHours}${tzMinutes}`)
|
return naive.replace("Z", `${tz < 0 ? "-" : "+"}${tzHours}${tzMinutes}`)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
|
|
||||||
export default function make_icon(icon, className) {
|
export default function make_icon(icon, className) {
|
||||||
if(isValidElement(icon)) {
|
if(isValidElement(icon)) {
|
||||||
return <span className={className}>icon</span>;
|
return <span className={className}>icon</span>
|
||||||
}
|
}
|
||||||
else if(icon) {
|
else if(icon) {
|
||||||
return (
|
return (
|
||||||
|
@ -12,6 +12,6 @@ export default function make_icon(icon, className) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue