Skip to content

Commit

Permalink
Add artifactTemplates source editor
Browse files Browse the repository at this point in the history
Also-by: Philipp Meyer <meyer.github@gmail.com>
Signed-off-by: Lukas Balzer <balzer814_dev@web.de>
  • Loading branch information
balzer814 committed Sep 20, 2017
1 parent b202495 commit 5afdbcd
Show file tree
Hide file tree
Showing 15 changed files with 667 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class IdNames {
// the files belonging to one artifact template are nested in the sub
// directory "files"
public static final String ARTIFACTTEMPLATEFILESDIRECTORY = "files";
public static final String ARTIFACTTEMPLATESRCDIRECTORY = "src";
public static final String ARTIFACTTEMPLATESRCDIRECTORY = "source";

public static final String CONSTRAINTTYPES = "constrainttypes";
public static final String NAMESPACES = "namespaces";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private Environment() {
* @return the version of Winery
*/
public static String getVersion() {
return Version.VERSION;
return org.eclipse.winery.repository.configuration.Version.VERSION;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright (c) 2017 University of Stuttgart. All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v2.0 and the Apache License 2.0 which both accompany this
* distribution, and are available at http://www.eclipse.org/legal/epl-v20.html and
* http://www.apache.org/licenses/LICENSE-2.0
*/
package org.eclipse.winery.repository.rest.resources.apiData;

public class ArtifactResourceApiData {

public String fileName;
public String content;

public void setContent(String content) {
this.content = content;
}

public void setFileName(String fileName) {
this.fileName = fileName;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*******************************************************************************
* Copyright (c) 2012-2013,2015 University of Stuttgart.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v2.0
* and the Apache License 2.0 which both accompany this distribution,
* and are available at http://www.eclipse.org/legal/epl-v10.html
* and are available at http://www.eclipse.org/legal/epl-v20.html
* and http://www.apache.org/licenses/LICENSE-2.0
*
* Contributors:
Expand Down Expand Up @@ -40,6 +40,7 @@
import org.eclipse.winery.repository.datatypes.ids.elements.ArtifactTemplateDirectoryId;
import org.eclipse.winery.repository.rest.RestUtils;
import org.eclipse.winery.repository.rest.datatypes.FileMeta;
import org.eclipse.winery.repository.rest.resources.apiData.ArtifactResourceApiData;

import com.sun.jersey.core.header.FormDataContentDisposition;
import com.sun.jersey.multipart.FormDataBodyPart;
Expand Down Expand Up @@ -110,10 +111,13 @@ public Response onPost(@FormDataParam("file") InputStream uploadedInputStream, @
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<FileMeta> getJSON() {
return this.getAllFileMetas();
public String getJSON() {
String json = BackendUtils.Object2JSON(this.getAllFileMetas());
json = "{\"files\":" + json + "}";
return json;
}


private List<FileMeta> getAllFileMetas() {
List<FileMeta> res = new ArrayList<>();
SortedSet<RepositoryFileReference> fileRefs = RepositoryFactory.getRepository().getContainedFiles(this.fileDir);
Expand Down Expand Up @@ -143,4 +147,15 @@ public Response deleteFile(@PathParam("fileName") String fileName) {
RepositoryFileReference ref = this.fileName2fileRef(fileName, true);
return RestUtils.delete(ref);
}

@POST
@Path("/{fileName}")
@Consumes(MediaType.APPLICATION_JSON)
public Response postFile(@PathParam("fileName") String fileName, ArtifactResourceApiData data) {
if (StringUtils.isEmpty(fileName)) {
return Response.status(Status.BAD_REQUEST).build();
}
RepositoryFileReference ref = this.fileName2fileRef(fileName, false);
return RestUtils.putContentToFile(ref, data.content, MediaType.TEXT_PLAIN_TYPE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2017 University of Stuttgart.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* and the Apache License 2.0 which both accompany this distribution,
* and are available at http://www.eclipse.org/legal/epl-v20.html
* and http://www.apache.org/licenses/LICENSE-2.0
*/

export class ArtifactResourceApiData {
private fileName = '';
private content = '';

constructor() {
}

public getFileName(): string {
return this.fileName;
}

public getContent(): string {
return this.content;
}

public setFileName(fileName: string) {
this.fileName = fileName;
}

public setContent(content: string) {
this.content = content;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/**
* Copyright (c) 2017 University of Stuttgart.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* and the Apache License 2.0 which both accompany this distribution,
* and are available at http://www.eclipse.org/legal/epl-v20.html
* and http://www.apache.org/licenses/LICENSE-2.0
*/
* {
box-sizing: border-box;
}

.fileContainer {
}

#fileGridHeader {
display: grid;
grid-column-gap: 10px;
grid-template-columns: 70px 120px 70px 70px 340px 120px 70px;
grid-template-rows: 30px;
margin-bottom: 10px;
}

#gridHeaderText {
grid-column: 1 / span 7;
grid-row: 1 / span 1;
}

#fileGridBody {
display: grid;
grid-template-columns: 300px auto;
grid-template-rows: 20px 480px;
}

#leftEditContent {
grid-column: 1 / span 1;
grid-row: 1 / span 2;
border-top: 1px solid #ddd;
}

#rightEditHeader {
padding-left: 5px;
border-top: 2px solid lightgray;
border-left: 2px solid lightgray;
border-right: 2px solid lightgray;
grid-column: 2 / span 1;
grid-row: 1 / span 1;
}

#rightEditContent {
grid-column: 2 / span 1;
grid-row: 2 / span 1;
}

table {
width: 90%;
margin-bottom: 20px;
background-color: transparent;
border-spacing: 0;
border-collapse: collapse;
border-color: grey;
}

tbody {
width: 90%;
display: table-row-group;
vertical-align: middle;
border-color: inherit;
min-width: 300px;
}

tr {
display: table-row;
vertical-align: inherit;
border-color: inherit;
width: 100%;
height: 20px;
min-width: 300px;
}

tr:hover {
background-color: #aaaaaa;
}

tr.selected {
background-color: #8c8c8c;
}

td {
padding: 8px;
line-height: 0;
vertical-align: center;
}

#srcNameCell {
width: 200px;
}

#filesList {
width: 300px;
height: 500px;
overflow: auto;
}

p {
display: block;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
}
Loading

0 comments on commit 5afdbcd

Please sign in to comment.