Skip to content

Commit

Permalink
codescoop integration
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Skorohod <alexey.skorohod@gmail.com>
  • Loading branch information
sweetca committed Jul 30, 2018
1 parent b110232 commit ed79f9a
Show file tree
Hide file tree
Showing 10 changed files with 1,213 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ public class PortalConstants {
//
public static String PROJECTIMPORT_HOSTS;

// CodeScoop integration
public static final String CODESCOOP_URL;
public static final String CODESCOOP_TOKEN;

static {
Properties props = CommonUtils.loadProperties(PortalConstants.class, PROPERTIES_FILE_PATH);

Expand All @@ -390,6 +394,9 @@ public class PortalConstants {
RELEASE_EXTERNAL_ID_KEYS = CommonUtils.splitToSet(props.getProperty("release.externalkeys", "org.maven.id,com.github.id,com.gitlab.id,purl.id"));
PROJECTIMPORT_HOSTS = props.getProperty("projectimport.hosts", "");
PREFERRED_COUNTRY_CODES = props.getProperty("preferred.country.codes", "DE,AT,CH,US");

CODESCOOP_URL = props.getProperty("codescoop.url", "");
CODESCOOP_TOKEN = props.getProperty("codescoop.token", "");
}

private PortalConstants() {
Expand Down
5 changes: 5 additions & 0 deletions frontend/sw360-portlet/src/main/resources/sw360.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@
## used in the projectimport-portlet UI, comma separated list of hosts
# projectimport.hosts=
## projectimport.hosts=https://some.host.domain,https://some.other.host.domain

## To enable Codescoop integration: unblock next 2 lines and put real token
#codescoop.url=https://api.codescoop.com/
#codescoop.token=PUT_REAL_TOKEN_HERE

25 changes: 25 additions & 0 deletions frontend/sw360-portlet/src/main/webapp/html/components/detail.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<%@ page import="javax.portlet.PortletRequest" %>
<%@ page import="com.liferay.portlet.PortletURLFactoryUtil" %>
<%@ page import="org.eclipse.sw360.portal.common.PortalConstants" %>
<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Component" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

Expand All @@ -35,6 +36,9 @@
<portlet:param name="<%=PortalConstants.COMPONENT_ID%>" value="${component.id}"/>
</portlet:resourceURL>

<portlet:actionURL var="updateComponentURL" name="updateComponent">
<portlet:param name="<%=PortalConstants.COMPONENT_ID%>" value="${component.id}"/>
</portlet:actionURL>
<c:catch var="attributeNotFoundException">
<jsp:useBean id="component" class="org.eclipse.sw360.datahandler.thrift.components.Component" scope="request"/>
<jsp:useBean id="selectedTab" class="java.lang.String" scope="request"/>
Expand Down Expand Up @@ -123,3 +127,24 @@
}
});
</script>
<c:set var="CODESCOOP_URL" value="<%=PortalConstants.CODESCOOP_URL%>"/>
<c:set var="CODESCOOP_TOKEN" value="<%=PortalConstants.CODESCOOP_TOKEN%>"/>
<c:if test="${not empty CODESCOOP_URL && not empty CODESCOOP_TOKEN}">
<form id="component_edit_form" name="componentEditForm" action="<%=updateComponentURL%>&updateOnlyRequested" method="post" style="display: none;">
</form>
<script>
var edit_form_fields = {
description: '<portlet:namespace/><%=Component._Fields.DESCRIPTION%>',
homepage: '<portlet:namespace/><%=Component._Fields.HOMEPAGE%>',
categories: '<portlet:namespace/><%=Component._Fields.CATEGORIES%>',
languages: '<portlet:namespace/><%=Component._Fields.LANGUAGES%>',
licenses: '<portlet:namespace/><%=Component._Fields.MAIN_LICENSE_IDS%>'
};
document.addEventListener("DOMContentLoaded", function() {
require(['modules/codeScoop' ], function(codeScoop) {
var api = new codeScoop('<%=PortalConstants.CODESCOOP_URL%>', '<%=PortalConstants.CODESCOOP_TOKEN%>');
api.activateMerge();
});
});
</script>
</c:if>
13 changes: 13 additions & 0 deletions frontend/sw360-portlet/src/main/webapp/html/components/edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@

<jsp:include page="/html/utils/includes/searchAndSelectUsers.jsp" />
<jsp:include page="/html/utils/includes/searchUsers.jsp" />

<c:set var="CODESCOOP_URL" value="<%=PortalConstants.CODESCOOP_URL%>"/>
<c:set var="CODESCOOP_TOKEN" value="<%=PortalConstants.CODESCOOP_TOKEN%>"/>
<c:if test="${not empty CODESCOOP_URL && not empty CODESCOOP_TOKEN}">
<script>
document.addEventListener("DOMContentLoaded", function() {
require(['modules/codeScoop' ], function(codeScoop) {
var api = new codeScoop('<%=PortalConstants.CODESCOOP_URL%>', '<%=PortalConstants.CODESCOOP_TOKEN%>');
api.activateAutoFill();
});
});
</script>
</c:if>
</core_rt:if>

<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
~ http://www.eclipse.org/legal/epl-v10.html
--%>
<%@ page import="org.eclipse.sw360.portal.common.page.PortletReleasePage,org.eclipse.sw360.datahandler.thrift.attachments.AttachmentType" %>

<portlet:resourceURL var="deleteReleaseAjaxURL">
<portlet:param name="<%=PortalConstants.ACTION%>" value='<%=PortalConstants.DELETE_RELEASE%>'/>
</portlet:resourceURL>
<portlet:renderURL var="addReleaseURL">
<portlet:param name="<%=PortalConstants.COMPONENT_ID%>" value="${component.id}"/>
<portlet:param name="<%=PortalConstants.PAGENAME%>" value="<%=PortalConstants.PAGENAME_EDIT_RELEASE%>"/>
</portlet:renderURL>

<core_rt:if test="${component.releasesSize == 0 }">
<h1>Please add release to view their clearing status here.</h1>
Expand All @@ -37,8 +40,59 @@
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/dataTable_Siemens.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/sw360.css">

<script>
var releaseData =
[<core_rt:forEach items="${component.releases}" var="release">
{
"DT_RowId": "${release.id}",
"0": "<sw360:out value="${release.name}"/>",
"1": "<a href='<portlet:renderURL ><portlet:param name="<%=PortalConstants.COMPONENT_ID%>" value="${component.id}"/><portlet:param name="<%=PortalConstants.RELEASE_ID%>" value="${release.id}"/><portlet:param name="<%=PortalConstants.PAGENAME%>" value="<%=PortalConstants.PAGENAME_RELEASE_DETAIL%>"/></portlet:renderURL>' target='_self'><sw360:out value="${release.version}"/></a>",
"2": "<span id='clearingState${release.id}'><sw360:DisplayEnum value="${release.clearingState}"/></span>",
"3": "<sw360:DisplayDownloadReport attachments="${release.attachments}" filterAttachmentType="<%=AttachmentType.CLEARING_REPORT%>" var="attachment"><sw360:DisplayDownloadApprovedClearingReport attachment="${attachment}" contextType="${release.type}" contextId="${release.id}" /></sw360:DisplayDownloadReport>",
"4": "<span id='mainlineState${release.id}'><sw360:DisplayEnum value="${release.mainlineState}"/></span>",
<core_rt:if test="${inComponentDetailsContext}">
"5": "<span id='fossologySending${release.id}'></span>"
+ "<span id='releaseAction${release.id}'>"
+ "<img class='action send-to-fossology' src='<%=request.getContextPath()%>/images/fossology-logo-24.gif' data-release-id='${release.id}' alt='SelectClearing' title='send to Fossology'>"
+ "<sw360:DisplayReleaseLink release="${release}" showName="false" page="<%=PortletReleasePage.EDIT%>"><img src='<%=request.getContextPath()%>/images/edit.png' alt='Edit' title='Edit'></sw360:DisplayReleaseLink>"
+ "<sw360:DisplayReleaseLink release="${release}" showName="false" page="<%=PortletReleasePage.DUPLICATE%>"><img src='<%=request.getContextPath()%>/images/ic_clone.png' alt='Duplicate' title='Duplicate'></sw360:DisplayReleaseLink>"
+ "<img class='action delete-release' src='<%=request.getContextPath()%>/images/Trash.png' data-release-id='${release.id}' data-release-name='<sw360:ReleaseName release="${release}" />' data-linked-releases='${release.releaseIdToRelationshipSize}' data-attachments='${release.attachmentsSize}' alt='Delete' title='Delete'>"
+ "</span>"
</core_rt:if>
<core_rt:if test="${!inComponentDetailsContext}">
"5": "NONE"
</core_rt:if>
},
</core_rt:forEach>];
var renderCallback = function () {
};
</script>

<core_rt:set var="CODESCOOP_URL" value="<%=PortalConstants.CODESCOOP_URL%>"/>
<core_rt:set var="CODESCOOP_TOKEN" value="<%=PortalConstants.CODESCOOP_TOKEN%>"/>
<core_rt:if test="${not empty CODESCOOP_URL && not empty CODESCOOP_TOKEN}">
<script>
document.addEventListener("DOMContentLoaded", function() {
require(['modules/codeScoop' ], function(codeScoop) {
var api = new codeScoop('<%=PortalConstants.CODESCOOP_URL%>', '<%=PortalConstants.CODESCOOP_TOKEN%>');
api.activateMissedReleases(
releaseData,
"componentOverview",
"releaseAggregateTable",
'<portlet:renderURL ><portlet:param name="<%=PortalConstants.COMPONENT_ID%>" value="${component.id}"/><portlet:param name="<%=PortalConstants.PAGENAME%>" value="<%=PortalConstants.PAGENAME_EDIT_RELEASE%>"/></portlet:renderURL>');
});
});
</script>
</core_rt:if>
<script type="text/javascript">
require(['jquery', 'utils/includes/fossologyClearing', 'modules/confirm', /* jquery-plugins */ 'datatables', 'datatables_buttons', 'buttons.print'], function ($, fossology, confirm) {
require([
'jquery',
'utils/includes/fossologyClearing',
'modules/confirm',
'datatables',
'datatables_buttons',
'buttons.print'], function ($, fossology, confirm) {

var releaseTable;

Liferay.on('allPortletsReady', function() {
Expand All @@ -56,32 +110,6 @@
});

function createClearingTable() {
var result = [];

<%-- TODO do the same as project Clearing Status --%>
<core_rt:forEach items="${component.releases}" var="release">
result.push({
"DT_RowId": "${release.id}",
"0": "<sw360:out value="${release.name}"/>",
"1": "<a href='<portlet:renderURL ><portlet:param name="<%=PortalConstants.COMPONENT_ID%>" value="${component.id}"/><portlet:param name="<%=PortalConstants.RELEASE_ID%>" value="${release.id}"/><portlet:param name="<%=PortalConstants.PAGENAME%>" value="<%=PortalConstants.PAGENAME_RELEASE_DETAIL%>"/></portlet:renderURL>' target='_self'><sw360:out value="${release.version}"/></a>",
"2": "<span id='clearingState${release.id}'><sw360:DisplayEnum value="${release.clearingState}"/></span>",
"3": "<sw360:DisplayDownloadReport attachments="${release.attachments}" filterAttachmentType="<%=AttachmentType.CLEARING_REPORT%>" var="attachment"><sw360:DisplayDownloadApprovedClearingReport attachment="${attachment}" contextType="${release.type}" contextId="${release.id}" /></sw360:DisplayDownloadReport>",
"4": "<span id='mainlineState${release.id}'><sw360:DisplayEnum value="${release.mainlineState}"/></span>",
<core_rt:if test="${inComponentDetailsContext}">
"5": "<span id='fossologySending${release.id}'></span>"
+ "<span id='releaseAction${release.id}'>"
+ "<img class='action send-to-fossology' src='<%=request.getContextPath()%>/images/fossology-logo-24.gif' data-release-id='${release.id}' alt='SelectClearing' title='send to Fossology'>"
+ "<sw360:DisplayReleaseLink release="${release}" showName="false" page="<%=PortletReleasePage.EDIT%>"><img src='<%=request.getContextPath()%>/images/edit.png' alt='Edit' title='Edit'></sw360:DisplayReleaseLink>"
+ "<sw360:DisplayReleaseLink release="${release}" showName="false" page="<%=PortletReleasePage.DUPLICATE%>"><img src='<%=request.getContextPath()%>/images/ic_clone.png' alt='Duplicate' title='Duplicate'></sw360:DisplayReleaseLink>"
+ "<img class='action delete-release' src='<%=request.getContextPath()%>/images/Trash.png' data-release-id='${release.id}' data-release-name='<sw360:ReleaseName release="${release}" />' data-linked-releases='${release.releaseIdToRelationshipSize}' data-attachments='${release.attachmentsSize}' alt='Delete' title='Delete'>"
+ "</span>"
</core_rt:if>
<core_rt:if test="${!inComponentDetailsContext}">
"5": "NONE"
</core_rt:if>
});
</core_rt:forEach>

releaseTable = $('#releasesTable').DataTable({
"pagingType": "simple_numbers",
"dom": "lBfrtip",
Expand All @@ -96,7 +124,7 @@
}
}
],
"data": result,
"data": releaseData,
"columns": [
{"sTitle": "Release name"},
{"sTitle": "Release version"},
Expand All @@ -105,9 +133,10 @@
{"sTitle": "Release Mainline state"},
{"sTitle": "Actions"}
],
"autoWidth": false
"autoWidth": false,
"drawCallback": renderCallback
});
}
};

function deleteRelease(id, name, linkedReleasesSize, attachmentsSize) {

Expand All @@ -118,9 +147,7 @@
cache: false,
data: {
<portlet:namespace/>releaseId: id,
<portlet:namespace/><%=PortalConstants.MODERATION_REQUEST_COMMENT%>:
btoa($("#moderationDeleteCommentField").val())

<portlet:namespace/><%=PortalConstants.MODERATION_REQUEST_COMMENT%>:btoa($("#moderationDeleteCommentField").val())
},
success: function(data) {
if (data.result == 'SUCCESS') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
<core_rt:set var="customMap" value="${component.roles}"/>
<%@include file="/html/utils/includes/mapEdit.jspf" %>

<core_rt:set var="CODESCOOP_URL" value="<%=PortalConstants.CODESCOOP_URL%>"/>
<core_rt:set var="CODESCOOP_TOKEN" value="<%=PortalConstants.CODESCOOP_TOKEN%>"/>
<!-- Adding similar component popup for new component case -->
<script>
require([ 'modules/linkListDialog' ], function(linkListDialog) {
Expand All @@ -136,6 +138,8 @@
checkComponentNameParamKey = '<portlet:namespace/><%=PortalConstants.COMPONENT_NAME%>',
openOnBlurOfElementId = '#comp_name';

<core_rt:if test="${empty CODESCOOP_URL || empty CODESCOOP_TOKEN}">
linkListDialog.registerLinkListDialog(openOnBlurOfElementId, checkComponentNameUrl, checkComponentNameParamKey);
</core_rt:if>
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
~ which accompanies this distribution, and is available at
~ http://www.eclipse.org/legal/epl-v10.html
--%>



<%@ page import="org.eclipse.sw360.datahandler.common.SW360Utils" %>
<%@ page import="org.eclipse.sw360.datahandler.thrift.components.Component" %>
<%@ page import="org.eclipse.sw360.datahandler.thrift.MainlineState" %>
Expand Down Expand Up @@ -55,11 +52,11 @@
value="<sw360:DisplayCollection value="${release.operatingSystems}" />"/>
</td>
<td width="33%">
<label class="textlabel stackedLabel mandatory" for="comp_id">CPE ID</label>
<label class="textlabel stackedLabel" for="comp_id">CPE ID</label>
<input id="comp_id" name="<portlet:namespace/><%=Release._Fields.CPEID%>" type="text"
class="toplabelledInput followedByImg"
value="<sw360:out value="${release.cpeid}"/>"
placeholder="Enter CPE ID" required="" />
placeholder="Enter CPE ID"/>
<img class="infopic" src="<%=request.getContextPath()%>/images/ic_info.png"
title="The formula for CPE ID creation is &#13;'cpe:2.3:a:VENDORNAME:COMPONENTNAME:VERSION' "/>
</td>
Expand Down Expand Up @@ -146,3 +143,18 @@

});
</script>

<core_rt:set var="CODESCOOP_URL" value="<%=PortalConstants.CODESCOOP_URL%>"/>
<core_rt:set var="CODESCOOP_TOKEN" value="<%=PortalConstants.CODESCOOP_TOKEN%>"/>
<core_rt:if test="${not empty CODESCOOP_URL && not empty CODESCOOP_TOKEN}">
<script>
document.addEventListener("DOMContentLoaded", function() {
require(['modules/codeScoop' ], function(codeScoop) {
var api = new codeScoop('<%=PortalConstants.CODESCOOP_URL%>', '<%=PortalConstants.CODESCOOP_TOKEN%>');
setTimeout(function () {
api.activateReleaseAutocomplete();
}, 500);
});
});
</script>
</core_rt:if>
Loading

0 comments on commit ed79f9a

Please sign in to comment.