sqoop.connectors.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. var connectors = (function($) {
  17. var ConnectorModel = koify.Model.extend({
  18. 'id': -1,
  19. 'name': null,
  20. 'class': null,
  21. 'job_forms': {
  22. 'IMPORT': [],
  23. 'EXPORT': []
  24. },
  25. 'con_forms': [],
  26. 'version': null,
  27. 'resources': {},
  28. 'initialize': function(attrs) {
  29. var self = this;
  30. var attrs = $.extend(true, attrs, {});
  31. attrs = transform_keys(attrs, {
  32. 'job-forms': 'job_forms',
  33. 'con-forms': 'con_forms'
  34. });
  35. attrs = transform_values(attrs, {
  36. 'con_forms': to_forms,
  37. 'job_forms': function(key, value) {
  38. transform_values(value, {
  39. 'IMPORT': to_forms,
  40. 'EXPORT': to_forms
  41. });
  42. return value;
  43. }
  44. });
  45. return attrs;
  46. }
  47. });
  48. var Connector = koify.Node.extend({
  49. 'identifier': 'connector',
  50. 'persist': false,
  51. 'modelClass': ConnectorModel,
  52. 'base_url': '/sqoop/api/connectors/',
  53. 'initialize': function() {
  54. var self = this;
  55. self.parent.initialize.apply(self, arguments);
  56. self.selected = ko.observable();
  57. }
  58. });
  59. function fetch_connectors(options) {
  60. $(document).trigger('load.connectors', [options]);
  61. var request = $.extend({
  62. url: '/sqoop/api/connectors/',
  63. dataType: 'json',
  64. type: 'GET',
  65. success: fetcher_success('connectors', Connector, options)
  66. }, options || {});
  67. $.ajax(request);
  68. }
  69. return {
  70. 'ConnectorModel': ConnectorModel,
  71. 'Connector': Connector,
  72. 'fetchConnectors': fetch_connectors
  73. };
  74. })($);