2 /*******************************************************************************
3 * Copyright (c) 2012-2013 University of Stuttgart.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and the Apache License 2.0 which both accompany this distribution,
7 * and are available at http://www.eclipse.org/legal/epl-v10.html
8 * and http://www.apache.org/licenses/LICENSE-2.0
11 * Oliver Kopp - initial API and implementation and/or initial documentation
12 *******************************************************************************/
14 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
16 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
17 <%@taglib prefix="v" uri="http://www.eclipse.org/winery/repository/functions" %>
18 <%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
19 <%@taglib prefix="wc" uri="http://www.eclipse.org/winery/functions" %>
21 <%-- In English, one can usually form a plural by adding an "s". Therefore, we resue the label to form the window title --%>
22 <t:genericpage windowtitle="${it.label}s" selected="${it.type}" cssClass="${it.CSSclass}">
25 <c:when test="${empty pageContext.request.contextPath}">
26 <c:set var="URL" value="/" />
29 <c:set var="URL" value="${pageContext.request.contextPath}/" />
32 <t:simpleSingleFileUpload
38 accept="application/zip,.csar"/>
40 <t:addComponentInstance
42 typeSelectorData="${it.typeSelectorData}"
45 <div class="middle" id="ccontainer">
48 <table cellpadding=0 cellspacing=0 style="margin-top: 0px; margin-left: 30px;">
50 <td valign="top" style="padding-top: 25px; width: 680px;">
52 <div id="searchBoxContainer">
54 <input id="searchBox" />
58 $('#searchBox').keyup(function() {
59 var searchString = $(this).val();
60 searchString = searchString.toLowerCase();
62 $(".entityContainer").each (function() {
63 var name = $(this).find(".informationContainer > .name").text();
64 var namespace = $(this).find(".informationContainer > .namespace").text();
66 var t = name + namespace;
69 if (t.indexOf(searchString) == -1) {
83 <c:forEach var="t" items="${it.componentInstanceIds}">
84 <%-- even though the id is an invalid XML, it is used for a simple implementation on a click on the graphical rendering to trigger opening the editor --%>
85 <div class="entityContainer ${it.CSSclass}" id="${v:URLencode(t.namespace.encoded)}/${v:URLencode(t.xmlId.encoded)}/">
87 <c:if test="${it.type eq 'NodeType'}">
88 <a href="./${v:URLencode(t.namespace.encoded)}/${v:URLencode(t.xmlId.encoded)}/?edit">
89 <img src='./${v:URLencode(t.namespace.encoded)}/${v:URLencode(t.xmlId.encoded)}/visualappearance/50x50' style='margin-top: 21px; margin-left: 30px; height: 40px; width: 40px;' />
94 <div class="informationContainer">
96 ${wc:escapeHtml4(t.xmlId.decoded)}
98 <div class="namespace" alt="${wc:escapeHtml4(t.namespace.decoded)}">
99 ${wc:escapeHtml4(t.namespace.decoded)}
102 <div class="buttonContainer">
103 <a href="${v:URLencode(t.namespace.encoded)}/${v:URLencode(t.xmlId.encoded)}/?csar" class="exportButton"></a>
104 <a href="${v:URLencode(t.namespace.encoded)}/${v:URLencode(t.xmlId.encoded)}/?edit" class="editButton"></a>
105 <%-- we need double encoding of the URL as the passing to javascript: decodes the given string once --%>
106 <a href="javascript:deleteCI('${wc:escapeHtml4(t.xmlId.decoded)}', '${v:URLencode(v:URLencode(t.namespace.encoded))}/${v:URLencode(v:URLencode(t.xmlId.encoded))}/');" class="deleteButton" onclick="element = $(this).parent().parent().parent();"></a>
109 <div class="right"></div>
113 <td id="gcprightcolumn" valign="top">
114 <div id="overviewtopshadow"></div>
115 <div id="overviewbottomshadow"></div>
118 <div class="btn-group-vertical" id="buttonList">
119 <button type="button" class="btn btn-default" onclick="openNewCIdiag();">Add new</button>
120 <button type="button" class="btn btn-default" onclick="importCSAR();">Import CSAR</button>
129 function entityContainerClicked(e) {
130 var target = $(e.target);
131 if (target.is("a")) {
132 // do nothing as a nested a element is clicked
134 var ec = target.parents("div.entityContainer");
135 var url = ec.attr('id');
137 // emulate browser's default behavior to open a new tab
140 window.location = url;
145 $("div.entityContainer").on("click", entityContainerClicked);
148 * deletes given component instance
149 * uses global variable "element", which stores the DOM element to delete upon successful deletion
151 function deleteCI(name, URL) {
152 deleteResource(name, URL, function() {
157 function importCSAR() {
158 $('#upCSARDiag').modal('show');
161 // If export button is clicked with "CTRL", the plain XML is shown, not the CSAR
162 // We use "on" with filters instead as new elements could be added when pressing "Add new" (in the future)
163 // contained code is the same as the code of the CSAR button at the topology modeler (see index.jsp)
164 $(document).on("click", ".exportButton", function(evt) {
165 var url = $(this).attr("href");
167 url = url.replace(/csar$/, "definitions");
173 <%-- Special feature in the case of the service template --%>
174 <c:if test="${it.type eq 'ServiceTemplate'}">
175 //If edit button is clicked with "CTRL", the topology modeler is opened, not the service template editor
176 //We use "on" with filters instead as new elements could be added when pressing "Add new" (in the future)
177 $(document).on("click", ".editButton", function(evt) {
178 var url = $(this).attr("href");
180 url = url.replace(/\?edit$/, "topologytemplate/?edit");
182 var newWin = window.open(url);
183 // focussing the new window does not work in Chrome
187 window.location = url;
189 evt.preventDefault();
193 $(".exportButton").tooltip({
196 title: "Export CSAR.<br/>Hold CTRL key to export XML only."
198 $(".editButton").tooltip({
201 title: <c:if test="${it.type eq 'ServiceTemplate'}">"Edit.<br/>Hold CTRL key to directly open the topology modeler."</c:if><c:if test="${not (it.type eq 'ServiceTemplate')}">"Edit"</c:if>
203 $(".deleteButton").tooltip({