c5c2b4ff88981b41e6f3f8555e20245a05578858
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / webapp / WEB-INF / tags / componentinstance.tag
1 <%--
2 /*******************************************************************************
3  * Copyright (c) 2012-2013, 2015 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
9  *
10  * Contributors:
11  *    Oliver Kopp - initial API and implementation and/or initial documentation
12  *******************************************************************************/
13 --%>
14 <%@tag description="Wrapper for resources, which are backed by definitions and thus offer an XML div" pageEncoding="UTF-8"%>
15
16 <%--
17   quick hack to avoid specifying windowtitle at elements having it.name, too.
18   TODO: check why in this class a check on it.name is done, although there is componentinstancewithname.tag
19 --%>
20 <%@attribute name="windowtitle" description="If it.name is not available, this parameter should be given"%>
21
22 <%@attribute name="selected" required="true"%>
23
24 <%@attribute name="cssClass" required="true"%>
25
26 <%@attribute name="image" required="false"%>
27
28 <%@attribute name="libs" fragment="true" %>
29
30 <%@attribute name="subMenus" required="false" type="java.util.List" description="list of SubMenuData objects stating the content of the submenus. The first submenu is used as default page. Subpage #xml must not be included, it is added automatically."%>
31
32 <%@attribute name="implementationFor" description="In case the component instance is an implementation for another type, the link (a href) to the type is put here"%>
33
34 <%@attribute name="type" description="In case the component instance is a template, the link (a href) to the type is put here"%>
35
36 <%@attribute name="twolines" required="false" description="if set, two lines are required for the tabs"%>
37
38 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
39 <%@taglib prefix="w" uri="http://www.eclipse.org/winery/repository/functions" %>
40 <%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
41
42 <c:if test="${empty windowtitle}">
43   <c:set var="windowtitle" value="${it.name}" />
44 </c:if>
45
46 <t:genericpage windowtitle="${windowtitle}" selected="${selected}" cssClass="mainContentContainer ${cssClass}" libs="${libs}">
47
48         <div class="top<c:if test="${not empty twolines}"> twolines</c:if>">
49                 <c:if test="${not empty image}">
50                         <img src='visualappearance/50x50' style='position: absolute; margin-top: 32px; margin-left: 27px; height: 40px; width: 40px;' />
51                 </c:if>
52
53                 <%-- Quick hack to enable usage of this tag at adminresource --%>
54                 <c:catch var="exception"><c:if test="${empty it.name}"></c:if></c:catch>
55                 <c:if test="${empty exception}">
56                         <%@ include file="/jsp/componentnaming.jspf" %>
57                         <div style="float:right; margin-right:29px; margin-top: -20px; position:relative;">
58                                 <div style="float:right;">
59                                         <button type="button" class="btn btn-danger" onclick="deleteResource('${it.name}', '.', openOverviewPage)">Delete</button>
60                                         <a href="?definitions" class="btn btn-info">XML</a>
61                                         <a href="?csar" class="btn btn-info">CSAR</a>
62                                         <c:if test="${w:isContainerLocallyAvailable()}">
63                                                 <button id="deployBtn" type="button" onclick="deployOnOpenTOSCAContainer()" class="btn btn-info" data-loading-text="Deploying...">Deploy</button>
64                                         </c:if>
65                                 </div>
66                                 <c:if test="${not empty implementationFor}">
67                                         <div style="clear:both; float:right;">
68                                         Implementation for ${implementationFor}
69                                         </div>
70                                 </c:if>
71                                 <c:if test="${not empty type}">
72                                         <div style="clear:both; float:right;">
73                                         Type ${type}
74                                         </div>
75                                 </c:if>
76                         </div>
77                 </c:if>
78                 <div class="subMenu">
79                         <c:if test="${not empty subMenus}">
80                                 <c:forEach items="${subMenus}" var="subMenu" varStatus="status">
81                                         <t:submenu selected="${status.first}" subMenuData="${subMenu}">
82                                         </t:submenu>
83                                 </c:forEach>
84                         </c:if>
85
86                         <%-- Quick hack to enable usage of this tag at adminresource --%>
87                         <c:if test="${empty exception}">
88                                 <t:submenu subMenuData="<%=org.eclipse.winery.repository.resources.SubMenuData.SUBMENU_DOCUMENTATION%>" selected="${empty subMenus}">
89                                 </t:submenu>
90                                 <t:submenu subMenuData="<%=org.eclipse.winery.repository.resources.SubMenuData.SUBMENU_XML%>" selected="${empty subMenus}">
91                                 </t:submenu>
92                         </c:if>
93                 </div>
94         </div>
95
96         <div class="middle" id="ccontainer">
97         </div>
98
99         <c:if test="${empty subMenus}">
100                 <jsp:include page="/jsp/hashloading.jsp">
101                         <jsp:param name="validpages" value="['#documentation', '#xml']" />
102                         <jsp:param name="defaultpage" value="#documentation" />
103                 </jsp:include>
104         </c:if>
105         <c:if test="${not empty subMenus}">
106                 <c:forEach items="${subMenus}" var="subMenu" varStatus="status">
107                         <c:if test="${status.first}">
108                                 <c:set var="defaultpage" value="${subMenu.href}"></c:set>
109                                 <c:set var="additionalHashes" value="'${subMenu.href}'"></c:set>
110                         </c:if>
111                         <c:if test="${not status.first}">
112                                 <c:set var="additionalHashes" value="${additionalHashes}, '${subMenu.href}'"></c:set>
113                         </c:if>
114                 </c:forEach>
115
116                 <jsp:include page="/jsp/hashloading.jsp">
117                         <jsp:param name="validpages" value="[${additionalHashes}, '#documentation', '#xml']" />
118                         <jsp:param name="defaultpage" value="${defaultpage}" />
119                 </jsp:include>
120         </c:if>
121
122         <div class="bottom">
123         </div>
124
125 <script>
126 function openOverviewPage() {
127         window.location="../../";
128 }
129
130 function deployOnOpenTOSCAContainer() {
131         $("#deployBtn").button('loading');
132
133         urlToUpload = window.location.href;
134         var hash = window.location.hash;
135         if (hash != "") {
136                 urlToUpload = urlToUpload.substr(0, urlToUpload.length - hash.length)
137         }
138         var search = window.location.search;
139         if (search != "") {
140                 urlToUpload = urlToUpload.substr(0, urlToUpload.length - search.length)
141         }
142
143         urlToUpload = urlToUpload + "?csar";
144
145         var data = {
146                 urlToUpload: urlToUpload
147         }
148
149         // we assume the container runs at the same host and port
150         $.ajax({
151                 url: "/admin/uploadCSARFromURL.action",
152                 data: data
153         }).always(function () {
154                 $("#deployBtn").button('reset');
155         }).fail(function (jqXHR, textStatus, errorThrown) {
156                 vShowAJAXError("Could not trigger CSAR deployment at OpenTOSCA container", jqXHR, errorThrown);
157         }).done(function (result) {
158                 vShowSuccess("Successfully triggered CSAR deployment at OpenTOSCA container");
159         });
160 }
161 </script>
162
163 </t:genericpage>