ViewAccountSchema.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <main v-if="schema">
  3. <h1>View schema</h1>
  4. <hr/>
  5. <br/>
  6. <p><b>Name</b>: {{ schema.name }}</p>
  7. <p><b>Description</b>: {{ schema.description }}</p>
  8. <p><b>Version</b>: v{{ schema.version }}</p>
  9. <p><b>Fields</b>: </p>
  10. <div class="fields-container">
  11. <div v-for="field in schema.fields" class="field-item">
  12. <p><b>Field ID</b>: {{ field.fieldId }}</p>
  13. <p><b>Name</b>: {{ field.name }}</p>
  14. <p><b>Min entries</b>: {{ field.minEntries }}</p>
  15. <p><b>Max entries</b>: {{ field.maxEntries }}</p>
  16. <p><b>Field types</b>:</p>
  17. <div class="field-types-container">
  18. <div v-for="fieldType in field.fieldTypes" class="field-type-item">
  19. <p><b>Field type ID</b>: {{ fieldType.fieldTypeId }}</p>
  20. <p><b>Type</b>: {{ fieldType.type }}</p>
  21. <p><b>Fill</b>: {{ fieldType.fill }}</p>
  22. <p v-if="fieldType.type === 'select'"><b>Options</b>: </p>
  23. <div v-if="fieldType.type === 'select'">
  24. <div v-for="option in fieldType.options" class="option-item">
  25. <p><b>Text</b>: {{ option.text }}</p>
  26. <p><b>Value</b>: {{ option.value }}</p>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <br/>
  34. <br/>
  35. <button class="button" @click="removeSchema()">Remove schema</button>
  36. </main>
  37. </template>
  38. <script>
  39. import io from "../../io.js";
  40. export default {
  41. components: {},
  42. data: () => {
  43. return {
  44. schema: null
  45. }
  46. },
  47. props: {
  48. },
  49. methods: {
  50. removeSchema() {
  51. this.socket.emit("accountSchema.removeById", this.schemaId, (res) => {
  52. alert(res.status);
  53. this.$router.push("/schemas");
  54. });
  55. }
  56. },
  57. mounted() {
  58. this.schemaId = this.$route.params.schemaId;
  59. io.getSocket(socket => {
  60. this.socket = socket;
  61. this.socket.emit("accountSchema.getLatest", this.schemaId, res => {
  62. if (res.status === "success") {
  63. this.schema = res.schema;
  64. }
  65. });
  66. });
  67. }
  68. };
  69. </script>
  70. <style lang="scss" scoped>
  71. .field-item, .field-type-item, .option-item {
  72. padding-left: 25px;
  73. border: 1px solid black;
  74. margin-right: -1px;
  75. margin-bottom: -1px;
  76. }
  77. </style>