node-menu.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. import Ember from 'ember';
  19. /**
  20. * Create left hand side node manager menu with menu item activated based
  21. * on page being accessed.
  22. */
  23. export default Ember.Helper.helper(function(params,hash) {
  24. // Place a menu within a panel inside col-md-2 container.
  25. var nodeIdSplitAtPort = hash.nodeId;
  26. var portIndex = nodeIdSplitAtPort.indexOf(':');
  27. if (portIndex != -1) {
  28. nodeIdSplitAtPort = nodeIdSplitAtPort.substring(0, portIndex) +
  29. ':​' + nodeIdSplitAtPort.substring(portIndex + 1);
  30. }
  31. var normalizedNodeId = '';
  32. var splitsAlongDots = nodeIdSplitAtPort.split('.');
  33. if (splitsAlongDots) {
  34. var len = splitsAlongDots.length;
  35. for (var i = 0; i < len; i++) {
  36. normalizedNodeId = normalizedNodeId + splitsAlongDots[i];
  37. if (i != len - 1) {
  38. normalizedNodeId = normalizedNodeId + '.&#8203;';
  39. }
  40. }
  41. } else {
  42. normalizedNodeId = nodeIdSplitAtPort;
  43. }
  44. var html = '<div class="col-md-2 container-fluid"><div class="panel panel-default">'+
  45. '<div class="panel-heading"><h4>Node Manager<br>(' + normalizedNodeId + ')</h4></div>'+
  46. '<div class="panel-body"><ul class="nav nav-pills nav-stacked" id="stacked-menu">' +
  47. '<ul class="nav nav-pills nav-stacked collapse in"><li';
  48. if (hash.path == 'yarnNode') {
  49. html = html + ' class="active"';
  50. }
  51. html = html + '><a href="yarnNode/' + hash.nodeId + '/' + hash.nodeAddr +
  52. '">Node Information</a></li><li';
  53. if (hash.path == 'yarnNodeApps') {
  54. html = html + ' class="active"';
  55. }
  56. html = html + '><a href="yarnNodeApps/' + hash.nodeId + '/' + hash.nodeAddr +
  57. '">List of Applications</a></li><li';
  58. if (hash.path == 'yarnNodeContainers') {
  59. html = html + ' class="active"';
  60. }
  61. html = html + '><a href="yarnNodeContainers/' +hash.nodeId + '/' + hash.nodeAddr +
  62. '">List of Containers</a></li></ul></ul></div>';
  63. return Ember.String.htmlSafe(html);
  64. });