diff --git a/hawtio-web/src/main/webapp/app/fabric/html/container.html b/hawtio-web/src/main/webapp/app/fabric/html/container.html index 84575d5d26..bc0398806b 100644 --- a/hawtio-web/src/main/webapp/app/fabric/html/container.html +++ b/hawtio-web/src/main/webapp/app/fabric/html/container.html @@ -79,7 +79,7 @@

Con
-
+
@@ -209,19 +209,59 @@

Con
Git:
-
{{getGitURL(row.jolokiaUrl)}}
+
+ + +
SSH:
-
{{row.sshUrl}}
+
+ + +
JMX:
-
{{row.jmxUrl}}
+
+ + +
Jolokia:
-
{{row.jolokiaUrl}}
+
+ + +
diff --git a/hawtio-web/src/main/webapp/app/fabric/js/container.ts b/hawtio-web/src/main/webapp/app/fabric/js/container.ts index 8d8945213c..31d045e63f 100644 --- a/hawtio-web/src/main/webapp/app/fabric/js/container.ts +++ b/hawtio-web/src/main/webapp/app/fabric/js/container.ts @@ -1,6 +1,6 @@ module Fabric { - export function ContainerController($scope, $routeParams, $location, localStorage, jolokia, workspace) { + export function ContainerController($scope, $routeParams, $location, localStorage, jolokia, workspace, userDetails) { Fabric.initScope($scope, $location, jolokia, workspace); @@ -10,6 +10,22 @@ module Fabric { $scope.operation = 'getContainer(java.lang.String)'; } + $scope.username = userDetails.username; + $scope.password = userDetails.password; + + $scope.tab = $routeParams['tab']; + if (!$scope.tab) { + $scope.tab = 'Status'; + } + + + $scope.$watch('tab', (newValue, oldValue) => { + if (newValue !== oldValue) { + $location.search({tab: newValue}); + } + }); + + /* // handy for working around any randomly added fields that won't marshal $scope.fields = jolokia.execute(Fabric.managerMBean, 'getFields(java.lang.String)', 'org.fusesource.fabric.api.Container'); @@ -65,9 +81,34 @@ module Fabric { }; $scope.getGitURL = (jolokiaUrl) => { - return jolokiaUrl ? jolokiaUrl.replace("jolokia", "git/fabric") : null; + var answer = jolokiaUrl ? jolokiaUrl.replace("jolokia", "git/fabric") : null; + if (answer !== null) { + var command = "git clone -b 1.0 " + answer; + if ($scope.username !== null && $scope.password !== null) { + command = command.replace("://", "://" + $scope.username + ":" + $scope.password + "@"); } + answer = command; + } + return answer; }; + + $scope.getSshURL = (sshUrl) => { + var answer = sshUrl; + if ($scope.username !== null && $scope.password !== null) { + var parts = sshUrl.split(":"); + if (parts.length === 2) { + answer = "ssh -p " + parts[1] + " " + $scope.username + "@" + parts[0]; + } + } + return answer; + }; + + + $scope.getJmxURL = (jmxUrl) => { + return jmxUrl; + }; + + $scope.getType = () => { if ($scope.row) { if ($scope.row.ensembleServer) { diff --git a/hawtio-web/src/main/webapp/app/ui/js/uiPlugin.ts b/hawtio-web/src/main/webapp/app/ui/js/uiPlugin.ts index 9fb480c283..d53021dd27 100644 --- a/hawtio-web/src/main/webapp/app/ui/js/uiPlugin.ts +++ b/hawtio-web/src/main/webapp/app/ui/js/uiPlugin.ts @@ -40,6 +40,8 @@ module UI { return new UI.JSPlumb(); //}).directive('connectTo', () => { // return new UI.JSPlumbConnection(); + }).directive('zeroClipboard', () => { + return new UI.ZeroClipboardDirective(); }).run(function (helpRegistry) { helpRegistry.addDevDoc("ui", 'app/ui/doc/developer.md'); }); diff --git a/hawtio-web/src/main/webapp/app/ui/js/zeroclipboard.ts b/hawtio-web/src/main/webapp/app/ui/js/zeroclipboard.ts new file mode 100644 index 0000000000..1b2be24fec --- /dev/null +++ b/hawtio-web/src/main/webapp/app/ui/js/zeroclipboard.ts @@ -0,0 +1,17 @@ +module UI { + + export class ZeroClipboardDirective { + public restrict = 'A'; + + public link = ($scope, $element, $attr) => { + var clip = new (window).ZeroClipboard($element.get(0), { + moviePath: "img/ZeroClipboard.swf" + }); + + clip.on('complete', (client, args) => { + notification('info', "Copied text to clipboard: " + args.text); + }); + + }; + } +} diff --git a/hawtio-web/src/main/webapp/img/ZeroClipboard.swf b/hawtio-web/src/main/webapp/img/ZeroClipboard.swf new file mode 100644 index 0000000000..5ce6955010 Binary files /dev/null and b/hawtio-web/src/main/webapp/img/ZeroClipboard.swf differ diff --git a/hawtio-web/src/main/webapp/index.html b/hawtio-web/src/main/webapp/index.html index 68d7f2acd4..bc434262a7 100644 --- a/hawtio-web/src/main/webapp/index.html +++ b/hawtio-web/src/main/webapp/index.html @@ -304,8 +304,6 @@

Cannot Connect: {{connectFail - - @@ -324,5 +322,15 @@

Cannot Connect: {{connectFail + + + + + + + + + + diff --git a/hawtio-web/src/main/webapp/lib/ZeroClipboard.min.js b/hawtio-web/src/main/webapp/lib/ZeroClipboard.min.js new file mode 100644 index 0000000000..44fcf8e7d4 --- /dev/null +++ b/hawtio-web/src/main/webapp/lib/ZeroClipboard.min.js @@ -0,0 +1,9 @@ +/*! +* ZeroClipboard +* The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. +* Copyright (c) 2013 Jon Rohan, James M. Greene +* Licensed MIT +* http://zeroclipboard.org/ +* v1.2.1 +*/ +!function(){"use strict";var a,b=function(){var a=/\-([a-z])/g,b=function(a,b){return b.toUpperCase()};return function(c){return c.replace(a,b)}}(),c=function(a,c){var d,e,f,g,h,i;if(window.getComputedStyle?d=window.getComputedStyle(a,null).getPropertyValue(c):(e=b(c),d=a.currentStyle?a.currentStyle[e]:a.style[e]),"cursor"===c&&(!d||"auto"===d))for(f=a.tagName.toLowerCase(),g=["a"],h=0,i=g.length;i>h;h++)if(f===g[h])return"pointer";return d},d=function(a){if(p.prototype._singleton){a||(a=window.event);var b;this!==window?b=this:a.target?b=a.target:a.srcElement&&(b=a.srcElement),p.prototype._singleton.setCurrent(b)}},e=function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)},f=function(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c)},g=function(a,b){if(a.addClass)return a.addClass(b),a;if(b&&"string"==typeof b){var c=(b||"").split(/\s+/);if(1===a.nodeType)if(a.className){for(var d=" "+a.className+" ",e=a.className,f=0,g=c.length;g>f;f++)d.indexOf(" "+c[f]+" ")<0&&(e+=" "+c[f]);a.className=e.replace(/^\s+|\s+$/g,"")}else a.className=b}return a},h=function(a,b){if(a.removeClass)return a.removeClass(b),a;if(b&&"string"==typeof b||void 0===b){var c=(b||"").split(/\s+/);if(1===a.nodeType&&a.className)if(b){for(var d=(" "+a.className+" ").replace(/[\n\t]/g," "),e=0,f=c.length;f>e;e++)d=d.replace(" "+c[e]+" "," ");a.className=d.replace(/^\s+|\s+$/g,"")}else a.className=""}return a},i=function(){var a,b,c,d=1;return"function"==typeof document.body.getBoundingClientRect&&(a=document.body.getBoundingClientRect(),b=a.right-a.left,c=document.body.offsetWidth,d=Math.round(100*(b/c))/100),d},j=function(a){var b={left:0,top:0,width:0,height:0,zIndex:999999999},d=c(a,"z-index");if(d&&"auto"!==d&&(b.zIndex=parseInt(d,10)),a.getBoundingClientRect){var e,f,g,h=a.getBoundingClientRect();"pageXOffset"in window&&"pageYOffset"in window?(e=window.pageXOffset,f=window.pageYOffset):(g=i(),e=Math.round(document.documentElement.scrollLeft/g),f=Math.round(document.documentElement.scrollTop/g));var j=document.documentElement.clientLeft||0,k=document.documentElement.clientTop||0;b.left=h.left+e-j,b.top=h.top+f-k,b.width="width"in h?h.width:h.right-h.left,b.height="height"in h?h.height:h.bottom-h.top}return b},k=function(a,b){var c=!(b&&b.useNoCache===!1);return c?(-1===a.indexOf("?")?"?":"&")+"nocache="+(new Date).getTime():""},l=function(a){var b=[],c=[];return a.trustedOrigins&&("string"==typeof a.trustedOrigins?c.push(a.trustedOrigins):"object"==typeof a.trustedOrigins&&"length"in a.trustedOrigins&&(c=c.concat(a.trustedOrigins))),a.trustedDomains&&("string"==typeof a.trustedDomains?c.push(a.trustedDomains):"object"==typeof a.trustedDomains&&"length"in a.trustedDomains&&(c=c.concat(a.trustedDomains))),c.length&&b.push("trustedOrigins="+encodeURIComponent(c.join(","))),"string"==typeof a.amdModuleId&&a.amdModuleId&&b.push("amdModuleId="+encodeURIComponent(a.amdModuleId)),"string"==typeof a.cjsModuleId&&a.cjsModuleId&&b.push("cjsModuleId="+encodeURIComponent(a.cjsModuleId)),b.join("&")},m=function(a,b){if(b.indexOf)return b.indexOf(a);for(var c=0,d=b.length;d>c;c++)if(b[c]===a)return c;return-1},n=function(a){if("string"==typeof a)throw new TypeError("ZeroClipboard doesn't accept query strings.");return a.length?a:[a]},o=function(a,b,c,d,e){e?window.setTimeout(function(){a.call(b,c,d)},0):a.call(b,c,d)},p=function(a,b){if(a&&(p.prototype._singleton||this).glue(a),p.prototype._singleton)return p.prototype._singleton;p.prototype._singleton=this,this.options={};for(var c in s)this.options[c]=s[c];for(var d in b)this.options[d]=b[d];this.handlers={},p.detectFlashSupport()&&v()},q=[];p.prototype.setCurrent=function(b){a=b,this.reposition();var d=b.getAttribute("title");d&&this.setTitle(d);var e=this.options.forceHandCursor===!0||"pointer"===c(b,"cursor");return r.call(this,e),this},p.prototype.setText=function(a){return a&&""!==a&&(this.options.text=a,this.ready()&&this.flashBridge.setText(a)),this},p.prototype.setTitle=function(a){return a&&""!==a&&this.htmlBridge.setAttribute("title",a),this},p.prototype.setSize=function(a,b){return this.ready()&&this.flashBridge.setSize(a,b),this},p.prototype.setHandCursor=function(a){return a="boolean"==typeof a?a:!!a,r.call(this,a),this.options.forceHandCursor=a,this};var r=function(a){this.ready()&&this.flashBridge.setHandCursor(a)};p.version="1.2.1";var s={moviePath:"ZeroClipboard.swf",trustedOrigins:null,text:null,hoverClass:"zeroclipboard-is-hover",activeClass:"zeroclipboard-is-active",allowScriptAccess:"sameDomain",useNoCache:!0,forceHandCursor:!1};p.setDefaults=function(a){for(var b in a)s[b]=a[b]},p.destroy=function(){p.prototype._singleton.unglue(q);var a=p.prototype._singleton.htmlBridge;a.parentNode.removeChild(a),delete p.prototype._singleton},p.detectFlashSupport=function(){var a=!1;if("function"==typeof ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(a=!0)}catch(b){}return!a&&navigator.mimeTypes["application/x-shockwave-flash"]&&(a=!0),a};var t=null,u=null,v=function(){var a=p.prototype._singleton,b=document.getElementById("global-zeroclipboard-html-bridge");if(!b){var c={};for(var d in a.options)c[d]=a.options[d];c.amdModuleId=t,c.cjsModuleId=u;var e=l(c),f=' ';b=document.createElement("div"),b.id="global-zeroclipboard-html-bridge",b.setAttribute("class","global-zeroclipboard-container"),b.setAttribute("data-clipboard-ready",!1),b.style.position="absolute",b.style.left="-9999px",b.style.top="-9999px",b.style.width="15px",b.style.height="15px",b.style.zIndex="9999",b.innerHTML=f,document.body.appendChild(b)}a.htmlBridge=b,a.flashBridge=document["global-zeroclipboard-flash-bridge"]||b.children[0].lastElementChild};p.prototype.resetBridge=function(){return this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),h(a,this.options.activeClass),a=null,this.options.text=null,this},p.prototype.ready=function(){var a=this.htmlBridge.getAttribute("data-clipboard-ready");return"true"===a||a===!0},p.prototype.reposition=function(){if(!a)return!1;var b=j(a);return this.htmlBridge.style.top=b.top+"px",this.htmlBridge.style.left=b.left+"px",this.htmlBridge.style.width=b.width+"px",this.htmlBridge.style.height=b.height+"px",this.htmlBridge.style.zIndex=b.zIndex+1,this.setSize(b.width,b.height),this},p.dispatch=function(a,b){p.prototype._singleton.receiveEvent(a,b)},p.prototype.on=function(a,b){for(var c=a.toString().split(/\s/g),d=0;d '; + container = document.createElement("div"); + container.id = "global-zeroclipboard-html-bridge"; + container.setAttribute("class", "global-zeroclipboard-container"); + container.setAttribute("data-clipboard-ready", false); + container.style.position = "absolute"; + container.style.left = "-9999px"; + container.style.top = "-9999px"; + container.style.width = "15px"; + container.style.height = "15px"; + container.style.zIndex = "9999"; + container.innerHTML = html; + document.body.appendChild(container); + } + client.htmlBridge = container; + client.flashBridge = document["global-zeroclipboard-flash-bridge"] || container.children[0].lastElementChild; + }; + ZeroClipboard.prototype.resetBridge = function() { + this.htmlBridge.style.left = "-9999px"; + this.htmlBridge.style.top = "-9999px"; + this.htmlBridge.removeAttribute("title"); + this.htmlBridge.removeAttribute("data-clipboard-text"); + _removeClass(currentElement, this.options.activeClass); + currentElement = null; + this.options.text = null; + return this; + }; + ZeroClipboard.prototype.ready = function() { + var ready = this.htmlBridge.getAttribute("data-clipboard-ready"); + return ready === "true" || ready === true; + }; + ZeroClipboard.prototype.reposition = function() { + if (!currentElement) return false; + var pos = _getDOMObjectPosition(currentElement); + this.htmlBridge.style.top = pos.top + "px"; + this.htmlBridge.style.left = pos.left + "px"; + this.htmlBridge.style.width = pos.width + "px"; + this.htmlBridge.style.height = pos.height + "px"; + this.htmlBridge.style.zIndex = pos.zIndex + 1; + this.setSize(pos.width, pos.height); + return this; + }; + ZeroClipboard.dispatch = function(eventName, args) { + ZeroClipboard.prototype._singleton.receiveEvent(eventName, args); + }; + ZeroClipboard.prototype.on = function(eventName, func) { + var events = eventName.toString().split(/\s/g); + for (var i = 0; i < events.length; i++) { + eventName = events[i].toLowerCase().replace(/^on/, ""); + if (!this.handlers[eventName]) this.handlers[eventName] = func; + } + if (this.handlers.noflash && !ZeroClipboard.detectFlashSupport()) { + this.receiveEvent("onNoFlash", null); + } + return this; + }; + ZeroClipboard.prototype.addEventListener = ZeroClipboard.prototype.on; + ZeroClipboard.prototype.off = function(eventName, func) { + var events = eventName.toString().split(/\s/g); + for (var i = 0; i < events.length; i++) { + eventName = events[i].toLowerCase().replace(/^on/, ""); + for (var event in this.handlers) { + if (event === eventName && this.handlers[event] === func) { + delete this.handlers[event]; + } + } + } + return this; + }; + ZeroClipboard.prototype.removeEventListener = ZeroClipboard.prototype.off; + ZeroClipboard.prototype.receiveEvent = function(eventName, args) { + eventName = eventName.toString().toLowerCase().replace(/^on/, ""); + var element = currentElement; + var performCallbackAsync = true; + switch (eventName) { + case "load": + if (args && parseFloat(args.flashVersion.replace(",", ".").replace(/[^0-9\.]/gi, "")) < 10) { + this.receiveEvent("onWrongFlash", { + flashVersion: args.flashVersion + }); + return; + } + this.htmlBridge.setAttribute("data-clipboard-ready", true); + break; + + case "mouseover": + _addClass(element, this.options.hoverClass); + break; + + case "mouseout": + _removeClass(element, this.options.hoverClass); + this.resetBridge(); + break; + + case "mousedown": + _addClass(element, this.options.activeClass); + break; + + case "mouseup": + _removeClass(element, this.options.activeClass); + break; + + case "datarequested": + var targetId = element.getAttribute("data-clipboard-target"), targetEl = !targetId ? null : document.getElementById(targetId); + if (targetEl) { + var textContent = targetEl.value || targetEl.textContent || targetEl.innerText; + if (textContent) this.setText(textContent); + } else { + var defaultText = element.getAttribute("data-clipboard-text"); + if (defaultText) this.setText(defaultText); + } + performCallbackAsync = false; + break; + + case "complete": + this.options.text = null; + break; + } + if (this.handlers[eventName]) { + var func = this.handlers[eventName]; + if (typeof func === "string" && typeof window[func] === "function") { + func = window[func]; + } + if (typeof func === "function") { + _dispatchCallback(func, element, this, args, performCallbackAsync); + } + } + }; + ZeroClipboard.prototype.glue = function(elements) { + elements = _prepGlue(elements); + for (var i = 0; i < elements.length; i++) { + if (_inArray(elements[i], gluedElements) == -1) { + gluedElements.push(elements[i]); + _addEventHandler(elements[i], "mouseover", _elementMouseOver); + } + } + return this; + }; + ZeroClipboard.prototype.unglue = function(elements) { + elements = _prepGlue(elements); + for (var i = 0; i < elements.length; i++) { + _removeEventHandler(elements[i], "mouseover", _elementMouseOver); + var arrayIndex = _inArray(elements[i], gluedElements); + if (arrayIndex != -1) gluedElements.splice(arrayIndex, 1); + } + return this; + }; + if (typeof define === "function" && define.amd) { + define([ "require", "exports", "module" ], function(require, exports, module) { + _amdModuleId = module && module.id || null; + return ZeroClipboard; + }); + } else if (typeof module === "object" && module && typeof module.exports === "object" && module.exports) { + _cjsModuleId = module.id || null; + module.exports = ZeroClipboard; + } else { + window.ZeroClipboard = ZeroClipboard; + } +})(); \ No newline at end of file