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 * Yves Schubert - switch to bootstrap 3
13 *******************************************************************************/
15 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
16 <%@taglib prefix="p" tagdir="/WEB-INF/tags/parameters" %>
17 <%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
21 var embeddedPlansTableInfo = {
22 id: '#embeddedPlansTable'
25 var linkedPlansTableInfo = {
26 id: '#linkedPlansTable'
30 require(["winery-support"], function(ws) {
31 ws.initTable(embeddedPlansTableInfo, {
33 { "bVisible": false, "bSearchable": false}, // ID column
34 { "sTitle": "Precondition" },
37 { "sTitle": "Language" }
39 "aaData" : ${it.embeddedPlansTableData}
42 ws.initTable(linkedPlansTableInfo, {
44 { "bVisible": false, "bSearchable": false}, // ID column
45 { "sTitle": "Precondition" },
48 { "sTitle": "Language" },
49 { "sTitle": "Reference" }
51 "aaData" : ${it.linkedPlansTableData}
56 function editIOParameters() {
57 if (embeddedPlansTableInfo.selectedRow) {
58 require(["winery-support"], function(ws) {
59 if (ws.isEmptyTable(embeddedPlansTableInfo)) {
60 vShowError("No plans available");
63 updateInputAndOutputParameters(getPlanURL());
64 $("#editParametersDiag").modal("show");
67 vShowError("No plan selected");
70 function createPlan(data) {
71 if (highlightRequiredFields()) {
72 vShowError("Please fill out all required fields");
78 function getPlanURL() {
79 var id = embeddedPlansTableInfo.table.fnGetData(embeddedPlansTableInfo.selectedRow, 0);
80 return "plans/" + encodeURIComponent(id) + "/";
83 function openPlanEditor() {
84 if (embeddedPlansTableInfo.selectedRow) {
85 var isEmptyTable = embeddedPlansTableInfo.table.children("tbody").children("tr").first().children("td").hasClass("dataTables_empty");
87 vShowError("No plans available");
90 window.open(getPlanURL() + "?edit", "_blank");
92 vShowError("No plan selected");
96 function letUserChooseAPlan() {
97 $('#planFileInput').trigger('click');
98 $('#planChooseBtn').focus();
101 requirejs(["jquery.fileupload"], function(){
102 $('#addPlanForm').fileupload().bind("fileuploadadd", function(e, data) {
103 $.each(data.files, function (index, file) {
104 $("#planFileText").val(file.name);
106 $("#addPlanBtnFUP").off("click");
107 $("#addPlanBtnFUP").on("click", function() {
110 }).bind("fileuploadstart", function(e) {
111 $("#addPlanBtnFUP").button("loading");
112 }).bind('fileuploadfail', function(e, data) {
113 vShowAJAXError("Could not add plan", data.jqXHR, data.errorThrown);
114 $("#addPlanBtnFUP").button("reset");
115 }).bind('fileuploaddone', function(e, data) {
116 vShowSuccess("Plan created successfully");
118 // reset the add button
119 $("#addPlanBtnFUP").button("reset");
120 // do not allow submission of the old files on a click if the dialog is opened another time
121 $("#addPlanBtnFUP").off("click");
123 // TODO: if id is already present in table, delete row in table
125 embeddedPlansTableInfo.table.fnAddData(data.result.tableData);
127 $('#addPlanDiag').modal('hide');
132 <div class="modal fade" id="addPlanDiag">
133 <div class="modal-dialog">
134 <div class="modal-content">
135 <div class="modal-header">
136 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
137 <h4 class="modal-title">Add Plan</h4>
139 <div class="modal-body">
140 <form id="addPlanForm" enctype="multipart/form-data" action="plans/" method="post">
141 <div class="form-group">
142 <label class="control-label">Name</label>
143 <input name="planName" id="planName" type="text" class="form-control" required="required">
146 <t:typeswithshortnameasselect label="Type" type="plantype" selectname="planType" typesWithShortNames="${it.planTypes}">
147 </t:typeswithshortnameasselect>
149 <t:typeswithshortnameasselect label="Language" type="planlanguage" selectname="planLanguage" typesWithShortNames="${it.planLanguages}">
150 </t:typeswithshortnameasselect>
152 <div class="form-group" id="fileDiv">
153 <label class="control-label" for="planFileDiv">Archive</label>
154 <div style="display: block; width: 100%" id="planFileDiv">
155 <input id="planFileInput" name="file" type="file" style="display:none">
156 <input name="fileText" id="planFileText" type="text" class="form-control" style="width:300px; display:inline;" onclick="letUserChooseAPlan();" required="required">
157 <button type="button" id="planChooseBtn" class="btn btn-default btn-xs" onclick="letUserChooseAPlan();">Choose</button>
162 <div class="modal-footer">
163 <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
164 <button type="button" class="btn btn-primary" data-loading-text="Uploading..." id="addPlanBtnFUP">Add</button>
165 <button type="button" class="btn btn-primary" style="display:none;" id="addPlanBtnBPMN4TOSCA">Add</button>
172 $("#planLanguage").on("change", function(e) {
173 var lang = $("#planLanguage").val();
174 if (lang == "http://www.opentosca.org/bpmn4tosca") {
175 $("#fileDiv").hide();
176 $("#addPlanBtnFUP").hide();
177 $("#addPlanBtnBPMN4TOSCA").show();
179 $("#fileDiv").show();
180 $("#addPlanBtnFUP").show();
181 $("#addPlanBtnBPMN4TOSCA").hide();
185 $("#addPlanBtnBPMN4TOSCA").on("click", function() {
186 var data = new FormData();
187 data.append("planName", $("#planName").val());
188 data.append("planType", $("#planType").val());
189 data.append("planLanguage", $("#planLanguage").val());
195 contentType: false, // jQuery automatically sets multipart/form-data; boundary=...
198 error: function(jqXHR, textStatus, errorThrown) {
199 vShowAJAXError("Could not add BPMN4TOSCSA plan", jqXHR, errorThrown);
201 success: function(data, textStatus, jqXHR) {
202 //typesTableInfo.table.fnAddData([$('#shortname').val(), $('#type').val()]);
203 $('#addPlanDiag').modal('hide');
204 vShowSuccess("Successfully added plan. Please refresh the page.");
211 <p:parametersJS></p:parametersJS>
213 <div class="modal fade" id="editParametersDiag">
214 <div class="modal-dialog">
215 <div class="modal-content">
216 <div class="modal-header">
217 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
218 <h4 class="modal-title">Edit Parameters</h4>
220 <div class="modal-body">
221 <p:parametersInput baseURL="getPlanURL()"></p:parametersInput>
222 <p:parametersOutput baseURL="getPlanURL()"></p:parametersOutput>
224 <div class="modal-footer">
225 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
231 <div id="managementPlans">
232 <h4>Embedded Plans</h4>
233 <button class="rightbutton btn btn-xs btn-danger" onclick="deleteOnServerAndInTable(embeddedPlansTableInfo, 'Plan', 'plans/', 0, 2);">Remove</button>
234 <button class="rightbutton btn btn-xs btn-info" onclick="$('#addPlanDiag').modal('show');">Add</button>
235 <button class="rightbutton btn btn-xs btn-default" onclick="editIOParameters();">I/O Parameters</button>
236 <button class="rightbutton btn btn-xs btn-primary" onclick="openPlanEditor();">Edit</button>
238 if (org.eclipse.winery.repository.Prefs.INSTANCE.isPlanBuilderAvailable()) {
241 function generateBuildPlan() {
242 $("#btnGenerateBuildPlan").button('loading');
244 url: 'topologytemplate/',
245 // targeting method triggerGenerateBuildPlan in TopologyTemplateResource.java
247 }).fail(function(jqXHR, textStatus, errorThrown) {
248 $("#btnGenerateBuildPlan").button('reset');
249 vShowAJAXError("Could not trigger plan generation.", jqXHR, errorThrown);
250 }).done(function(data, textStatus, jqXHR) {
251 $("#btnGenerateBuildPlan").button('reset');
252 var resultText = "Successfully generated build plan. Please refresh the page.";
253 vShowSuccess(resultText);
257 <button id="btnGenerateBuildPlan" class="btn btn-xs btn-default" data-loading-text="Generating..." onclick="generateBuildPlan();">Generate Build Plan</button>
261 <table cellpadding="0" cellspacing="0" border="0" class="display" id="embeddedPlansTable"></table>
264 <h4>Linked Plans</h4>
265 <table cellpadding="0" cellspacing="0" border="0" class="display" id="linkedPlansTable"></table>