1
0

ConvertAccounts.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <main>
  3. <h1>Accounts</h1>
  4. <hr/>
  5. <br/>
  6. <input v-model="importConvertSchemaName"/>
  7. <button @click="importConvertSchema()" class="button">Import convert 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="`/convert/${props.data.accountId}`"
  18. class="button"
  19. >
  20. Convert account
  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. accounts: [],
  34. fields: [
  35. {
  36. name: "name",
  37. displayName: "Name"
  38. },
  39. {
  40. name: "version",
  41. displayName: "Version"
  42. },
  43. {
  44. name: "actions-slot",
  45. displayName: "Actions"
  46. }
  47. ],
  48. sortOrder: [
  49. {
  50. field: "name",
  51. order: "desc"
  52. },
  53. {
  54. field: "version",
  55. order: "asc"
  56. }
  57. ],
  58. importConvertSchemaName: ""
  59. }
  60. },
  61. computed: {
  62. localData: function() {
  63. return this.accounts.map(account => {
  64. return {
  65. name: account.fields.name[0].name,
  66. version: account.version,
  67. accountId: account._id
  68. };
  69. });
  70. }
  71. },
  72. methods: {
  73. importConvertSchema() {
  74. this.socket.emit("convertSchema.import", this.importConvertSchemaName, (res) => {
  75. console.log(res);
  76. alert(res.status);
  77. });
  78. }
  79. },
  80. mounted() {
  81. io.getSocket(socket => {
  82. this.socket = socket;
  83. socket.emit("account.getAll", res => {
  84. console.log(res);
  85. this.accounts = res.accounts;
  86. });
  87. });
  88. }
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. </style>