components.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with this
  4. * work for additional information regarding copyright ownership. The ASF
  5. * licenses this file to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance with the License.
  7. * 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, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. var App = require('app');
  18. module.exports = {
  19. installHostComponent: function(hostName, component) {
  20. var self = this;
  21. var componentName = component.get('componentName');
  22. var displayName = component.get('displayName');
  23. App.ajax.send({
  24. name: 'host.host_component.add_new_component',
  25. sender: self,
  26. data: {
  27. hostName: hostName,
  28. component: component,
  29. data: JSON.stringify({
  30. RequestInfo: {
  31. "context": Em.I18n.t('requestInfo.installHostComponent') + " " + displayName
  32. },
  33. Body: {
  34. host_components: [
  35. {
  36. HostRoles: {
  37. component_name: componentName
  38. }
  39. }
  40. ]
  41. }
  42. })
  43. },
  44. success: 'addNewComponentSuccessCallback',
  45. error: 'ajaxErrorCallback'
  46. });
  47. },
  48. /**
  49. * Success callback for add host component request
  50. * @param {object} data
  51. * @param {object} opt
  52. * @param {object} params
  53. * @method addNewComponentSuccessCallback
  54. */
  55. addNewComponentSuccessCallback: function (data, opt, params) {
  56. console.log('Send request for ADDING NEW COMPONENT successfully');
  57. App.ajax.send({
  58. name: 'common.host.host_component.update',
  59. sender: App.router.get('mainHostDetailsController'),
  60. data: {
  61. hostName: params.hostName,
  62. componentName: params.component.get('componentName'),
  63. serviceName: params.component.get('serviceName'),
  64. component: params.component,
  65. "context": Em.I18n.t('requestInfo.installNewHostComponent') + " " + params.component.get('displayName'),
  66. HostRoles: {
  67. state: 'INSTALLED'
  68. },
  69. urlParams: "HostRoles/state=INIT"
  70. },
  71. success: 'installNewComponentSuccessCallback',
  72. error: 'ajaxErrorCallback'
  73. });
  74. },
  75. /**
  76. * Default error-callback for ajax-requests in current page
  77. * @param {object} request
  78. * @param {object} ajaxOptions
  79. * @param {string} error
  80. * @param {object} opt
  81. * @param {object} params
  82. * @method ajaxErrorCallback
  83. */
  84. ajaxErrorCallback: function (request, ajaxOptions, error, opt, params) {
  85. console.log('error on change component host status');
  86. App.ajax.defaultErrorHandler(request, opt.url, opt.method);
  87. }
  88. };