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

new.tmpl 6.4 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. {{template "base/head" .}}
  2. <style>
  3. .inline.required.field.cloudbrain_benchmark {
  4. display: none;
  5. }
  6. </style>
  7. <div id="mask">
  8. <div id="loadingPage">
  9. <div class="rect1"></div>
  10. <div class="rect2"></div>
  11. <div class="rect3"></div>
  12. <div class="rect4"></div>
  13. <div class="rect5"></div>
  14. </div>
  15. </div>
  16. <div class="repository">
  17. {{template "repo/header" .}}
  18. <div class="repository new repo ui middle very relaxed page grid">
  19. <div class="column">
  20. {{template "base/alert" .}}
  21. <div class="ui positive message" id="messageInfo">
  22. <p></p>
  23. </div>
  24. <form class="ui form" id="form_id" action="{{.Link}}" method="post">
  25. {{.CsrfTokenHtml}}
  26. <h3 class="ui top attached header">
  27. {{.i18n.Tr "repo.cloudbrain.new"}}
  28. </h3>
  29. <div class="ui attached segment">
  30. <!-- <br> -->
  31. <div class="inline required field">
  32. <label>任务名称</label>
  33. <input name="job_name" id="cloudbrain_job_name" placeholder="任务名称" value="{{.job_name}}" tabindex="3" autofocus required maxlength="254">
  34. </div>
  35. <div class="inline field">
  36. <label>数据集</label>
  37. <input type="text" list="cloudbrain_dataset" placeholder="选择数据集" name="" id="answerInput" autofocus maxlength="36">
  38. <datalist id="cloudbrain_dataset" class="ui search" style='width:385px' name="attachment">
  39. {{range .attachments}}
  40. <option name="attachment" data-value="{{.UUID}}">{{.Attachment.Name}}</option>
  41. {{end}}
  42. </datalist>
  43. <input type="hidden" name="attachment" id="answerInput-hidden">
  44. </div>
  45. <div class="inline required field">
  46. <label>工作环境</label>
  47. <input name="de" id="cloudbrain_de" value="{{.env}}" tabindex="3" disabled autofocus required maxlength="254" readonly="readonly">
  48. </div>
  49. <div class="inline required field">
  50. <label>类型</label>
  51. <input name="job_type" id="cloudbrain_job_type" value="{{.notebook_type}}" tabindex="3" disabled autofocus required maxlength="254" readonly="readonly">
  52. </div>
  53. <div class="inline required field">
  54. <label>规格</label>
  55. <select id="cloudbrain_flavor" class="ui search dropdown" placeholder="选择规格" style='width:385px' name="flavor">
  56. {{range .flavors}}
  57. <option name="flavor" value="{{.Value}}">{{.Desc}}</option>
  58. {{end}}
  59. </select>
  60. </div>
  61. <div class="inline required field">
  62. <label>数据集存放路径</label>
  63. <input name="dataset_path" id="cloudbrain_dataset_path" value="{{.dataset_path}}" tabindex="3" disabled autofocus required maxlength="254" readonly="readonly">
  64. </div>
  65. <div class="inline field">
  66. <label>描述</label>
  67. <input name="description" id="cloudbrain_description" tabindex="3" autofocus maxlength="254">
  68. </div>
  69. <div class="inline field">
  70. <label></label>
  71. <button class="ui green button">
  72. {{.i18n.Tr "repo.cloudbrain.new"}}
  73. </button>
  74. <a class="ui button" href="/">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  75. </div>
  76. </div>
  77. </form>
  78. </div>
  79. </div>
  80. </div>
  81. {{template "base/footer" .}}
  82. <script>
  83. // 取消创建跳转
  84. let url_href = window.location.pathname.split('create')[0]
  85. $(".ui.button").attr('href',url_href)
  86. // 判断必填选项是否填写正确
  87. let form = document.getElementById('form_id');
  88. $('#messageInfo').css('display','none')
  89. form.onsubmit = function(e){
  90. let value_task = $("input[name='job_name']").val()
  91. let re = /^[a-z0-9][a-z0-9-_]{1,36}$/
  92. let flag = re.test(value_task)
  93. if(!flag){
  94. $('#messageInfo').css('display','block')
  95. let str = '只能以小写字母或数字开头且只包含小写字母、数字、_和-、最长36个字符。'
  96. $('#messageInfo p').text(str)
  97. return false
  98. }
  99. let min_value_task = value_task.toLowerCase()
  100. $("input[name='job_name']").attr("value",min_value_task)
  101. document.getElementById("mask").style.display = "block"
  102. }
  103. // 点击按钮后遮罩层显示
  104. // function showmask() {
  105. // document.getElementById("mask").style.display = "block"
  106. // }
  107. // 页面加载完毕后遮罩层隐藏
  108. document.onreadystatechange = function() {
  109. if (document.readyState === "complete") {
  110. document.getElementById("mask").style.display = "none"
  111. }
  112. }
  113. $('select.dropdown')
  114. .dropdown();
  115. $(function() {
  116. $("#cloudbrain_job_type").change(function() {
  117. if ($(this).val() == 'BENCHMARK') {
  118. $(".cloudbrain_benchmark").show();
  119. } else {
  120. $(".cloudbrain_benchmark").hide();
  121. }
  122. })
  123. })
  124. document.querySelector('input[list]').addEventListener('input',function(e){
  125. var input = e.target,
  126. list = input.getAttribute('list'),
  127. options = document.querySelectorAll('#'+list+' option'),
  128. hiddenInput = document.getElementById(input.getAttribute('id')+'-hidden'),
  129. inputValue = input.value;
  130. hiddenInput.value = inputValue;
  131. for (let i=0;i<options.length;i++){
  132. var option = options[i]
  133. if(option.innerText===inputValue){
  134. hiddenInput.value = option.getAttribute('data-value');
  135. break
  136. }
  137. }
  138. })
  139. </script>