upgrade_task_view.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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.upgradeTaskView = Em.View.extend({
  20. templateName: require('templates/main/admin/stack_upgrade/upgrade_task'),
  21. /**
  22. * view observed directly
  23. * @type {boolean}
  24. */
  25. outsideView: false,
  26. /**
  27. * @type {boolean}
  28. */
  29. showContent: Em.computed.or('outsideView', 'content.isExpanded'),
  30. /**
  31. * @type {boolean}
  32. */
  33. errorLogOpened: false,
  34. /**
  35. * @type {boolean}
  36. */
  37. outputLogOpened: false,
  38. /**
  39. * @type {App.upgradeEntity}
  40. * @default null
  41. */
  42. content: null,
  43. /**
  44. * @type {Array}
  45. */
  46. tasks: [],
  47. /**
  48. * @type {string}
  49. */
  50. logTabId: Em.computed.format('{0}-log-tab', 'elementId'),
  51. /**
  52. * @type {string}
  53. */
  54. errorTabId: Em.computed.format('{0}-error-tab', 'elementId'),
  55. /**
  56. * @type {string}
  57. */
  58. logTabIdLink: Em.computed.format('#{0}','logTabId'),
  59. /**
  60. * @type {string}
  61. */
  62. errorTabIdLInk: Em.computed.format('#{0}','errorTabId'),
  63. /**
  64. * open error log in textarea to give ability to cope content
  65. * @param {object} event
  66. */
  67. copyErrLog: function(event) {
  68. this.toggleProperty('errorLogOpened');
  69. },
  70. /**
  71. * open stdout log in textarea to give ability to cope content
  72. * @param {object} event
  73. */
  74. copyOutLog: function(event) {
  75. this.toggleProperty('outputLogOpened');
  76. },
  77. /**
  78. * open error log in new window
  79. */
  80. openErrorLog: function () {
  81. this.openLogWindow(this.get('content.stderr'));
  82. },
  83. /**
  84. * open stdout log in new window
  85. */
  86. openOutLog: function () {
  87. this.openLogWindow(this.get('content.stdout'));
  88. },
  89. /**
  90. * open logs in new window
  91. * @param {string} log
  92. */
  93. openLogWindow: function(log) {
  94. var newWindow = window.open(),
  95. newDocument = newWindow.document,
  96. outputWrapper = newDocument.createElement('pre'),
  97. output = newDocument.createTextNode(log);
  98. outputWrapper.appendChild(output);
  99. newDocument.body.appendChild(outputWrapper);
  100. newDocument.close();
  101. }
  102. });