Skip to content

Commit

Permalink
fix: change organisation of files
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekzyla committed Sep 13, 2022
1 parent 3650830 commit c129eb1
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 17 deletions.
16 changes: 8 additions & 8 deletions frontend/packages/manager/src/Manager.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import React from 'react';
import TabLayout from '@splunk/react-ui/TabLayout';
import ProfilePanel from "./ProfilePanel";
import InventoryList from "./InventoryList";
import InventoryModal from "./InventoryModal";
import ProfilesModal from "./ProfilesModal";
import ProfilesPage from "./pages/ProfilesPage";
import InventoryPage from "./pages/InventoryPage"
import GroupsPage from "./pages/GroupsPage"

function Uncontrolled() {
return (
<TabLayout defaultActivePanelId="one">
<TabLayout.Panel label="Profiles" panelId="one">
<ProfilePanel />
<ProfilesModal />
<ProfilesPage />
</TabLayout.Panel>
<TabLayout.Panel label="Inventory" panelId="two" style={{ margin: 20 }}>
<InventoryList />
<InventoryModal />
<InventoryPage />
</TabLayout.Panel>
<TabLayout.Panel label="Groups" panelId="three">
<GroupsPage />
</TabLayout.Panel>
</TabLayout>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SortableColumns extends Component {
allInventoryRecords: []
};
}
url = 'http://localhost:5000/inventory'
url = 'http://127.0.0.1:5000/inventory'
getFetchInventoryRows() {
axios.get(`${this.url}`)
.then((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function InventoryModal() {
useEffect(() => {
let isMounted = true;
console.log('use effect')
axios.get('http://localhost:5000/profiles')
axios.get('http://127.0.0.1:5000/profiles')
.then((response) => {
if (isMounted)
setInitProfiles(response.data);
Expand All @@ -47,7 +47,7 @@ function InventoryModal() {
}, [setInitProfiles]);

const postInventory = (inventoryObj) => {
axios.post('http://localhost:5000/inventory/add', inventoryObj)
axios.post('http://127.0.0.1:5000/inventory/add', inventoryObj)
.then((response) => {
console.log(response)
})
Expand Down
48 changes: 48 additions & 0 deletions frontend/packages/manager/src/components/groups/AddGroupModal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, { useState, useRef } from 'react';
import Button from '@splunk/react-ui/Button';
import ControlGroup from '@splunk/react-ui/ControlGroup';
import Modal from '@splunk/react-ui/Modal';
import P from '@splunk/react-ui/Paragraph';
import Select from '@splunk/react-ui/Select';
import Multiselect from '@splunk/react-ui/Multiselect';
import Text from '@splunk/react-ui/Text';

function AddGroupModal() {
const modalToggle = useRef(null);

const [open, setOpen] = useState(false);

const handleRequestOpen = () => {
setOpen(true);
};

const handleRequestClose = () => {
setOpen(false);
modalToggle?.current?.focus(); // Must return focus to the invoking element when the modal closes
};

const handleRequestSubmit = () => {
setOpen(false);
modalToggle?.current?.focus();
};

return (
<div>
<Button onClick={handleRequestOpen} ref={modalToggle} label="Click me" />
<Modal onRequestClose={handleRequestClose} open={open} style={{ width: '600px' }}>
<Modal.Header title="Add a new group" onRequestClose={handleRequestClose} />
<Modal.Body>
<ControlGroup label="Group Name">
<Text />
</ControlGroup>
</Modal.Body>
<Modal.Footer>
<Button appearance="secondary" onClick={handleRequestClose} label="Cancel" />
<Button appearance="primary" onClick={handleRequestSubmit} label="Submit" />
</Modal.Footer>
</Modal>
</div>
);
}

export default AddGroupModal;
Empty file.
37 changes: 37 additions & 0 deletions frontend/packages/manager/src/components/groups/GroupsList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { useState } from 'react';
import Accordion from '@splunk/react-ui/Accordion';
import P from '@splunk/react-ui/Paragraph';
import { lorem } from '@splunk/react-ui/fixtures/text';

const DUMMY_HOSTS = [{address: 0.0.0.0, port: 161, }];

function Controlled() {
const [openPanelId, setOpenPanelId] = useState(2);

const handleChange = (e, { panelId: panelValue }) => {
setOpenPanelId(panelValue);
};

return (
<Accordion openPanelId={openPanelId} onChange={handleChange}>
<Accordion.Panel panelId={1} title="Panel 1">
<P>
{lorem}
{lorem}
{lorem}
</P>
</Accordion.Panel>
<Accordion.Panel panelId={2} title="Panel 2">
<P>{lorem}</P>
</Accordion.Panel>
<Accordion.Panel panelId={3} title="Panel 3">
<P>
{lorem}
{lorem}
</P>
</Accordion.Panel>
</Accordion>
);
}

export default Controlled;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function ProfilePanel() {
useEffect(() => {
let isMounted = true;
console.log('use effect')
axios.get('http://localhost:5000/profiles/all')
axios.get('http://127.0.0.1:5000/profiles/all')
.then((response) => {
if (isMounted)
setProfiles(response.data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import ControlGroup from '@splunk/react-ui/ControlGroup';
import Modal from '@splunk/react-ui/Modal';
import Number from '@splunk/react-ui/Number';
import Text from '@splunk/react-ui/Text';
import VarbindsCreator from "./VarbindsCreator";
import Conditions from "./Conditions";
import VarbindsCreator from "../VarbindsCreator";
import Conditions from "../Conditions";
import axios from "axios";


Expand Down Expand Up @@ -46,7 +46,7 @@ function ProfilesModal() {
}

const postProfile = (profileObj) => {
axios.post('http://localhost:5000/profiles/add', profileObj)
axios.post('http://127.0.0.1:5000/profiles/add', profileObj)
.then((response) => {
console.log(response)
})
Expand All @@ -58,8 +58,10 @@ function ProfilesModal() {
frequency: frequency,
varBinds: varBinds,
conditions: conditions}
postProfile(profileObj)},
[frequency, profileName, varBinds, conditions]
postProfile(profileObj)
setOpen(false);
modalToggle?.current?.focus();},
[frequency, profileName, varBinds, conditions, setOpen, modalToggle]
);

return (
Expand Down
10 changes: 10 additions & 0 deletions frontend/packages/manager/src/pages/GroupsPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import AddGroupModal from "../components/groups/AddGroupModal"

function GroupsPage() {
return (
<AddGroupModal />
);
}

export default GroupsPage;
14 changes: 14 additions & 0 deletions frontend/packages/manager/src/pages/InventoryPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import InventoryList from "../components/InventoryList"
import InventoryModal from "../components/InventoryModal"

function InventoryPage() {
return (
<div>
<InventoryModal />
<InventoryList />
</div>
);
}

export default InventoryPage;
14 changes: 14 additions & 0 deletions frontend/packages/manager/src/pages/ProfilesPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import ProfilePanel from "../components/profiles/ProfilePanel"
import ProfilesModal from "../components/profiles/ProfilesModal"

function ProfilesPage(){
return (
<div>
<ProfilesModal />
<ProfilePanel />
</div>
);
}

export default ProfilesPage;

0 comments on commit c129eb1

Please sign in to comment.