-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement most of the requirements for this feature
- Loading branch information
Showing
12 changed files
with
348 additions
and
157 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...n/src/main/java/com/djrapitops/plan/delivery/domain/datatransfer/PlayerJoinAddresses.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* This file is part of Player Analytics (Plan). | ||
* | ||
* Plan is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License v3 as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Plan is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Plan. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.djrapitops.plan.delivery.domain.datatransfer; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Represents data returned by {@link com.djrapitops.plan.delivery.webserver.resolver.json.PlayerJoinAddressJSONResolver}. | ||
* | ||
* @author AuroraLS3 | ||
*/ | ||
public class PlayerJoinAddresses { | ||
|
||
private final List<String> joinAddresses; | ||
private final Map<UUID, String> joinAddressByPlayer; | ||
|
||
public PlayerJoinAddresses(List<String> joinAddresses, Map<UUID, String> joinAddressByPlayer) { | ||
this.joinAddresses = joinAddresses; | ||
this.joinAddressByPlayer = joinAddressByPlayer; | ||
} | ||
|
||
public List<String> getJoinAddresses() { | ||
return joinAddresses; | ||
} | ||
|
||
public Map<UUID, String> getJoinAddressByPlayer() { | ||
return joinAddressByPlayer; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
PlayerJoinAddresses that = (PlayerJoinAddresses) o; | ||
return Objects.equals(getJoinAddresses(), that.getJoinAddresses()) && Objects.equals(getJoinAddressByPlayer(), that.getJoinAddressByPlayer()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getJoinAddresses(), getJoinAddressByPlayer()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "PlayerJoinAddresses{" + | ||
"joinAddresses=" + joinAddresses + | ||
", joinAddressByPlayer=" + joinAddressByPlayer + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Plan/react/dashboard/src/components/cards/common/AddressListCard.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {useTranslation} from "react-i18next"; | ||
import React, {useCallback, useEffect, useState} from "react"; | ||
import {Card, Form} from "react-bootstrap"; | ||
import CardHeader from "../CardHeader.jsx"; | ||
import {faCheck, faList, faPencil} from "@fortawesome/free-solid-svg-icons"; | ||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; | ||
import MultiSelect from "../../input/MultiSelect.jsx"; | ||
import {faTrashAlt} from "@fortawesome/free-regular-svg-icons"; | ||
|
||
const AddressListCard = ({n, group, editGroup, allAddresses, remove}) => { | ||
const {t} = useTranslation(); | ||
const [selectedIndexes, setSelectedIndexes] = useState([]); | ||
const [editingName, setEditingName] = useState(false); | ||
const [name, setName] = useState(group.name); | ||
|
||
const isUpToDate = group.addresses === allAddresses.filter((a, i) => selectedIndexes.includes(i)); | ||
const applySelected = useCallback(() => { | ||
editGroup({...group, addresses: allAddresses.filter((a, i) => selectedIndexes.includes(i))}) | ||
}, [editGroup, group, allAddresses, selectedIndexes]); | ||
const editName = useCallback(newName => { | ||
editGroup({...group, name: newName}); | ||
}, [editGroup, group]); | ||
useEffect(() => { | ||
if (!editingName && name !== group.name) editName(name); | ||
}, [editName, editingName, name]) | ||
|
||
return ( | ||
<Card> | ||
<CardHeader icon={faList} color={"amber"} label={ | ||
editingName ? | ||
<Form.Control style={{maxWidth: "75%", marginTop: "-1rem", marginBottom: "-1rem"}} value={name} | ||
onChange={e => setName(e.target.value)}/> : group.name | ||
}> | ||
<button style={{marginLeft: "0.5rem"}} onClick={() => setEditingName(!editingName)}> | ||
<FontAwesomeIcon icon={editingName ? faCheck : faPencil}/> | ||
</button> | ||
</CardHeader> | ||
<Card.Body> | ||
<MultiSelect options={allAddresses} selectedIndexes={selectedIndexes} | ||
setSelectedIndexes={setSelectedIndexes}/> | ||
<button className={'mt-2 btn ' + (isUpToDate ? 'bg-transparent' : 'bg-theme')} | ||
onClick={applySelected} disabled={isUpToDate}> | ||
{t('html.label.apply')} | ||
</button> | ||
<button className={'mt-2 btn btn-outline-secondary float-end'} | ||
onClick={remove}> | ||
<FontAwesomeIcon icon={faTrashAlt}/> | ||
</button> | ||
</Card.Body> | ||
</Card> | ||
) | ||
} | ||
export default AddressListCard; |
48 changes: 48 additions & 0 deletions
48
Plan/react/dashboard/src/components/cards/common/JoinAddresses.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import LoadIn from "../../animation/LoadIn.jsx"; | ||
import ExtendableRow from "../../layout/extension/ExtendableRow.jsx"; | ||
import JoinAddressGraphCard from "../server/graphs/JoinAddressGraphCard.jsx"; | ||
import {Col, Row} from "react-bootstrap"; | ||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; | ||
import {faPlus} from "@fortawesome/free-solid-svg-icons"; | ||
import React from "react"; | ||
import {useAuth} from "../../../hooks/authenticationHook.jsx"; | ||
import {useTranslation} from "react-i18next"; | ||
import {useJoinAddressListContext} from "../../../hooks/context/joinAddressListContextHook.jsx"; | ||
import AddressListCard from "./AddressListCard.jsx"; | ||
|
||
const JoinAddresses = ({id, permission, identifier}) => { | ||
const {t} = useTranslation(); | ||
const {hasPermission} = useAuth(); | ||
const {list, add, remove, replace, allAddresses} = useJoinAddressListContext(); | ||
|
||
const seeTime = hasPermission(permission); | ||
|
||
return ( | ||
<LoadIn> | ||
<section className={id}> | ||
<ExtendableRow id={`row-${id}-0`}> | ||
<Col lg={12}> | ||
{seeTime && <JoinAddressGraphCard identifier={identifier}/>} | ||
</Col> | ||
</ExtendableRow> | ||
<Row> | ||
{list.map((group, i) => | ||
<Col lg={2} key={group.uuid}> | ||
<AddressListCard n={i + 1} | ||
group={group} | ||
editGroup={replacement => replace(replacement, i)} | ||
allAddresses={allAddresses} | ||
remove={() => remove(i)}/> | ||
</Col>)} | ||
<Col lg={2}> | ||
<button className={"btn bg-theme mb-4"} onClick={add}> | ||
<FontAwesomeIcon icon={faPlus}/> Add address group | ||
</button> | ||
</Col> | ||
</Row> | ||
</section> | ||
</LoadIn> | ||
) | ||
} | ||
|
||
export default JoinAddresses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.