disk_create.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. {% extends "layout.html" %}
  2. {% block head %}
  3. {{ super() }}
  4. <style type="text/css">
  5. @media (min-width: 768px) {
  6. .form-horizontal .control-label {
  7. text-align: left;
  8. }
  9. }
  10. label>span {
  11. color: deepskyblue;
  12. }
  13. .btn,
  14. .form-group>div>div,
  15. .form-control {
  16. border-radius: 0;
  17. }
  18. .btn-ability {
  19. margin-right: 16px;
  20. height: 50px;
  21. padding: 8px 50px;
  22. margin-bottom: 30px;
  23. }
  24. </style>
  25. {% endblock head %}
  26. {% block body %}
  27. <script>
  28. $(document).ready(function() {
  29. $('body').addClass('add-transition');
  30. $('.add-page-transition').on('click', function(){
  31. var transAttr = $(this).attr('data-transition');
  32. $('.add-transition').attr('class', 'add-transition');
  33. $('.add-transition').addClass(transAttr);
  34. });
  35. {% if show_on_host %}
  36. refresh_hosts_selectpicker($('#on_host'));
  37. {% else %}
  38. $('#on_host_form').remove();
  39. {% endif %}
  40. $('#create_disk_form').formValidation({
  41. framework: 'bootstrap4',
  42. icon: {
  43. valid: 'fa fa-check',
  44. invalid: 'fa fa-times',
  45. validating: 'fa fa-refresh'
  46. },
  47. // Since the Bootstrap Button hides the radio and checkbox
  48. // We exclude the disabled elements only
  49. excluded: ':disabled',
  50. locale: 'zh_CN',
  51. fields: {
  52. size: {
  53. validators: {
  54. between: {
  55. min: 1,
  56. max: 10240
  57. }
  58. }
  59. },
  60. quantity: {
  61. validators: {
  62. between: {
  63. min: 1,
  64. max: 20
  65. }
  66. }
  67. },
  68. remark: {
  69. validators: {
  70. stringLength: {
  71. max: 64
  72. }
  73. }
  74. }
  75. }
  76. })
  77. .on('success.field.fv', function(e, data) {
  78. if (data.fv.getInvalidFields().length > 0) { // There is invalid field
  79. data.fv.disableSubmitButtons(true);
  80. }
  81. })
  82. });
  83. $(function() { "use strict";
  84. $("#size").TouchSpin({
  85. max: 10240,
  86. min: 100,
  87. verticalbuttons: true,
  88. verticalupclass: 'glyph-icon icon-plus',
  89. verticaldownclass: 'glyph-icon icon-minus'
  90. });
  91. });
  92. $(function() { "use strict";
  93. $("#quantity").TouchSpin({
  94. max: 20,
  95. min: 1,
  96. verticalbuttons: true,
  97. verticalupclass: 'glyph-icon icon-plus',
  98. verticaldownclass: 'glyph-icon icon-minus'
  99. });
  100. });
  101. function refresh_hosts_selectpicker(selectpicker) {
  102. $.ajax({
  103. url : '/api/hosts',
  104. type : 'GET',
  105. contentType: "application/json; charset=utf-8",
  106. dataType: 'json',
  107. error : function() {
  108. },
  109. success : function(data, textStatus, xhr) {
  110. selectpicker.empty();
  111. $.each(data.data, function(k, v) {
  112. selectpicker.append(
  113. $('<option>', {value: v['hostname'], text: v['hostname']})
  114. );
  115. });
  116. selectpicker.selectpicker('refresh');
  117. }
  118. });
  119. }
  120. </script>
  121. <div class="container" style="padding-top: 100px;">
  122. <div class="panel">
  123. <div class="panel-body">
  124. <h3 class="title-hero" style="display: inline;">
  125. 创建磁盘
  126. </h3>
  127. <a href="/disks" class="btn btn-xs btn-default add-page-transition" data-transition="pt-page-moveFromLeft-init" style="margin-bottom: 4px; margin-left: 10px;">
  128. <span class="glyph-icon icon-separator" style="transform: rotateY(-180deg);">
  129. <i class="glyph-icon icon-level-up"></i>
  130. </span>
  131. <span class="button-content">
  132. 返回磁盘列表
  133. </span>
  134. </a>
  135. <div class="example-box-wrapper">
  136. <form id="create_disk_form" class="form-horizontal bordered-row" action="/disks/create" method="post">
  137. <div class="form-group">
  138. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-hdd"></span>&nbsp;&nbsp;磁盘大小 (GB)</label>
  139. <div class="col-sm-6">
  140. <input id="size" title="磁盘大小" class="form-control" type="text" value="100" name="size">
  141. </div>
  142. </div>
  143. <div class="form-group">
  144. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-th-list"></span>&nbsp;&nbsp;数量</label>
  145. <div class="col-sm-6">
  146. <input id="quantity" title="实例数量" class="form-control" type="text" value="1" name="quantity">
  147. </div>
  148. </div>
  149. <div id="on_host_form" class="form-group">
  150. <label class="col-sm-2 control-label"><span class="glyph-icon icon-desktop"></span>&nbsp;&nbsp;计算节点</label>
  151. <div class="col-sm-6">
  152. <select id="on_host" name="on_host" title="计算节点" class="selectpicker">
  153. </select>
  154. </div>
  155. </div>
  156. <div class="form-group">
  157. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;标识</label>
  158. <div class="col-sm-6">
  159. <div style="height: 10px;"></div>
  160. <div class="row form-group">
  161. <label class="col-sm-2 control-label">磁盘标识:</label>
  162. <div class="col-sm-6">
  163. <input id="remark" name="remark" type="text" title="磁盘标识" class="form-control">
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. <div class="form-group">
  169. <label class="col-sm-2 control-label"></label>
  170. <div class="col-sm-3 pull-right">
  171. <button type="submit" class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;">创建</button>
  172. </div>
  173. </div>
  174. </form>
  175. </div>
  176. </div>
  177. </div>
  178. </div>
  179. {% endblock body %}