inject.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <style>
  2. .terminal-container {
  3. width: 100%;
  4. position: fixed;
  5. bottom: 0;
  6. margin-bottom: 0;
  7. background-color: #2b2b2b;
  8. border-width: 1px 0 0 0;
  9. border-radius: 4px 4px 0 0;
  10. z-index: 999;
  11. }
  12. .terminal-content {
  13. width: 100%;
  14. border: 0;
  15. }
  16. #terminal-panel {
  17. cursor: n-resize;
  18. }
  19. .terminal-collapse {
  20. width: 16px;
  21. content: url('/img/chevron_up.svg');
  22. vertical-align: middle;
  23. }
  24. .terminal-collapse.collapsed {
  25. content: url('/img/chevron_down.svg');
  26. }
  27. .module-content {
  28. padding-bottom: 60px;
  29. }
  30. </style>
  31. <div id="terminal-module" class="panel panel-default terminal-container collapse">
  32. <div id="terminal-panel" class="panel-heading">
  33. <a id="terminal-close" class="close">&times;</a>
  34. <h4 class="panel-title">
  35. <span data-toggle="collapse" data-target="#terminal" class="terminal-collapse chevron pointer"></span>
  36. Terminal
  37. <img id="terminal-socket-status" width="10px" src="modules/Terminal/img/disconnected-dot.png">
  38. </h4>
  39. </div>
  40. <div id="terminal" class="panel-collapse collapse"></div>
  41. </div>
  42. <script type="text/javascript">
  43. $(function() {
  44. //registerController('TerminalController', ['$scope', '$api', function($scope, $api){
  45. var $scope = {};
  46. var $api = window.pineapple;
  47. $scope.status = false;
  48. $scope.openTerminalPanel = (function () {
  49. $('#terminal-open').addClass('active');
  50. $('#terminal-module').collapse('show');
  51. $('#terminal').collapse('show').append('<iframe id="terminal-iframe" class="terminal-content"src="modules/Terminal/html/iframe.html"></iframe>');
  52. var iframe = document.getElementById("terminal-iframe");
  53. if (typeof iframe.contentWindow.addEventListener != "undefined") {
  54. iframe.contentWindow.addEventListener("wsterminal", function(event) {
  55. if (event.detail.status) {
  56. var statusImage = (event.detail.status ? "connected-dot.png" : "disconnected-dot.png");
  57. $("#terminal-socket-status").attr("src", "modules/Terminal/img/" + statusImage);
  58. }
  59. });
  60. }
  61. $("#terminal").resizable({
  62. handleSelector: "#terminal-panel",
  63. resizeWidth: false,
  64. resizeHeightFrom: "top",
  65. onDrag: function(event, el) {
  66. $("#terminal-iframe").height( el.height() );
  67. },
  68. });
  69. });
  70. $scope.closeTerminalPanel = (function () {
  71. $('#terminal-open').removeClass('active');
  72. $('#terminal-module').collapse('hide');
  73. $('#terminal').empty();
  74. });
  75. $scope.openTerminal = (function () {
  76. if ($scope.status) {
  77. return;
  78. }
  79. $api.request({
  80. module: 'Terminal',
  81. action: 'startTerminal'
  82. }, function(data) {
  83. if (data.error === undefined && data.success){
  84. $scope.status = true;
  85. $scope.openTerminalPanel();
  86. }
  87. });
  88. });
  89. $scope.closeTerminal = (function () {
  90. $api.request({
  91. module: 'Terminal',
  92. action: 'stopTerminal'
  93. }, function(data) {
  94. if (data.error === undefined && data.success){
  95. $scope.status = false;
  96. $scope.closeTerminalPanel();
  97. }
  98. });
  99. });
  100. $scope.checkStatus = (function () {
  101. $api.request({
  102. module: 'Terminal',
  103. action: 'getStatus'
  104. }, function(data) {
  105. if (data.error === undefined && data.status){
  106. $scope.status = true;
  107. $scope.openTerminalPanel();
  108. }
  109. });
  110. });
  111. $('#terminal-open').click(function(event) {
  112. $scope.openTerminal();
  113. });
  114. $('#terminal-close').click(function(event) {
  115. $scope.closeTerminal();
  116. });
  117. $scope.checkStatus();
  118. });
  119. </script>