-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'aiccra-tip-integration' into aiccra-dev
- Loading branch information
Showing
7 changed files
with
259 additions
and
1 deletion.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/superadmin/TIPManagementAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* 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.superadmin; | ||
|
||
import org.cgiar.ccafs.marlo.action.BaseAction; | ||
import org.cgiar.ccafs.marlo.data.manager.TipParametersManager; | ||
import org.cgiar.ccafs.marlo.data.model.TipParameters; | ||
import org.cgiar.ccafs.marlo.utils.APConfig; | ||
import org.cgiar.ccafs.marlo.validation.superadmin.FeedbackManagementValidator; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.jfree.util.Log; | ||
|
||
|
||
public class TIPManagementAction extends BaseAction { | ||
|
||
private static final long serialVersionUID = -793652591843623397L; | ||
private TipParametersManager tipParameterManager; | ||
private TipParameters tipParameter; | ||
|
||
@Inject | ||
public TIPManagementAction(APConfig config, TipParametersManager tipParameterManager, | ||
FeedbackManagementValidator validator) { | ||
super(config); | ||
this.tipParameterManager = tipParameterManager; | ||
} | ||
|
||
public TipParameters getTipParameter() { | ||
return tipParameter; | ||
} | ||
|
||
@Override | ||
public void prepare() throws Exception { | ||
try { | ||
tipParameter = tipParameterManager.findAll().get(0); | ||
} catch (Exception e) { | ||
Log.error("error getting tip parameters " + e); | ||
} | ||
} | ||
|
||
@Override | ||
public String save() { | ||
if (this.canAccessSuperAdmin()) { | ||
if (tipParameter != null) { | ||
|
||
TipParameters tipParameterSave = new TipParameters(); | ||
if (tipParameter.getId() != null) { | ||
tipParameterSave.setId(tipParameter.getId()); | ||
} | ||
if (tipParameter.getTipLoginService() != null) { | ||
tipParameterSave.setTipLoginService(tipParameter.getTipLoginService()); | ||
} | ||
if (tipParameter.getTipStatusService() != null) { | ||
tipParameterSave.setTipStatusService(tipParameter.getTipStatusService()); | ||
} | ||
if (tipParameter.getTipTokenService() != null) { | ||
tipParameterSave.setTipTokenService(tipParameter.getTipTokenService()); | ||
} | ||
if (tipParameter.getTokenDueDate() != null) { | ||
tipParameterSave.setTokenDueDate(tipParameter.getTokenDueDate()); | ||
} | ||
if (tipParameter.getTokenValue() != null) { | ||
tipParameterSave.setTokenValue(tipParameter.getTokenValue()); | ||
} | ||
if (tipParameter.getPrivateKey() != null) { | ||
tipParameterSave.setPrivateKey(tipParameter.getPrivateKey()); | ||
} | ||
|
||
tipParameterManager.saveTipParameters(tipParameterSave); | ||
|
||
} | ||
|
||
if (this.getUrl() == null || this.getUrl().isEmpty()) { | ||
Collection<String> messages = this.getActionMessages(); | ||
if (this.getInvalidFields() != null && !this.getInvalidFields().isEmpty()) { | ||
this.setActionMessages(null); | ||
// this.addActionMessage(Map.toString(this.getInvalidFields().toArray())); | ||
List<String> keys = new ArrayList<String>(this.getInvalidFields().keySet()); | ||
for (String key : keys) { | ||
this.addActionMessage(key + ": " + this.getInvalidFields().get(key)); | ||
} | ||
} else { | ||
this.addActionMessage("message:" + this.getText("saving.saved")); | ||
} | ||
return SUCCESS; | ||
} else { | ||
this.addActionMessage(""); | ||
this.setActionMessages(null); | ||
return REDIRECT; | ||
} | ||
|
||
} else { | ||
return NOT_AUTHORIZED; | ||
} | ||
} | ||
|
||
public void setTipParameter(TipParameters tipParameter) { | ||
this.tipParameter = tipParameter; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
marlo-web/src/main/webapp/WEB-INF/global/views/superadmin/tipManagement.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
[#ftl] | ||
[#assign title = "TIP Management" /] | ||
[#assign currentSectionString = "${actionName?replace('/','-')}-phase-${(actualPhase.id)!}" /] | ||
[#assign pageLibs = [] /] | ||
[#assign customJS = [ "${baseUrlCdn}/global/js/superadmin/tipManagement.js?20231214a", "${baseUrlCdn}/global/js/fieldsValidation.js" | ||
] /] | ||
[#assign customCSS = [ "${baseUrlCdn}/global/css/superadmin/superadmin.css" ] /] | ||
[#assign currentSection = "superadmin" /] | ||
[#assign currentStage = "tipManagement" /] | ||
|
||
[#assign breadCrumb = [ | ||
{"label":"superadmin", "nameSpace":"", "action":"marloBoard"}, | ||
{"label":"tipManagement", "nameSpace":"", "action":""} | ||
]/] | ||
|
||
[#include "/WEB-INF/global/pages/header.ftl" /] | ||
<hr /> | ||
|
||
<div class="container"> | ||
[#include "/WEB-INF/global/pages/breadcrumb.ftl" /] | ||
</div> | ||
[#include "/WEB-INF/global/pages/generalMessages.ftl" /] | ||
|
||
|
||
<section class="marlo-content"> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-3"> | ||
[#include "/WEB-INF/global/views/superadmin/menu-superadmin.ftl" /] | ||
</div> | ||
<div class="col-md-9"> | ||
[@s.form action=actionName enctype="multipart/form-data" ] | ||
|
||
[#-- System Level Outcomes --] | ||
<h4 class="sectionTitle">[@s.text name="tipParameterManagement.title" /]</h4> | ||
|
||
<div id="tipManagement" class="borderBox"> | ||
<div class="form-group"> | ||
[@customForm.input name="tipParameter.privateKey" i18nkey="tipParameter.privateKey" className="description limitWords-100" required=true /] | ||
</div> | ||
<div class="clearfix"></div> | ||
<div class="form-group"> | ||
[@customForm.input name="tipParameter.tipTokenService" i18nkey="tipParameter.tipTokenService" className="description limitWords-100" required=true /] | ||
</div> | ||
<div class="clearfix"></div> | ||
<div class="form-group "> | ||
[@customForm.input name="tipParameter.tipLoginService" i18nkey="tipParameter.tipLoginService" className="description limitWords-100" required=true /] | ||
</div> | ||
<div class="clearfix"></div> | ||
<div class="form-group"> | ||
[@customForm.input name="tipParameter.tipStatusService" i18nkey="tipParameter.tipStatusService" className="description limitWords-100" required=true /] | ||
</div> | ||
<div class="clearfix"></div> | ||
<div class="form-group" style="display:block"> | ||
[@customForm.input id="tipParameter.tokenValue" name="tipParameter.tokenValue" i18nkey="tipParameter.tokenValue" className="description limitWords-100" required=true /] | ||
<a id="updateTokenBtn" class="addButton">[@s.text name="tipParameter.updateToken" /]</a> | ||
</div> | ||
<div class="clearfix"></div> | ||
<div class="form-group"> | ||
[@customForm.input name="tipParameter.tokenDueDate" i18nkey="tipParameter.tokenDueDate" className="description limitWords-100" required=false editable=false /] | ||
</div> | ||
<div class="clearfix"></div> | ||
</div> | ||
|
||
|
||
[#-- Section Buttons--] | ||
<div class="buttons"> | ||
<div class="buttons-content"> | ||
[@s.submit type="button" name="save" cssClass="button-save"]<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> [@s.text name="form.buttons.save" /][/@s.submit] | ||
</div> | ||
</div> | ||
|
||
[/@s.form] | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
|
||
[#include "/WEB-INF/global/pages/footer.ftl" /] |
28 changes: 28 additions & 0 deletions
28
marlo-web/src/main/webapp/global/js/superadmin/tipManagement.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
$(init); | ||
|
||
function init(){ | ||
updateTipToken(); | ||
} | ||
|
||
function updateTipToken() { | ||
$("#updateTokenBtn").on("click", function(event) { | ||
$.ajax({ | ||
url: baseURL + '/tipTokenService.do', | ||
type: 'POST', | ||
dataType: 'json', | ||
success: function(response) { | ||
|
||
var token = response.token; | ||
$("#tipParameter.tokenValue").val(token); | ||
$('input[name="tipParameter.tokenValue"]').val(token); | ||
|
||
|
||
}, | ||
error: function(error) { | ||
console.error('Error getting embedded URL:', error); | ||
} | ||
}); | ||
}); | ||
|
||
} | ||
|