disk_create.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. fields: {
  51. size: {
  52. validators: {
  53. between: {
  54. min: 1,
  55. max: 10240
  56. }
  57. }
  58. },
  59. quantity: {
  60. validators: {
  61. between: {
  62. min: 1,
  63. max: 20
  64. }
  65. }
  66. },
  67. remark: {
  68. validators: {
  69. stringLength: {
  70. max: 64
  71. }
  72. }
  73. }
  74. }
  75. })
  76. .on('success.field.fv', function(e, data) {
  77. if (data.fv.getInvalidFields().length > 0) { // There is invalid field
  78. data.fv.disableSubmitButtons(true);
  79. }
  80. })
  81. });
  82. $(function() { "use strict";
  83. $("#size").TouchSpin({
  84. max: 10240,
  85. min: 100,
  86. verticalbuttons: true,
  87. verticalupclass: 'glyph-icon icon-plus',
  88. verticaldownclass: 'glyph-icon icon-minus'
  89. });
  90. });
  91. $(function() { "use strict";
  92. $("#quantity").TouchSpin({
  93. max: 20,
  94. min: 1,
  95. verticalbuttons: true,
  96. verticalupclass: 'glyph-icon icon-plus',
  97. verticaldownclass: 'glyph-icon icon-minus'
  98. });
  99. });
  100. function refresh_hosts_selectpicker(selectpicker) {
  101. $.ajax({
  102. url : '/api/hosts',
  103. type : 'GET',
  104. contentType: "application/json; charset=utf-8",
  105. dataType: 'json',
  106. error : function() {
  107. },
  108. success : function(data, textStatus, xhr) {
  109. selectpicker.empty();
  110. $.each(data.data, function(k, v) {
  111. selectpicker.append(
  112. $('<option>', {value: v['hostname'], text: v['hostname']})
  113. );
  114. });
  115. selectpicker.selectpicker('refresh');
  116. }
  117. });
  118. }
  119. </script>
  120. <div class="container" style="padding-top: 100px;">
  121. <div class="panel">
  122. <div class="panel-body">
  123. <h3 class="title-hero" style="display: inline;">
  124. 创建磁盘
  125. </h3>
  126. <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;">
  127. <span class="glyph-icon icon-separator" style="transform: rotateY(-180deg);">
  128. <i class="glyph-icon icon-level-up"></i>
  129. </span>
  130. <span class="button-content">
  131. 返回磁盘列表
  132. </span>
  133. </a>
  134. <div class="example-box-wrapper">
  135. <form id="create_disk_form" class="form-horizontal bordered-row" action="/disks/create" method="post">
  136. <div class="form-group">
  137. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-hdd"></span>&nbsp;&nbsp;磁盘大小 (GB)</label>
  138. <div class="col-sm-6">
  139. <input id="size" title="磁盘大小" class="form-control" type="text" value="100" name="size">
  140. </div>
  141. </div>
  142. <div class="form-group">
  143. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-th-list"></span>&nbsp;&nbsp;数量</label>
  144. <div class="col-sm-6">
  145. <input id="quantity" title="实例数量" class="form-control" type="text" value="1" name="quantity">
  146. </div>
  147. </div>
  148. <div id="on_host_form" class="form-group">
  149. <label class="col-sm-2 control-label"><span class="glyph-icon icon-desktop"></span>&nbsp;&nbsp;计算节点</label>
  150. <div class="col-sm-6">
  151. <select id="on_host" name="on_host" title="计算节点" class="selectpicker">
  152. </select>
  153. </div>
  154. </div>
  155. <div class="form-group">
  156. <label class="col-sm-2 control-label"><span class="glyph-icon icon-elusive-compass-circled"></span>&nbsp;&nbsp;标识</label>
  157. <div class="col-sm-6">
  158. <div style="height: 10px;"></div>
  159. <div class="row form-group">
  160. <label class="col-sm-2 control-label">磁盘标识:</label>
  161. <div class="col-sm-6">
  162. <input id="remark" name="remark" type="text" title="磁盘标识" class="form-control">
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. <div class="form-group">
  168. <label class="col-sm-2 control-label"></label>
  169. <div class="col-sm-3 pull-right">
  170. <button type="submit" class="btn btn-blue-alt" style="width: 180px; height: 40px; font-size: 16px;">创建</button>
  171. </div>
  172. </div>
  173. </form>
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. {% endblock body %}