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 11 kB

4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. {{template "base/head" .}}
  2. <style>
  3. .inline.required.field.cloudbrain_benchmark {
  4. display: none;
  5. }
  6. </style>
  7. {{template "custom/global_mask" .}}
  8. <div class="repository">
  9. {{template "repo/header" .}}
  10. <div class="repository new repo ui middle very relaxed page grid">
  11. <div class="column">
  12. <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}"></div>
  13. {{if eq .NotStopTaskCount 0}}
  14. {{template "base/alert" .}}
  15. {{end}}
  16. <div class="ui negative message" id="messageInfo" style="display: none;">
  17. <p></p>
  18. </div>
  19. {{template "custom/alert_cb" .}}
  20. <form class="ui form" id="form_id" action="{{.Link}}" method="post">
  21. {{.CsrfTokenHtml}}
  22. <h3 class="ui top attached header">
  23. {{.i18n.Tr "repo.cloudbrain.new"}}
  24. </h3>
  25. <div class="ui attached segment">
  26. <!-- <br> -->
  27. <div class="inline required field">
  28. <label>{{.i18n.Tr "cloudbrain.compute_resource"}}</label>
  29. <div class="ui blue small menu compact selectcloudbrain">
  30. <a class="item" href="{{.RepoLink}}/cloudbrain/create">
  31. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
  32. <path fill="none" d="M0 0h24v24H0z"/>
  33. <path d="M3 2.992C3 2.444 3.445 2 3.993 2h16.014a1 1 0 0 1 .993.992v18.016a.993.993 0 0 1-.993.992H3.993A1 1 0 0 1 3 21.008V2.992zM19 11V4H5v7h14zm0 2H5v7h14v-7zM9 6h6v2H9V6zm0 9h6v2H9v-2z"/>
  34. </svg>
  35. CPU/GPU</a>
  36. <a class="active item" href="{{.RepoLink}}/modelarts/notebook/create">
  37. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
  38. <path fill="none" d="M0 0h24v24H0z"/>
  39. <path d="M3 2.992C3 2.444 3.445 2 3.993 2h16.014a1 1 0 0 1 .993.992v18.016a.993.993 0 0 1-.993.992H3.993A1 1 0 0 1 3 21.008V2.992zM19 11V4H5v7h14zm0 2H5v7h14v-7zM9 6h6v2H9V6zm0 9h6v2H9v-2z"/>
  40. </svg>
  41. Ascend NPU</a>
  42. </div>
  43. </div>
  44. <div class="inline field">
  45. <label></label>
  46. {{template "custom/task_wait_count" .}}
  47. </div>
  48. <div class="inline required field">
  49. <label>{{.i18n.Tr "cloudbrain.task_name"}}</label>
  50. <input name="display_job_name" id="cloudbrain_job_name" placeholder="任务名称" value="{{.display_job_name}}" tabindex="3" autofocus required maxlength="36" onkeyup="this.value=this.value.replace(/[, ]/g,'')">
  51. </div>
  52. <div class="inline required field">
  53. <label>{{.i18n.Tr "cloudbrain.mirror"}}</label>
  54. <select id="cloudbrain_image" class="ui search dropdown" placeholder="{{.i18n.Tr "cloudbrain.choose_mirror"}}" style='width:385px' name="image_id">
  55. {{range .images}}
  56. <option name="image_id" value="{{.Id}}">{{.Value}}</option>
  57. {{end}}
  58. </select>
  59. </div>
  60. <div id="select-multi-dataset">
  61. </div>
  62. <!--<div class="inline required field">
  63. <label>工作环境</label>
  64. <input name="de" id="cloudbrain_de" value="{{.env}}" tabindex="3" disabled autofocus required maxlength="255" readonly="readonly">
  65. </div>
  66. <div class="inline required field">
  67. <label>类型</label>
  68. <input name="job_type" id="cloudbrain_job_type" value="{{.notebook_type}}" tabindex="3" disabled autofocus required maxlength="255" readonly="readonly">
  69. </div> -->
  70. <!--<div class="inline required field">
  71. <label>{{.i18n.Tr "cloudbrain.specification"}}</label>
  72. <select id="cloudbrain_flavor" class="ui search dropdown" placeholder="选择规格" style='width:385px' name="flavor">
  73. {{range .flavors}}
  74. <option name="flavor" value="{{.Value}}">{{.Desc}}</option>
  75. {{end}}
  76. </select>
  77. </div>-->
  78. <div class="inline required field">
  79. <label>{{.i18n.Tr "cloudbrain.specification"}}</label>
  80. <select id="__specs__" class="ui search dropdown" ovalue="{{.spec_id}}"
  81. {{if .CloudBrainPaySwitch}}blance="{{.PointAccount.Balance}}"{{end}}
  82. placeholder="{{.i18n.Tr "cloudbrain.select_specification"}}" style='width:385px' name="spec_id"></select>
  83. <span><i class="question circle icon link"></i></span>
  84. <a href="{{AppSubUrl}}/resource_desc" target="_blank">{{.i18n.Tr "custom.resource_description"}}</a>
  85. {{if .CloudBrainPaySwitch}}
  86. <div class="cloudbrain_resource_spec_blance_tip" style="padding:0 5px;margin:6px 0;margin-left:265px;font-size:12px;width: 50%!important;">
  87. <span>{{$.i18n.Tr "points.balance_of_points"}}<span style="color:red;margin: 0 3px">{{.PointAccount.Balance}}</span>{{$.i18n.Tr "points.points"}}</span><span>{{$.i18n.Tr "points.expected_time"}}<span style="color:red;margin: 0 3px" class="can-use-time"></span>{{$.i18n.Tr "points.hours"}}</span>
  88. <span style="float:right;">
  89. <i class="question circle icon link" data-position="right center" data-variation="mini"></i>
  90. <a href="{{AppSubUrl}}/reward/point/rule" target="_blank">{{$.i18n.Tr "points.points_acquisition_instructions"}}</a>
  91. </span>
  92. </div>
  93. {{end}}
  94. </div>
  95. <!--<div class="inline required field">
  96. <label>数据集存放路径</label>
  97. <input name="dataset_path" id="cloudbrain_dataset_path" value="{{.dataset_path}}" tabindex="3" disabled autofocus required maxlength="255" readonly="readonly">
  98. </div> -->
  99. <div class="inline field">
  100. <label>{{.i18n.Tr "cloudbrain.description"}}</label>
  101. <input name="description" id="cloudbrain_description" tabindex="3" autofocus maxlength="255">
  102. </div>
  103. <div class="inline field">
  104. <label></label>
  105. <button class="ui green button {{if eq .NotStopTaskCount 1}}disabled{{end}}">
  106. {{.i18n.Tr "repo.cloudbrain.new"}}
  107. </button>
  108. <a class="ui button cancel" href="{{.RepoLink}}/debugjob?debugListType=all">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  109. </div>
  110. </div>
  111. </form>
  112. </div>
  113. </div>
  114. </div>
  115. {{template "base/footer" .}}
  116. <script src="{{StaticUrlPrefix}}/js/specsuse.js?v={{MD5 AppVer}}" type="text/javascript"></script>
  117. <script>
  118. // 判断必填选项是否填写正确
  119. let form = document.getElementById('form_id');
  120. $('#messageInfo').css('display','none')
  121. var isValidate = false;
  122. function validate(){
  123. $('.ui.form').form({
  124. on: 'blur',
  125. fields: {
  126. display_job_name:{
  127. identifier : 'display_job_name',
  128. rules: [
  129. {
  130. type: 'regExp[/^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/]',
  131. }
  132. ]
  133. },
  134. spec_id: {
  135. identifier: 'spec_id',
  136. rules: [{ type: 'empty' }]
  137. }
  138. },
  139. onSuccess: function(){
  140. isValidate = true;
  141. },
  142. onFailure: function(e){
  143. isValidate = false;
  144. return false;
  145. }
  146. })
  147. }
  148. validate();
  149. let createFlag = false
  150. form.onsubmit = function(e){
  151. if(!isValidate) return false;
  152. if(createFlag) return false;
  153. let value_task = $("input[name='display_job_name']").val()
  154. let re = /^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/
  155. let flag = re.test(value_task)
  156. if(!flag){
  157. $('#messageInfo').css('display','block')
  158. let str = '只能以小写字母或数字开头且只包含小写字母、数字、_和-,不能以_结尾,最长36个字符。'
  159. $('#messageInfo p').text(str)
  160. return false
  161. }
  162. let min_value_task = value_task.toLowerCase()
  163. $("input[name='display_job_name']").attr("value",min_value_task)
  164. document.getElementById("mask").style.display = "block"
  165. createFlag = true
  166. }
  167. // 点击按钮后遮罩层显示
  168. // function showmask() {
  169. // document.getElementById("mask").style.display = "block"
  170. // }
  171. // 页面加载完毕后遮罩层隐藏
  172. document.onreadystatechange = function() {
  173. if (document.readyState === "complete") {
  174. document.getElementById("mask").style.display = "none"
  175. }
  176. }
  177. $('select.dropdown')
  178. .dropdown();
  179. $(function() {
  180. $("#cloudbrain_job_type").change(function() {
  181. if ($(this).val() == 'BENCHMARK') {
  182. $(".cloudbrain_benchmark").show();
  183. } else {
  184. $(".cloudbrain_benchmark").hide();
  185. }
  186. })
  187. })
  188. $(document).ready(function(){
  189. $(document).keydown(function(event){
  190. if(event.keyCode==13){
  191. event.preventDefault();
  192. }
  193. });
  194. });
  195. ;(function() {
  196. var SPECS = {{ .Specs }};
  197. var showPoint = {{ .CloudBrainPaySwitch }};
  198. window.renderSpecsSelect($('#__specs__'), SPECS, showPoint, {
  199. gpu_memory: {{$.i18n.Tr "cloudbrain.gpu_memory"}},
  200. free: {{$.i18n.Tr "cloudbrain.free"}},
  201. point_hr: {{$.i18n.Tr "cloudbrain.point_hr"}},
  202. memory: {{$.i18n.Tr "cloudbrain.memory"}},
  203. shared_memory: {{$.i18n.Tr "cloudbrain.shared_memory"}},
  204. });
  205. })();
  206. console.log("-------------:",{{.NotStopTaskCount}})
  207. </script>