446bd4645aaaf9e20badcefdf31198db2a543226
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / webapp / jsp / admin / repository.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 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
17 <%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
18
19 <h4>General Repository Commands</h4>
20 <div>
21         <a href="repository/?dump" class="btn btn-primary">Dump Repository</a>
22         <button class="btn btn-danger" onclick="clearRepository();" id="btnclearrepository" data-loading-text="Deleting...">Clear Repository</button>
23         <button class="btn btn-default" onclick="$('#upRepoZipDiag').modal('show');">Import Repository</button>
24 </div>
25
26 <%
27 org.eclipse.winery.repository.backend.IRepository rep;
28 rep = org.eclipse.winery.repository.Prefs.INSTANCE.getRepository();
29 boolean isGitBasedRepo = (rep instanceof org.eclipse.winery.repository.backend.filebased.GitBasedRepository);
30
31 org.eclipse.winery.repository.backend.filebased.GitBasedRepository repo = null;
32 if (isGitBasedRepo) {
33         repo = (org.eclipse.winery.repository.backend.filebased.GitBasedRepository) rep;
34 }
35
36 // We only support the commit and reset buttons if we can authenticate at the repository
37 // This is a hack to offer different versions of winery at dev.winery.opentosca.org and winery.opentosca.org
38 isGitBasedRepo = isGitBasedRepo && (repo.authenticationInfoAvailable());
39
40 if (isGitBasedRepo) {
41 %>
42 <h4>Versioning</h4>
43 <div>
44 <button id="commitBtn" class="btn btn-default" onclick="doCommit();" data-loading-text="committing...">Commit</button>
45 <button id="resetBtn" class="btn btn-danger" onclick="doReset();" data-loading-text="resetting...">Reset</button>
46 </div>
47
48 <script>
49 function doCommit() {
50         $("#commitBtn").button("loading");
51         $.ajax({
52                 url: "repository/?commit",
53                 async: false,
54                 error: function(jqXHR, textStatus, errorThrown) {
55                         $("#commitBtn").button("reset");
56                         vShowAJAXError("Could not commit", jqXHR, errorThrown);
57                 },
58                 success: function(data, textSTatus, jqXHR) {
59                         $("#commitBtn").button("reset");
60                         vShowSuccess("Successfully committed changes.");
61                 }
62         });
63 }
64
65 function doReset() {
66         $("#resetBtn").button("loading");
67         $.ajax({
68                 url: "repository/?reset",
69                 async: false,
70                 error: function(jqXHR, textStatus, errorThrown) {
71                         $("#resetBtn").button("reset");
72                         vShowAJAXError("Could not reset", jqXHR, errorThrown);
73                 },
74                 success: function(data, textSTatus, jqXHR) {
75                         $("#resetBtn").button("reset");
76                         vShowSuccess("Successfully reset to last known state.");
77                 }
78         });
79 }
80 </script>
81 <%
82 }
83 %>
84
85 <t:simpleSingleFileUpload
86         title="Upload Repository Content"
87         text="Repository dump file"
88         URL="repository/"
89         type="POST"
90         id="upRepoZip"
91         accept="application/zip" />
92
93 <script>
94 function clearRepository() {
95         deleteResource('the complete repository', 'repository/',
96                         function() {$("#btnclearrepository").button("reset");},
97                         function() {$("#btnclearrepository").button("reset");},
98                         function() {$("#btnclearrepository").button("loading");}
99         );
100 }
101 </script>