Added sorting options and show secret toggle

This commit is contained in:
Gourav Kumar 2024-06-16 12:25:00 +05:30
parent ee31d128d5
commit 08a4882eaa
3 changed files with 101 additions and 15 deletions

View File

@ -16,6 +16,31 @@
>Clear</el-button >Clear</el-button
> >
</el-button-group> </el-button-group>
<div>
<el-form-item label="Show Secrets" style="float: right">
<el-switch v-model="showSecrets" />
</el-form-item>
</div>
<div class="sort-options">
<span>
<el-form-item label="Sort">
<el-select
v-model="currentSort"
filterable
placeholder="Select"
style="width: 80px"
@change="sortItems"
>
<el-option
v-for="item in sortOptions"
:key="item.key"
:label="item.name"
:value="item.key"
/>
</el-select>
</el-form-item>
</span>
</div>
</div> </div>
</div> </div>
@ -26,6 +51,8 @@
:username="secret.username" :username="secret.username"
:secret="secret.secret" :secret="secret.secret"
:id="secret.id" :id="secret.id"
:hideOtps="showSecrets"
:key="showSecrets"
@edit="editSecret" @edit="editSecret"
/> />
</span> </span>
@ -57,6 +84,22 @@ export default {
currentFilter: [], currentFilter: [],
loadCards: false, loadCards: false,
showClear: false, showClear: false,
showSecrets: false,
currentSort: "none",
sortOptions: [
{
name: "None",
key: "none",
},
{
name: "A-Z",
key: "asc",
},
{
name: "Z-A",
key: "desc",
},
],
}; };
}, },
@ -129,6 +172,15 @@ export default {
this.filteredSecretsList = this.secretsList; this.filteredSecretsList = this.secretsList;
this.showClear = false; this.showClear = false;
}, },
sortItems() {
console.log(this.currentSort);
if (this.currentSort === "asc") {
this.filteredSecretsList.sort((a, b) => a.issuer.localeCompare(b.issuer));
} else if (this.currentSort === "desc") {
this.filteredSecretsList.sort((a, b) => b.issuer.localeCompare(a.issuer));
}
},
}, },
computed: {}, computed: {},
@ -158,6 +210,25 @@ export default {
width: 90%; width: 90%;
display: flex; display: flex;
margin-bottom: 20px; margin-bottom: 20px;
justify-content: center; justify-content: space-between;
flex-wrap: wrap;
} }
.sort-options {
display: flex;
justify-content: space-between;
min-width: 80px;
}
/*
#sort {
border: none;
border-bottom: 1px solid green;
margin: 0 4px 0 4px;
font-size: 1rem;
text-align: center;
}
#sort:focus {
outline: none;
} */
</style> </style>

View File

@ -8,6 +8,7 @@
</div> </div>
<span class="user">{{ username }}</span> <br /> <span class="user">{{ username }}</span> <br />
<div class="otp-container">
<span <span
class="otp" class="otp"
@click="copyOtp" @click="copyOtp"
@ -21,6 +22,7 @@
<img src="../assets/copy-icon.png" class="button-icon" /> <img src="../assets/copy-icon.png" class="button-icon" />
</button> </button>
</div> </div>
</div>
</template> </template>
<script> <script>
@ -31,6 +33,7 @@ export default {
issuer: String, issuer: String,
username: String, username: String,
secret: String, secret: String,
hideOtps: Boolean,
}, },
data() { data() {
return { return {
@ -67,7 +70,13 @@ export default {
}, },
}, },
mounted() {}, mounted() {
if (this.hideOtps) {
this.otpHidden = !this.hideOtps;
}
},
created() {},
}; };
</script> </script>
@ -104,10 +113,16 @@ export default {
right: 0; right: 0;
margin-left: auto; margin-left: auto;
border: none; border: none;
background: none;
} }
.button-icon { .button-icon {
width: 16px; width: 16px;
height: 16px; height: 16px;
} }
.otp-container {
display: flex;
justify-content: space-between;
}
</style> </style>

View File

@ -36,6 +36,6 @@ typer==0.12.3
typing_extensions==4.12.2 typing_extensions==4.12.2
ujson==5.10.0 ujson==5.10.0
uvicorn==0.30.1 uvicorn==0.30.1
uvloop==0.19.0 # uvloop==0.19.0
watchfiles==0.22.0 watchfiles==0.22.0
websockets==12.0 websockets==12.0