minor changes

This commit is contained in:
2018-09-20 20:33:12 +02:00
parent c8c2b4ef29
commit 0316a2fcd8
7 changed files with 100 additions and 8 deletions

View File

@ -187,7 +187,7 @@ const New = inject("rootStore") ( observer(
</Input>
</Form.Field>
<p>The encryption key for this entry is '<b>{this.props.encryptionkey}</b>'</p>
<p>Login and password are going to be encrypted with the key you have set.</p>
<Button loading={this.state.loading} type='submit' primary>Add</Button>
<Button loading={this.state.loading} onClick={this.props.toggleNewWindow}><Icon name="x" />Cancel</Button>

View File

@ -4,6 +4,7 @@ import jss from 'jss';
import preset from 'jss-preset-default';
import { Menu, Segment, Dropdown, Table, Button, Loader, Icon, Header, Input } from 'semantic-ui-react';
import alertify from 'alertify.js';
import ReactHtmlParser from 'react-html-parser';
/*
* Functions import
@ -143,6 +144,8 @@ const PasswordManager = inject("rootStore") ( observer(
var components = [];
function copyToClipboard(string) {
//Copy string to clipboard
var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = 0;
@ -170,6 +173,15 @@ const PasswordManager = inject("rootStore") ( observer(
}
document.body.removeChild(textArea);
}
function transformUrl(text) {
//Transforms url into clickable link
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig;
var text1 = text.replace(exp, '<a target="_blank" href="$1">$1</a>');
var exp2 = /(^|[^/])(www\.[\S]+(\b|$))/gim;
return ReactHtmlParser(text1.replace(exp2, '$1<a target="_blank" href="http://$2">$2</a>'));
}
dataList.forEach((element, index) => {
if(element.url.includes(this.state.search)) {
@ -179,16 +191,21 @@ const PasswordManager = inject("rootStore") ( observer(
const copyPassword = () => {
copyToClipboard(decrypt(element.password, this.state.key));
}
const url = transformUrl(element.url);
const password = decrypt(element.password, this.state.key);
const login = decrypt(element.login, this.state.key);
components.push(
<Table.Row key={index}>
<Table.Cell>{element.url}</Table.Cell>
<Table.Cell>{decrypt(element.login, this.state.key)}</Table.Cell>
<Table.Cell>{url}</Table.Cell>
<Table.Cell>{login}</Table.Cell>
<Table.Cell>
<Button icon>
<Icon onClick={copyLogin} name='copy' />
</Button>
</Table.Cell>
<Table.Cell>{decrypt(element.password, this.state.key)}</Table.Cell>
<Table.Cell>{password}</Table.Cell>
<Table.Cell>
<Button icon>
<Icon onClick={copyPassword} name='copy' />