e80ad1d5fac7491c05cbacd4dd5e9364889063e0
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / webapp / jsp / admin / namespaces.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  *    Yves Schubert - switch to bootstrap 3
13  *******************************************************************************/
14 --%>
15 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
16 <%@ taglib uri="http://www.eclipse.org/winery/repository/functions" prefix="w" %>
17 <script>
18 var namespacePrefixesTableInfo = {
19         id : '#namespacePrefixesTable'
20 };
21
22 $(function() {
23         require(["winery-support"], function(ws) {
24                 ws.initTable(namespacePrefixesTableInfo);
25         });
26 });
27
28 function addNSprefix() {
29         $.ajax({
30                 url: "${pageContext.request.contextPath}/admin/namespaces/",
31                 type: "POST",
32                 async: false,
33                 data: $('#addNamespacePrefixForm').serialize(),
34                 error: function(jqXHR, textStatus, errorThrown) {
35                         vShowAJAXError("Could not add namespace prefix", jqXHR, errorThrown);
36                 },
37                 success: function(data, textSTatus, jqXHR) {
38                         namespacePrefixesTableInfo.table.fnAddData([$('#nsPrefixAdded').val(), $('#namespaceAdded').val()]);
39                         $('#addNamespacePrefixDiag').modal('hide');
40                         vShowSuccess("Successfully added namespace prefix.");
41                 }
42         });
43 }
44
45 </script>
46
47 <div class="modal fade" id="addNamespacePrefixDiag">
48         <div class="modal-dialog">
49                 <div class="modal-content">
50                         <div class="modal-header">
51                                 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
52                                 <h4 class="modal-title">Add namespace prefix</h4>
53                         </div>
54                         <div class="modal-body">
55                                 <form id="addNamespacePrefixForm" enctype="multipart/form-data">
56                                         <fieldset>
57                                                 <div class="form-group">
58                                                         <label for="nsPrefixAdded">Prefix</label>
59                                                         <input name="nsPrefix" id="nsPrefixAdded" class="form-control" type="text" />
60                                                 </div>
61
62                                                 <div class="form-group">
63                                                         <label for="namespaceAdded">Namespace</label>
64                                                         <input name="namespace" id="namespaceAdded" class="form-control" type="text" />
65                                                 </div>
66                                         </fieldset>
67                                 </form>
68                         </div>
69
70                         <div class="modal-footer">
71                                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
72                                 <button type="button" class="btn btn-primary" onclick="addNSprefix()">Add</button>
73                         </div>
74                 </div>
75         </div>
76 </div>
77
78 <div id="namespaces">
79         <div class="listheading">
80                 <label>Defined Prefixes for Namespaces</label>
81                 <button class="rightbutton btn btn-danger btn-xs" type="button" onclick="deleteOnServerAndInTable(namespacePrefixesTableInfo, 'namespace', 'namespaces/', 1);">Remove</button>
82                 <button class="rightbutton btn btn-primary btn-xs" type="button" onclick="$('#addNamespacePrefixDiag').modal('show')">Add</button>
83         </div>
84         <table cellpadding="0" cellspacing="0" border="0" class="display" id="namespacePrefixesTable">
85                 <thead>
86                         <tr>
87                                 <th>Prefix</th>
88                                 <th>Namespace</th>
89                         </tr>
90                 </thead>
91                 <tbody>
92                         <c:forEach var="ns" items="${it.namespacesForJSP}">
93                                 <tr>
94                                         <td class="prefix">${w:getPrefix(ns.decoded)}</td>
95                                         <td>${ns.decoded}</td>
96                                 </tr>
97                         </c:forEach>
98                 </tbody>
99         </table>
100 </div>
101
102 <script>
103 $(document).on("click", "td.prefix",
104         vCreateTdClickFunction(
105                 "${pageContext.request.contextPath}/admin/namespaces/",
106                 "nsPrefix",
107                 "namespace"));
108 </script>