targetClusterController.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. App.MainMirroringTargetClusterController = Ember.Controller.extend({
  19. name: 'mainMirroringTargetClusterController',
  20. model: Ember.Object.create({
  21. targetCluster : null,
  22. originalRecord : null,
  23. isPopupForEdit : false // set the default to add scenario
  24. }),
  25. setOriginalRecord : function(targetClusterRecord){
  26. this.set('model.originalRecord', targetClusterRecord);
  27. },
  28. setTargetCluster: function (targetClusterRecord) {
  29. var targetCluster = Ember.Object.create({
  30. id: targetClusterRecord.get('id'),
  31. clusterName: targetClusterRecord.get('clusterName'),
  32. nameNodeWebUrl: targetClusterRecord.get('nameNodeWebUrl'),
  33. nameNodeRpcUrl: targetClusterRecord.get('nameNodeRpcUrl'),
  34. oozieServerUrl: targetClusterRecord.get('oozieServerUrl')
  35. });
  36. this.set('model.targetCluster', targetCluster);
  37. },
  38. createTargetCluster: function () {
  39. var targetCluster = Ember.Object.create({
  40. clusterName: null,
  41. nameNodeWebUrl: null,
  42. nameNodeRpcUrl: null,
  43. oozieServerUrl: null
  44. });
  45. this.set('model.targetCluster', targetCluster);
  46. return targetCluster;
  47. /* For future (but on record objects , not on pojos):
  48. targetCluster.on('didUpdate', function() {
  49. console.log("------Updated!");
  50. });
  51. targetCluster.on('didDelete', function() {
  52. console.log("------Deleted!");
  53. });
  54. targetCluster.on('didCreate', function() {
  55. console.log("------Created!");
  56. });
  57. */
  58. },
  59. getTargetCluster: function () {
  60. return this.get('content.targetCluster');
  61. },
  62. popup : null,
  63. /**
  64. * "Delete" button handler.
  65. * A DataSet
  66. */
  67. deleteTargetCluster: function () {
  68. var self = this;
  69. App.showConfirmationPopup(function () {
  70. var originalRecord = self.get('model.originalRecord');
  71. originalRecord.deleteRecord();
  72. originalRecord.get("transaction").commit();
  73. self.get('popup').hide();
  74. App.router.transitionTo('main.mirroring.index');
  75. });
  76. }
  77. });