1
0

Homepage.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div>
  3. <input v-model="importAccountSchemaName"/>
  4. <button @click="importAccountSchema()">Import account schema</button>
  5. <hr />
  6. <h1>Sites</h1>
  7. <form>
  8. <field
  9. v-for="field in fields"
  10. :name="field.name"
  11. :minEntries="field.minEntries"
  12. :maxEntries="field.maxEntries"
  13. :initialEntries="[]"
  14. :fieldTypes="field.fieldTypes"/>
  15. </form>
  16. </div>
  17. </template>
  18. <script>
  19. import Field from '../components/Field.vue';
  20. import io from "../../io.js";
  21. export default {
  22. components: { Field },
  23. data: () => {
  24. return {
  25. fields: [],
  26. accounts: [],
  27. importAccountSchemaName: ""
  28. }
  29. },
  30. methods: {
  31. importAccountSchema() {
  32. this.socket.emit("importAccountSchema", this.importAccountSchemaName, (res) => {
  33. console.log(res);
  34. alert(res.status);
  35. });
  36. }
  37. },
  38. mounted() {
  39. io.getSocket(socket => {
  40. this.socket = socket;
  41. socket.emit("getAccountSchema", res => {
  42. console.log(res);
  43. this.fields = res.schema.fields;
  44. });
  45. socket.emit("getAccounts", res => {
  46. this.accounts = res.accounts;
  47. });
  48. });
  49. }
  50. };
  51. </script>
  52. <style lang="scss" scoped>
  53. form {
  54. width: 400px;
  55. }
  56. </style>