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.

93 lines
3.1KB

  1. <template>
  2. <div id="submit">
  3. <v-card class="bench elevation-5">
  4. <h2 class="bot">Submit new Benchmark</h2>
  5. <v-alert v-show="alertShow" :type="alertType">{{ alertMessage }}</v-alert>
  6. <v-divider class="bot"></v-divider>
  7. <v-form class="submit-form" v-model="valid">
  8. <v-text-field v-model="vendor" autocomplete="vendor" label="Vendor" required></v-text-field>
  9. <v-text-field v-model="model" autocomplete="model" label="Model" required></v-text-field>
  10. <v-text-field v-model="memory" autocomplete="memory" label="Memory" required></v-text-field>
  11. <v-text-field v-model="hashrate" autocomplete="hashrate" label="Hashrate" required></v-text-field>
  12. <v-text-field v-model="watts" autocomplete="watts" label="Watts" required></v-text-field>
  13. <v-text-field v-model="miner" autocomplete="miner" label="Miner" required></v-text-field>
  14. <v-text-field v-model="user" autocomplete="user" label="User" class="text-field" equired></v-text-field>
  15. <v-btn @click="submit()" color="blue">Submit</v-btn>
  16. </v-form>
  17. </v-card>
  18. <h4>Back to <router-link to="/">Benchmarks</router-link></h4>
  19. </div>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. valid: false,
  26. vendor: "",
  27. model: "",
  28. memory: "",
  29. hashrate: "",
  30. watts: 0,
  31. miner: "",
  32. user: "",
  33. alertType: "error",
  34. alertMessage: "",
  35. alertShow: false,
  36. submitted: false,
  37. }
  38. },
  39. methods: {
  40. submit() {
  41. if (!this.submitted && this.valid) {
  42. this.submitted = true
  43. fetch(this.$api + "/api/submit", {
  44. method: "POST",
  45. body: JSON.stringify({
  46. vendor: this.vendor.toUpperCase(),
  47. model: this.model,
  48. memory: this.memory,
  49. hashrate: this.hashrate,
  50. watts: this.watts,
  51. minerVersion: this.miner,
  52. owner: this.user
  53. })
  54. }).then(result => result.json()).then(json => {
  55. this.alertType = json.success ? "success" : "error"
  56. this.alertMessage = json.message
  57. this.alertShow = true
  58. if (json.success) {
  59. setTimeout(() => this.$router.push("/"), 5000)
  60. } else {
  61. this.submitted = false
  62. }
  63. }).catch(() => {
  64. this.alertType = "error"
  65. this.alertMessage = "An error has occurred !"
  66. this.alertShow = true
  67. this.submitted = false
  68. })
  69. }
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped>
  75. .bot {
  76. margin-bottom: 5%;
  77. }
  78. .bench {
  79. padding: 2%;
  80. margin: auto;
  81. margin-top: 5%;
  82. margin-bottom: 5%;
  83. width: 30%;
  84. }
  85. .submit-form {
  86. width: 70%;
  87. margin: auto;
  88. }
  89. </style>