wizard_view.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.HighAvailabilityWizardView = Em.View.extend(App.WizardMenuMixin, {
  20. templateName: require('templates/main/admin/highAvailability/nameNode/wizard'),
  21. isLoaded: false,
  22. willInsertElement: function() {
  23. this.set('isLoaded', false);
  24. this.loadHosts();
  25. },
  26. /**
  27. * load hosts from server
  28. */
  29. loadHosts: function () {
  30. App.ajax.send({
  31. name: 'hosts.high_availability.wizard',
  32. data: {},
  33. sender: this,
  34. success: 'loadHostsSuccessCallback',
  35. error: 'loadHostsErrorCallback'
  36. });
  37. },
  38. /**
  39. * success callback of <code>loadHosts</code>
  40. * @param data
  41. * @param opt
  42. * @param params
  43. */
  44. loadHostsSuccessCallback: function (data, opt, params) {
  45. var hosts = {};
  46. data.items.forEach(function (item) {
  47. hosts[item.Hosts.host_name] = {
  48. name: item.Hosts.host_name,
  49. cpu: item.Hosts.cpu_count,
  50. memory: item.Hosts.total_mem,
  51. disk_info: item.Hosts.disk_info,
  52. bootStatus: "REGISTERED",
  53. isInstalled: true
  54. };
  55. });
  56. App.db.setHosts(hosts);
  57. this.set('controller.content.hosts', hosts);
  58. this.set('isLoaded', true);
  59. },
  60. /**
  61. * error callback of <code>loadHosts</code>
  62. */
  63. loadHostsErrorCallback: function() {
  64. this.set('isLoaded', true);
  65. },
  66. didInsertElement: function() {
  67. var currentStep = this.get('controller.currentStep');
  68. if (currentStep > 4) {
  69. this.get('controller').setLowerStepsDisable(currentStep);
  70. }
  71. }
  72. });