<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="master.html" />
<head>
	<!--[if IE]>  
	<script type="text/javascript" src="${tg.url('/scripts/excanvas.js')}"></script>
	<![endif]-->
	<script type="text/javascript" src="${tg.url('/scripts/js-graph-it.js')}"></script>
	<link rel="stylesheet" type="text/css" href="${tg.url('/css/js-graph-it.css')}" />
	<script type="text/javascript">
		window.addEvent('load', function() {
			initPageObjects();
		});
	</script>
	<title>Viewing tube ${'%s (%s)' % (tube.display_name, tube.name)}</title>
	<style type="text/css">
		div#tubegraph
		{
			border: 2px solid #EEEEEE;
			-moz-border-radius:10px 50px 10px 50px;
			-webkit-border-radius:10px 50px 10px 50px;
			background-color: white;
			background-repeat: no-repeat;
			background-position: top right;
			padding: 0px;
		}
		
		div.connector
		{
			background-color: #FF9900;
			z-index: 1000;
		}
		
		#tubegraph .block
		{
			/*background: 4px 4px #23A4FF no-repeat;*/
			background-color: #B7E0FF;
			-moz-border-radius: 5px;
			padding: 3px;
			font-size: 10px;
			border: 1px solid #444;
			-moz-box-shadow: 2px 2px 3px rgba(0, 0, 0, .4);
			width: 200px;
		}
		
		#tubegraph img.type_info
		{
			background:#FFF;
			-moz-border-radius: 3px;
			padding: 3px;
			float: left;
			margin: 1px;
		}
		
		#tubegraph .name_info
		{
			height: 24px;
			line-height: 24px;
			background: url('${tg.url("/images/sprites.png")}') left top repeat-y;
			display: block;
			-moz-border-radius: 4px;
			color: #FFF;
			padding-right: 3px;
			min-width: 100px;
		}
		
		/*#tubegraph .block.adapter
		{
			background-image: url('${tg.url("/images/silk/cog.png")}');
		}
		
		#tubegraph .block.producer
		{
			background-image: url('${tg.url("/images/silk/cog_go.png")}');
		}*/
	</style>
</head>
<body>
	<div id="sidebar">
		<h3>Type</h3>
		<p class="text" py:if="not tube.needs_source">This is a standalone tube</p>
		<p class="text" py:if="tube.needs_source">This is a processing tube needing a source</p>
		<h3>Actions</h3>
		<ul>
			<li>Show tube content</li>
			<li py:if="'manage' in request.identity['permissions'] or 'tube_edit' in request.identity['permissions']">
				<a py:attrs="dict(href=tg.url('/tubes/design/%d'%tube.id))">Edit tube (design view)</a>
			</li>
			<li py:if="'manage' in request.identity['permissions'] or 'tube_edit' in request.identity['permissions']">
				<a py:attrs="dict(href=tg.url('/tubes/%d/edit'%tube.id))">Edit tube (xml view)</a>
			</li>
			<li py:if="(not tube.needs_source) and ('manage' in request.identity['permissions'] or 'tube_launch' in request.identity['permissions'])">
				<a py:attrs="dict(href=tg.url('/tubes/%d/launch'%tube.id))">Launch tube now</a>
			</li>
			<li py:if="tube.active and (not tube.needs_source) and ('manage' in request.identity['permissions'] or 'tube_launch' in request.identity['permissions'])" py:for="variant in sorted(tube.get_variant_names(show_inactive=False))">
				<a py:attrs="dict(href=tg.url('/tubes/launch', tube_id=tube.id, variant=variant))">Launch variant ${variant} now</a>
			</li>
			<py:if test="tube.needs_source and ('manage' in request.identity['permissions'] or 'dispatch_view' in request.identity['permissions'])">
				<li py:for="dispatch in tube.dispatchs">
					See dispatch <em>
						<a py:attrs="dict(href=tg.url('/dispatchs/%d'%dispatch.id))">
							${dispatch.display_name}
						</a>
					</em>
				</li>
			</py:if>
		</ul>
	</div>
	<div id="content">
		<h2 py:content="'%s (%s)' % (tube.display_name, tube.name)"></h2>
		<p py:content="tube.description"></p>
		
		<py:if test="tube.active and (not tube.needs_source) and ('manage' in request.identity['permissions'] or 'tube_launch' in request.identity['permissions'])">
			<h3>Launch Tube</h3>
			${tmpl_context.launcher.form()}
		</py:if>
		
		<py:if test="'manage' in request.identity['permissions'] or 'tubelayer_view' in request.identity['permissions']">
			<h3 style="margin-top:1px;">Tube Layers</h3>
			${tmpl_context.widget(value=layers_value)}
		</py:if>
		<div id="tubegraph">
			<div class="canvas" style="height: 500px;" py:with="graph = tube.get_graph(type='network')">
				<!--<p class="block draggable" style="top: 100px; left: 10px; width: 300px;" id="par_1">
				We have created a sample page with a canvas, two blocks and a connector with all its features.
				Simple, isn't it?
				</p>
				
				<p class="block draggable" style="top: 200px; left: 100px; width: 300px;" id="par_2">
				Now, go create lots of awesome web pages, applications or whatever with a new tool.
				</p>-->
				
				<p py:for="node in graph['nodes']"
				   class="block draggable ${node.get('type')}"
				   id="${node['name']}"
				   style="left: ${20 + (node['x'] * 240)}px; top: ${20 + (node['y'] * 70)}px;">
					<strong class="name_info">
						<img py:if="node.get('type') == 'producer'"
					     src="${tg.url('/images/silk/cog_go.png')}"
						 title="${node.get('type')}"
						 class="type_info" />
					<img py:if="node.get('type') == 'adapter'"
					     src="${tg.url('/images/silk/cog.png')}"
						 title="${node.get('type')}"
						 class="type_info" />
					<img py:if="node.get('type') == 'consumer'"
					     src="${tg.url('/images/silk/package_go.png')}"
						 title="${node.get('type')}"
						 class="type_info" />
					${node.get('name')}</strong>
					<span py:if="node.get('source') == 'plugin'" class="source"><em>Plugin:</em> ${node.get('pluginname')}<br /></span>
					<span py:if="node.get('source') == 'code'" class="source"><em>Source:</em> Custom code <br /></span>
					<span py:if="node.get('joiner')" class="joiner"><em>Joiner</em> ${node.get('joiner')}</span>
				</p>
				
				<div py:for="link in graph['links']" class="connector ${link[0]} ${link[1]}">
					<img class="connector-end" src="${tg.url('/images/arrow.gif')}" />
				</div>
			</div>
		</div>
	</div>
</body>
</html>
