Skip to content

Commit

Permalink
✨ feat(TIP integration): Create tip embedded module
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Mar 6, 2024
1 parent c58e014 commit 459c5be
Show file tree
Hide file tree
Showing 11 changed files with 358 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*****************************************************************
* This file is part of Managing Agricultural Research for Learning &
* Outcomes Platform (MARLO).
* MARLO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* MARLO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with MARLO. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************/

package org.cgiar.ccafs.marlo.action.json.tip;

import org.cgiar.ccafs.marlo.action.BaseAction;
import org.cgiar.ccafs.marlo.data.manager.TipParametersManager;
import org.cgiar.ccafs.marlo.data.model.TipParameters;

import java.util.List;

import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TipDinamicUrlGenerationAction extends BaseAction {

private static final long serialVersionUID = 3229622720197560976L;
private static final Logger LOG = LoggerFactory.getLogger(TipDinamicUrlGenerationAction.class);

// Front-end
private String dinamicTipURL;

@Inject
private TipParametersManager tipParametersManager;

@Inject
public TipDinamicUrlGenerationAction() {

}

public String createDinamicURL() {
String tipURL = null;
boolean isCGIARUser = true;

try {
String userEmail = "", token = "", loginService = "";
if (this.getCurrentUser() != null && this.getCurrentUser().getEmail() != null) {
userEmail = this.getCurrentUser().getEmail();
if (this.getCurrentUser().isCgiarUser() == true) {
isCGIARUser = true;
} else {
isCGIARUser = false;
}
}

List<TipParameters> tipParameters = tipParametersManager.findAll();
if (isCGIARUser) {
if (tipParameters != null && !tipParameters.isEmpty() && tipParameters.get(0) != null) {
if (tipParameters.get(0).getTipTokenService() != null) {
token = tipParameters.get(0).getTokenValue();
}
if (tipParameters.get(0).getTipLoginService() != null) {
loginService = tipParameters.get(0).getTipLoginService();
}
}
tipURL = loginService + "/" + token + "/staff/" + userEmail;
} else {
// Not CGIAR User
if (tipParameters != null && tipParameters.get(0) != null && tipParameters.get(0).getTipBaseUrl() != null) {
tipURL = tipParameters.get(0).getTipBaseUrl();
}
}
} catch (NumberFormatException e) {
LOG.error("Error getting tip URL: " + e);
}

return tipURL;
}

@Override
public String execute() throws Exception {

if (this.createDinamicURL() != null) {
this.dinamicTipURL = this.createDinamicURL();
return SUCCESS;
}
return ERROR;
}

public String getDinamicTipURL() {
return dinamicTipURL;
}

@Override
public void prepare() throws Exception {
}

public void setDinamicTipURL(String dinamicTipURL) {
this.dinamicTipURL = dinamicTipURL;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*****************************************************************
* This file is part of Managing Agricultural Research for Learning &
* Outcomes Platform (MARLO).
* MARLO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
* MARLO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with MARLO. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************/

package org.cgiar.ccafs.marlo.action.tip;

import org.cgiar.ccafs.marlo.action.BaseAction;
import org.cgiar.ccafs.marlo.data.manager.BiParametersManager;
import org.cgiar.ccafs.marlo.data.manager.BiReportsManager;
import org.cgiar.ccafs.marlo.data.model.BiParameters;
import org.cgiar.ccafs.marlo.data.model.BiReports;
import org.cgiar.ccafs.marlo.utils.APConfig;

import java.util.List;

import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TIPEmbeddedAction extends BaseAction {

private static final long serialVersionUID = 1329042468240291639L;

private static final Logger LOG = LoggerFactory.getLogger(TIPEmbeddedAction.class);

// Managers
private BiReportsManager biReportsManager;
private BiParametersManager biParametersManager;

// Front-end
private List<BiReports> biReports;
private List<BiParameters> biParameters;

@Inject
public TIPEmbeddedAction(APConfig config, BiReportsManager biReportsManager,
BiParametersManager biParametersManager) {
super(config);
this.biReportsManager = biReportsManager;
this.biParametersManager = biParametersManager;
}

public List<BiParameters> getBiParameters() {
return biParameters;
}


public List<BiReports> getBiReports() {
return biReports;
}


@Override
public void prepare() {
biReports = biReportsManager.findAll();
biParameters = biParametersManager.findAll();
}


public void setBiParameters(List<BiParameters> biParameters) {
this.biParameters = biParameters;
}


public void setBiReports(List<BiReports> biReports) {
this.biReports = biReports;
}


}
1 change: 1 addition & 0 deletions marlo-web/src/main/resources/custom/aicrra.properties
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ menu.additionalReporting.help=Supplementary Reporting not directly linked to a C
menu.studies=OICRs & MELIAs
menu.bi=BI
menu.bi.deliverablesMonitoring=Deliverables Monitoring
menu.tip=Dissemination

# Breadcrumb
breadCrumb.menu.guestUsers=Guest Users
Expand Down
1 change: 1 addition & 0 deletions marlo-web/src/main/resources/global.properties
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ menu.additionalReporting=Supplementary
menu.additionalReporting.help=Supplementary Reporting not directly linked to a Project
menu.studies=Evidences
menu.bi=BI
menu.tip=Dissemination

# Breadcrumb
breadCrumb.menu.guestUsers=Guest Users
Expand Down
8 changes: 8 additions & 0 deletions marlo-web/src/main/resources/struts-json.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,14 @@
<param name="excludeNullProperties">true</param>
</result>
</action>

<action name="tipGenerateUrlAction"
class="org.cgiar.ccafs.marlo.action.json.tip.TipDinamicUrlGenerationAction">
<result type="json">
<param name="noCache">true</param>
<param name="excludeNullProperties">true</param>
</result>
</action>

</package>

Expand Down
20 changes: 20 additions & 0 deletions marlo-web/src/main/resources/struts-tip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<!-- Add addition packages and configuration here. -->
<package name="tip" namespace="/tip"
extends="marlo-default">

<action name="{crp}/tip"
class="org.cgiar.ccafs.marlo.action.tip.TIPEmbeddedAction">
<!-- interceptor-ref name="autoLogin" / -->
<interceptor-ref name="homeStack" />
<result name="input">/WEB-INF/crp/views/tip/tipEmbedded.ftl
</result>
</action>

</package>

</struts>
1 change: 1 addition & 0 deletions marlo-web/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@
<include file="struts-fundingSources.xml" />
<include file="struts-summaries.xml" />
<include file="struts-bi.xml" />
<include file="struts-tip.xml" />
<include file="struts-synthesis.xml" />
<include file="struts-powb.xml" />
<include file="struts-annualReport.xml" />
Expand Down
28 changes: 28 additions & 0 deletions marlo-web/src/main/webapp/WEB-INF/crp/views/tip/tipEmbedded.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[#ftl]
[#assign title = "TIP" /]
[#assign currentSectionString = "${actionName?replace('/','-')}-phase-${(actualPhase.id)!}" /]
[#assign customJS = ["${baseUrlMedia}/js/tip/tipEmbedded.js?20240306"] /]
[#assign customCSS = [
"${baseUrl}/crp/css/tip/tipEmbedded.css?20240306", "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
]
/]
[#assign currentSection = "tip" /]

[#include "/WEB-INF/global/pages/header.ftl" /]
[#include "/WEB-INF/global/pages/main-menu.ftl" /]

[#import "/WEB-INF/global/macros/utils.ftl" as utils /]

<section class="container">
<h4 class="sectionTitle sectionTitle-tip">Deliverable Dissemination</h4>
<div id="tip">
Our main goal is to continuously improve the planning and reporting process for our users in the system. Taking into account the above and working in line with OneCGIAR, we have integrated with the TIP tool of the Alliance, which will allow users to disseminate publications in CGSpace and Harvard Datavers for the AICCRA project collections.</br>
With this new tool, we will have a more efficient process when putting our publications online
</div>
</br>
</br>

<div id="embeddedPage"></div>
</section>

[#include "/WEB-INF/global/pages/footer.ftl"]
30 changes: 16 additions & 14 deletions marlo-web/src/main/webapp/WEB-INF/global/pages/main-menu.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
[#-- SUMMARIES - ALL --]
{ 'slug': 'summaries', 'name': 'menu.summaries', 'namespace': '/summaries', 'action': '${(crpSession)!}/summaries', 'visible': logged, 'active': true }
[#-- BI Module --]
{ 'slug': 'bi', 'name': 'menu.bi', 'namespace': '/bi', 'action': '${(crpSession)!}/bi', 'visible': logged && biModuleActive, 'active': true }
{ 'slug': 'bi', 'name': 'menu.bi', 'namespace': '/bi', 'action': '${(crpSession)!}/bi', 'visible': logged && biModuleActive, 'active': true },
[#-- TIP Module --]
{ 'slug': 'tip', 'name': 'menu.tip', 'namespace': '/tip', 'action': '${(crpSession)!}/tip', 'visible': logged && action.hasSpecificities('tip_section_active'), 'active': true }
]/]


Expand Down Expand Up @@ -116,27 +118,27 @@

<nav id="mainMenu">
<div class="menuContent">
<div class="container">
<ul class="hidden-md hidden-lg">
<li> <span class="glyphicon glyphicon-menu-hamburger"></span> Main menu
<ul class="subMenu">
[@mainMenuList /]
</ul>
</li>
</ul>
<ul class="visible-md-block visible-lg-block visible-ul">
[@mainMenuList /]
</ul>
<div class="container">
<ul class="hidden-md hidden-lg">
<li> <span class="glyphicon glyphicon-menu-hamburger"></span> Main menu
<ul class="subMenu">
[@mainMenuList /]
</ul>
</li>
</ul>
<ul class="visible-md-block visible-lg-block visible-ul">
[@mainMenuList /]
</ul>

[#if logged?? && logged]
[#if logged?? && logged]
<div id="userInfo">
<a id="userLogOut" href="[@s.url action="logout" namespace="/" /]">[@s.text name="header.logout" /]</a>
<p class="userId" style="display:none">${(currentUser.id)!}</p>
<p class="name"><span class="glyphicon glyphicon-user"></span> ${(currentUser.composedCompleteName)!}</p>
<p class="institution">${(currentUser.email)!}</p>
<p class="roles"> [${(roles)!}${(roles?has_content && liasons?has_content)?string(',','')}${(liasons)!}]</p>
</div>
[/#if]
[/#if]
</div>
</div>
</nav>
Expand Down
13 changes: 13 additions & 0 deletions marlo-web/src/main/webapp/crp/css/tip/tipEmbedded.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.fullscreen-button {
position: absolute;
top: -10x;
right: 17px;
}

.timeline-phases {
display: none;
}

.sectionTitle-tip{
margin-top:10px;
}
Loading

0 comments on commit 459c5be

Please sign in to comment.