-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
676783c
commit f1b249b
Showing
10 changed files
with
280 additions
and
80 deletions.
There are no files selected for viewing
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
85 changes: 85 additions & 0 deletions
85
frontend/packages/manager/src/components/menu_header/Header.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,85 @@ | ||
import React, {useCallback, useContext, useState} from 'react'; | ||
import MenuHeaderContxt from '../../store/menu-header-contxt'; | ||
import ProfileContext from "../../store/profile-contxt"; | ||
import GroupContext from "../../store/group-contxt"; | ||
import InventoryContext from "../../store/inventory-contxt"; | ||
import { StyledHeader, StyledHeaderLeft, StyledHeaderRight } from "../../styles/HeaderStyle"; | ||
import Button from '@splunk/react-ui/Button'; | ||
import Plus from '@splunk/react-icons/Plus'; | ||
import P from '@splunk/react-ui/Paragraph'; | ||
|
||
function Header(){ | ||
const MenuCtx = useContext(MenuHeaderContxt); | ||
const ProfCtx = useContext(ProfileContext); | ||
const GrCtx = useContext(GroupContext); | ||
const InvCtx = useContext(InventoryContext); | ||
|
||
const handleRequestOpenProfile = () => { | ||
ProfCtx.setProfileName(""); | ||
ProfCtx.setFrequency(1); | ||
ProfCtx.setVarBinds(null); | ||
ProfCtx.setConditions(null); | ||
ProfCtx.setAddOpen(true); | ||
ProfCtx.setIsEdit(false); | ||
}; | ||
|
||
const handleRequestOpenGroups = () => { | ||
GrCtx.setAddGroupOpen(true); | ||
GrCtx.setIsGroupEdit(false); | ||
GrCtx.setGroupName(''); | ||
GrCtx.setGroupId(null); | ||
}; | ||
|
||
const handleRequestOpenInventory = () => { | ||
InvCtx.setAddOpen(true); | ||
InvCtx.setIsEdit(false); | ||
InvCtx.resetFormData(); | ||
}; | ||
|
||
const handleApplyChanges = () => { | ||
console.log("Applying changes") | ||
}; | ||
|
||
const addButtonLabel = { | ||
Profiles: "Add new profile", | ||
Groups: "Add new group", | ||
Inventory: "Add new device" | ||
}; | ||
|
||
const addButtonHandler = { | ||
Profiles: handleRequestOpenProfile, | ||
Groups: handleRequestOpenGroups, | ||
Inventory: handleRequestOpenInventory | ||
}; | ||
|
||
return( | ||
<StyledHeader> | ||
<StyledHeaderLeft> | ||
<div> | ||
<span id="project-title"> | ||
<P> | ||
Splunk Connect for SNMP | ||
</P> | ||
</span> | ||
<span id="project-description"> | ||
<P> | ||
Collect SNMP data for Splunk Enterprise, Splunk Enterprise Cloud and Splunk | ||
Infrastructure Monitoring. Make any changes to Profiles, Groups and Inventory. Then select | ||
Aply changes to put the changes into effect. Applying changes can only be done every | ||
5 minutes. | ||
</P> | ||
</span> | ||
</div> | ||
</StyledHeaderLeft> | ||
<StyledHeaderRight> | ||
<div> | ||
<Button icon={<Plus screenReaderText={null} />} appearance="primary" | ||
label={addButtonLabel[MenuCtx.activeTabId]} | ||
onClick={addButtonHandler[MenuCtx.activeTabId]}/> | ||
<Button label="Apply Changes" onClick={handleApplyChanges}/> | ||
</div> | ||
</StyledHeaderRight> | ||
</StyledHeader>) | ||
} | ||
|
||
export default Header; |
34 changes: 34 additions & 0 deletions
34
frontend/packages/manager/src/components/menu_header/Menu.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,34 @@ | ||
import React, {useCallback, useContext, useState} from 'react'; | ||
import MenuHeaderContxt from '../../store/menu-header-contxt'; | ||
import { StyledTab, StyledMenuBar, StyledMenuBarLeft, StyledMenuBarRight } from "../../styles/MenuBarStyle"; | ||
import P from '@splunk/react-ui/Paragraph'; | ||
import TabBar from '@splunk/react-ui/TabBar'; | ||
|
||
function Menu(){ | ||
const MenuCtx = useContext(MenuHeaderContxt); | ||
|
||
const handleMenuChange = useCallback((e, { selectedTabId }) => { | ||
MenuCtx.setActiveTabId(selectedTabId); | ||
}, []); | ||
|
||
return( | ||
<StyledMenuBar> | ||
<StyledMenuBarLeft> | ||
<StyledTab activeTabId={MenuCtx.activeTabId} onChange={handleMenuChange}> | ||
<TabBar.Tab label="Profiles" tabId="Profiles" /> | ||
<TabBar.Tab label="Groups" tabId="Groups" /> | ||
<TabBar.Tab label="Inventory" tabId="Inventory" /> | ||
</StyledTab> | ||
</StyledMenuBarLeft> | ||
<StyledMenuBarRight> | ||
<div> | ||
<P> | ||
Splunk Connect for SNMP | ||
</P> | ||
</div> | ||
</StyledMenuBarRight> | ||
</StyledMenuBar> | ||
) | ||
} | ||
|
||
export default Menu; |
41 changes: 41 additions & 0 deletions
41
frontend/packages/manager/src/components/menu_header/TabPanels.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,41 @@ | ||
import React, {useContext} from 'react'; | ||
import MenuHeaderContxt from '../../store/menu-header-contxt'; | ||
import ProfilesPage from "../../pages/ProfilesPage"; | ||
import InventoryPage from "../../pages/InventoryPage"; | ||
import GroupsPage from "../../pages/GroupsPage"; | ||
|
||
import { InventoryDevicesValidationContxtProvider } from "../../store/inventory-devices-validation-contxt"; | ||
import { ProfilesValidationContxtProvider } from "../../store/profiles-validation-contxt"; | ||
|
||
|
||
function TabPanels(){ | ||
const MenuCtx = useContext(MenuHeaderContxt); | ||
|
||
return( | ||
<div> | ||
{ | ||
MenuCtx.activeTabId == "Profiles" ? | ||
<ProfilesValidationContxtProvider> | ||
<ProfilesPage /> | ||
</ProfilesValidationContxtProvider> | ||
: null | ||
} | ||
{ | ||
MenuCtx.activeTabId == "Groups" ? | ||
<InventoryDevicesValidationContxtProvider> | ||
<GroupsPage /> | ||
</InventoryDevicesValidationContxtProvider> | ||
: null | ||
} | ||
{ | ||
MenuCtx.activeTabId == "Inventory" ? | ||
<InventoryDevicesValidationContxtProvider> | ||
<InventoryPage /> | ||
</InventoryDevicesValidationContxtProvider> | ||
: null | ||
} | ||
</div> | ||
) | ||
}; | ||
|
||
export default TabPanels; |
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
20 changes: 20 additions & 0 deletions
20
frontend/packages/manager/src/store/menu-header-contxt.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,20 @@ | ||
import React, {useState, createContext, useRef, useContext} from 'react'; | ||
|
||
const MenuHeaderContxt = createContext(); | ||
|
||
export function MenuHeaderContxtProvider(props){ | ||
const [activeTabId, setActiveTabId] = useState('Profiles'); | ||
|
||
const context = { | ||
activeTabId: activeTabId, | ||
setActiveTabId: setActiveTabId | ||
}; | ||
|
||
return( | ||
<MenuHeaderContxt.Provider value={context}> | ||
{props.children} | ||
</MenuHeaderContxt.Provider> | ||
) | ||
}; | ||
|
||
export default MenuHeaderContxt; |
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,54 @@ | ||
import styled from "styled-components"; | ||
|
||
const StyledHeader = styled.div` | ||
height: 188px; | ||
width: 100%; | ||
display: flex; | ||
`; | ||
|
||
|
||
const StyledHeaderLeft = styled.div` | ||
height: 188px; | ||
width: 50%; | ||
display: flex; | ||
justify-content: flex-start; | ||
align-items: center; | ||
& > div{ | ||
margin-left: 20px; | ||
width: 600px; | ||
display: flex; | ||
justify-content: flex-start; | ||
align-items: left; | ||
flex-direction: column; | ||
} | ||
& > div > #project-title > P{ | ||
font-style: normal; | ||
font-weight: 700; | ||
font-size: 24px; | ||
line-height: 24px; | ||
} | ||
& > div > #project-description > P{ | ||
font-style: normal; | ||
font-weight: 400; | ||
font-size: 16px; | ||
line-height: 16px; | ||
} | ||
`; | ||
|
||
const StyledHeaderRight = styled.div` | ||
height: 188px; | ||
width: 50%; | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
& > div { | ||
display: flex; | ||
margin-right: 20px; | ||
} | ||
`; | ||
|
||
export { StyledHeader, StyledHeaderLeft, StyledHeaderRight } |
Oops, something went wrong.