Showing posts with label Maximo. Show all posts
Showing posts with label Maximo. Show all posts

Tuesday, October 6, 2015

Making the Maximo 7.5 or 7.6 Starcenter portlet and KPI manager KPI scale dynamic

Problem

The scale on the KPI Gauge when using a percentage is always from 0 to 100 (or from 0 to any high number you use for your percentage). When using KPI's with very small changes in range (e.g. 0.1 variance) the scale is not useable. 

It shows a lot of red, green or yellow but it is impossible to read the correct value from the Gauge. It also look depressing, a lot of red on the screen while the actual value may be a good (green) value.

I want to be able to change the scale so it can start at e.g. 80 and run to 100. This would give a better view for some KPI's with high (or low) percentages.

And while we are at it, remove the gray Target pointer, it is confusing sometimes!

Example

Graph that is not useable anymore because of the low variance I want to monitor:




Irritating Target Arrow:




My Configuration

Hyper-V vitual machine with 2 CPU's and 8GB RAM
Maximo 7.6.0.2
DB2 10.5

I also tested this on a 7.5.0.6 configuration with Oracle, works the same :)

Solution

No for the solution, no java code needs to be altered :) whoohooo

We do however change two files;

  • kpigraph.jsp
  • kpigraphportlet.jsp

These are located in: \SMP\maximo\applications\maximo\maximouiweb\webmodule\webclient\components

The first file is for the graph when opening the KPI in the KPI Manager. The second file is for the KPI graph on the starcenter.

Developer Mode

I want to change these files and while testing and tweaking it is nice to set the MXServer in Developer Mode. This way you can tweak the files, save them directly in the ear file and see your changes without restarting your MXserver of rebuilding en redeploying.

Below where to enable Developer Mode in Websphere:




This is the ear file in which I copy the modified file directly





Modifications

Copy the kpigraph.jsp and kpiportlet.jsp to the desktop.

Open the files from the desktop in an editor like notepad ++


kpigraph.jsp:

In the kpigraph.jsp, search for "if (chartData instanceof DialChartData)"
Should be around line 120.

In between the {} of the if statement I changed the code:

DialChartData dialData = (DialChartData)chartData;
%> dojo.require('ibm.tivoli.mbs.dijit.kpi.DialGauge');

//Different start points for various KPI's
<%
Double targ = dialData.target;
Double caut = dialData.arc1Threshold;
Double alert = dialData.arc2Threshold;
int start = dialData.start;
Double interval = dialData.tickInterval;
Double targetVal = dialData.target;

//hide the target
targetVal = 0.00;

if (targ > 84 && targ <= 100 && caut > 84 && caut <= 100 && alert > 84 && alert <= 100) 
{
start = 80;
interval = 2.00;
}
if (targ > 92 && targ <= 100 && caut > 92 && caut <= 100 && alert > 92 && alert <= 100) 
{
start = 90;
interval = 1.00;
}
if (targ > 97 && targ <= 100 && caut > 97 && caut <= 100 && alert > 97 && alert <= 100) 
{
start = 97;
interval = 0.25;
}

%> var gauge = new ibm.tivoli.mbs.dijit.kpi.DialGauge({<%
%>id: "kpichart_<%= id %>", <%
%>width: 400, <%
%>height: 140, <%
%>radius: 75, <%
%>cx: 140, <%
%>cy: 130, <%
//%>startValue: <%=dialData.start%>, <%
%>startValue: <%=start%>, <%
%>endValue: <%=dialData.end%>, <%
%>hover: "<%=HTML.encode(dialData.label)%>", <%
%>innerColor: "<%=dialData.innerColor%>", <%
%>tickOffset: 90, <%
//%>tickInterval: <%=dialData.tickInterval%>, <% 
%>tickInterval: <%=interval%>, <% 
%>arc1Color: "<%=dialData.arc1Color%>", <%
%>arc1Label: "<%=dialData.arc1Label%>", <%
%>arc1Threshold: <%=dialData.arc1Threshold%>, <%
%>arc2Color: "<%=dialData.arc2Color%>", <%
%>arc2Label: "<%=dialData.arc2Label%>", <%
%>arc2Threshold: <%=dialData.arc2Threshold%>, <%
%>arc3Color: "<%=dialData.arc3Color%>", <%
%>arc3Label: "<%=dialData.arc3Label%>", <%
//%>target: <%=dialData.target%>, <%
%>target: <%=targetVal%>, <%
//%>targetColor: "<%=dialData.targetColor%>", <%
%>targetColor: "<%=dialData.innerColor%>", <%
%>targetLabel: "<%=dialData.targetLabel%>", <%
%>value: <%=dialData.kpi%>, <%
%>valueColor: "<%=dialData.kpiColor%>", <%
%>valueLabel: "<%=dialData.kpiLabel%>"<%
if(rtl)
{
%>,orientation: "cclockwise"<%
}
%>}, 'kpichart_<%= id %>_holder');


gauge.startup();






I created three different scales in this example. The scale changes depending on the values entered in the KPI in the  "Target", "Caution At" and "Alert At" fields:





Depending on the values fileld in there I change the start of the scale and the interval and put those in a variable.

I use that variable in the graph buildup.

To do this I do not delete the lines or replace them but comment them out and put the new field below the original. Like so:

//%>startValue: <%=dialData.start%>, <%
  %>startValue: <%=start%>, <%

//%>tickInterval: <%=dialData.tickInterval%>, <% 
  %>tickInterval: <%=interval%>, <%


I changed the color of the Target Arrow to the color of the innerColor so the Arrow is still there but it isn't visible. And I set the arrow on position 0.0:

//%>target: <%=dialData.target%>, <%
  %>target: <%=targetVal%>, <%

//%>targetColor: "<%=dialData.targetColor%>", <%
  %>targetColor: "<%=dialData.innerColor%>", <%



kpigraphportlet.jsp:

The same applies to the kpigraphportlet.jsp.  The code is just in another place.
Again search for "if(chartData instanceof DialChartData)"

Replace the code in the { (begin)  and } (end) with:


DialChartData dialData = (DialChartData)chartData;
%>dojo.require('ibm.tivoli.mbs.dijit.kpi.DialGauge');
document.<%=methodName%> = function()
{
var dJit = dijit.byId("kpiportletchart_<%= id %>");
if(dJit)
dJit.destroyRecursive(true);
//Different start points for various KPI's
<%
Double targ = dialData.target;
Double caut = dialData.arc1Threshold;
Double alert = dialData.arc2Threshold;
int start = dialData.start;
Double interval = dialData.tickInterval;
Double targetVal = dialData.target;

//hide the target
targetVal = 0.00;

if (targ > 84 && targ <= 100 && caut > 84 && caut <= 100 && alert > 84 && alert <= 100) 
{
start = 80;
interval = 2.00;
}
if (targ > 92 && targ <= 100 && caut > 92 && caut <= 100 && alert > 92 && alert <= 100) 
{
start = 90;
interval = 1.00;
}
if (targ > 97 && targ <= 100 && caut > 97 && caut <= 100 && alert > 97 && alert <= 100) 
{
start = 97;
interval = 0.25;
}
%>
var gauge = new ibm.tivoli.mbs.dijit.kpi.DialGauge({<%
%>id: "kpiportletchart_<%= id %>", <%
%>width: <%=dialwidth%>, <%
%>height: <%=dialheight%>, <%
%>radius: <%=dialradius%>, <%
%>cx: <%=dialcx%>, <%
%>cy: <%=dialcy%>, <%
%>url: <%=dialData.url != null ? '"' + wcs.getMaximoRequestContextURL() + dialData.url + '"': null%>,<%
//%>startValue: <%=dialData.start%>, <%
%>startValue: <%=start%>, <%
%>endValue: <%=dialData.end%>, <%
%>hover: "<%=HTML.encode(dialData.label)%>", <%
%>innerColor: "<%=dialData.innerColor%>", <%
%>tickOffset: <%=dialmajortickoffset%>, <%
//%>tickInterval: <%=dialData.tickInterval%>, <% 
%>tickInterval: <%=interval%>, <% 
%>arc1Color: "<%=dialData.arc1Color%>", <%
%>arc1Label: "<%=dialData.arc1Label%>", <%
%>arc1Threshold: <%=dialData.arc1Threshold%>, <%
%>arc2Color: "<%=dialData.arc2Color%>", <%
%>arc2Label: "<%=dialData.arc2Label%>", <%
%>arc2Threshold: <%=dialData.arc2Threshold%>, <%
%>arc3Color: "<%=dialData.arc3Color%>", <%
%>arc3Label: "<%=dialData.arc3Label%>", <%
//%>target: <%=dialData.target%>, <%
%>target: <%=targetVal%>, <%
//%>targetColor: "<%=dialData.targetColor%>", <%
%>targetColor: "<%=dialData.innerColor%>", <%
%>targetLabel: "<%=dialData.targetLabel%>", <%
%>value: <%=dialData.kpi%>, <%
%>valueColor: "<%=dialData.kpiColor%>", <%
%>valueLabel: "<%=dialData.kpiLabel%>"<%
if(rtl)
{
%>,orientation: "cclockwise"<%
}
%>}, 'kpiportletchart_<%= id %>_holder');

gauge.startup();
};
dojo.addOnLoad(document.<%=methodName%>);







The same changes apply here as for the kpigraph.jsp

Save both files and copy them to the \SMP\maximo\applications\maximo\maximouiweb\webmodule\webclient\components 
Overwrite the old files (make a backup before overwriting them...)


Also copy them into you ear file:

C:\Program Files (x86)\ibm\WebSphere\AppServer\profiles\ctgAppSrv01\installedApps\ctgCell01\MAXIMO.ear\maximouiweb.war\webclient\components

Now open the KPI and startcenter again:





You can modify the if statements or maybe even think of something even more dynamic. But I think this is a great starting point :)


GNZ

Wednesday, January 29, 2014

Show the Username and Default Insert Site in the Maximo header

Goal: 
To show the currently logged-in user and his Default Insert site in the header of the Maximo 7.5.0.5 application 

Problem:
When working in some Maximo applications (e.g. workorder and locations) in a multi-site environment the user must have the Default Insert site set to the site he wants to insert a new record for.

This information is displayed in Maximo through a menu, but the user will first have to open it. It would be nice to always show the user his Default Insert Site.

Solution:
Show the Default Insert site of the user in the header of Maximo.

In the header there is room for some information, like shown in the picture below:





Step 1 - Locate the file

In order to show information in this part of Maximo we need to modify the titlebar.jsp

This file is located in \IBM\SMP\maximo\applications\maximo\maximouiweb\webmodule\webclient\components

This is regardless of what skin you use.

Make a copy of titlebar.jsp as a backup in this directory. 


Modify the titlebar.jsp

After the line  (line 20):


String userFullName = control.getWebClientSession().getUserInfo().getDisplayName();

Enter the following lines:

String defSite= "";

try
{
  defSite= control.getWebClientSession().getUserInfo().getInsertSite();
}
  catch(Exception ex)
{
  defSite="Unknown";
}


In essention I create a variable that is empty. I try to get the user his InsertSite and put that in the variable. If no InsertSite exists I fill the variable with the text "Unknown"

Here a picture of the first change:





Then find the following block of code(original line number 130) :

<td style="vertical-align:<%if(useHomeButton){%>middle<%}else{%>top<%}%>;white-space: nowrap;">
    <span id="txtappname" class="<%if(useHomeButton)%>homeButton<%}%>txtappname">&nbsp;
<%=apptitle%>
    </span>
</td>


Enter the following code after the code found above:

<td width="290"nowrap style="vertical-align:top" align="right">
    <span class="txtappname">&nbsp;
        <font color="C0C0C0">User:        </font><%=userFullName%> &nbsp; &nbsp;
        <font color="C0C0C0">Insert Site: </font><%=defSite%>
    </span>
</td>

Here I add the code to set the new variable on the screen, I also show the userFullName variable here in order to show the user his full name.

Here is a picture of the modification:




Next rebuild the maximo.ear and redeploy the Maximo application.
After loggin in to Maximo you should see the username and default insert site in the header. Could be that your browser has cached some headerinformation, always try a hard refresh (CTRL + F5) if nothing shows up.

It should end up looking like this (I changed the name for privacy reasons):



It looks like itis show twice, but that is only on the startscreen. When opening the Workorders application for example you will see the second mention of the name is useful:





GNZ.

Monday, August 19, 2013

Maximo 7.5 - Use button with Automation Script

Goal: 
To Create an automation script in Maximo 7.5.0.4 that is triggered by clicking on an button in an application.


Example:
A button on the Work Order Tracking application that triggers a script. The script will read the Target Start Date from the Work Order, add the Duration to it and will automatically fill in the Target Finish Date.

How to:
Open the Automation Scripts application.  Create a new ‘Script with Action Launch Point’

Fill in the name of the Launch Point, the Object and the Name of the Action. 

We will see this Actionname later when we configure the button and an Action with this name will automatically be created. We choose to use a New script. Click [Next] to continue


Next give the New Script a name and description. I use jython as the script language. We will add variabeles later on, so leave them for now and click [Next] to continue.


We need to fill in the script here. As we cannot test it here we will fill in a ‘1’ (cannot leave it blank for some reason) We will return later to add the correct script. Click the [Create] button




Open the script and go to the ‘Variables’ tab.

Add the following variables by pressing the [New Row] button

Variable:             TARGSTART_IN
Description:       Target Start Date            
Variable Type:   IN
Override:            Checked
Binding Type:    Attribute

Variable:             ESTDUR_IN
Description:       Estimated Duration        
Variable Type:   IN
Override:            Checked
Binding Type:    Attribute

Variable:             TARGFINISH_OUT
Description:       Target Finish Date          
Variable Type:   OUT
Override:            Checked
Binding Type:    Attribute



Click the ‘Save’ icon at the top of the screen and go to the ‘Launch Points’ tab. Click on the ‘Edit Launch Point Detail’ button.



In this screen we bind the created variables to Attributes. This can be done per Launch point. So if you create multiple launch points you can use the same variables but bind them to different Attributes.

Open the Details of the attribute and click on the ‘Select Attribute Name’ button.



Check the Action application to see the configuration of the Action that was created.


Do not change anything here, this is configured by creating the launch point, we will just check it here.



Next we will add the button to the screen. Open the Application Designer en open the WOTRACK application.


Add a Signature Option to the WOTRACK application by going to the ‘Select Action’ menu and clicking on ‘Add/Modify Signature Options’




Create a new Signature with the same name as the Action.

Open the ‘Advanced Signature Options’ at the bottom of the dialog and make sure that “This is an action that must be invoked by use in the UI”  is selected.



Click [OK] and Save the ‘WOTRACK’ application.

Now we add a ‘Pushbutton’ to the Work Order tab. Just somewhere near the Target Start and Target Finish Date fields.




Open the properties of the Pushbutton. Give the Pushbutton a label and enter the Signature name as Event.




Save the WOTRACK application.

Now we need to give rights to the authorized groups on the button. Open the Security Groups application. Open the MAXADMIN group, go to the ‘Applications’ tab and filter for the ‘Work Order Tracking’ application.

Next filter or search for the Signature option we created and check the ‘Grant Access?’ option.


Save the group.



Now we need to create the actual script. Go to the ‘Automation Scripting’ application. Open the script we created earlier.

We will replace the current code with the code below;

from java.util import Date
TARGFINISH_OUT = Date(TARGSTART_IN.getTime() + long(ESTDUR_IN * 60 * 60 *1000))

In short the code does the following;
Coverting the TargetStartDate to milliseconds, converting the estimated Duration to milliseconds and adding them up, converting the total of milliseconds to a date and storing that in the Target Finish Data.

Click the ‘Save’ button, and to test the script, click the ‘Run’ button.


Result of the ‘Run’ button;


This isn’t telling us much as the variabele is empty, so the calculation is not working…

To properly test the configuration, we will go to the Workorder Tracking application, and actually push the button.



Push the button, and the date will be calculated.


That was the end of the automation script with a button in Maximo. Let me know if you have any remarks.

GNZ.