Schemas.vue 894 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <main>
  3. <input v-model="importAccountSchemaName"/>
  4. <button @click="importAccountSchema()">Import account schema</button>
  5. <router-link v-for="schema in schemas" :to="`/schemas/${schema._id}`" class="schema-item">{{ schema.name }} v{{ schema.version }}</router-link>
  6. </main>
  7. </template>
  8. <script>
  9. import io from "../../io.js";
  10. export default {
  11. components: {},
  12. data: () => {
  13. return {
  14. importAccountSchemaName: "",
  15. schemas: []
  16. }
  17. },
  18. methods: {
  19. importAccountSchema() {
  20. this.socket.emit("accountSchema.import", this.importAccountSchemaName, (res) => {
  21. console.log(res);
  22. alert(res.status);
  23. });
  24. }
  25. },
  26. mounted() {
  27. io.getSocket(socket => {
  28. this.socket = socket;
  29. this.socket.emit("accountSchema.getAll", res => {
  30. this.schemas = res.schemas;
  31. });
  32. });
  33. }
  34. };
  35. </script>
  36. <style lang="scss" scoped>
  37. .schema-item {
  38. display: block;
  39. }
  40. </style>