details.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.MainHostDetailsController = Em.Controller.extend({
  20. name: 'mainHostDetailsController',
  21. content: null,
  22. isFromHosts: false,
  23. isStarting: function(){
  24. return this.get('content.workStatus');
  25. }.property('content.workStatus'),
  26. isStopping: function(){
  27. return !this.get('isStarting');
  28. }.property('isStarting'),
  29. setBack: function(isFromHosts){
  30. this.set('isFromHosts', isFromHosts);
  31. },
  32. startComponent: function(event){
  33. var self = this;
  34. App.ModalPopup.show({
  35. header: Em.I18n.t('hosts.host.start.popup.header'),
  36. body: Em.I18n.t('hosts.host.start.popup.body'),
  37. primary: 'Yes',
  38. secondary: 'No',
  39. onPrimary: function() {
  40. var component = event.context;
  41. component.set('workStatus', true);
  42. var stopped = self.get('content.components').filterProperty('workStatus', false);
  43. if (stopped.length == 0)
  44. self.set('content.workStatus', true);
  45. this.hide();
  46. },
  47. onSecondary: function() {
  48. this.hide();
  49. }
  50. });
  51. },
  52. stopComponent: function(event){
  53. var self = this;
  54. App.ModalPopup.show({
  55. header: Em.I18n.t('hosts.host.start.popup.header'),
  56. body: Em.I18n.t('hosts.host.start.popup.body'),
  57. primary: 'Yes',
  58. secondary: 'No',
  59. onPrimary: function() {
  60. var component = event.context;
  61. component.set('workStatus', false);
  62. var started = self.get('content.components').filterProperty('workStatus', true);
  63. if (started.length == 0)
  64. self.set('content.workStatus', false);
  65. this.hide();
  66. },
  67. onSecondary: function() {
  68. this.hide();
  69. }
  70. });
  71. },
  72. startConfirmPopup: function (event) {
  73. var self = this;
  74. App.ModalPopup.show({
  75. header: Em.I18n.t('hosts.host.start.popup.header'),
  76. body: Em.I18n.t('hosts.host.start.popup.body'),
  77. primary: 'Yes',
  78. secondary: 'No',
  79. onPrimary: function() {
  80. self.get('content.components').setEach('workStatus', true);
  81. self.set('content.workStatus', !self.get('content.workStatus'));
  82. this.hide();
  83. },
  84. onSecondary: function() {
  85. this.hide();
  86. }
  87. });
  88. },
  89. stopConfirmPopup: function (event) {
  90. var self = this;
  91. App.ModalPopup.show({
  92. header: Em.I18n.t('hosts.host.stop.popup.header'),
  93. body: Em.I18n.t('hosts.host.stop.popup.body'),
  94. primary: 'Yes',
  95. secondary: 'No',
  96. onPrimary: function() {
  97. self.get('content.components').setEach('workStatus', false);
  98. self.set('content.workStatus', !self.get('content.workStatus'));
  99. this.hide();
  100. },
  101. onSecondary: function() {
  102. this.hide();
  103. }
  104. });
  105. }
  106. })