search, copy and fixes
This commit is contained in:
parent
8d93af6552
commit
c8c2b4ef29
@ -1,14 +1,11 @@
|
|||||||
{
|
{
|
||||||
// Example:
|
"indexes": [
|
||||||
//
|
{
|
||||||
// "indexes": [
|
"collectionId": "passwords",
|
||||||
// {
|
"fields": [
|
||||||
// "collectionId": "widgets",
|
{ "fieldPath": "uid", "mode": "ASCENDING" },
|
||||||
// "fields": [
|
{ "fieldPath": "time", "mode": "DESCENDING" }
|
||||||
// { "fieldPath": "foo", "mode": "ASCENDING" },
|
]
|
||||||
// { "fieldPath": "bar", "mode": "DESCENDING" }
|
}
|
||||||
// ]
|
]
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
"indexes": []
|
|
||||||
}
|
}
|
BIN
src/loc.exe
Normal file
BIN
src/loc.exe
Normal file
Binary file not shown.
@ -120,17 +120,26 @@ const New = inject("rootStore") ( observer(
|
|||||||
const password = encrypt(this.state.password, this.props.encryptionkey);
|
const password = encrypt(this.state.password, this.props.encryptionkey);
|
||||||
const uid = this.stores.authStore.userData.uid;
|
const uid = this.stores.authStore.userData.uid;
|
||||||
|
|
||||||
db.collection("passwords").add({
|
const data = {
|
||||||
uid: uid,
|
uid: uid,
|
||||||
url: url,
|
url: url,
|
||||||
login: login,
|
login: login,
|
||||||
password: password,
|
password: password,
|
||||||
time: new Date()
|
time: new Date()
|
||||||
})
|
}
|
||||||
|
|
||||||
|
//Add a new doc locally so no new data transfer from firestore
|
||||||
|
//is needed
|
||||||
|
this.props.addDoc(data);
|
||||||
|
|
||||||
|
db.collection("passwords/"+uid+"/passwords").add(data)
|
||||||
.then((docRef) => {
|
.then((docRef) => {
|
||||||
console.log("Document written with ID: ", docRef.id);
|
console.log("Document written with ID: ", docRef.id);
|
||||||
alertify.success("Document successfully added!");
|
alertify.success("Document successfully added!");
|
||||||
this.props.toggleNewWindow();
|
this.props.toggleNewWindow();
|
||||||
|
this.setState({
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
console.error("Error adding document: ", error);
|
console.error("Error adding document: ", error);
|
||||||
|
@ -54,6 +54,7 @@ const PasswordManager = inject("rootStore") ( observer(
|
|||||||
|
|
||||||
this.toggleNewWindow = this.toggleNewWindow.bind(this);
|
this.toggleNewWindow = this.toggleNewWindow.bind(this);
|
||||||
this.onChangeInput = this.onChangeInput.bind(this);
|
this.onChangeInput = this.onChangeInput.bind(this);
|
||||||
|
this.addDoc = this.addDoc.bind(this);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
newWindowOpen: false,
|
newWindowOpen: false,
|
||||||
@ -82,6 +83,18 @@ const PasswordManager = inject("rootStore") ( observer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addDoc(data) {
|
||||||
|
//Add a new doc locally so no new data transfer from firestore
|
||||||
|
//is needed
|
||||||
|
var newArr = [];
|
||||||
|
newArr[0] = data;
|
||||||
|
newArr = newArr.concat(this.state.data);
|
||||||
|
this.setState({
|
||||||
|
data: newArr
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
onChangeInput(e) {
|
onChangeInput(e) {
|
||||||
//Encryption key and search input
|
//Encryption key and search input
|
||||||
|
|
||||||
@ -111,11 +124,11 @@ const PasswordManager = inject("rootStore") ( observer(
|
|||||||
|
|
||||||
const uid = this.stores.authStore.userData.uid;
|
const uid = this.stores.authStore.userData.uid;
|
||||||
|
|
||||||
db.collection("passwords").where("uid", "==", uid).orderBy("time", "desc").get().then((querySnapshot) => {
|
db.collection("passwords/"+uid+"/passwords").where("uid", "==", uid).orderBy("time", "desc").get().then((querySnapshot) => {
|
||||||
var arr = [];
|
var arr = [];
|
||||||
querySnapshot.forEach((doc) => {
|
querySnapshot.forEach((doc) => {
|
||||||
const data = doc.data();
|
const data = doc.data();
|
||||||
arr.push(data);
|
arr.push(data);
|
||||||
});
|
});
|
||||||
this.setState({
|
this.setState({
|
||||||
data: arr,
|
data: arr,
|
||||||
@ -129,24 +142,61 @@ const PasswordManager = inject("rootStore") ( observer(
|
|||||||
//Returns array with all table row components
|
//Returns array with all table row components
|
||||||
var components = [];
|
var components = [];
|
||||||
|
|
||||||
|
function copyToClipboard(string) {
|
||||||
|
var textArea = document.createElement("textarea");
|
||||||
|
textArea.style.position = 'fixed';
|
||||||
|
textArea.style.top = 0;
|
||||||
|
textArea.style.left = 0;
|
||||||
|
textArea.style.width = '2em';
|
||||||
|
textArea.style.height = '2em';
|
||||||
|
textArea.style.padding = 0;
|
||||||
|
textArea.style.border = 'none';
|
||||||
|
textArea.style.outline = 'none';
|
||||||
|
textArea.style.boxShadow = 'none';
|
||||||
|
textArea.style.background = 'transparent';
|
||||||
|
textArea.value = string;
|
||||||
|
document.body.appendChild(textArea);
|
||||||
|
textArea.focus();
|
||||||
|
textArea.select();
|
||||||
|
try {
|
||||||
|
var successful = document.execCommand('copy');
|
||||||
|
if(successful) {
|
||||||
|
alertify.success("Copied to clipboard!");
|
||||||
|
} else {
|
||||||
|
alertify.error("Unable to copy to clipboard");
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
alertify.error("Unable to copy to clipboard");
|
||||||
|
}
|
||||||
|
document.body.removeChild(textArea);
|
||||||
|
}
|
||||||
|
|
||||||
dataList.forEach((element, index) => {
|
dataList.forEach((element, index) => {
|
||||||
components.push(
|
if(element.url.includes(this.state.search)) {
|
||||||
<Table.Row key={index}>
|
const copyLogin = () => {
|
||||||
<Table.Cell>{element.url}</Table.Cell>
|
copyToClipboard(decrypt(element.login, this.state.key));
|
||||||
<Table.Cell>{decrypt(element.login, this.state.key)}</Table.Cell>
|
}
|
||||||
<Table.Cell>
|
const copyPassword = () => {
|
||||||
<Button icon>
|
copyToClipboard(decrypt(element.password, this.state.key));
|
||||||
<Icon name='copy' />
|
}
|
||||||
</Button>
|
components.push(
|
||||||
</Table.Cell>
|
<Table.Row key={index}>
|
||||||
<Table.Cell>{decrypt(element.password, this.state.key)}</Table.Cell>
|
<Table.Cell>{element.url}</Table.Cell>
|
||||||
<Table.Cell>
|
<Table.Cell>{decrypt(element.login, this.state.key)}</Table.Cell>
|
||||||
<Button icon>
|
<Table.Cell>
|
||||||
<Icon name='copy' />
|
<Button icon>
|
||||||
</Button>
|
<Icon onClick={copyLogin} name='copy' />
|
||||||
</Table.Cell>
|
</Button>
|
||||||
</Table.Row>
|
</Table.Cell>
|
||||||
);
|
<Table.Cell>{decrypt(element.password, this.state.key)}</Table.Cell>
|
||||||
|
<Table.Cell>
|
||||||
|
<Button icon>
|
||||||
|
<Icon onClick={copyPassword} name='copy' />
|
||||||
|
</Button>
|
||||||
|
</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return components;
|
return components;
|
||||||
@ -158,7 +208,7 @@ const PasswordManager = inject("rootStore") ( observer(
|
|||||||
|
|
||||||
return(
|
return(
|
||||||
<div>
|
<div>
|
||||||
<New encryptionkey={this.state.key} open={this.state.newWindowOpen} toggleNewWindow={this.toggleNewWindow} />
|
<New addDoc={this.addDoc} encryptionkey={this.state.key} open={this.state.newWindowOpen} toggleNewWindow={this.toggleNewWindow} />
|
||||||
|
|
||||||
<Headline black="Password " red="manager" />
|
<Headline black="Password " red="manager" />
|
||||||
|
|
||||||
@ -179,7 +229,7 @@ const PasswordManager = inject("rootStore") ( observer(
|
|||||||
<Menu.Menu position='right'>
|
<Menu.Menu position='right'>
|
||||||
<div className='ui right aligned category search item'>
|
<div className='ui right aligned category search item'>
|
||||||
<div className='ui transparent icon input'>
|
<div className='ui transparent icon input'>
|
||||||
<input className='prompt' type='text' placeholder='Encryption key...' name="key" onChange={this.onChangeInput} autoComplete="off" />
|
<input className='prompt' type='password' placeholder='Encryption key...' name="key" onChange={this.onChangeInput} autoComplete="off" />
|
||||||
<i className='key icon' />
|
<i className='key icon' />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -193,9 +243,9 @@ const PasswordManager = inject("rootStore") ( observer(
|
|||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.HeaderCell width={4}>Application / URL</Table.HeaderCell>
|
<Table.HeaderCell width={4}>Application / URL</Table.HeaderCell>
|
||||||
<Table.HeaderCell width={5}>Username / Email adress</Table.HeaderCell>
|
<Table.HeaderCell width={5}>Username / Email adress</Table.HeaderCell>
|
||||||
<Table.HeaderCell width={1}>Copy</Table.HeaderCell>
|
<Table.HeaderCell width={1}></Table.HeaderCell>
|
||||||
<Table.HeaderCell width={5}>Password</Table.HeaderCell>
|
<Table.HeaderCell width={5}>Password</Table.HeaderCell>
|
||||||
<Table.HeaderCell width={1}>Copy</Table.HeaderCell>
|
<Table.HeaderCell width={1}></Table.HeaderCell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
</Table.Header>
|
</Table.Header>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user