| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <template>
- <div class="bg-lightgray m-1 p-2 border rounded container-fluid">
- <credential-form-modal :descriptions="creddescList" :modal-id="'credential'+this.data.credid+'editModal'" :populateWith="this.data"></credential-form-modal>
- <div class="row no-gutters">
- <div class="h5 col-3 text-left">{{this.data.creddesc}}</div>
- <div class="col-9 text-right">{{this.data.creddate}}</div>
- </div>
- <div class="row">
- <div class="col-lg-9">
- <div>
- <label for="username"><i class="fas fa-fw fa-user"></i></label>
- <input type="text" v-bind:id="'username' + this.data.credid" class="border-0 credential" v-bind:value=this.data.creduser readonly/>
- <button v-bind:id="'btn-username' + this.data.credid" class="btn-clip btn btn-sm btn-primary rounded-pill" v-bind:data-clipboard-target="'#username' + this.data.credid">
- <i class="far fa-clone"></i>
- </button>
- </div>
- <div>
- <label for="password"><i class="fas fa-fw fa-key"></i></label>
- <input type="text" v-bind:id="'password' + this.data.credid" class="border-0 credential" v-bind:value=this.data.credpass readonly/>
- <button v-bind:id="'btn-password' + this.data.credid" class="btn-clip btn btn-sm btn-primary rounded-pill" v-bind:data-clipboard-target="'#password' + this.data.credid">
- <i class="far fa-clone"></i>
- </button>
- </div>
- </div>
- <div class="btn-group col-lg-2 align-self-end w-25 w-lg-auto" role="group" aria-label="Edit and Delete">
- <button type="button" class="btn btn-sm btn-secondary p-lg-1" data-toggle="modal" :data-target="'#credential'+this.data.credid+'editModal'"><i class="fas fa-fw fa-edit"></i></button>
- <button type="button" class="btn btn-sm btn-danger p-lg-1"><i class="fas fa-fw fa-trash-alt"></i></button>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- props: ['credential', 'descriptions'],
- data() {
- return {
- data: this.credential,
- creddescList: this.descriptions
- }
- },
- mounted() {
- Echo.channel('credentials')
- .listen('CredentialUpdated', (e) => {
- // This part could potentially use a refactor.
- // Probably needs a credential list component to listen for this
- // even and update the corresponding credential. Currently every
- // credential on the page receives this event and checks whether it was intended
- // for its credential or not. I would imagine this could cause a problem
- // on the group page, which will potentially have a lot more credentials from
- // various assets. Better solution may be to have a credentials list component
- // That listens for credential update events and updates the appropriate credential.
- // There would still be multiples of those on the group credentials page, but an
- // order of magnitude less of those than of individual credentials.
- // It also may not be a big deal performance wise to do it like this, not sure.
- let eData = JSON.parse(e.data);
- if (this.data.credid === eData.credid) {
- this.data = eData;
- }
- });
- }
- }
- </script>
|