coordinator.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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, i18n) {
  18. var coordCron =
  19. $('#coord-frequency')
  20. .jqCron({
  21. texts: {
  22. i18n: i18n
  23. },
  24. enabled_minute: false,
  25. multiple_dom: true,
  26. multiple_month: true,
  27. multiple_mins: true,
  28. multiple_dow: true,
  29. multiple_time_hours: true,
  30. multiple_time_minutes: false,
  31. default_period: 'day',
  32. default_value: coordinator_json.frequency,
  33. no_reset_button: true,
  34. lang: 'i18n'
  35. })
  36. .jqCronGetInstance();
  37. var coordViewModel = function() {
  38. var self = this;
  39. self.isSaveVisible = ko.observable(false);
  40. self.isAdvancedCron = ko.observable(false);
  41. self.isAdvancedCron.subscribe(function(value) {
  42. if (value) {
  43. coordCron.disable();
  44. } else {
  45. coordCron.enable();
  46. }
  47. });
  48. };
  49. window.coordViewModel = new coordViewModel();
  50. window.coordViewModel.isAdvancedCron(coordinator_json.isAdvancedCron);
  51. $('#coord-frequency').val(coordinator_json.frequency),
  52. ko.applyBindings(window.coordViewModel, document.getElementById('step2'));
  53. }