You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
3.5 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <v-stepper-content step="2">
  3. <v-card>
  4. <v-card-text class="pa-0">
  5. <v-form>
  6. <h4 class="text-h6">Set parameters</h4>
  7. <p class="font-weight-regular body-1">
  8. You can set parameters to fetch API response.
  9. </p>
  10. <template v-for="item in value">
  11. <v-text-field
  12. v-if="item.type === 'textField'"
  13. :key="item.name"
  14. v-model="item.value"
  15. :label="item.name"
  16. outlined
  17. />
  18. <v-select
  19. v-if="item.type === 'selectField'"
  20. :key="item.name"
  21. v-model="item.value"
  22. :items="item.items"
  23. :label="item.name"
  24. outlined
  25. />
  26. <object-field
  27. v-if="item.type === 'objectField'"
  28. :key="item.name"
  29. v-model="item.value"
  30. :title="item.name"
  31. />
  32. </template>
  33. <h4 class="text-h6">Test the parameters</h4>
  34. <p class="font-weight-regular body-1">
  35. Before proceeding, you need to test the parameters whether they can fetch API response.
  36. Please input sample text and press the <strong>Test</strong> button.
  37. </p>
  38. <v-text-field
  39. v-if="project.isTextProject"
  40. v-model="payload"
  41. outlined
  42. label="Sample Text"
  43. />
  44. <file-field
  45. v-else
  46. v-model="payload"
  47. />
  48. <v-alert
  49. v-for="(error, index) in errorMessages"
  50. :key="index"
  51. prominent
  52. type="error"
  53. >
  54. <v-row align="center">
  55. <v-col class="grow">
  56. {{ error }}
  57. </v-col>
  58. </v-row>
  59. </v-alert>
  60. <h4 class="text-h6">
  61. Response
  62. </h4>
  63. <v-sheet
  64. :dark="!$vuetify.theme.dark"
  65. :light="$vuetify.theme.dark"
  66. class="mb-5 pa-5"
  67. >
  68. <pre>{{ JSON.stringify(response, null, 4) }}</pre>
  69. </v-sheet>
  70. </v-form>
  71. </v-card-text>
  72. <v-card-actions class="pa-0">
  73. <v-spacer />
  74. <v-btn
  75. text
  76. class="text-capitalize"
  77. @click="$emit('prev')"
  78. >
  79. Prev
  80. </v-btn>
  81. <v-btn
  82. v-show="!isPassed"
  83. color="primary"
  84. class="text-capitalize"
  85. @click="$emit('onTest', payload)"
  86. >
  87. Test
  88. </v-btn>
  89. <v-btn
  90. v-show="isPassed"
  91. color="primary"
  92. class="text-capitalize"
  93. @click="$emit('next')"
  94. >
  95. Next
  96. </v-btn>
  97. </v-card-actions>
  98. </v-card>
  99. </v-stepper-content>
  100. </template>
  101. <script lang="ts">
  102. import Vue from 'vue'
  103. import ObjectField from './ObjectField.vue'
  104. import FileField from './FileField.vue'
  105. export default Vue.extend({
  106. components: {
  107. ObjectField,
  108. FileField,
  109. },
  110. props: {
  111. value: {
  112. type: Array,
  113. default: () => [],
  114. required: true
  115. },
  116. errorMessages: {
  117. type: Array,
  118. default: () => [],
  119. required: true
  120. },
  121. isPassed: {
  122. type: Boolean,
  123. default: false,
  124. required: true
  125. },
  126. response: {
  127. type: [String, Array, Object],
  128. default: () => [],
  129. required: true
  130. }
  131. },
  132. data() {
  133. return {
  134. payload: '',
  135. project: {}
  136. }
  137. },
  138. async created() {
  139. this.project = await this.$services.project.findById(this.$route.params.id)
  140. }
  141. })
  142. </script>