summary.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. App.MainServiceInfoSummaryController = Em.Controller.extend({
  19. name: 'mainServiceInfoSummaryController',
  20. selectedFlumeAgent: null,
  21. /**
  22. * Send start command for selected Flume Agent
  23. * @method startFlumeAgent
  24. */
  25. startFlumeAgent: function () {
  26. var selectedFlumeAgent = this.get('selectedFlumeAgent');
  27. if (selectedFlumeAgent && selectedFlumeAgent.get('status') === 'INSTALLED') {
  28. var self = this;
  29. App.showConfirmationPopup(function () {
  30. var command = 'START';
  31. var context = Em.I18n.t('services.service.summary.flume.start.context').format(selectedFlumeAgent.get('name'));
  32. self.sendFlumeAgentCommandToServer(command, context, selectedFlumeAgent);
  33. });
  34. }
  35. },
  36. /**
  37. * Send stop command for selected Flume Agent
  38. * @method stopFlumeAgent
  39. */
  40. stopFlumeAgent: function () {
  41. var selectedFlumeAgent = this.get('selectedFlumeAgent');
  42. if (selectedFlumeAgent && selectedFlumeAgent.get('status') === 'RUNNING') {
  43. var self = this;
  44. App.showConfirmationPopup(function () {
  45. var command = 'STOP';
  46. var context = Em.I18n.t('services.service.summary.flume.stop.context').format(selectedFlumeAgent.get('name'));
  47. self.sendFlumeAgentCommandToServer(command, context, selectedFlumeAgent);
  48. });
  49. }
  50. },
  51. /**
  52. * Send command for Flume Agent to server
  53. * @param {string} command
  54. * @param {string} context
  55. * @param {Object} agent
  56. * @method sendFlumeAgentCommandToServer
  57. */
  58. sendFlumeAgentCommandToServer: function (command, context, agent) {
  59. App.ajax.send({
  60. name: 'service.flume.agent.command',
  61. sender: this,
  62. data: {
  63. command: command,
  64. context: context,
  65. agentName: agent.get('name'),
  66. host: agent.get('host.hostName')
  67. },
  68. success: 'commandSuccessCallback'
  69. });
  70. },
  71. /**
  72. * Callback, that shows Background operations popup if request was successful
  73. */
  74. commandSuccessCallback: function () {
  75. console.log('Send request for refresh configs successfully');
  76. // load data (if we need to show this background operations popup) from persist
  77. App.router.get('applicationController').dataLoading().done(function (showPopup) {
  78. if (showPopup) {
  79. App.router.get('backgroundOperationsController').showPopup();
  80. }
  81. });
  82. },
  83. nagiosUrl: function(){
  84. return App.router.get('clusterController.nagiosUrl');
  85. }.property('App.router.clusterController.nagiosUrl'),
  86. isNagiosInstalled: function(){
  87. return App.router.get('clusterController.isNagiosInstalled');
  88. }.property('App.router.clusterController.isNagiosInstalled'),
  89. isGangliaInstalled: function(){
  90. return App.router.get('clusterController.isGangliaInstalled');
  91. }.property('App.router.clusterController.isGangliaInstalled')
  92. });