coordinator.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Licensed to Cloudera, Inc. under one
  2. // or more contributor license agreements. See the NOTICE file
  3. // distributed with this work for additional information
  4. // regarding copyright ownership. Cloudera, Inc. licenses this file
  5. // to you under the Apache License, Version 2.0 (the
  6. // "License"); you may not use this file except in compliance
  7. // with the License. You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. // Not in coordinator_properties as also used in create coordinator.
  17. function initCoordinator(coordinator_json) {
  18. var coordCron =
  19. $('#coord-frequency')
  20. .jqCron({
  21. enabled_minute: false,
  22. multiple_dom: true,
  23. multiple_month: true,
  24. multiple_mins: true,
  25. multiple_dow: true,
  26. multiple_time_hours: true,
  27. multiple_time_minutes: false,
  28. default_period: 'day',
  29. default_value: coordinator_json.frequency,
  30. no_reset_button: true,
  31. lang: 'en'
  32. })
  33. .jqCronGetInstance();
  34. var coordViewModel = function() {
  35. var self = this;
  36. self.isSaveVisible = ko.observable(false);
  37. self.isAdvancedCron = ko.observable(false);
  38. self.isAdvancedCron.subscribe(function(value) {
  39. if (value) {
  40. coordCron.disable();
  41. } else {
  42. coordCron.enable();
  43. }
  44. });
  45. };
  46. window.coordViewModel = new coordViewModel();
  47. window.coordViewModel.isAdvancedCron(coordinator_json.isAdvancedCron);
  48. $('#coord-frequency').val(coordinator_json.frequency),
  49. ko.applyBindings(window.coordViewModel, document.getElementById('step2'));
  50. }