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

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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. {{template "base/head" .}}
  2. {{template "custom/global_mask" .}}
  3. <div class="repository">
  4. {{template "repo/header" .}}
  5. <div class="repository new repo ui middle very relaxed page grid">
  6. <div class="column">
  7. <div class="cloudbrain-type" style="display: none;" data-cloudbrain-type="{{.datasetType}}" data-repo-link="{{.RepoLink}}" data-queue="{{.QueuesDetail}}" data-queue-start="{{.i18n.Tr "repo.wait_count_start"}}" data-queue-end="{{.i18n.Tr "repo.wait_count_end"}}"></div>
  8. {{if eq .NotStopTaskCount 0}}
  9. {{template "base/alert" .}}
  10. {{end}}
  11. <div class="ui negative message" id="messageInfo" style="display:none;">
  12. <p></p>
  13. </div>
  14. {{template "custom/alert_cb" .}}
  15. <form id="form_id" class="ui form" action="{{.Link}}" method="post">
  16. {{.CsrfTokenHtml}}
  17. <input type="hidden" name="type" value="0">
  18. <h3 class="ui top attached header">
  19. {{.i18n.Tr "repo.cloudbrain.new"}}
  20. </h3>
  21. <div class="ui attached segment">
  22. <div class="required inline field">
  23. <label>{{.i18n.Tr "cloudbrain.resource_cluster"}}</label>
  24. <div class="ui blue mini menu compact selectcloudbrain">
  25. <a class="item" href="{{.RepoLink}}/cloudbrain/create">
  26. <svg class="svg" sxmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-2.29-2.333A17.9 17.9 0 0 1 8.027 13H4.062a8.008 8.008 0 0 0 5.648 6.667zM10.03 13c.151 2.439.848 4.73 1.97 6.752A15.905 15.905 0 0 0 13.97 13h-3.94zm9.908 0h-3.965a17.9 17.9 0 0 1-1.683 6.667A8.008 8.008 0 0 0 19.938 13zM4.062 11h3.965A17.9 17.9 0 0 1 9.71 4.333 8.008 8.008 0 0 0 4.062 11zm5.969 0h3.938A15.905 15.905 0 0 0 12 4.248 15.905 15.905 0 0 0 10.03 11zm4.259-6.667A17.9 17.9 0 0 1 15.973 11h3.965a8.008 8.008 0 0 0-5.648-6.667z"></path></svg>
  27. {{.i18n.Tr "cloudbrain.resource_cluster_openi"}}
  28. </a>
  29. <a class="active item" href="{{.RepoLink}}/grampus/notebook/create?type=0">
  30. <svg class="svg" sxmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-2.29-2.333A17.9 17.9 0 0 1 8.027 13H4.062a8.008 8.008 0 0 0 5.648 6.667zM10.03 13c.151 2.439.848 4.73 1.97 6.752A15.905 15.905 0 0 0 13.97 13h-3.94zm9.908 0h-3.965a17.9 17.9 0 0 1-1.683 6.667A8.008 8.008 0 0 0 19.938 13zM4.062 11h3.965A17.9 17.9 0 0 1 9.71 4.333 8.008 8.008 0 0 0 4.062 11zm5.969 0h3.938A15.905 15.905 0 0 0 12 4.248 15.905 15.905 0 0 0 10.03 11zm4.259-6.667A17.9 17.9 0 0 1 15.973 11h3.965a8.008 8.008 0 0 0-5.648-6.667z"></path></svg>
  31. {{.i18n.Tr "cloudbrain.resource_cluster_c2net"}}(Beta)
  32. </a>
  33. </div>
  34. </div>
  35. <div class="inline required field">
  36. <label>{{.i18n.Tr "cloudbrain.compute_resource"}}</label>
  37. <div class="ui blue small menu compact selectcloudbrain">
  38. <a class="active item" href="{{.RepoLink}}/grampus/notebook/create?type=0">
  39. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16"
  40. height="16">
  41. <path fill="none" d="M0 0h24v24H0z" />
  42. <path
  43. 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" />
  44. </svg>
  45. CPU/GPU
  46. </a>
  47. <a class="item" href="{{.RepoLink}}/grampus/notebook/create?type=1">
  48. <svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16"
  49. height="16">
  50. <path fill="none" d="M0 0h24v24H0z" />
  51. <path
  52. 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" />
  53. </svg>
  54. Ascend NPU</a>
  55. </div>
  56. </div>
  57. <div class="inline field">
  58. <label></label>
  59. {{template "custom/task_wait_count" .}}
  60. </div>
  61. <div class="inline required field">
  62. <label>{{.i18n.Tr "cloudbrain.task_name"}}</label>
  63. <input name="display_job_name" id="cloudbrain_job_name"
  64. placeholder="{{.i18n.Tr "cloudbrain.task_name"}}" value="{{.display_job_name}}" tabindex="3"
  65. autofocus required maxlength="255" onkeyup="this.value=this.value.replace(/[, ]/g,'')">
  66. </div>
  67. <div class="inline required field">
  68. <label>{{.i18n.Tr "repo.modelarts.code_version"}}</label>
  69. <select class="ui dropdown width80 left2 {{if not .Branches}}error{{end}}" id="code_version"
  70. name="branch_name">
  71. {{if .branch_name}}
  72. <option name="branch_name" value="{{.branch_name}}">{{.branch_name}}</option>
  73. {{range $k, $v :=.Branches}}
  74. {{ if ne $v $.branch_name }}
  75. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  76. {{end}}
  77. {{end}}
  78. {{else}}
  79. <option name="branch_name" value="{{.branchName}}">{{.branchName}}</option>
  80. {{range $k, $v :=.Branches}}
  81. {{ if ne $v $.branchName }}
  82. <option name="branch_name" value="{{$v}}">{{$v}}</option>
  83. {{end}}
  84. {{end}}
  85. {{end}}
  86. </select>
  87. </div>
  88. <div id="images-new-cb">
  89. </div>
  90. <div id="select-multi-dataset">
  91. </div>
  92. <div class="inline required field">
  93. <label>{{.i18n.Tr "cloudbrain.resource_specification"}}</label>
  94. <select id="__specs__" class="ui search dropdown"
  95. placeholder="{{.i18n.Tr "cloudbrain.select_specification"}}" style='width:385px' ovalue="{{.spec_id}}"
  96. {{if .CloudBrainPaySwitch}}blance="{{.PointAccount.Balance}}"{{end}}
  97. name="spec_id">
  98. </select>
  99. <span><i class="question circle icon link"></i></span>
  100. <a href="{{AppSubUrl}}/resource_desc" target="_blank">{{.i18n.Tr "custom.resource_description"}}</a>
  101. {{if .CloudBrainPaySwitch}}
  102. <div class="cloudbrain_resource_spec_blance_tip" style="padding:0 5px;margin:6px 0;margin-left:265px;font-size:12px;width: 50%!important;">
  103. <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>
  104. <span style="float:right;">
  105. <i class="question circle icon link" data-position="right center" data-variation="mini"></i>
  106. <a href="{{AppSubUrl}}/reward/point/rule" target="_blank">{{$.i18n.Tr "points.points_acquisition_instructions"}}</a>
  107. </span>
  108. </div>
  109. {{end}}
  110. </div>
  111. <div class="inline required field">
  112. <label>{{.i18n.Tr "cloudbrain.dataset_storage_path"}}</label>
  113. <input name="dataset_path" id="cloudbrain_dataset_path" value="{{.dataset_path}}" tabindex="3"
  114. disabled autofocus required maxlength="255" readonly="readonly">
  115. </div>
  116. <div class="inline required field">
  117. <label>{{.i18n.Tr "cloudbrain.model_storage_path"}}</label>
  118. <input name="model_path" id="cloudbrain_model_path" value="{{.model_path}}" tabindex="3"
  119. disabled autofocus required maxlength="255" readonly="readonly">
  120. </div>
  121. <div class="inline required field">
  122. <label>{{.i18n.Tr "cloudbrain.code_storage_path"}}</label>
  123. <input name="code_path" id="cloudbrain_code_path" value="{{.code_path}}" tabindex="3" disabled
  124. autofocus required maxlength="255" readonly="readonly">
  125. </div>
  126. <div class="inline field">
  127. <label>{{.i18n.Tr "cloudbrain.description"}}</label>
  128. <input name="description" id="cloudbrain_description" tabindex="3" autofocus maxlength="255">
  129. </div>
  130. <div class="inline field">
  131. <label></label>
  132. <button class="ui green button {{if eq .NotStopTaskCount 1}}disabled{{end}}">
  133. {{.i18n.Tr "repo.cloudbrain.new"}}
  134. </button>
  135. <a class="ui button cancel"
  136. href="{{.RepoLink}}/debugjob?debugListType=all">{{.i18n.Tr "repo.cloudbrain.cancel"}}</a>
  137. </div>
  138. </div>
  139. </form>
  140. </div>
  141. </div>
  142. </div>
  143. {{template "base/footer" .}}
  144. <script src="{{StaticUrlPrefix}}/js/specsuse.js?v={{MD5 AppVer}}" type="text/javascript"></script>
  145. <script>
  146. let form = document.getElementById('form_id');
  147. var isValidate = false;
  148. function validate(){
  149. $('.ui.form').form({
  150. on: 'blur',
  151. fields: {
  152. display_job_name:{
  153. identifier : 'display_job_name',
  154. rules: [
  155. {
  156. type: 'regExp[/^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/]',
  157. }
  158. ]
  159. },
  160. spec_id: {
  161. identifier: 'spec_id',
  162. rules: [{ type: 'empty' }]
  163. }
  164. },
  165. onSuccess: function(){
  166. isValidate = true;
  167. },
  168. onFailure: function(e){
  169. isValidate = false;
  170. return false;
  171. }
  172. })
  173. }
  174. validate();
  175. let createFlag = false
  176. form.onsubmit = function (e) {
  177. if (!isValidate) return false;
  178. if(createFlag) return false
  179. let value_task = $("input[name='display_job_name']").val()
  180. let re = /^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/
  181. let flag = re.test(value_task)
  182. if (!flag) {
  183. $('#messageInfo').css('display', 'block')
  184. let str = '只能以小写字母或数字开头且只包含小写字母、数字、_和-,不能以_结尾,最长36个字符。'
  185. $('#messageInfo p').text(str)
  186. return false
  187. }
  188. let min_value_task = value_task.toLowerCase()
  189. $("input[name='display_job_name']").attr("value", min_value_task)
  190. createFlag = true
  191. document.getElementById("mask").style.display = "block"
  192. }
  193. // 页面加载完毕后遮罩层隐藏
  194. document.onreadystatechange = function () {
  195. if (document.readyState === "complete") {
  196. document.getElementById("mask").style.display = "none"
  197. }
  198. }
  199. ;(function() {
  200. var SPECS = {{ .Specs }};
  201. var showPoint = {{ .CloudBrainPaySwitch }};
  202. window.renderSpecsSelect($('#__specs__'), SPECS, showPoint, {
  203. gpu_memory: {{$.i18n.Tr "cloudbrain.gpu_memory"}},
  204. free: {{$.i18n.Tr "cloudbrain.free"}},
  205. point_hr: {{$.i18n.Tr "cloudbrain.point_hr"}},
  206. memory: {{$.i18n.Tr "cloudbrain.memory"}},
  207. shared_memory: {{$.i18n.Tr "cloudbrain.shared_memory"}},
  208. });
  209. })();
  210. console.log({{.Specs}})
  211. </script>