<html>
<head>
<title>Default Report</title>
<script src="jquery-3.2.1.min.js" type="text/javascript"></script>
</head>
<body>
<script>
var debug = true; //1.2 true or false 'browse_tree_expandid' 'browse_tree_frameid'
</script>
<div style="float:right;">
<input type="button" id="odxdSaveAsDefaultReportButton" value="Save As" />
</div>
<iframe id="<%=request.getParameter("iframeid")%>"
src="/pentaho/api/repos/<%=request.getParameter("file_path")%>/prpti.edit?parameterDate=<%=request.getParameter("dateFilter")%>&ts=<%=System.currentTimeMillis()%>"
scrolling="auto" frameborder="0" height="1200px" width="100%"></iframe>
<script>
givenFilePath = '<%=request.getParameter("file_path")%>';
$(document).on('click', '#odxdSaveAsDefaultReportButton', function() {
// var givenFilePath = ':public:optum:odxd:tenant:share:ireport_message_outbound.prpti';
var directoryPath = givenFilePath.substr(0, givenFilePath.lastIndexOf(':')).replace(/:/g, "/").replace("/tenant/share", "/tenant/protected/<%=request.getParameter("tenantSubFolder")%>" );//tenantSubFolder
var filenameOnly = givenFilePath.substr(givenFilePath.lastIndexOf(':') + 1).replace(".prpti","");
//var directoryPath = 'public/optum/odxd/tenant/protected/nyulmc_hie';//tenantSubFolder
var iframeId ='<%=request.getParameter("iframeid")%>';
if(debug) console.log('rr1 1.93 DefaultReport given iframeId =' + iframeId + ' givenFilePath=' + givenFilePath + ' directoryPath=' + directoryPath + ' filenameOnly=' + filenameOnly );
// pirUrlBase contains the location to the Pentaho Interactive Reporting entry point
var pirUrlBase = '/pentaho/api/repos/pentaho-interactive-reporting/prpti.new';
// pirLocation holds the value of the most recent location opened or saved.
var pirLocation;
// lastMessage keeps track of the last error during the save process.
var lastMessage;
// The alertOn and alertlog are used for debugging; set alertOn to see when the different callbacks are made.
var alertOn = false;
function alertlog(txt) {
if (alertOn) {
alert(txt);
}
}
console.log(test);
// API Methods that Interactive Reporting relies on to determine/provide available functionality.
//
// mantle_initialized must be set for Interactive Reporting to enable certain functionality
var mantle_initialized=true;
// The enableContentEdit method is called when a content generator is editable or not
function enableContentEdit(contentEdit) {
alertlog('enableContentEdit called: ' + contentEdit);
document.getElementById("edit").style.display = (contentEdit ? "inline" : "none");
}
// This function is called during the save process. triggers a repository refresh.
function mantle_refreshRepository() {
alertlog('mantle_refreshRepository called');
}
var test = 'hello there2';
console.log(test);
// The getSolutionPath method prompts for a .prpti file.
function getSolutionPath() {
var solutionPath = pirLocation;
if (solutionPath == null) {
solutionPath = [directoryPath,'Custom_iReport.prpti'];
}
//solutionPath[0] = prompt("Step 1 of 2 - Path:", solutionPath[0]);
if (!solutionPath[0]) {
return null;
}
solutionPath[1] = prompt("Enter File Name", solutionPath[1]);
if (!solutionPath[1]) {
return null;
}
window.parent.document.getElementById('browse_tree_frameid1').contentDocument.location.reload(true);
return solutionPath;
}
console.log(test);
// Local functions for interacting with Pentaho Interactive Reporting
//
// Returns the iFrame PIR is loaded in
function getPIRiFrame() {
return window.frames[0];
}
// Create a new Interactive Report. Called when the user clicks 'New'
function newPIRReport() {
alertlog("Loading new PIR Report");
getPIRiFrame().location = pirUrlBase;
editMode = true;
enableAdhocSave(true);
}
// Open an existing Interactive Report. Called when the user clicks "Open".
function openPIRReport() {
// Ajax call to solution browser
// display list
var sp = getSolutionPath();
if (sp != null) {
// This URL opens a PIR report at a given location within the repository.
// command=view is required to view the document at the provided path.
var url = '/pentaho/api/repos/' + sp[0].replace(/\//g, ":") + ':' + sp[1] + '/prpti.view';
getPIRiFrame().location = url;
editMode = false;
updateInfo(sp);
enableAdhocSave(true);
}
}
// Enables and disabled
function editPIRReport() {
// Toggle edit mode and editMode = !editMode;
getPIRiFrame().window.editContentToggled(editMode);
}
// The savePIRReport function is called when the user clicks "Save" or "Save As".
function savePIRReport(saveas) {
var sp;
if (pirLocation == null || saveas) {
sp = getSolutionPath();
} else {
sp = pirLocation;
}
if (sp != null) {
// This call tells PIR to save content in a specified location within a solution.
getPIRiFrame().handle_puc_save(sp[0], sp[1], true, function() {alert('An error occurred during save!');});
//updateInfo(sp);
}
}
var test = 'hello there';
console.log(test);
//var newFilename = prompt('Please enter a new file name.','Custom_' + filenameOnly);
var newFilename = 'Custom_' + filenameOnly;
if(!newFilename){
alert('You did not enter a name. Action will be canceled.');
}
else{
if(debug) console.log('rr1 1.93 DefaultReport SaveAS-clicked ' + ' newFilename =' + newFilename + ' directoryPath=' + directoryPath);
// api.operation.saveReport(newFilename, directoryPath,
// function(){ alert('Report: "' + newFilename + '" Saved Sucessfully'); },
// function(){ alert('Failed to save Report: "' + newFilename + '", Please check with administrator'); },
// true);
// window.location.reload(true);
//window.parent.document.getElementById('browse_tree_frameid').contentDocument.location.reload(true);
savePIRReport(true);
//window.location.reload(true);
}});
</script>
</body>
</html>
<head>
<title>Default Report</title>
<script src="jquery-3.2.1.min.js" type="text/javascript"></script>
</head>
<body>
<script>
var debug = true; //1.2 true or false 'browse_tree_expandid' 'browse_tree_frameid'
</script>
<div style="float:right;">
<input type="button" id="odxdSaveAsDefaultReportButton" value="Save As" />
</div>
<iframe id="<%=request.getParameter("iframeid")%>"
src="/pentaho/api/repos/<%=request.getParameter("file_path")%>/prpti.edit?parameterDate=<%=request.getParameter("dateFilter")%>&ts=<%=System.currentTimeMillis()%>"
scrolling="auto" frameborder="0" height="1200px" width="100%"></iframe>
<script>
givenFilePath = '<%=request.getParameter("file_path")%>';
$(document).on('click', '#odxdSaveAsDefaultReportButton', function() {
// var givenFilePath = ':public:optum:odxd:tenant:share:ireport_message_outbound.prpti';
var directoryPath = givenFilePath.substr(0, givenFilePath.lastIndexOf(':')).replace(/:/g, "/").replace("/tenant/share", "/tenant/protected/<%=request.getParameter("tenantSubFolder")%>" );//tenantSubFolder
var filenameOnly = givenFilePath.substr(givenFilePath.lastIndexOf(':') + 1).replace(".prpti","");
//var directoryPath = 'public/optum/odxd/tenant/protected/nyulmc_hie';//tenantSubFolder
var iframeId ='<%=request.getParameter("iframeid")%>';
if(debug) console.log('rr1 1.93 DefaultReport given iframeId =' + iframeId + ' givenFilePath=' + givenFilePath + ' directoryPath=' + directoryPath + ' filenameOnly=' + filenameOnly );
// pirUrlBase contains the location to the Pentaho Interactive Reporting entry point
var pirUrlBase = '/pentaho/api/repos/pentaho-interactive-reporting/prpti.new';
// pirLocation holds the value of the most recent location opened or saved.
var pirLocation;
// lastMessage keeps track of the last error during the save process.
var lastMessage;
// The alertOn and alertlog are used for debugging; set alertOn to see when the different callbacks are made.
var alertOn = false;
function alertlog(txt) {
if (alertOn) {
alert(txt);
}
}
console.log(test);
// API Methods that Interactive Reporting relies on to determine/provide available functionality.
//
// mantle_initialized must be set for Interactive Reporting to enable certain functionality
var mantle_initialized=true;
// The enableContentEdit method is called when a content generator is editable or not
function enableContentEdit(contentEdit) {
alertlog('enableContentEdit called: ' + contentEdit);
document.getElementById("edit").style.display = (contentEdit ? "inline" : "none");
}
// This function is called during the save process. triggers a repository refresh.
function mantle_refreshRepository() {
alertlog('mantle_refreshRepository called');
}
var test = 'hello there2';
console.log(test);
// The getSolutionPath method prompts for a .prpti file.
function getSolutionPath() {
var solutionPath = pirLocation;
if (solutionPath == null) {
solutionPath = [directoryPath,'Custom_iReport.prpti'];
}
//solutionPath[0] = prompt("Step 1 of 2 - Path:", solutionPath[0]);
if (!solutionPath[0]) {
return null;
}
solutionPath[1] = prompt("Enter File Name", solutionPath[1]);
if (!solutionPath[1]) {
return null;
}
window.parent.document.getElementById('browse_tree_frameid1').contentDocument.location.reload(true);
return solutionPath;
}
console.log(test);
// Local functions for interacting with Pentaho Interactive Reporting
//
// Returns the iFrame PIR is loaded in
function getPIRiFrame() {
return window.frames[0];
}
// Create a new Interactive Report. Called when the user clicks 'New'
function newPIRReport() {
alertlog("Loading new PIR Report");
getPIRiFrame().location = pirUrlBase;
editMode = true;
enableAdhocSave(true);
}
// Open an existing Interactive Report. Called when the user clicks "Open".
function openPIRReport() {
// Ajax call to solution browser
// display list
var sp = getSolutionPath();
if (sp != null) {
// This URL opens a PIR report at a given location within the repository.
// command=view is required to view the document at the provided path.
var url = '/pentaho/api/repos/' + sp[0].replace(/\//g, ":") + ':' + sp[1] + '/prpti.view';
getPIRiFrame().location = url;
editMode = false;
updateInfo(sp);
enableAdhocSave(true);
}
}
// Enables and disabled
function editPIRReport() {
// Toggle edit mode and editMode = !editMode;
getPIRiFrame().window.editContentToggled(editMode);
}
// The savePIRReport function is called when the user clicks "Save" or "Save As".
function savePIRReport(saveas) {
var sp;
if (pirLocation == null || saveas) {
sp = getSolutionPath();
} else {
sp = pirLocation;
}
if (sp != null) {
// This call tells PIR to save content in a specified location within a solution.
getPIRiFrame().handle_puc_save(sp[0], sp[1], true, function() {alert('An error occurred during save!');});
//updateInfo(sp);
}
}
var test = 'hello there';
console.log(test);
//var newFilename = prompt('Please enter a new file name.','Custom_' + filenameOnly);
var newFilename = 'Custom_' + filenameOnly;
if(!newFilename){
alert('You did not enter a name. Action will be canceled.');
}
else{
if(debug) console.log('rr1 1.93 DefaultReport SaveAS-clicked ' + ' newFilename =' + newFilename + ' directoryPath=' + directoryPath);
// api.operation.saveReport(newFilename, directoryPath,
// function(){ alert('Report: "' + newFilename + '" Saved Sucessfully'); },
// function(){ alert('Failed to save Report: "' + newFilename + '", Please check with administrator'); },
// true);
// window.location.reload(true);
//window.parent.document.getElementById('browse_tree_frameid').contentDocument.location.reload(true);
savePIRReport(true);
//window.location.reload(true);
}});
</script>
</body>
</html>