|
| 1 | +<template> |
| 2 | + <v-container fluid pa-0 class="d-flex flex-column flex-grow-1 fill-parent-height"> |
| 3 | + <v-row no-gutters class="top-row flex-grow-1 flex-shrink-1"> |
| 4 | + <v-col class="side-panel fill-parent-height"> |
| 5 | + <h2 style="text-align: center;">Configuration</h2> |
| 6 | + |
| 7 | + <v-subheader>Active Key Node</v-subheader> |
| 8 | + <v-select value="~/.polykey" :items="nodePathList" label="Active Key Node" solo style="margin: 10px;" /> |
| 9 | + |
| 10 | + <v-subheader>Key Node List</v-subheader> |
| 11 | + <v-list-item> |
| 12 | + <v-list-item-content> |
| 13 | + <v-btn color="success" rounded small @click="newKeyNode()">New KeyNode</v-btn> |
| 14 | + </v-list-item-content> |
| 15 | + </v-list-item> |
| 16 | + |
| 17 | + <v-list :item-height="50" color="transparent"> |
| 18 | + <v-list-item-group v-model="selectedVaultIndex" color="primary" mandatory> |
| 19 | + <v-list-item v-for="item in nodePathList" :key="item" color="primary" link :ripple="false"> |
| 20 | + <v-list-item-icon> |
| 21 | + <v-icon>fas fa-file</v-icon> |
| 22 | + </v-list-item-icon> |
| 23 | + |
| 24 | + <v-list-item-title>{{item}}</v-list-item-title> |
| 25 | + |
| 26 | + <v-spacer></v-spacer> |
| 27 | + <v-btn link icon x-small color="warning" @click="deleteVault(item)"> |
| 28 | + <v-icon>fas fa-trash</v-icon> |
| 29 | + </v-btn> |
| 30 | + </v-list-item> |
| 31 | + </v-list-item-group> |
| 32 | + </v-list> |
| 33 | + </v-col> |
| 34 | + <v-col class="main-panel fill-parent-height"> |
| 35 | + <!-- <v-card color="FloralWhite" style="position: relative" width="100%"> |
| 36 | + <v-form v-model="valid" ref="newVaultForm"> |
| 37 | + <v-container> |
| 38 | + <h2>New KeyNode</h2> |
| 39 | + <span>Use this form to initialize a new keynode state</span> |
| 40 | + <v-row> |
| 41 | + <v-col> |
| 42 | + <v-list outlined> |
| 43 | + <v-text-field |
| 44 | + v-model="secretName" |
| 45 | + :rules="secretNameRules" |
| 46 | + label="Full Name" |
| 47 | + counter="100" |
| 48 | + required |
| 49 | + outlined |
| 50 | + style="padding-left: 10px; padding-right: 10px" |
| 51 | + placeholder="Enter your full name" |
| 52 | + /> |
| 53 | +
|
| 54 | + <v-textarea |
| 55 | + v-model="secretContent" |
| 56 | + label="Secret Content" |
| 57 | + required |
| 58 | + outlined |
| 59 | + style="padding-left: 10px; padding-right: 10px" |
| 60 | + placeholder="Enter the content of the secret" |
| 61 | + ></v-textarea> |
| 62 | + </v-list> |
| 63 | + </v-col> |
| 64 | + </v-row> |
| 65 | + </v-container> |
| 66 | +
|
| 67 | + <v-card-actions> |
| 68 | + <v-btn @click="cancel">Cancel</v-btn> |
| 69 | + <v-btn color="warning" @click="resetValidation">Clear</v-btn> |
| 70 | + <v-spacer></v-spacer> |
| 71 | + <v-btn color="success" @click="newSecret">Create</v-btn> |
| 72 | + </v-card-actions> |
| 73 | + </v-form> |
| 74 | + </v-card> --> |
| 75 | + </v-col> |
| 76 | + </v-row> |
| 77 | + </v-container> |
| 78 | +</template> |
| 79 | + |
| 80 | +<script lang="ts"> |
| 81 | +import { Component, Vue, Prop } from 'vue-property-decorator'; |
| 82 | +import { namespace } from 'vuex-class'; |
| 83 | +import { polykeyClient } from '@/store'; |
| 84 | +import { getConfiguration } from '@/store/modules/Configuration'; |
| 85 | +
|
| 86 | +const configuration = namespace('Configuration'); |
| 87 | +
|
| 88 | +const namingRule = name => |
| 89 | + /^\b[\w]+(?:['-]?[\w]+)*\b$/.test(name) || !name || 'Name must only contain letters, numbers and hyphens'; |
| 90 | +
|
| 91 | +@Component({}) |
| 92 | +export default class Configuration extends Vue { |
| 93 | + @configuration.State |
| 94 | + public activeNodePath!: string; |
| 95 | +
|
| 96 | + @configuration.State |
| 97 | + public nodePathList!: string[]; |
| 98 | +
|
| 99 | + @configuration.Action |
| 100 | + public loadNodePathList!: () => Promise<void>; |
| 101 | +
|
| 102 | + public valid: boolean = false; |
| 103 | + public secretName = ''; |
| 104 | + public secretNameRules = [namingRule]; |
| 105 | + public secretContent = ''; |
| 106 | + selectedVaultIndex = 0 |
| 107 | +
|
| 108 | + newKeyNode() { |
| 109 | + this.$router.push('Configuration/NewKeyNode') |
| 110 | + } |
| 111 | +
|
| 112 | + validate(): boolean { |
| 113 | + return (<any>this.$refs.newVaultForm).validate(); |
| 114 | + } |
| 115 | + reset() { |
| 116 | + (<any>this.$refs.newVaultForm).reset(); |
| 117 | + } |
| 118 | + resetValidation() { |
| 119 | + this.reset(); |
| 120 | + } |
| 121 | + async newSecret() { |
| 122 | + if (this.validate()) { |
| 123 | + // const successful = await polykeyClient.createSecret( |
| 124 | + // getConfiguration().activeNodePath, |
| 125 | + // this.selectedVaultName, |
| 126 | + // this.secretName, |
| 127 | + // Buffer.from(this.secretContent), |
| 128 | + // ); |
| 129 | + // console.log(successful); |
| 130 | + // if (successful) { |
| 131 | + // this.$router.back(); |
| 132 | + // } |
| 133 | + } else { |
| 134 | + alert('Please address errors'); |
| 135 | + } |
| 136 | + } |
| 137 | +
|
| 138 | + cancel() { |
| 139 | + this.$router.back(); |
| 140 | + } |
| 141 | +
|
| 142 | + constructor() { |
| 143 | + super() |
| 144 | + this.loadNodePathList().then(() => { |
| 145 | + console.log(this.nodePathList); |
| 146 | +
|
| 147 | + }) |
| 148 | + } |
| 149 | +} |
| 150 | +</script> |
| 151 | + |
| 152 | +<style scoped> |
| 153 | +.main-panel { |
| 154 | + margin: 10px; |
| 155 | + min-height: 0; |
| 156 | +} |
| 157 | +
|
| 158 | +.side-panel { |
| 159 | + background-color: rgb(184, 184, 184); |
| 160 | + overflow-y: scroll; |
| 161 | + max-width: 300px; |
| 162 | + min-width: 150px; |
| 163 | +} |
| 164 | +
|
| 165 | +.fill-parent-height { |
| 166 | + height: 100%; |
| 167 | +} |
| 168 | +
|
| 169 | +.top-row { |
| 170 | + min-height: 0; |
| 171 | +} |
| 172 | +</style> |
0 commit comments