Guest User

Untitled

a guest
Jul 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. <div name="New Service Setting" id="new_service_setting_tab" style="padding-left:4px">
  2. <% remote_form_table :service_setting,
  3. :url => service_settings_url,
  4. :loading => 'showLoading("Creating service setting...", "new_service_setting_loading")',
  5. :complete => 'hideLoading("new_service_setting_loading")',
  6. :success => 'showMessage("Setting successfully added");$("new_setting_form").reset()',
  7. :resubmit => true,
  8. :html => {:multipart => true, :id => 'new_setting_form'} do |f| %>
  9. <%= f.hidden_field :revision_id, :value => @revision.id %>
  10. <%= f.hidden_field :service_id, :id => 'service_id' %>
  11. <p>Note: Adding settings to config files could cause problems with server software.<br/>
  12. Before adding a setting, make sure that the software supports it properly.</p>
  13. <table><tr>
  14. <td valign="top" rowspan=2>
  15. <b>Step 1.</b> Select Service<br/>
  16. <div id="new_service_setting_tree" class="tree_sm"></div>
  17. </td>
  18. <td valign="top" style="width:500px;">
  19. <b>Step 2.</b> Enter Details</br>
  20. <% f.fieldset do %>
  21. <%= f.text_field :setting, :required => true, :disabled => true %>
  22. <%= f.text_field :modified_value, :label => 'Value', :disabled => true %>
  23. <%= f.text_field :validation, :comment => '(optional)', :disabled => true %>
  24. <%= f.check_box :is_required, :checked => true, :comment => icon_for(:required) %>
  25. <%= f.check_box :is_promotable, :checked => true, :comment => icon_for(:promote) %>
  26. <%= f.check_box :is_protected, :comment => icon_for(:protect) %>
  27. <%# f.check_box :is_portstacked, :comment => icon_for(:plus) %>
  28. <%= f.row 'Config File',
  29. '<span id="config_file">[Select a service at left]</span><br/>
  30. <div class="comment">Note: If no config file is chosen, the setting will be usable in $[variables],
  31. but will not appear on remote hosts or be accessible to other programs.</div>' %>
  32. <% end %>
  33. <%= submit_controls :add, :cancel => false %>
  34. <div id="new_service_setting_loading"></div>
  35. </td>
  36. </tr>
  37. <tr>
  38. <td>
  39. <b>Optional.</b> Load settings from file
  40. <% f.fieldset do %>
  41. <%= f.file_field :import_filename, :size => 30,
  42. :label => 'Upload a file ',
  43. :onchange => 'updateTest()',
  44. :id => 'service_setting_import_filename' %>
  45. <% end %>
  46. <%= submit_icon :import2 %>
  47. </td>
  48. </tr>
  49. </table>
  50. <% end %>
  51.  
  52. <!-- tree for selecting the service to use -->
  53. <%= javascript_include_merged :dhtmlxtree %>
  54. <%= javascript_tag <<-EndJS
  55.  
  56. function updateTest()
  57. {
  58. alert($('service_setting_import_filename').value);
  59. }
  60.  
  61. ServiceConfigFiles = {};
  62. function clickService (row_id) {
  63. if (row_id.match(/^void/)) {
  64. alert("Please select a service, not a component.");
  65. $$('#new_setting_form input').each(function(element){
  66. element.disabled = true;
  67. });
  68. return false;
  69. }
  70.  
  71. // Set the service id
  72. $('service_id').value = row_id;
  73.  
  74. $$('#new_setting_form input').each(function(element){
  75. element.disabled = false;
  76. });
  77. showLoading("Loading config files...","config_file");
  78.  
  79. // cached version
  80. if (ServiceConfigFiles[row_id]) {
  81. $('config_file').update(ServiceConfigFiles[row_id]);
  82. return true;
  83. }
  84.  
  85. // Ajax call to populate options
  86. new Ajax.Request('#{ config_files_url }?service_id='+row_id, {
  87. method: 'get',
  88. onSuccess: function(request){
  89. ServiceConfigFiles[row_id] = request.responseText;
  90. $('config_file').update(ServiceConfigFiles[row_id]);
  91. },
  92. onComplete: function(){
  93. hideLoading("config_file");
  94. }
  95. });
  96. }
  97.  
  98. FastInit.addOnLoad(function(){
  99. // Load the tree when the run_environment_id changes
  100. var url = '#{ services_url }.tree?revision_id=#{@revision.id}';
  101. var mytree = new dhtmlXTreeObject("new_service_setting_tree","100%","100%",0);
  102. mytree.setImagePath('#{ System.dhtmlx_tree_image_path }');
  103. //mytree.enableCheckBoxes(true);
  104. //mytree.enableThreeStateCheckboxes(true);
  105. mytree.attachEvent('onClick', clickService);
  106. mytree.loadXML(url);
  107. });
  108. EndJS
  109. %>
  110.  
  111. </div><!-- must nest even JS inside wrapper div partial -->
Add Comment
Please, Sign In to add comment