Skip to content

Commit

Permalink
Merge pull request #94 from rapid7/OPS-1-profileNames
Browse files Browse the repository at this point in the history
OPS-1 make profileName user configurable
  • Loading branch information
fmitchell-r7 authored Aug 24, 2017
2 parents 8c75630 + f4c19a5 commit c6f97e1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 23 deletions.
14 changes: 12 additions & 2 deletions lib/routes/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ module.exports = (app, auth) => {
const metadataUrl = req.body.metadataUrl;
const metaDataResponseObj = Object.assign(ResponseObj, {defaultMetadataUrl: metadataUrl});

let storedMetadataUrls = Storage.get('metadataUrls') || {},
profileName = req.body.profileName;

if (profileName === '') {
profileName = metadataUrl;
}

if (profileName && storedMetadataUrls[metadataUrl] && storedMetadataUrls[metadataUrl] !== profileName) {
storedMetadataUrls[metadataUrl] = profileName;
Storage.set(storedMetadataUrls);
}
app.set('metadataUrl', metadataUrl);

const xmlReq = https.get(metadataUrl, (xmlRes) => {
Expand Down Expand Up @@ -101,8 +112,7 @@ module.exports = (app, auth) => {
let metadataUrls = Storage.get('metadataUrls') || {};

if (!metadataUrls.hasOwnProperty(metadataUrl)) {
metadataUrls[metadataUrl] = metadataUrl

metadataUrls[metadataUrl] = profileName || metadataUrl;
Storage.set('metadataUrls', metadataUrls);
}

Expand Down
6 changes: 6 additions & 0 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,9 @@ summary {
.login-button {
margin-left: auto;
}

div.profile {
width: 80%;
height: 2.5em;
line-height: 2.5em;
}
46 changes: 25 additions & 21 deletions views/configure.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,42 @@ class Configure extends React.Component {

return (
<li className='list-group-item' key={key}>
<details>
<summary>{pretty}
<form className='login-button' method='post'>
<form method='post'>
<details>
<summary>
<div className='profile'>
<input className='form-control' name='profileName' type='text' value={pretty} />
</div>
<input
className='form-control'
id='metadataUrl'
name='metadataUrl'
type='hidden'
value={key}
/>
<span>
<button className='btn btn-default' type='submit'>Login</button>
<span className='login-button'>
<button className='login-button btn btn-default' type='submit'>Login</button>
</span>
</form>

</summary>
</summary>

<br/>
<br/>

<div className='input-group'>
<input
className='form-control' defaultValue={key}
name={pretty} readonly // eslint-disable-line react/no-unknown-property
/>
<span className='input-group-btn'>
<button
className='btn btn-default copy-to-clipboard-button'
data-clipboard-target={urlSelector}
><span className='glyphicon glyphicon-copy'/></button>
</span>
</div>
</details>
<div className='input-group'>
<input
className='form-control' defaultValue={key}
name={pretty} readonly // eslint-disable-line react/no-unknown-property
/>
<span className='input-group-btn'>
<button
className='btn btn-default copy-to-clipboard-button'
data-clipboard-target={urlSelector}
type='button'
><span className='glyphicon glyphicon-copy'/></button>
</span>
</div>
</details>
</form>
</li>
);
})
Expand Down

0 comments on commit c6f97e1

Please sign in to comment.