Schemas.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <main>
  3. <h1>Schemas</h1>
  4. <hr/>
  5. <br/>
  6. <input v-model="importAccountSchemaName"/>
  7. <button @click="importAccountSchema()" class="button">Import account schema</button>
  8. <br/>
  9. <br/>
  10. <data-table ref="datatable"
  11. :fields="fields"
  12. :sort-order="sortOrder"
  13. :data="localData"
  14. >
  15. <div slot="actions-slot" slot-scope="props">
  16. <router-link
  17. :to="`/schemas/${props.data.schemaId}`"
  18. class="button"
  19. >
  20. View schema
  21. </router-link>
  22. </div>
  23. </data-table>
  24. </main>
  25. </template>
  26. <script>
  27. import io from "../../io.js";
  28. import DataTable from '../components/DataTable.vue';
  29. export default {
  30. components: { DataTable },
  31. data: () => {
  32. return {
  33. importAccountSchemaName: "",
  34. schemas: [],
  35. fields: [
  36. {
  37. name: "name",
  38. displayName: "Name"
  39. },
  40. {
  41. name: "version",
  42. displayName: "Version"
  43. },
  44. {
  45. name: "actions-slot",
  46. displayName: "Actions"
  47. }
  48. ],
  49. sortOrder: [
  50. {
  51. field: "version",
  52. order: "desc"
  53. }
  54. ]
  55. }
  56. },
  57. computed: {
  58. localData: function() {
  59. return this.schemas.map(schema => {
  60. return {
  61. name: schema.name,
  62. version: schema.version,
  63. schemaId: schema._id
  64. };
  65. });
  66. }
  67. },
  68. methods: {
  69. importAccountSchema() {
  70. this.socket.emit("accountSchema.import", this.importAccountSchemaName, (res) => {
  71. console.log(res);
  72. alert(res.status);
  73. });
  74. }
  75. },
  76. mounted() {
  77. io.getSocket(socket => {
  78. this.socket = socket;
  79. this.socket.emit("accountSchema.getAll", res => {
  80. this.schemas = res.schemas;
  81. });
  82. });
  83. }
  84. };
  85. </script>
  86. <style lang="scss" scoped>
  87. .schema-item {
  88. display: block;
  89. }
  90. </style>