2015-04-17 15:17:24 -04:00
/**************************************************************/
var WidgetBuilder = function ( ) {
this . helper = new ViewDashboardHelper ( ) ;
}
WidgetBuilder . prototype . getIndicatorWidget = function ( indicator ) {
var retval = null ;
switch ( indicator . type ) {
case "1010" : retval = this . buildSpecialIndicatorButton ( indicator ) ; break ;
case "1030" : retval = this . buildSpecialIndicatorButton ( indicator ) ; break ;
case "1050" : retval = this . buildStatusIndicatorButton ( indicator ) ; break ;
case "1020" :
case "1040" :
case "1060" :
case "1070" :
case "1080" :
retval = this . buildIndicatorButton ( indicator ) ; break ;
}
if ( retval == null ) { throw new Error ( indicator . type + " has not associated a widget." ) ; }
return retval ;
} ;
WidgetBuilder . prototype . buildSpecialIndicatorButton = function ( indicator ) {
_ . templateSettings . variable = "indicator" ;
var template = _ . template ( $ ( "script.specialIndicatorButtonTemplate" ) . html ( ) ) ;
var $retval = $ ( template ( indicator ) ) ;
if ( indicator . comparative < 0 ) {
$retval . find ( ".ind-container-selector" ) . removeClass ( "panel-green" ) . addClass ( "panel-red" ) ;
2015-06-03 10:31:39 -04:00
$retval . find ( ".ind-symbol-selector" ) . removeClass ( "fa-arrow-up" ) . addClass ( "fa-arrow-down" ) ;
2015-04-17 15:17:24 -04:00
}
if ( indicator . comparative > 0 ) {
$retval . find ( ".ind-container-selector" ) . removeClass ( "panel-red" ) . addClass ( "panel-green" ) ;
2015-06-03 10:31:39 -04:00
$retval . find ( ".ind-symbol-selector" ) . removeClass ( "fa-arrow-down" ) . addClass ( "fa-arrow-up" ) ;
2015-04-17 15:17:24 -04:00
}
if ( indicator . comparative == 0 ) {
2015-06-03 10:31:39 -04:00
$retval . find ( ".ind-symbol-selector" ) . removeClass ( "fa-arrow-up" ) ;
$retval . find ( ".ind-symbol-selector" ) . removeClass ( "fa-arrow-down" ) ;
$retval . find ( ".ind-symbol-selector" ) . addClass ( "fa-arrows-h" ) ;
2015-04-17 15:17:24 -04:00
$retval . find ( ".ind-container-selector" ) . removeClass ( "panel-red" ) . addClass ( "panel-green" ) ;
}
return $retval ;
}
WidgetBuilder . prototype . buildStatusIndicatorButton = function ( indicator ) {
_ . templateSettings . variable = "indicator" ;
var template = _ . template ( $ ( "script.statusIndicatorButtonTemplate" ) . html ( ) ) ;
var $retval = $ ( template ( indicator ) ) ;
return $retval ;
}
WidgetBuilder . prototype . buildIndicatorButton = function ( indicator ) {
_ . templateSettings . variable = "indicator" ;
var template = _ . template ( $ ( "script.statusIndicatorButtonTemplate" ) . html ( ) ) ;
var $retval = $ ( template ( indicator ) ) ;
var $comparative = $retval . find ( '.ind-comparative-selector' ) ;
var $title = $retval . find ( '.ind-title-selector' ) ;
if ( indicator . isWellDone ) {
$comparative . text ( "(" + indicator . directionSymbol + " " + indicator . comparative + "%)-" + G _STRING . ID _WELL _DONE ) ;
$retval . find ( ".ind-container-selector" ) . removeClass ( "panel-low" ) . addClass ( "panel-high" ) ;
}
else {
$comparative . text ( "Goal: " + indicator . directionSymbol + " " + indicator . comparative + "%" ) ;
$retval . find ( ".ind-container-selector" ) . removeClass ( "panel-high" ) . addClass ( "panel-low" ) ;
}
return $retval ;
}
WidgetBuilder . prototype . buildSpecialIndicatorFirstView = function ( indicatorData ) {
if ( indicatorData == null ) { throw new Error ( "indicatorData is null." ) ; }
if ( ! indicatorData . hasOwnProperty ( "id" ) ) { throw new Error ( "indicatorData has no id." ) ; }
_ . templateSettings . variable = "indicator" ;
var template = _ . template ( $ ( "script.specialIndicatorMainPanel" ) . html ( ) ) ;
var $retval = $ ( template ( indicatorData ) ) ;
var indicatorPrincipalData = this . getIndicatorLoadedById ( indicatorData . id )
$retval . find ( '.breadcrumb' ) . find ( 'li' ) . remove ( )
$retval . find ( '.breadcrumb' ) . append ( '<li><b>' + indicatorPrincipalData . title + '</b></li>' )
$retval . find ( ".sind-index-selector" ) . text ( G _STRING . ID _EFFICIENCY _INDEX ) ;
$retval . find ( ".sind-cost-selector" ) . text ( G _STRING . ID _INEFFICIENCY _COST ) ;
2015-04-20 10:52:16 -04:00
this . setColorForInefficiency ( $retval . find ( ".sind-cost-number-selector" ) , indicatorData ) ;
2015-04-17 15:17:24 -04:00
return $retval ;
}
WidgetBuilder . prototype . buildSpecialIndicatorFirstViewDetail = function ( oneItemDetail ) {
//detailData = {indicatorId, uid, name, averateTime...}
if ( oneItemDetail == null ) { throw new Error ( "oneItemDetail is null " ) ; }
if ( ! typeof ( oneItemDetail ) === 'object' ) { throw new Error ( "detailData is not and object ->" + oneItemDetail ) ; }
2015-05-29 11:45:06 -04:00
if ( ! oneItemDetail . hasOwnProperty ( "name" ) ) { throw new Error ( "buildSpecialIndicatorFirstViewDetail -> detailData has not the name param. Has it the correct Type? ->" + oneItemDetail ) ; }
_ . templateSettings . variable = "detailData" ;
var template = _ . template ( $ ( "script.specialIndicatorDetail" ) . html ( ) ) ;
var $retval = $ ( template ( oneItemDetail ) ) ;
$retval . find ( ".detail-efficiency-selector" ) . text ( G _STRING . ID _EFFICIENCY _INDEX ) ;
$retval . find ( ".detail-cost-selector" ) . text ( G _STRING . ID _INEFFICIENCY _COST ) ;
this . setColorForInefficiency ( $retval . find ( ".detail-cost-number-selector" ) , oneItemDetail ) ;
return $retval ;
2015-04-17 15:17:24 -04:00
}
WidgetBuilder . prototype . buildStatusIndicatorFirstView = function ( indicatorData ) {
if ( indicatorData == null ) { throw new Error ( "indicatorData is null." ) ; }
if ( ! indicatorData . hasOwnProperty ( "id" ) ) { throw new Error ( "indicatorData has no id." ) ; }
_ . templateSettings . variable = "indicator" ;
var template = _ . template ( $ ( "script.statusIndicatorMainPanel" ) . html ( ) ) ;
var $retval = $ ( template ( indicatorData ) ) ;
var indicatorPrincipalData = this . getIndicatorLoadedById ( indicatorData . id )
$retval . find ( '.breadcrumb' ) . find ( 'li' ) . remove ( )
$retval . find ( '.breadcrumb' ) . append ( '<li><b>' + indicatorPrincipalData . title + '</b></li>' )
return $retval ;
}
WidgetBuilder . prototype . buildStatusIndicatorFirstViewDetail = function ( oneItemDetail ) {
//detailData = {indicatorId, uid, name, averateTime...}
if ( oneItemDetail == null ) { throw new Error ( "oneItemDetail is null " ) ; }
if ( ! typeof ( oneItemDetail ) === 'object' ) { throw new Error ( "detailData is not and object ->" + oneItemDetail ) ; }
if ( ! oneItemDetail . hasOwnProperty ( "taskTitle" ) ) { throw new Error ( "detailData has not the name param. Has it the correct Type? ->" + oneItemDetail ) ; }
_ . templateSettings . variable = "detailData" ;
var template = _ . template ( $ ( "script.statusDetail" ) . html ( ) ) ;
var $retval = $ ( template ( oneItemDetail ) ) ;
return $retval ;
}
WidgetBuilder . prototype . buildSpecialIndicatorSecondView = function ( secondViewData ) {
//presenterData= object {dataToDraw[], entityData[] //user/tasks data}
_ . templateSettings . variable = "indicator" ;
var template = _ . template ( $ ( "script.specialIndicatorMainPanel" ) . html ( ) ) ;
var $retval = $ ( template ( window . currentEntityData ) ) ;
//var indicatorPrincipalData = this.getIndicatorLoadedById(indicatorId);
//$retval.find(".sind-title-selector").text(indicatorPrincipalData.title);
$retval . find ( ".sind-index-selector" ) . text ( G _STRING . ID _EFFICIENCY _INDEX ) ;
$retval . find ( ".sind-cost-selector" ) . text ( G _STRING . ID _INEFFICIENCY _COST ) ;
$retval . find ( '.breadcrumb' ) . find ( 'li' ) . remove ( ) ;
$retval . find ( '.breadcrumb' ) . append ( '<li><a class="bread-back-selector" href="#"><i class="fa fa-chevron-left fa-fw"></i>' + window . currentIndicator . title + '</a></li>' ) ;
$retval . find ( '.breadcrumb' ) . append ( '<li><b>' + window . currentEntityData . name + '</b></li>' ) ;
2015-04-20 10:52:16 -04:00
this . setColorForInefficiency ( $retval . find ( ".sind-cost-number-selector" ) , window . currentEntityData ) ;
2015-04-17 15:17:24 -04:00
return $retval ;
} ;
2015-04-27 16:15:06 -04:00
WidgetBuilder . prototype . buildSpecialIndicatorSecondViewDetailPei = function ( oneItemDetail ) {
2015-04-17 15:17:24 -04:00
if ( oneItemDetail == null ) { throw new Error ( "oneItemDetail is null " ) ; }
if ( ! typeof ( oneItemDetail ) === 'object' ) { throw new Error ( "detailData is not and object ->" + oneItemDetail ) ; }
if ( ! oneItemDetail . hasOwnProperty ( "name" ) ) { throw new Error ( "buildSpecialIndicatorFirstViewDetail -> detailData has not the name param. Has it the correct Type? ->" + oneItemDetail ) ; }
_ . templateSettings . variable = "detailData" ;
2015-04-27 16:15:06 -04:00
var template = _ . template ( $ ( "script.specialIndicatorSecondViewDetailPei" ) . html ( ) ) ;
var $retval = $ ( template ( oneItemDetail ) ) ;
$retval . find ( ".detail-efficiency-selector" ) . text ( G _STRING . ID _EFFICIENCY _INDEX ) ;
$retval . find ( ".detail-cost-selector" ) . text ( G _STRING . ID _INEFFICIENCY _COST ) ;
this . setColorForInefficiency ( $retval . find ( ".detail-cost-number-selector" ) , oneItemDetail ) ;
return $retval ;
}
WidgetBuilder . prototype . buildSpecialIndicatorSecondViewDetailUei = function ( oneItemDetail ) {
if ( oneItemDetail == null ) { throw new Error ( "oneItemDetail is null " ) ; }
if ( ! typeof ( oneItemDetail ) === 'object' ) { throw new Error ( "detailData is not and object ->" + oneItemDetail ) ; }
if ( ! oneItemDetail . hasOwnProperty ( "name" ) ) { throw new Error ( "buildSpecialIndicatorFirstViewDetail -> detailData has not the name param. Has it the correct Type? ->" + oneItemDetail ) ; }
_ . templateSettings . variable = "detailData" ;
var template = _ . template ( $ ( "script.specialIndicatorSecondViewDetailUei" ) . html ( ) ) ;
var $retval = $ ( template ( oneItemDetail ) ) ;
$retval . find ( ".detail-efficiency-selector" ) . text ( G _STRING . ID _EFFICIENCY _INDEX ) ;
$retval . find ( ".detail-cost-selector" ) . text ( G _STRING . ID _INEFFICIENCY _COST ) ;
this . setColorForInefficiency ( $retval . find ( ".detail-cost-number-selector" ) , oneItemDetail ) ;
return $retval ;
}
WidgetBuilder . prototype . buildSpecialIndicatorSecondViewDetaiUei = function ( oneItemDetail ) {
if ( oneItemDetail == null ) { throw new Error ( "oneItemDetail is null " ) ; }
if ( ! typeof ( oneItemDetail ) === 'object' ) { throw new Error ( "detailData is not and object ->" + oneItemDetail ) ; }
if ( ! oneItemDetail . hasOwnProperty ( "name" ) ) { throw new Error ( "buildSpecialIndicatorFirstViewDetail -> detailData has not the name param. Has it the correct Type? ->" + oneItemDetail ) ; }
_ . templateSettings . variable = "detailData" ;
var template = _ . template ( $ ( "script.specialIndicatorSencondViewDetailUei" ) . html ( ) ) ;
2015-04-17 15:17:24 -04:00
var $retval = $ ( template ( oneItemDetail ) ) ;
$retval . find ( ".detail-efficiency-selector" ) . text ( G _STRING . ID _EFFICIENCY _INDEX ) ;
2015-04-20 10:52:16 -04:00
$retval . find ( ".detail-cost-selector" ) . text ( G _STRING . ID _INEFFICIENCY _COST ) ;
this . setColorForInefficiency ( $retval . find ( ".detail-cost-number-selector" ) , oneItemDetail ) ;
2015-04-17 15:17:24 -04:00
return $retval ;
}
WidgetBuilder . prototype . getIndicatorLoadedById = function ( searchedIndicatorId ) {
var retval = null ;
for ( key in window . loadedIndicators ) {
var indicator = window . loadedIndicators [ key ] ;
if ( indicator . id == searchedIndicatorId ) {
retval = indicator ;
}
}
if ( retval == null ) { throw new Error ( searchedIndicatorId + " was not found in the loaded indicators." ) ; }
return retval ;
}
2015-05-04 18:11:42 -04:00
WidgetBuilder . prototype . getDashboardLoadedById = function ( searchedDashboardId ) {
var retval = null ;
for ( key in window . loadedDashboards ) {
var dashboard = window . loadedDashboards [ key ] ;
if ( dashboard . id == searchedDashboardId ) {
retval = dashboard ;
}
}
if ( retval == null ) { throw new Error ( searchedIndicatorId + " was not found in the loaded indicators." ) ; }
return retval ;
}
2015-04-17 15:17:24 -04:00
WidgetBuilder . prototype . buildGeneralIndicatorFirstView = function ( indicatorData ) {
_ . templateSettings . variable = "indicator" ;
var template = _ . template ( $ ( "script.generalIndicatorMainPanel" ) . html ( ) ) ;
var $retval = $ ( template ( indicatorData ) ) ;
$retval . find ( ".ind-title-selector" ) . text ( window . currentIndicator . title ) ;
return $retval ;
}
2015-04-20 10:52:16 -04:00
WidgetBuilder . prototype . setColorForInefficiency = function ( $widget , indicatorData ) {
//turn red/gree the font according if is positive or negative: var $widget = $retval.find(".sind-cost-number-selector");
$widget . removeClass ( "red" ) ;
$widget . removeClass ( "green" ) ;
if ( indicatorData . inefficiencyCost >= 0 ) {
$widget . addClass ( "green" ) ;
}
else {
$widget . addClass ( "red" ) ;
}
}
2015-04-17 15:17:24 -04:00
/**********************************************************************/
helper = new ViewDashboardHelper ( ) ;
2016-03-29 11:21:17 -04:00
model = new ViewDashboardModel ( token , urlProxy , workspace , moneyUnit ) ;
2015-04-17 15:17:24 -04:00
presenter = new ViewDashboardPresenter ( model ) ;
window . loadedIndicators = [ ] ; //updated in das-title-selector.click->fillIndicatorWidgets, ready->fillIndicatorWidgets
2015-05-04 18:11:42 -04:00
window . loadedDashboards = [ ] ;
2015-04-17 15:17:24 -04:00
window . currentEntityData = null ;
window . currentIndicator = null ; //updated in ind-button-selector.click ->loadIndicator, ready->loadIndicator
window . currentDashboardId = null ;
2015-04-20 10:52:16 -04:00
window . currentDetailFunction = null ;
window . currentDetailList = null ;
2015-04-17 15:17:24 -04:00
$ ( document ) . ready ( function ( ) {
$ ( '#indicatorsGridStack' ) . gridstack ( ) ;
$ ( '#indicatorsDataGridStack' ) . gridstack ( ) ;
$ ( '#relatedDetailGridStack' ) . gridstack ( ) ;
2015-04-20 10:52:16 -04:00
$ ( '#sortListButton' ) . click ( function ( ) {
var btn = $ ( this ) ;
2015-06-03 10:31:39 -04:00
if ( btn . hasClass ( 'fa-arrow-up' ) ) {
btn . removeClass ( 'fa-arrow-up' ) ;
btn . addClass ( 'fa-arrow-down' ) ;
2015-04-20 10:52:16 -04:00
}
else {
2015-06-03 10:31:39 -04:00
btn . removeClass ( 'fa-arrow-down' ) ;
btn . addClass ( 'fa-arrow-up' ) ;
2015-04-20 10:52:16 -04:00
}
2015-04-17 15:17:24 -04:00
2015-04-20 10:52:16 -04:00
window . currentDetailFunction ( presenter . orderDataList (
window . currentDetailList ,
selectedOrderOfDetailList ( ) ) ) ;
//send scroll +1 and -1 to activate the show/hide event.
//both scrolls are sent cause if the scroll at the end
//scroll +1 has no effect but -1 yes
$ ( window ) . scrollTop ( $ ( window ) . scrollTop ( ) + 1 ) ;
$ ( window ) . scrollTop ( $ ( window ) . scrollTop ( ) - 1 ) ;
return false ;
} ) ;
/* Show on scroll functionality */
2015-04-17 15:17:24 -04:00
$ ( window ) . scroll ( function ( ) {
/* Check the location of each desired element */
$ ( '.hideme' ) . each ( function ( i ) {
var bottom _of _object = $ ( this ) . offset ( ) . top + $ ( this ) . outerHeight ( ) ;
var bottom _of _window = $ ( window ) . scrollTop ( ) + $ ( window ) . height ( ) ;
/* If the object is completely visible in the window, fade it in */
if ( bottom _of _window + 100 > bottom _of _object ) {
$ ( this ) . animate ( { 'opacity' : '1' } , 500 ) ;
$ ( this ) . removeClass ( 'hideme' ) ;
}
} ) ;
hideScrollIfAllDivsAreVisible ( ) ;
} ) ;
var isHover = false ;
$ ( '#scrollImg' ) . mouseover ( function ( ) {
isHover = true ;
var interval = window . setInterval ( function ( ) {
2015-04-20 10:52:16 -04:00
var newPos = $ ( window ) . scrollTop ( ) + 100 ;
2015-04-17 15:17:24 -04:00
$ ( window ) . scrollTop ( newPos ) ;
if ( isHover == false ) {
window . clearInterval ( interval ) ;
}
2015-04-20 10:52:16 -04:00
} , 200 ) ;
2015-04-17 15:17:24 -04:00
} ) ;
$ ( '#scrollImg' ) . mouseleave ( function ( ) {
isHover = false ;
} ) ;
//When some item is moved
$ ( '.grid-stack' ) . on ( 'change' , function ( e , items ) {
var widgets = [ ] ;
_ . map ( $ ( '.grid-stack .grid-stack-item:visible' ) , function ( el ) {
el = $ ( el ) ;
var item = el . data ( '_gridstack_node' ) ;
var idWidGet = el . data ( "indicator-id" ) ;
/ * i f ( f a v o r i t e = = a c t u a l D a s h I d ) {
favoriteData = 1 ;
} else {
favoriteData = 0 ;
} * /
2015-04-22 13:30:25 -04:00
if ( typeof idWidGet != "undefined" && el . hasClass ( 'ind-button-selector' ) ) {
2015-04-17 15:17:24 -04:00
var widgetsObj = {
'indicatorId' : idWidGet ,
'x' : item . x ,
'y' : item . y ,
'width' : item . width ,
'height' : item . height <= 1 ? 2 : item . height
}
widgets . push ( widgetsObj ) ;
}
} ) ;
var favoriteDasbhoardId = $ ( '.das-icon-selector.selected' ) . parent ( ) . data ( 'dashboard-id' ) ;
if ( favoriteDasbhoardId == null || favoriteDasbhoardId == 'undefined' ) { throw new Error ( 'No favorite dashboard detected' ) ; }
if ( widgets . length != 0 ) {
var dashboard = {
'dashId' : window . currentDashboardId ,
'dashFavorite' : ( ( window . currentDashboardId == favoriteDasbhoardId ) ? 1 : 0 ) ,
'dashData' : widgets
}
model . setPositionIndicator ( dashboard ) ;
}
} ) ;
$ ( 'body' ) . on ( 'click' , '.das-icon-selector' , function ( ) {
var dashboardId = $ ( this ) . parent ( ) . data ( 'dashboard-id' ) ;
$ ( '.das-icon-selector' ) . removeClass ( "selected" ) ;
$ ( this ) . addClass ( 'selected' ) ;
var dashboard = {
'dashId' : dashboardId ,
'dashFavorite' : 1 ,
'dashData' : ''
}
model . setPositionIndicator ( dashboard ) ;
} ) ;
$ ( '#dashboardsList' ) . on ( 'click' , '.das-title-selector' , function ( ) {
var dashboardId = $ ( this ) . parent ( ) . data ( 'dashboard-id' ) ;
window . currentDashboardId = dashboardId ;
presenter . getDashboardIndicators ( dashboardId , defaultInitDate ( ) , defaultEndDate ( ) )
. done ( function ( indicatorsVM ) {
fillIndicatorWidgets ( indicatorsVM ) ;
2015-04-17 16:10:51 -04:00
loadIndicator ( getFavoriteIndicator ( ) . id , defaultInitDate ( ) , defaultEndDate ( ) ) ;
2015-05-04 18:11:42 -04:00
setActiveDashboard ( ) ;
2015-04-17 15:17:24 -04:00
} ) ;
} ) ;
$ ( '#indicatorsGridStack' ) . on ( 'click' , '.ind-button-selector' , function ( ) {
var indicatorId = $ ( this ) . data ( 'indicator-id' ) ;
2015-04-17 16:10:51 -04:00
loadIndicator ( indicatorId , defaultInitDate ( ) , defaultEndDate ( ) ) ;
2015-04-17 15:17:24 -04:00
} ) ;
2015-06-11 11:27:12 -04:00
$ ( '#indicatorsGridStack' ) . on ( 'click' , '.status-indicator-low' , function ( ) {
locationCases ( 'OVERDUE' ) ;
} ) ;
$ ( '#indicatorsGridStack' ) . on ( 'click' , '.status-indicator-medium' , function ( ) {
locationCases ( 'AT_RISK' ) ;
} ) ;
$ ( '#indicatorsGridStack' ) . on ( 'click' , '.status-indicator-high' , function ( ) {
locationCases ( 'ON_TIME' ) ;
} ) ;
2015-04-17 15:17:24 -04:00
$ ( 'body' ) . on ( 'click' , '.bread-back-selector' , function ( ) {
var indicatorId = window . currentIndicator . id ;
2015-04-17 16:10:51 -04:00
loadIndicator ( indicatorId , defaultInitDate ( ) , defaultEndDate ( ) ) ;
2015-04-17 15:17:24 -04:00
return false ;
} ) ;
$ ( '#relatedDetailGridStack' ) . on ( 'click' , '.detail-button-selector' , function ( ) {
var detailId = $ ( this ) . data ( 'detail-id' ) ;
window . currentEntityData = { "entityId" : $ ( this ) . data ( 'detail-id' ) ,
"indicatorId" : $ ( this ) . data ( 'indicator-id' ) ,
"efficiencyIndexToShow" : $ ( this ) . data ( 'detail-index' ) ,
2015-04-20 10:52:16 -04:00
"inefficiencyCostToShow" : $ ( this ) . data ( 'detail-cost-to-show' ) ,
"inefficiencyCost" : $ ( this ) . data ( 'detail-cost' ) ,
2015-04-17 15:17:24 -04:00
"name" : $ ( this ) . data ( 'detail-name' )
} ;
2015-04-17 16:10:51 -04:00
presenter . getSpecialIndicatorSecondLevel ( detailId , window . currentIndicator . type , defaultInitDate ( ) , defaultEndDate ( ) )
2015-04-17 15:17:24 -04:00
. done ( function ( viewModel ) {
fillSpecialIndicatorSecondView ( viewModel ) ;
} ) ;
} ) ;
2015-06-02 12:29:07 -04:00
2015-06-12 10:24:35 -04:00
initialDraw ( ) ;
2015-06-11 13:38:27 -04:00
2015-06-11 09:33:03 -04:00
2015-04-17 15:17:24 -04:00
} ) ;
2015-04-20 10:52:16 -04:00
var hideScrollIfAllDivsAreVisible = function ( ) {
if ( $ ( '.hideme' ) . length <= 0 ) {
$ ( '#scrollImg' ) . hide ( ) ;
}
else {
2015-04-27 17:26:14 -04:00
$ ( '#scrollImg' ) . css ( 'visibility' , 'visible' ) ;
2015-04-20 10:52:16 -04:00
$ ( '#scrollImg' ) . show ( ) ;
}
}
2015-04-27 17:26:14 -04:00
var hideTitleAndSortDiv = function ( ) {
if ( window . currentIndicator == null ) {
$ ( '#relatedLabel' ) . hide ( ) ;
}
switch ( window . currentIndicator . type ) {
case "1010" :
case "1030" :
2015-04-29 08:52:32 -04:00
if ( $ ( '.detail-button-selector' ) . length == 0 ) {
$ ( '#relatedLabel' ) . hide ( ) ;
//$('#relatedLabel').find('h3').text(G_STRING['ID_NO_DATA_TO_DISPLAY']);
}
else {
$ ( '#relatedLabel' ) . css ( 'visibility' , 'visible' ) ;
$ ( '#relatedLabel' ) . show ( ) ;
}
2015-04-27 17:26:14 -04:00
break ;
default :
$ ( '#relatedLabel' ) . hide ( ) ;
break ;
}
}
2015-04-20 10:52:16 -04:00
var selectedOrderOfDetailList = function ( ) {
2015-06-03 10:31:39 -04:00
return ( $ ( '#sortListButton' ) . hasClass ( 'fa-arrow-up' ) ? "up" : "down" ) ;
2015-04-20 10:52:16 -04:00
}
2015-04-29 08:52:32 -04:00
var selectDefaultMonthAndYear = function ( ) {
var compareDate = new Date ( ) ;
2015-05-06 08:42:02 -04:00
compareDate . setDate ( 1 ) ;
2015-04-29 08:52:32 -04:00
compareDate . setMonth ( compareDate . getMonth ( ) - 1 ) ;
var compareMonth = compareDate . getMonth ( ) + 1 ;
2015-05-06 08:42:02 -04:00
var compareYear = compareDate . getFullYear ( ) ;
2015-06-11 09:33:03 -04:00
$ ( '#endPeriodList' ) . val ( compareMonth ) ;
$ ( '#endYearList' ) . val ( compareYear ) ;
2015-04-29 08:52:32 -04:00
}
2015-05-04 18:11:42 -04:00
var setActiveDashboard = function ( ) {
var builder = new WidgetBuilder ( ) ;
var dashboard = builder . getDashboardLoadedById ( window . currentDashboardId ) ;
if ( dashboard == null ) {
return ;
}
2015-06-19 13:21:37 -04:00
$ ( '#titleH4' ) . html ( dashboard . title ) ;
2015-05-04 18:11:42 -04:00
}
2015-04-20 10:52:16 -04:00
var initialDraw = function ( ) {
2015-04-29 12:15:59 -04:00
selectDefaultMonthAndYear ( ) ;
2015-04-17 15:17:24 -04:00
presenter . getUserDashboards ( pageUserId )
. then ( function ( dashboardsVM ) {
fillDashboardsList ( dashboardsVM ) ;
2015-04-21 10:21:12 -04:00
if ( window . currentDashboardId == null ) { return ; }
2015-06-12 10:24:35 -04:00
tsPresenter . initializePresenter ( window . currentDashboardId )
. done ( function ( data ) {
bindTimeSeriesLists ( tsPresenter ) ;
/**** window initialization with favorite dashboard*****/
presenter . getDashboardIndicators ( window . currentDashboardId , defaultInitDate ( ) , defaultEndDate ( ) )
. done ( function ( indicatorsVM ) {
fillIndicatorWidgets ( indicatorsVM ) ;
loadIndicator ( getFavoriteIndicator ( ) . id , defaultInitDate ( ) , defaultEndDate ( ) ) ;
setActiveDashboard ( ) ;
} ) ;
} ) ;
2015-04-17 15:17:24 -04:00
} ) ;
}
2015-04-20 10:52:16 -04:00
var loadIndicator = function ( indicatorId , initDate , endDate ) {
2015-06-30 17:47:47 -04:00
$ ( '#indicatorsView' ) . show ( ) ;
$ ( '#scrollImg' ) . show ( ) ;
$ ( '#compareDiv' ) . hide ( ) ;
2015-04-21 10:21:12 -04:00
if ( indicatorId == null || indicatorId === undefined ) { return ; }
2015-04-17 15:17:24 -04:00
var builder = new WidgetBuilder ( ) ;
window . currentIndicator = builder . getIndicatorLoadedById ( indicatorId ) ;
presenter . getIndicatorData ( indicatorId , window . currentIndicator . type , initDate , endDate )
. done ( function ( viewModel ) {
switch ( window . currentIndicator . type ) {
case "1010" :
case "1030" :
fillSpecialIndicatorFirstView ( viewModel ) ;
break ;
case "1050" :
2015-06-17 13:47:52 -04:00
//fillStatusIndicatorFirstView(viewModel);
2015-04-17 15:17:24 -04:00
break ;
default :
fillGeneralIndicatorFirstView ( viewModel ) ;
break ;
}
2015-04-30 15:36:27 -04:00
hideScrollIfAllDivsAreVisible ( ) ;
hideTitleAndSortDiv ( ) ;
2015-06-11 13:59:54 -04:00
$ ( '[data-toggle="tooltip"]' ) . tooltip ( {
animated : 'fade' ,
2015-07-09 15:50:49 -04:00
placement : 'top'
2015-06-11 13:59:54 -04:00
} ) ;
2015-04-17 15:17:24 -04:00
} ) ;
2015-06-11 13:38:27 -04:00
} ;
2015-04-17 15:17:24 -04:00
2015-04-20 10:52:16 -04:00
var setIndicatorActiveMarker = function ( ) {
2015-04-17 15:17:24 -04:00
$ ( '.panel-footer' ) . each ( function ( ) {
$ ( this ) . removeClass ( 'panel-active' ) ;
var indicatorId = $ ( this ) . parents ( '.ind-button-selector' ) . data ( 'indicator-id' ) ;
if ( window . currentIndicator . id == indicatorId ) {
$ ( this ) . addClass ( 'panel-active' ) ;
}
} ) ;
}
2015-04-20 10:52:16 -04:00
var getFavoriteIndicator = function ( ) {
2015-04-17 15:17:24 -04:00
var retval = ( window . loadedIndicators . length > 0 )
? window . loadedIndicators [ 0 ]
: null ;
for ( key in window . loadedIndicators ) {
var indicator = window . loadedIndicators [ key ] ;
if ( indicator . favorite == 1 ) {
retval = indicator ;
}
}
if ( retval == null ) { throw new Error ( 'No favorites found.' ) ; }
return retval ;
}
2015-04-20 10:52:16 -04:00
var defaultInitDate = function ( ) {
2015-04-17 15:17:24 -04:00
var date = new Date ( ) ;
var dateMonth = date . getMonth ( ) ;
var dateYear = date . getFullYear ( ) ;
2015-07-09 15:50:49 -04:00
var initDate = new Date ( dateYear , dateMonth , 1 ) ;
initDate . setMonth ( initDate . getMonth ( ) - 1 ) ;
var retval = $ ( '#initYearList' ) . val ( ) + '-' + ( initDate . getMonth ( ) + 1 ) + '-' + '01' ;
return retval ;
2015-04-17 15:17:24 -04:00
}
2015-04-20 10:52:16 -04:00
var defaultEndDate = function ( ) {
2015-07-09 15:50:49 -04:00
var endDate = helper . periodEndDate ( $ ( '#periodicityList' ) . val ( ) , $ ( '#endPeriodList' ) . val ( ) , $ ( '#endYearList' ) . val ( ) ) ;
var retval = $ ( '#endYearList' ) . val ( ) + '-' + $ ( '#endPeriodList' ) . val ( ) + '-' + endDate . getDate ( ) ;
return retval ;
2015-04-17 15:17:24 -04:00
}
2015-04-20 10:52:16 -04:00
var fillDashboardsList = function ( presenterData ) {
2015-04-17 15:17:24 -04:00
if ( presenterData == null || presenterData . length == 0 ) {
2015-05-07 15:26:07 -04:00
$ ( '#dashboardMessage' ) . text ( G _STRING [ 'ID_GRID_PAGE_NO_DASHBOARD_MESSAGE' ] ) ;
2015-06-19 13:21:37 -04:00
$ ( '#titleH4' ) . html ( G _STRING [ 'ID_GRID_PAGE_NO_DASHBOARD_MESSAGE' ] ) ;
2015-05-07 15:26:07 -04:00
$ ( '#compareIndicators' ) . hide ( ) ;
2015-04-17 15:17:24 -04:00
}
_ . templateSettings . variable = "dashboard" ;
var template = _ . template ( $ ( "script.dashboardButtonTemplate" ) . html ( ) )
2015-05-04 18:11:42 -04:00
window . loadedDashboards = presenterData ;
2015-04-17 15:17:24 -04:00
for ( key in presenterData ) {
var dashboard = presenterData [ key ] ;
2015-07-09 15:50:49 -04:00
dashboard . title = helper . unescape ( dashboard . title ) ;
2015-04-17 15:17:24 -04:00
$ ( '#dashboardsList' ) . append ( template ( dashboard ) ) ;
if ( dashboard . isFavorite == 1 ) {
window . currentDashboardId = dashboard . id ;
$ ( '#dashboardButton-' + dashboard . id )
. find ( '.das-icon-selector' )
. addClass ( 'selected' ) ;
}
}
} ;
2015-04-20 10:52:16 -04:00
var fillIndicatorWidgets = function ( presenterData ) {
2015-04-21 10:21:12 -04:00
if ( presenterData == null || presenterData === undefined ) { return ; }
2015-04-17 15:17:24 -04:00
var widgetBuilder = new WidgetBuilder ( ) ;
var grid = $ ( '#indicatorsGridStack' ) . data ( 'gridstack' ) ;
grid . remove _all ( ) ;
window . loadedIndicators = presenterData ;
$ . each ( presenterData , function ( key , indicator ) {
var $widget = widgetBuilder . getIndicatorWidget ( indicator ) ;
grid . add _widget ( $widget , indicator . toDrawX , indicator . toDrawY , indicator . toDrawWidth , indicator . toDrawHeight , true ) ;
var $title = $widget . find ( '.ind-title-selector' ) ;
if ( indicator . favorite == "1" ) {
$title . addClass ( "panel-active" ) ;
}
} ) ;
}
2015-04-20 10:52:16 -04:00
var fillStatusIndicatorFirstView = function ( presenterData ) {
2015-04-17 15:17:24 -04:00
var widgetBuilder = new WidgetBuilder ( ) ;
var panel = $ ( '#indicatorsDataGridStack' ) . data ( 'gridstack' ) ;
panel . remove _all ( ) ;
$ ( '#relatedDetailGridStack' ) . data ( 'gridstack' ) . remove _all ( ) ;
var $widget = widgetBuilder . buildStatusIndicatorFirstView ( presenterData ) ;
panel . add _widget ( $widget , 0 , 15 , 20 , 4.7 , true ) ;
var graphParams1 = {
canvas : {
containerId : 'graph1' ,
width : 300 ,
height : 300 ,
2015-04-29 15:50:19 -04:00
stretch : true ,
noDataText : G _STRING . ID _DISPLAY _EMPTY
2015-04-17 15:17:24 -04:00
} ,
graph : {
2015-04-21 10:21:12 -04:00
allowDrillDown : true ,
2015-04-17 15:17:24 -04:00
allowTransition : true ,
2015-05-06 14:52:14 -04:00
showTip : true ,
2015-04-17 15:17:24 -04:00
allowZoom : false ,
2015-04-21 10:21:12 -04:00
showLabels : true
2015-04-17 15:17:24 -04:00
}
} ;
2015-04-22 13:30:25 -04:00
2015-04-17 15:17:24 -04:00
var graph1 = new PieChart ( presenterData . graph1Data , graphParams1 , null , null ) ;
graph1 . drawChart ( ) ;
var graphParams2 = graphParams1 ;
graphParams2 . canvas . containerId = "graph2" ;
var graph2 = new PieChart ( presenterData . graph2Data , graphParams2 , null , null ) ;
graph2 . drawChart ( ) ;
var graphParams3 = graphParams1 ;
graphParams3 . canvas . containerId = "graph3" ;
var graph3 = new PieChart ( presenterData . graph3Data , graphParams3 , null , null ) ;
graph3 . drawChart ( ) ;
2015-05-29 11:45:06 -04:00
var indicatorPrincipalData = widgetBuilder . getIndicatorLoadedById ( presenterData . id )
2015-04-17 15:17:24 -04:00
setIndicatorActiveMarker ( ) ;
}
2015-04-20 10:52:16 -04:00
var fillStatusIndicatorFirstViewDetail = function ( presenterData ) {
2015-04-17 15:17:24 -04:00
var widgetBuilder = new WidgetBuilder ( ) ;
var gridDetail = $ ( '#relatedDetailGridStack' ) . data ( 'gridstack' ) ;
//gridDetail.remove_all();
$ . each ( presenterData . dataList , function ( index , dataItem ) {
var $widget = widgetBuilder . buildStatusIndicatorFirstViewDetail ( dataItem ) ;
var x = ( index % 2 == 0 ) ? 6 : 0 ;
gridDetail . add _widget ( $widget , x , 15 , 6 , 2 , true ) ;
} ) ;
if ( window . currentIndicator . type == "1010" ) {
$ ( '#relatedLabel' ) . find ( 'h3' ) . text ( G _STRING [ 'ID_RELATED_PROCESS' ] ) ;
}
if ( window . currentIndicator . type == "1030" ) {
$ ( '#relatedLabel' ) . find ( 'h3' ) . text ( G _STRING [ 'ID_RELATED_GROUPS' ] ) ;
}
if ( window . currentIndicator . type == "1050" ) {
$ ( '#relatedLabel' ) . find ( 'h3' ) . text ( G _STRING [ 'ID_RELATED_PROCESS' ] ) ;
}
}
2015-04-20 10:52:16 -04:00
var fillSpecialIndicatorFirstView = function ( presenterData ) {
2015-04-17 15:17:24 -04:00
var widgetBuilder = new WidgetBuilder ( ) ;
var panel = $ ( '#indicatorsDataGridStack' ) . data ( 'gridstack' ) ;
panel . remove _all ( ) ;
$ ( '#relatedDetailGridStack' ) . data ( 'gridstack' ) . remove _all ( ) ;
var $widget = widgetBuilder . buildSpecialIndicatorFirstView ( presenterData ) ;
panel . add _widget ( $widget , 0 , 15 , 20 , 4.7 , true ) ;
var peiParams = {
canvas : {
containerId : 'specialIndicatorGraph' ,
width : 300 ,
height : 300 ,
2015-04-29 15:50:19 -04:00
stretch : true ,
noDataText : G _STRING . ID _NO _INEFFICIENT _PROCESSES
2015-04-17 15:17:24 -04:00
} ,
graph : {
allowDrillDown : false ,
allowTransition : true ,
2015-05-06 14:52:14 -04:00
showTip : true ,
2015-04-17 15:17:24 -04:00
allowZoom : false ,
2015-04-20 10:52:16 -04:00
gapWidth : 0.3 ,
2015-04-17 15:17:24 -04:00
useShadows : true ,
thickness : 30 ,
2015-04-21 10:21:12 -04:00
showLabels : true
2015-04-17 15:17:24 -04:00
}
} ;
var ueiParams = {
canvas : {
containerId : 'specialIndicatorGraph' ,
width : 500 ,
height : 300 ,
2015-04-29 15:50:19 -04:00
stretch : true ,
noDataText : G _STRING . ID _NO _INEFFICIENT _USER _GROUPS
2015-04-17 15:17:24 -04:00
} ,
graph : {
allowDrillDown : false ,
allowTransition : true ,
2015-04-28 14:55:51 -04:00
axisX : { showAxis : true , label : G _STRING [ 'ID_GROUPS' ] } ,
axisY : { showAxis : true , label : G _STRING [ 'ID_COSTS' ] } ,
2015-04-17 15:17:24 -04:00
gridLinesX : false ,
gridLinesY : true ,
2015-05-06 14:52:14 -04:00
showTip : true ,
2015-04-17 15:17:24 -04:00
allowZoom : false ,
useShadows : true ,
2015-05-05 16:48:13 -04:00
paddingTop : 50 ,
colorPalette : [ '#5486bf' , '#bf8d54' , '#acb30c' , '#7a0c0c' , '#bc0000' , '#906090' , '#007efb' , '#62284a' , '#0c7a7a' , '#74a9a9' ]
2015-04-17 15:17:24 -04:00
}
} ;
2015-05-29 11:45:06 -04:00
var indicatorPrincipalData = widgetBuilder . getIndicatorLoadedById ( presenterData . id )
2015-04-17 15:17:24 -04:00
if ( indicatorPrincipalData . type == "1010" ) {
var graph = new Pie3DChart ( presenterData . dataToDraw , peiParams , null , null ) ;
graph . drawChart ( ) ;
2015-04-20 10:52:16 -04:00
//the pie chart goes to much upwards,so a margin is added:
$ ( '#specialIndicatorGraph' ) . css ( 'margin-top' , '60px' ) ;
2015-04-17 15:17:24 -04:00
}
if ( indicatorPrincipalData . type == "1030" ) {
var graph = new BarChart ( presenterData . dataToDraw , ueiParams , null , null ) ;
graph . drawChart ( ) ;
}
2015-04-20 10:52:16 -04:00
this . fillSpecialIndicatorFirstViewDetail ( presenter . orderDataList ( presenterData . data , selectedOrderOfDetailList ( ) ) ) ;
2015-04-17 15:17:24 -04:00
setIndicatorActiveMarker ( ) ;
}
2015-04-20 10:52:16 -04:00
var fillSpecialIndicatorFirstViewDetail = function ( list ) {
2015-04-17 15:17:24 -04:00
//presenterData = { id: "indId", efficiencyIndex: "0.11764706", efficiencyVariation: -0.08235294,
// inefficiencyCost: "-127.5000", inefficiencyCostToShow: -127, efficiencyIndexToShow: 0.12
// data: {indicatorId, uid, name, averateTime...}, dataToDraw: [{datalabe, value}] }
var widgetBuilder = new WidgetBuilder ( ) ;
var gridDetail = $ ( '#relatedDetailGridStack' ) . data ( 'gridstack' ) ;
2015-04-20 10:52:16 -04:00
gridDetail . remove _all ( ) ;
2015-04-17 15:17:24 -04:00
2015-05-29 11:45:06 -04:00
window . currentDetailList = list ;
2015-04-20 10:52:16 -04:00
window . currentDetailFunction = fillSpecialIndicatorFirstViewDetail ;
$ . each ( list , function ( index , dataItem ) {
2015-04-17 15:17:24 -04:00
var $widget = widgetBuilder . buildSpecialIndicatorFirstViewDetail ( dataItem ) ;
var x = ( index % 2 == 0 ) ? 6 : 0 ;
2015-04-20 10:52:16 -04:00
//the first 2 elements are not hidden
if ( index < 2 ) {
$widget . removeClass ( "hideme" ) ;
}
2015-04-17 15:17:24 -04:00
gridDetail . add _widget ( $widget , x , 15 , 6 , 2 , true ) ;
} ) ;
2015-05-29 11:45:06 -04:00
if ( window . currentIndicator . type == "1010" ) {
$ ( '#relatedLabel' ) . find ( 'h3' ) . text ( G _STRING [ 'ID_RELATED_PROCESS' ] ) ;
}
if ( window . currentIndicator . type == "1030" ) {
$ ( '#relatedLabel' ) . find ( 'h3' ) . text ( G _STRING [ 'ID_RELATED_GROUPS' ] ) ;
}
hideScrollIfAllDivsAreVisible ( ) ;
2015-04-17 15:17:24 -04:00
}
2015-04-20 10:52:16 -04:00
var fillSpecialIndicatorSecondView = function ( presenterData ) {
2015-04-17 15:17:24 -04:00
//presenterData= object {dataToDraw[], entityData[] //user/tasks data}
var widgetBuilder = new WidgetBuilder ( ) ;
var panel = $ ( '#indicatorsDataGridStack' ) . data ( 'gridstack' ) ;
panel . remove _all ( ) ;
var $widget = widgetBuilder . buildSpecialIndicatorSecondView ( presenterData ) ;
panel . add _widget ( $widget , 0 , 15 , 20 , 4.7 , true ) ;
var detailParams = {
canvas : {
containerId : 'specialIndicatorGraph' ,
width : 300 ,
height : 300 ,
stretch : true
} ,
graph : {
allowTransition : false ,
allowDrillDown : true ,
2015-05-06 14:52:14 -04:00
showTip : true ,
2015-04-17 15:17:24 -04:00
allowZoom : false ,
useShadows : false ,
gridLinesX : true ,
gridLinesY : true ,
area : { visible : false , css : "area" } ,
2015-04-28 14:55:51 -04:00
axisX : { showAxis : true , label : G _STRING [ 'ID_USER' ] } ,
axisY : { showAxis : true , label : G _STRING [ 'ID_COSTS' ] } ,
2015-05-05 16:48:13 -04:00
showErrorBars : true ,
colorPalette : [ '#5486bf' , '#bf8d54' , '#acb30c' , '#7a0c0c' , '#bc0000' , '#906090' , '#007efb' , '#62284a' , '#0c7a7a' , '#74a9a9' ]
2015-04-17 15:17:24 -04:00
}
} ;
var indicatorPrincipalData = widgetBuilder . getIndicatorLoadedById ( window . currentEntityData . indicatorId ) ;
if ( window . currentIndicator . type == "1010" ) {
2015-04-28 14:55:51 -04:00
detailParams . graph . axisX . label = G _STRING [ 'ID_TASK' ] ;
2015-04-29 15:50:19 -04:00
detailParams . canvas . noDataText = G _STRING [ 'ID_NO_INEFFICIENT_TASKS' ] ;
2015-04-17 16:10:51 -04:00
var graph = new BarChart ( presenterData . dataToDraw , detailParams , null , null ) ;
2015-04-17 15:17:24 -04:00
graph . drawChart ( ) ;
}
if ( window . currentIndicator . type == "1030" ) {
2015-04-29 15:50:19 -04:00
detailParams . canvas . noDataText = G _STRING [ 'ID_NO_INEFFICIENT_USERS' ] ;
2015-04-17 15:17:24 -04:00
var graph = new BarChart ( presenterData . dataToDraw , detailParams , null , null ) ;
graph . drawChart ( ) ;
}
2015-04-20 10:52:16 -04:00
this . fillSpecialIndicatorSecondViewDetail ( presenter . orderDataList ( presenterData . entityData , selectedOrderOfDetailList ( ) ) ) ;
2015-07-09 15:50:49 -04:00
$ ( '[data-toggle="tooltip"]' ) . tooltip ( {
animated : 'fade' ,
placement : 'top'
} ) ;
2015-04-17 15:17:24 -04:00
}
2015-04-20 10:52:16 -04:00
var fillSpecialIndicatorSecondViewDetail = function ( list ) {
2015-04-17 15:17:24 -04:00
//presenterData = { entityData: Array[{name,uid,inefficiencyCost,
// inefficiencyIndex, deviationTime,
// averageTime}],
// dataToDraw: Array[{datalabel, value}] }
var widgetBuilder = new WidgetBuilder ( ) ;
var gridDetail = $ ( '#relatedDetailGridStack' ) . data ( 'gridstack' ) ;
gridDetail . remove _all ( ) ;
2015-04-20 10:52:16 -04:00
window . currentDetailList = list ;
window . currentDetailFunction = fillSpecialIndicatorSecondViewDetail ;
$ . each ( list , function ( index , dataItem ) {
2015-04-27 16:15:06 -04:00
if ( window . currentIndicator . type == "1010" ) {
var $widget = widgetBuilder . buildSpecialIndicatorSecondViewDetailPei ( dataItem ) ;
}
if ( window . currentIndicator . type == "1030" ) {
var $widget = widgetBuilder . buildSpecialIndicatorSecondViewDetailUei ( dataItem ) ;
}
2015-04-17 15:17:24 -04:00
var x = ( index % 2 == 0 ) ? 6 : 0 ;
2015-04-20 10:52:16 -04:00
//the first 2 elements are not hidden
if ( index < 2 ) {
$widget . removeClass ( "hideme" ) ;
}
2015-04-17 15:17:24 -04:00
gridDetail . add _widget ( $widget , x , 15 , 6 , 2 , true ) ;
} ) ;
if ( window . currentIndicator . type == "1010" ) {
$ ( '#relatedLabel' ) . find ( 'h3' ) . text ( G _STRING [ 'ID_RELATED_TASKS' ] ) ;
}
if ( window . currentIndicator . type == "1030" ) {
$ ( '#relatedLabel' ) . find ( 'h3' ) . text ( G _STRING [ 'ID_RELATED_USERS' ] ) ;
}
2015-04-20 10:52:16 -04:00
hideScrollIfAllDivsAreVisible ( ) ;
2015-04-17 15:17:24 -04:00
}
2015-04-20 10:52:16 -04:00
var fillGeneralIndicatorFirstView = function ( presenterData ) {
2015-04-17 15:17:24 -04:00
var widgetBuilder = new WidgetBuilder ( ) ;
var panel = $ ( '#indicatorsDataGridStack' ) . data ( 'gridstack' ) ;
panel . remove _all ( ) ;
$ ( '#relatedDetailGridStack' ) . data ( 'gridstack' ) . remove _all ( ) ;
var $widget = widgetBuilder . buildGeneralIndicatorFirstView ( presenterData ) ;
panel . add _widget ( $widget , 0 , 15 , 20 , 4.7 , true ) ;
$ ( '#relatedLabel' ) . find ( 'h3' ) . text ( '' ) ;
var generalLineParams1 = {
canvas : {
containerId : 'generalGraph1' ,
width : 300 ,
height : 300 ,
stretch : true
} ,
graph : {
allowTransition : false ,
allowDrillDown : true ,
2015-05-06 14:52:14 -04:00
showTip : true ,
2015-04-17 15:17:24 -04:00
allowZoom : false ,
useShadows : false ,
gridLinesX : true ,
gridLinesY : true ,
area : { visible : false , css : "area" } ,
axisX : { showAxis : true , label : G _STRING . ID _PROCESS _TASKS } ,
axisY : { showAxis : true , label : G _STRING . ID _TIME _HOURS } ,
2015-07-23 17:43:02 -04:00
marker : { ratio : 5 , css : "line-chart-point" } ,
2015-04-17 15:17:24 -04:00
showErrorBars : false
}
} ;
var generalLineParams2 = {
canvas : {
containerId : 'generalGraph2' ,
width : 300 ,
height : 300 ,
stretch : true
} ,
graph : {
allowTransition : false ,
allowDrillDown : true ,
2015-05-06 14:52:14 -04:00
showTip : true ,
2015-04-17 15:17:24 -04:00
allowZoom : false ,
useShadows : false ,
gridLinesX : true ,
gridLinesY : true ,
area : { visible : false , css : "area" } ,
axisX : { showAxis : true , label : G _STRING . ID _PROCESS _TASKS } ,
axisY : { showAxis : true , label : G _STRING . ID _TIME _HOURS } ,
showErrorBars : false
}
} ;
var generalBarParams1 = {
canvas : {
containerId : 'generalGraph1' ,
width : 300 ,
height : 300 ,
stretch : true
} ,
graph : {
allowDrillDown : false ,
allowTransition : true ,
axisX : { showAxis : true , label : G _STRING . ID _YEAR } ,
2015-04-28 14:55:51 -04:00
axisY : { showAxis : true , label : G _STRING . ID _TIME _HOURS } ,
2015-04-17 15:17:24 -04:00
gridLinesX : false ,
gridLinesY : true ,
2015-05-06 14:52:14 -04:00
showTip : true ,
2015-04-17 15:17:24 -04:00
allowZoom : false ,
useShadows : true ,
paddingTop : 50 ,
colorPalette : [ '#5486bf' , '#bf8d54' , '#acb30c' , '#7a0c0c' , '#bc0000' , '#906090' , '#007efb' , '#62284a' , '#0c7a7a' , '#74a9a9' ]
}
} ;
var generalBarParams2 = {
canvas : {
containerId : 'generalGraph2' ,
width : 300 ,
height : 300 ,
stretch : true
} ,
graph : {
allowDrillDown : false ,
allowTransition : true ,
axisX : { showAxis : true , label : G _STRING . ID _YEAR } ,
2015-04-28 14:55:51 -04:00
axisY : { showAxis : true , label : G _STRING . ID _TIME _HOURS } ,
2015-04-17 15:17:24 -04:00
gridLinesX : false ,
gridLinesY : true ,
2015-05-06 14:52:14 -04:00
showTip : true ,
2015-04-17 15:17:24 -04:00
allowZoom : false ,
useShadows : true ,
paddingTop : 50 ,
colorPalette : [ '#5486bf' , '#bf8d54' , '#acb30c' , '#7a0c0c' , '#bc0000' , '#906090' , '#007efb' , '#62284a' , '#0c7a7a' , '#74a9a9' ]
}
} ;
var graph1 = null ;
if ( presenterData . graph1Type == '10' ) {
generalBarParams1 . graph . axisX . label = presenterData . graph1XLabel ;
generalBarParams1 . graph . axisY . label = presenterData . graph1YLabel ;
graph1 = new BarChart ( presenterData . graph1Data , generalBarParams1 , null , null ) ;
} else {
generalLineParams1 . graph . axisX . label = presenterData . graph1XLabel ;
generalLineParams1 . graph . axisY . label = presenterData . graph1YLabel ;
graph1 = new LineChart ( presenterData . graph1Data , generalLineParams1 , null , null ) ;
}
graph1 . drawChart ( ) ;
var graph2 = null ;
if ( presenterData . graph2Type == '10' ) {
generalBarParams2 . graph . axisX . label = presenterData . graph2XLabel ;
generalBarParams2 . graph . axisY . label = presenterData . graph2YLabel ;
graph2 = new BarChart ( presenterData . graph2Data , generalBarParams2 , null , null ) ;
} else {
generalLineParams2 . graph . axisX . label = presenterData . graph2XLabel ;
generalLineParams2 . graph . axisY . label = presenterData . graph2YLabel ;
graph2 = new LineChart ( presenterData . graph2Data , generalLineParams2 , null , null ) ;
}
graph2 . drawChart ( ) ;
setIndicatorActiveMarker ( ) ;
}
2015-05-29 11:45:06 -04:00
var animateProgress = function ( indicatorItem , widget ) {
2015-04-17 15:17:24 -04:00
var getRequestAnimationFrame = function ( ) {
return window . requestAnimationFrame ||
window . webkitRequestAnimationFrame ||
window . mozRequestAnimationFrame ||
window . oRequestAnimationFrame ||
window . msRequestAnimationFrame ||
function ( callback ) {
window . setTimeout ( enroute , 1 / 60 * 1000 ) ;
} ;
} ;
var fpAnimationFrame = getRequestAnimationFrame ( ) ;
var i = 0 ;
var j = 0 ;
var indicator = indicatorItem ;
var animacion = function ( ) {
var intComparative = parseInt ( indicator . comparative ) ;
var divId = "#indicatorButton" + indicator . id ;
var $valueLabel = widget
. find ( '.ind-value-selector' ) ;
var $progressBar = widget
. find ( '.ind-progress-selector' ) ;
if ( ! ( $valueLabel . length > 0 ) ) { throw new Error ( '"No ind-value-selector found for " + divId' ) ; }
this . helper . assert ( $progressBar . length > 0 , "No ind-progress-selector found for " + divId ) ;
$progressBar . attr ( 'aria-valuemax' , intComparative ) ;
var indexToPaint = Math . min ( indicator . value * 100 / intComparative , 100 ) ;
if ( i <= indexToPaint ) {
$progressBar . css ( 'width' , i + '%' ) . attr ( 'aria-valuenow' , i ) ;
i ++ ;
fpAnimationFrame ( animacion ) ;
}
if ( j <= indicator . value ) {
$valueLabel . text ( j + "%" ) ;
j ++ ;
fpAnimationFrame ( animacion ) ;
}
}
fpAnimationFrame ( animacion ) ;
2015-05-29 11:45:06 -04:00
} ;
2015-04-17 15:17:24 -04:00
2015-06-11 11:27:12 -04:00
var createCookie = function ( name , value , time ) {
if ( time ) {
var date = new Date ( ) ;
date . setTime ( date . getTime ( ) + ( time * 24 * 60 * 60 * 1000 ) ) ;
var expires = "; expires=" + date . toUTCString ( ) ;
} else {
var expires = "" ;
}
document . cookie = name + "=" + value + expires + "; path=/sys" + workspace ;
} ;
var locationCases = function ( type ) {
createCookie ( "dashboardListInbox" , type , 1 ) ;
var currentLocation = location . href ;
var position = currentLocation . lastIndexOf ( '/' , currentLocation . lastIndexOf ( '/' ) - 1 ) ;
currentLocation = currentLocation . substring ( 0 , position + 1 ) ;
currentLocation = currentLocation + 'cases/main' ;
parent . location . href = currentLocation ;
} ;
2015-06-11 13:38:27 -04:00
2015-04-17 15:17:24 -04:00
/ * v a r d a s h b o a r d B u t t o n T e m p l a t e = ' < d i v c l a s s = " b t n - g r o u p p u l l - l e f t " > \
< button id = "favorite" type = "button" class = "btn btn-success" > < i class = "fa fa-star fa-1x" > < / i > < / b u t t o n > \
< button id = "dasB" type = "button" class = "btn btn-success" > '+ G_STRING.ID_MANAGERS_DASHBOARDS +' < / b u t t o n > \
< /div>';*/