Merge "Fix build errors in autorelease full clean build"
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / webapp / jsp / entitytemplates / properties.jsp
1 <%--
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
9  *
10  * Contributors:
11  *    Oliver Kopp - initial API and implementation and/or initial documentation
12  *******************************************************************************/
13 --%>
14 <%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
15
16 <%@page import="org.eclipse.winery.model.tosca.TEntityTemplate"%>
17 <%@page import="org.eclipse.winery.model.tosca.TEntityType"%>
18 <%@page import="org.eclipse.winery.common.ModelUtilities"%>
19 <%@page import="org.eclipse.winery.repository.Utils"%>
20
21 <%@taglib prefix="c"     uri="http://java.sun.com/jsp/jstl/core"%>
22 <%@taglib prefix="props" tagdir="/WEB-INF/tags/common/templates" %>
23 <%@taglib prefix="w"     uri="http://www.eclipse.org/winery/repository/functions"%>
24 <%@taglib prefix="wc"    uri="http://www.eclipse.org/winery/functions" %>
25
26 <script type="text/javascript" src="${pageContext.request.contextPath}/components/XMLWriter/XMLWriter.js"></script>
27
28 <style>
29         div.header {
30                 display: none;
31         }
32         span.elementName {
33                 display: none;
34         }
35         span.namespace {
36                 display: none;
37         }
38 </style>
39
40 <props:propertiesBasic></props:propertiesBasic>
41
42 <c:set var="type" value="${w:typeForTemplate(it.template)}" />
43
44 <div id="containerForPropertiesContainer">
45 <div> <%-- This div is required by props:properties to be consistent with a node template. This mirrors div class="content" --%>
46 <props:properties
47         propertiesDefinition="${type.propertiesDefinition}"
48         wpd="${wc:winerysPropertiesDefinition(type)}"
49         template="${it.template}"
50         pathToImages="${w:topologyModelerURI()}/images/">
51 </props:properties>
52 </div>
53 </div>
54
55 <c:choose>
56         <c:when test="${not empty type.propertiesDefinition or not empty wc:winerysPropertiesDefinition(type)}">
57                 <button id="propsSaveBtn" data-loading-text="Saving..." type="button" class="btn btn-primary btn-sm" onclick="saveProperties();">Save</button>
58         </c:when>
59         <c:otherwise>
60                 The type does not have a &ldquo;properties definition&rdquo;.
61         </c:otherwise>
62 </c:choose>
63
64 <script>
65 $(".KVPropertyValue").editable();
66
67 // similar to topology modeler's index.jsp save() function
68 function saveProperties() {
69         $("#propsSaveBtn").button('loading');
70         var w = new XMLWriter("utf-8");
71         w.writeStartDocument();
72         var divContainer = $("#containerForPropertiesContainer");
73         savePropertiesFromDivToXMLWriter(divContainer.children("div").children(".propertiesContainer"), w, true);
74         w.writeEndDocument();
75
76         $.ajax({
77                 url: "properties/",
78                 type: "PUT",
79                 contentType: 'text/xml',
80                 data: w.flush(),
81                 success: function(data, textStatus, jqXHR) {
82                         $("#propsSaveBtn").button('reset');
83                         vShowSuccess("successfully saved.");
84                 },
85                 error: function(jqXHR, textStatus, errorThrown) {
86                         $("#propsSaveBtn").button('reset');
87                         vShowAJAXError("Could not save", errorThrown, jqXHR.responseText);
88                 }
89         });
90
91 }
92 </script>