All Downloads are FREE. Search and download functionalities are using the official Maven repository.

web-interface.assets.57e33c6c-50.11b9f72925818240e61d.js.map Maven / Gradle / Ivy

There is a newer version: 6.0.1
Show newest version
{"version":3,"sources":["webpack:///./src/components/common/Section/SectionComponent.tsx","webpack:///./src/components/users/navigation/UserActionLinks.tsx","webpack:///./src/components/users/navigation/UserOverviewLinks.tsx","webpack:///./src/util/SortUtils.js","webpack:///./src/components/users/CreateTokenForm.tsx","webpack:///./src/components/users/TokenList.tsx","webpack:///./src/pages/UserTokensEditPage.tsx"],"names":["Header","styled","div","Headline","h2","LoadingSpinner","Spinner","theme","css","fonts","size","h3","SectionComponent","children","title","showLoading","headerActions","className","xs","text","delay","defaultProps","undefined","UserActionLinks","userId","userIsReadOnly","to","Routes","SYSTEM","USERS","show","bsStyle","edit","TOKENS","UserOverviewLinks","teamsRoute","getPluginRoute","permissions","OVERVIEW","sortByDate","d1","d2","sortOrder","effectiveSortOrder","d1Time","moment","d2Time","isBefore","naturalSortIgnoreCase","s1","s2","naturalSort","toLowerCase","StyledForm","form","CreateTokenForm","creatingToken","onCreate","useState","tokenName","setTokenName","onSubmit","event","preventDefault","controlId","type","placeholder","value","onChange","target","id","disabled","propTypes","PropTypes","bool","func","isRequired","StyledTokenPanel","Panel","props","colors","global","contentBackground","gray","StyledCopyTokenButton","ClipboardButton","StyledSearchForm","SearchForm","StyledLastAccess","small","TokenList","deletingToken","onDelete","tokens","createdToken","setCreatedToken","query","setQuery","effectiveTokens","useMemo","queryRegex","RegExp","filter","name","test","sort","token1","token2","last_access","deleteToken","token","updateQuery","nextQuery","then","Heading","Title","Body","fixedWidth","bsSize","onClick","onSearch","onReset","searchButtonLabel","searchBsStyle","label","useLoadingState","length","Item","map","tokenNeverUsed","Date","parse","key","md","dateTime","relative","arrayOf","object","string","PageTitle","fullName","withParams","params","currentUser","useContext","CurrentUserContext","loadedUser","setLoadedUser","setTokens","deletingTokenId","setDeletingTokenId","setCreatingToken","loadTokens","useCallback","isPermitted","username","UsersDomain","_loadTokens","useEffect","load","subactions","readOnly","DocumentationLink","page","DocsHelper","PAGES","USERS_ROLES","lg","tokenId","promise","_deleteToken","createToken","_createToken"],"mappings":"2GAAA,sGA8BMA,EAASC,UAAOC,IAAV,2EAAGD,CAAH,8GAUCE,EAAWF,UAAOG,GAAV,6EAAGH,CAAH,wCAKfI,EAAiBJ,kBAAOK,KAAV,mFAAGL,EAAgB,gBAAGM,EAAH,EAAGA,MAAH,OAAeC,cAAd,CAAD,mCAExBD,EAAME,MAAMC,KAAKC,OAG1BC,EAAmB,SAAC,GAAD,IAAGC,EAAH,EAAGA,SAAUC,EAAb,EAAaA,MAAb,IAAoBC,mBAApB,SAAyCC,EAAzC,EAAyCA,cAAeC,EAAxD,EAAwDA,UAAxD,OACvB,gBAAC,IAAD,CAAKA,UAAS,kBAAaA,IACzB,gBAAC,IAAD,CAAKC,GAAI,IACP,gBAAClB,EAAD,KACE,gBAACG,EAAD,KACGW,EACAC,GAAe,gBAACV,EAAD,CAAgBc,KAAK,GAAGC,MAAO,KAEhDJ,GAEFH,KAKPD,EAAiBS,aAAe,CAC9BJ,UAAW,GACXF,aAAa,EACbC,mBAAeM,GAGFV,O,sCCvEf,oEAmDeW,IAtBS,SAAC,GAAD,IAAGC,EAAH,EAAGA,OAAQC,EAAX,EAAWA,eAAX,OACtB,gBAAC,IAAD,KACE,gBAAC,IAAD,CAAeC,GAAIC,IAAOC,OAAOC,MAAMC,KAAKN,IAC1C,gBAAC,IAAD,CAAQO,QAAQ,WAAhB,kBAIAN,GACA,gBAAC,IAAD,CAAeC,GAAIC,IAAOC,OAAOC,MAAMG,KAAKR,IAC1C,gBAAC,IAAD,CAAQO,QAAQ,WAAhB,cAKJ,gBAAC,IAAD,CAAeL,GAAIC,IAAOC,OAAOC,MAAMI,OAAOD,KAAKR,IACjD,gBAAC,IAAD,CAAQO,QAAQ,WAAhB,mB,sCC5CN,oFA8CeG,IAvBW,WACxB,IAAMC,EAAaR,IAAOS,eAAe,g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,SAAUM,aAAF,EAAEA,EAAYN,WACxCoB,WACE,gBAACzI,EAAA,EAAD,CAAiBC,OAAQA,EACRC,eAAc,UAAEyH,aAAF,EAAEA,EAAYe,gBAAd,YAE3C,6EAIA,gDACoB,IAClB,gBAACC,EAAA,EAAD,CAAmBC,KAAMC,IAAWC,MAAMC,YACvBnJ,KAAK,mBAG1B,gBAACe,EAAA,EAAD,OAGF,gBAAC,IAAD,CAAKjB,UAAU,WACb,gBAAC,IAAD,CAAKsJ,GAAI,GACP,gBAAC,IAAD,+BACCrB,EACC,gBAAC,EAAD,CAAWrD,OAAQA,EACRD,SA/BM,SAAC4E,EAAS7G,GAAV,OAlCR,SAAC6G,EAAS7G,EAAWnC,EAAQgI,EAAYF,GAC5D,IAAMmB,EAAUb,IAAY/C,YAAYrF,EAAQgJ,EAAS7G,GAEzD2F,EAAmBkB,GAEnBC,EAAQxD,MAAK,WACXuC,IACAF,OAAmBhI,MA2B8BoJ,CAAaF,EAAS7G,EAAWnC,EAAQgI,EAAYF,IAgCnF7F,SA/BM,SAACE,GAAD,OAxBR,SAACA,EAAWnC,EAAQgI,EAAYD,GACnD,IAAMkB,EAAUb,IAAYe,YAAYnJ,EAAQmC,GAIhD,OAFA4F,GAAiB,GAEVkB,EAAQxD,MAAK,SAACH,GAInB,OAHA0C,IACAD,GAAiB,GAEVzC,KAeiC8D,CAAajH,EAAWnC,EAAQgI,EAAYD,IAgCjE/F,cAAeA,EACfmC,cAAe0D,IAE1B,gBAAC,IAAD,KACE,gBAAC,IAAD,CAAKnI,GAAI,IACP,gBAAC,KAAD","file":"57e33c6c-50.11b9f72925818240e61d.js","sourcesContent":["/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport * as React from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Spinner from 'components/common/Spinner';\nimport { Row, Col } from 'components/graylog';\n\ntype Props = {\n  children: React.ReactNode,\n  title: string,\n  showLoading?: boolean,\n  headerActions?: React.ReactElement,\n  className?: string,\n};\n\nconst Header = styled.div`\n  display: flex;\n  justify-content: space-between;\n  align-items: flex-start;\n\n  *:not(:first-child) {\n    margin-left: 10px;\n  }\n`;\n\nexport const Headline = styled.h2`\n  margin-bottom: 15px;\n  display: inline;\n`;\n\nconst LoadingSpinner = styled(Spinner)(({ theme }) => css`\n  margin-left: 10px;\n  font-size: ${theme.fonts.size.h3};\n`);\n\nconst SectionComponent = ({ children, title, showLoading = false, headerActions, className }: Props) => (\n  \n    \n      
\n \n {title}\n {showLoading && }\n \n {headerActions}\n
\n {children}\n \n
\n);\n\nSectionComponent.defaultProps = {\n className: '',\n showLoading: false,\n headerActions: undefined,\n};\n\nexport default SectionComponent;\n","/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport * as React from 'react';\nimport { $PropertyType } from 'utility-types';\n\nimport { LinkContainer } from 'components/graylog/router';\nimport User from 'logic/users/User';\nimport Routes from 'routing/Routes';\nimport { ButtonToolbar, Button } from 'components/graylog';\n\ntype Props = {\n userId: $PropertyType,\n userIsReadOnly: boolean,\n};\n\nconst UserActionLinks = ({ userId, userIsReadOnly }: Props) => (\n \n \n \n \n {!userIsReadOnly && (\n \n \n \n )}\n \n \n \n \n);\n\nexport default UserActionLinks;\n","/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport * as React from 'react';\n\nimport { LinkContainer } from 'components/graylog/router';\nimport { IfPermitted } from 'components/common';\nimport Routes from 'routing/Routes';\nimport { ButtonToolbar, Button } from 'components/graylog';\n\nconst UserOverviewLinks = () => {\n const teamsRoute = Routes.getPluginRoute('SYSTEM_TEAMS');\n\n return (\n \n \n \n \n \n \n {teamsRoute && (\n \n \n \n \n \n )}\n \n );\n};\n\nexport default UserOverviewLinks;\n","/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport moment from 'moment';\nimport naturalSort from 'javascript-natural-sort';\n\n// sortOrder: \"asc\"|\"desc\"\nexport function sortByDate(d1, d2, sortOrder) {\n const effectiveSortOrder = sortOrder || 'asc';\n const d1Time = moment(d1);\n const d2Time = moment(d2);\n\n if (effectiveSortOrder === 'asc') {\n return (d1Time.isBefore(d2Time) ? -1 : d2Time.isBefore(d1Time) ? 1 : 0);\n }\n\n return (d2Time.isBefore(d1Time) ? -1 : d1Time.isBefore(d2Time) ? 1 : 0);\n}\n\nexport function naturalSortIgnoreCase(s1, s2, sortOrder) {\n const effectiveSortOrder = sortOrder || 'asc';\n\n return (effectiveSortOrder === 'asc' ? naturalSort(s1.toLowerCase(), s2.toLowerCase()) : naturalSort(s2.toLowerCase(), s1.toLowerCase()));\n}\n","/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport styled, { StyledComponent } from 'styled-components';\n\nimport { Button, ControlLabel, FormControl, FormGroup } from 'components/graylog';\nimport { Spinner } from 'components/common';\n\nconst StyledForm: StyledComponent<'form', {}> = styled.form`\n margin-top: 10px;\n &.form-inline > .form-group {\n margin-right: 10px;\n > input {\n width: 300px;\n }\n }\n`;\n\ntype Props = {\n creatingToken: boolean,\n onCreate: (tokenName: string) => void,\n};\n\nconst CreateTokenForm = ({ creatingToken, onCreate }: Props) => {\n const [tokenName, setTokenName] = useState('');\n\n const createToken = (event) => {\n event.preventDefault();\n onCreate(tokenName);\n setTokenName('');\n };\n\n return (\n \n \n Token Name\n setTokenName(event.target.value)} />\n \n \n \n );\n};\n\nCreateTokenForm.propTypes = {\n creatingToken: PropTypes.bool,\n onCreate: PropTypes.func.isRequired,\n};\n\nCreateTokenForm.defaultProps = {\n creatingToken: false,\n};\n\nexport default CreateTokenForm;\n","/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport PropTypes from 'prop-types';\nimport React, { useMemo, useState } from 'react';\nimport styled from 'styled-components';\n\nimport { ClipboardButton, ControlledTableList, Icon, Timestamp, SearchForm, Spinner } from 'components/common';\nimport { Button, Col, Panel, Row } from 'components/graylog';\nimport type { Token, TokenSummary } from 'actions/users/UsersActions';\nimport { sortByDate } from 'util/SortUtils';\n\nimport CreateTokenForm from './CreateTokenForm';\n\nconst StyledTokenPanel = styled(Panel)`\n &.panel {\n margin: 10px 0;\n background-color: ${(props) => props.theme.colors.global.contentBackground};\n\n .panel-heading {\n color: ${(props) => props.theme.colors.gray[30]};\n }\n }\n`;\n\nconst StyledCopyTokenButton = styled(ClipboardButton)`\n vertical-align: baseline;\n margin-left: 1em;\n`;\n\nconst StyledSearchForm = styled(SearchForm)`\n margin-bottom: 10px;\n`;\n\nconst StyledLastAccess = styled.div`\n color: ${(props) => props.theme.colors.gray[60]};\n font-size: ${(props) => props.theme.fonts.size.small};\n margin-bottom: 5px;\n`;\n\ntype Props = {\n creatingToken: boolean,\n deletingToken?: string,\n onCreate: (tokenName: string) => Promise,\n onDelete: (tokenId: string, tokenName: string) => void,\n tokens: TokenSummary[],\n};\n\nconst TokenList = ({ creatingToken, deletingToken, onCreate, onDelete, tokens }: Props) => {\n const [createdToken, setCreatedToken] = useState();\n const [query, setQuery] = useState('');\n\n const effectiveTokens = useMemo(() => {\n const queryRegex = new RegExp(query, 'i');\n\n return tokens\n .filter(({ name }) => queryRegex.test(name))\n .sort((token1, token2) => sortByDate(token1.last_access, token2.last_access, 'desc'));\n }, [query, tokens]);\n\n const handleTokenCreation = (tokenName) => {\n const promise = onCreate(tokenName);\n\n promise.then((token) => {\n setCreatedToken(token);\n\n return token;\n });\n };\n\n const deleteToken = (token) => {\n return () => {\n onDelete(token.id, token.name);\n };\n };\n\n const updateQuery = (nextQuery?: string) => setQuery(nextQuery || '');\n\n return (\n \n \n {createdToken && (\n \n \n Token {createdToken.name} created!\n \n \n

This is your new token. Make sure to copy it now, you will not be able to see it again.

\n
\n              {createdToken.token}\n              } text={createdToken.token} bsSize=\"xsmall\" />\n            
\n \n
\n
\n )}\n
\n \n\n \n \n {effectiveTokens.length === 0 && (\n \n

{query === '' ? 'No tokens to display.' : 'No tokens match the filter.'}

\n
\n )}\n {effectiveTokens.map((token) => {\n const tokenNeverUsed = Date.parse(token.last_access) === 0;\n\n return (\n \n \n \n {token.name}\n \n {tokenNeverUsed ? 'Never used' : <>Last used }\n \n \n \n \n \n \n \n );\n })}\n
\n
\n );\n};\n\nTokenList.propTypes = {\n tokens: PropTypes.arrayOf(PropTypes.object),\n onDelete: PropTypes.func,\n onCreate: PropTypes.func,\n creatingToken: PropTypes.bool,\n deletingToken: PropTypes.string,\n};\n\nTokenList.defaultProps = {\n tokens: [],\n onDelete: () => {},\n onCreate: () => {},\n creatingToken: false,\n deletingToken: undefined,\n};\n\nexport default TokenList;\n","/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport * as React from 'react';\nimport { useEffect, useState, useContext, useCallback } from 'react';\n\nimport User from 'logic/users/User';\nimport withParams from 'routing/withParams';\nimport { Row, Col } from 'components/graylog';\nimport CurrentUserContext from 'contexts/CurrentUserContext';\nimport { isPermitted } from 'util/PermissionsMixin';\nimport DocsHelper from 'util/DocsHelper';\nimport UsersDomain from 'domainActions/users/UsersDomain';\nimport { PageHeader, DocumentTitle, Spinner } from 'components/common';\nimport { Headline } from 'components/common/Section/SectionComponent';\nimport TokenList from 'components/users/TokenList';\nimport UserOverviewLinks from 'components/users/navigation/UserOverviewLinks';\nimport UserActionLinks from 'components/users/navigation/UserActionLinks';\nimport DocumentationLink from 'components/support/DocumentationLink';\n\ntype Props = {\n params: {\n userId: string,\n },\n};\n\nconst PageTitle = ({ fullName }: { fullName: string | null | undefined }) => (\n <>\n Edit Tokens Of User {fullName && (\n <>\n - {fullName}\n \n )}\n \n);\n\nconst _loadTokens = (loadedUser, currentUser, setTokens) => {\n if (loadedUser) {\n if (isPermitted(currentUser?.permissions, [`users:tokenlist:${loadedUser.username}`])) {\n UsersDomain.loadTokens(loadedUser.id).then(setTokens);\n } else {\n setTokens([]);\n }\n }\n};\n\nconst _deleteToken = (tokenId, tokenName, userId, loadTokens, setDeletingTokenId) => {\n const promise = UsersDomain.deleteToken(userId, tokenId, tokenName);\n\n setDeletingTokenId(tokenId);\n\n promise.then(() => {\n loadTokens();\n setDeletingTokenId(undefined);\n });\n};\n\nconst _createToken = (tokenName, userId, loadTokens, setCreatingToken) => {\n const promise = UsersDomain.createToken(userId, tokenName);\n\n setCreatingToken(true);\n\n return promise.then((token) => {\n loadTokens();\n setCreatingToken(false);\n\n return token;\n });\n};\n\nconst UserEditPage = ({ params }: Props) => {\n const currentUser = useContext(CurrentUserContext);\n const [loadedUser, setLoadedUser] = useState();\n const [tokens, setTokens] = useState([]);\n const [deletingTokenId, setDeletingTokenId] = useState();\n const [creatingToken, setCreatingToken] = useState(false);\n\n const userId = params?.userId;\n\n const loadTokens = useCallback(() => _loadTokens(loadedUser, currentUser, setTokens), [currentUser, loadedUser]);\n const _handleTokenDelete = (tokenId, tokenName) => _deleteToken(tokenId, tokenName, userId, loadTokens, setDeletingTokenId);\n const _handleTokenCreate = (tokenName) => _createToken(tokenName, userId, loadTokens, setCreatingToken);\n\n useEffect(() => { loadTokens(); }, [loadTokens, loadedUser]);\n useEffect(() => { UsersDomain.load(userId).then(setLoadedUser); }, [userId]);\n\n return (\n \n }\n subactions={(\n \n )}>\n \n You can create new tokens or delete old ones.\n \n\n \n Learn more in the{' '}\n \n \n\n \n \n\n \n \n Create And Edit Tokens\n {loadedUser ? (\n \n ) : (\n \n \n \n \n \n )}\n \n \n \n );\n};\n\nexport default withParams(UserEditPage);\n"],"sourceRoot":""}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy