6
0

model-interaction-settings.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div class="model-interaction-settings">
  3. <model-abilities :model="model"/>
  4. <div class="predict">
  5. <h3>Predict</h3>
  6. <button-row>
  7. <button-input :type="running ? 'disabled' : 'primary'"
  8. @click="predict('new')">
  9. new
  10. <loading-icon v-if="running"/>
  11. </button-input>
  12. <button-input :type="running ? 'disabled' : 'primary'"
  13. @click="predict('all')">
  14. all
  15. <loading-icon v-if="running"/>
  16. </button-input>
  17. </button-row>
  18. </div>
  19. <div class="download">
  20. <h3>Download Predictions</h3>
  21. <button-input type="primary"
  22. @click="download">
  23. download
  24. </button-input>
  25. </div>
  26. <div v-if="supported.fit" class="fit">
  27. <h3>Fit</h3>
  28. <button-input :type="running ? 'disabled' : 'primary'"
  29. @click="fit">
  30. run
  31. <loading-icon v-if="running"/>
  32. </button-input>
  33. </div>
  34. </div>
  35. <!-- TODO model description -->
  36. </template>
  37. <script>
  38. import ButtonInput from "@/components/base/button-input";
  39. import LoadingIcon from "@/components/base/loading-icon";
  40. import ButtonRow from "@/components/base/button-row";
  41. import ModelAbilities from "@/components/models/model-abilities";
  42. export default {
  43. name: "model-interaction-settings",
  44. components: {ModelAbilities, ButtonRow, LoadingIcon, ButtonInput},
  45. props: ['model', 'jobs'],
  46. computed: {
  47. supported: function () {
  48. return {
  49. fit: this.model.supports.includes('fit')
  50. }
  51. },
  52. running: function () {
  53. return this.jobs.filter(j => !j.finished && j.type === 'Model Interaction').length > 0;
  54. }
  55. },
  56. methods: {
  57. predict: function (name) {
  58. // TODO then / error
  59. this.$root.socket.post(`/projects/${this.$root.project.id}/pipelines/predict`, {
  60. predict: name
  61. });
  62. },
  63. download: function () {
  64. window.location.href = this.$root.socket.url(`/projects/${this.$root.project.id}/results`);
  65. },
  66. fit: function () {
  67. // TODO then / error
  68. this.$root.socket.post(`/projects/${this.$root.project.id}/pipelines/fit`, {
  69. fit: true
  70. });
  71. }
  72. }
  73. }
  74. </script>
  75. <style scoped>
  76. .model-interaction-settings {
  77. font-size: 80%;
  78. }
  79. h3 {
  80. margin-bottom: 0.2rem;
  81. }
  82. .loading-icon {
  83. float: right;
  84. width: 1.3rem;
  85. height: 1.3rem;
  86. margin: -0.15rem -0.4rem -0.15rem 0.5rem;
  87. }
  88. </style>