diff --git a/bin/combineMinifyWMStats.py b/bin/combineMinifyWMStats.py index 3be2bdcdda..c261d56f32 100644 --- a/bin/combineMinifyWMStats.py +++ b/bin/combineMinifyWMStats.py @@ -26,28 +26,30 @@ t1_dataStruct = ["DataStruct/T1/WMStats.RequestSummary.js", "DataStruct/T1/WMStats.CampaignSummary.js", "DataStruct/T1/WMStats.CMSSWSummary.js", + "DataStruct/T1/WMStats.AgentRequestSummary.js", "DataStruct/T1/WMStats.ReqMgrRequest.js"] + # tier0 specific library t0_dataStruct = ["DataStruct/T0/WMStats.RequestSummary.js", "DataStruct/T0/WMStats.RunSummary.js"] -# analysis specific library -an_dataStruct = ["DataStruct/T1/WMStats.RequestSummary.js", - "DataStruct/T1/WMStats.CampaignSummary.js", - "DataStruct/Analysis/WMStats.UserSummary.js"] +viewModel = ["ViewModels/WMStats.ViewModel.js"] -views = ["Views/Controls/WMStats.CommonControls.js", +views = ["Views/WMStats.CategoryMap.js", + "Views/WMStats.View.IndexHTML.js", + "Views/Controls/WMStats.CommonControls.js", "Views/Tables/WMStats.Table.js", "Views/Tables/WMStats.JobSummaryTable.js", "Views/Tables/WMStats.SiteSummaryTable.js", "Views/Tables/WMStats.WorkloadSummaryTable.js", + "Views/Tables/WMStats.TableController.js", "Views/HTMLList/WMStats.JobDetailList.js", - "Views/HTMLList/WMStats.AgentStatusGUI.js", "Views/HTMLList/WMStats.AgentDetailList.js", "Views/HTMLList/WMStats.CategoryTitle.js", "Views/HTMLList/WMStats.RequestTitle.js", - "Views/Graphs/WMStats.SiteHistoryGraph.js"] + "Views/Graphs/WMStats.SiteHistoryGraph.js" + ] # tier1 specific library t1_views = ["Views/Controls/T1/WMStats.Controls.js", @@ -55,6 +57,8 @@ "Views/Tables/T1/WMStats.ActiveRequestTableWithJob.js", "Views/Tables/T1/WMStats.CampaignSummaryTable.js", "Views/Tables/T1/WMStats.CMSSWSummaryTable.js", + "Views/Tables/T1/WMStats.AgentRequestSummaryTable.js", + "Views/Tables/T1/addCategoryMap.js", "Views/HTMLList/T1/WMStats.RequestDetailList.js", "Views/HTMLList/T1/WMStats.RequestAlertGUI.js", "Views/HTMLList/T1/WMStats.CategoryDetailList.js", @@ -66,23 +70,13 @@ t0_views = ["Views/Controls/T0/WMStats.Controls.js", "Views/Tables/T0/WMStats.ActiveRequestTable.js", "Views/Tables/T0/WMStats.RunSummaryTable.js", + "Views/Tables/T0/addCategoryMap.js", "Views/HTMLList/T0/WMStats.RequestDetailList.js", "Views/HTMLList/T0/WMStats.RequestAlertGUI.js", "Views/HTMLList/T0/WMStats.CategoryDetailList.js", "Views/HTMLList/T0/WMStats.RequestSummaryList.js", "Views/HTMLList/T0/WMStats.RequestDataList.js"] -# tier1 specific library -an_views = ["Views/Controls/Analysis/WMStats.Controls.js", - "Views/Tables/T1/WMStats.ActiveRequestTable.js", - "Views/Tables/T1/WMStats.CampaignSummaryTable.js", - "Views/Tables/Analysis/WMStats.UserSummaryTable.js", - "Views/HTMLList/Analysis/WMStats.RequestDetailList.js", - "Views/HTMLList/Analysis/WMStats.CategoryDetailList.js", - "Views/HTMLList/T1/WMStats.RequestAlertGUI.js", - "Views/HTMLList/T1/WMStats.RequestSummaryList.js", - "Views/HTMLList/T1/WMStats.RequestDataList.js"] - models =["Models/WMStats._ModelBase.js", "Models/WMStats._RequestModelBase.js", "Models/WMStats.JobSummaryModel.js", @@ -97,18 +91,11 @@ t0_models =["Models/T0/WMStats.ActiveRequestModel.js"] -an_models =["Models/T1/WMStats.ActiveRequestModel.js"] -controller = ["Controller/WMStats.Env.js", - "Controller/WMStats.GenericController.js", +controller = ["Controller/WMStats.GenericController.js", "Controller/WMStats.ActiveRequestController.js", - "Controller/WMStats.CategoryMap.js", - "Controller/WMStats.TableController.js", "Controller/WMStats.WorkloadSummaryController.js"] -t1_controller = ["Controller/T1/addCategoryMap.js"] -t0_controller = ["Controller/T0/addCategoryMap.js"] -an_controller = ["Controller/Analysis/addCategoryMap.js"] def concatenateFiles(filelist, fileName): destPath = os.path.join(MINIFIED_DIR, fileName) @@ -129,40 +116,29 @@ def concatenateFiles(filelist, fileName): initLoadDest = 'global.min.js' t1Dest = 'import-all-t1.min.js' t0Dest = 'import-all-t0.min.js' - anDest = 'import-all-analysis.min.js' concatenateFiles(globalLib, initLoadDest) t1_lib = [] t1_lib.extend(dataStrunct) t1_lib.extend(t1_dataStruct) + t1_lib.extend(viewModel) t1_lib.extend(views) t1_lib.extend(t1_views) t1_lib.extend(models) t1_lib.extend(t1_models) t1_lib.extend(controller) - t1_lib.extend(t1_controller) concatenateFiles(t1_lib, t1Dest) t0_lib = [] t0_lib.extend(dataStrunct) t0_lib.extend(t0_dataStruct) + t0_lib.extend(viewModel) t0_lib.extend(views) t0_lib.extend(t0_views) t0_lib.extend(models) t0_lib.extend(t0_models) t0_lib.extend(controller) - t0_lib.extend(t0_controller) concatenateFiles(t0_lib, t0Dest) - - an_lib = [] - an_lib.extend(dataStrunct) - an_lib.extend(an_dataStruct) - an_lib.extend(views) - an_lib.extend(an_views) - an_lib.extend(models) - an_lib.extend(an_models) - an_lib.extend(controller) - an_lib.extend(an_controller) - concatenateFiles(an_lib, anDest) + \ No newline at end of file diff --git a/src/couchapps/WMStats/_attachments/css/main_layout.css b/src/couchapps/WMStats/_attachments/css/main_layout.css index 1a17c84670..c32150cbb9 100644 --- a/src/couchapps/WMStats/_attachments/css/main_layout.css +++ b/src/couchapps/WMStats/_attachments/css/main_layout.css @@ -518,7 +518,7 @@ legend { padding: 5px; } -.agent_detail_box { +.agent_detail_box, .request_error_box{ padding: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; diff --git a/src/couchapps/WMStats/_attachments/index.html b/src/couchapps/WMStats/_attachments/index.html index 5cdbdada1a..569a0501d2 100644 --- a/src/couchapps/WMStats/_attachments/index.html +++ b/src/couchapps/WMStats/_attachments/index.html @@ -47,7 +47,6 @@
-
@@ -60,6 +59,11 @@
+
+
+
+
+
@@ -83,6 +87,7 @@
+ @@ -90,36 +95,6 @@ diff --git a/src/couchapps/WMStats/_attachments/index.html.min b/src/couchapps/WMStats/_attachments/index.html.min index 5cdbdada1a..569a0501d2 100644 --- a/src/couchapps/WMStats/_attachments/index.html.min +++ b/src/couchapps/WMStats/_attachments/index.html.min @@ -47,7 +47,6 @@
-
@@ -60,6 +59,11 @@
+
+
+
+
+
@@ -83,6 +87,7 @@
+ @@ -90,36 +95,6 @@ diff --git a/src/couchapps/WMStats/_attachments/index.html.org b/src/couchapps/WMStats/_attachments/index.html.org index 5673fda9e6..5e742319b0 100644 --- a/src/couchapps/WMStats/_attachments/index.html.org +++ b/src/couchapps/WMStats/_attachments/index.html.org @@ -47,7 +47,6 @@
-
@@ -60,6 +59,11 @@
+
+
+
+
+
@@ -96,45 +100,20 @@ - + + + + + + diff --git a/src/couchapps/WMStats/_attachments/js/Controller/Analysis/addCategoryMap.js b/src/couchapps/WMStats/_attachments/js/Controller/Analysis/addCategoryMap.js deleted file mode 100644 index 51944bead8..0000000000 --- a/src/couchapps/WMStats/_attachments/js/Controller/Analysis/addCategoryMap.js +++ /dev/null @@ -1,4 +0,0 @@ -WMStats.CategorySummaryMap.add(WMStats.Controls.userDN, WMStats.UserSummary); -WMStats.CategoryTableMap.add(WMStats.Controls.userDN, WMStats.UserSummaryTable); -WMStats.CategorySummaryMap.add(WMStats.Controls.campaign, WMStats.CampaignSummary); -WMStats.CategoryTableMap.add(WMStats.Controls.campaign, WMStats.CampaignSummaryTable); diff --git a/src/couchapps/WMStats/_attachments/js/Controller/T0/addCategoryMap.js b/src/couchapps/WMStats/_attachments/js/Controller/T0/addCategoryMap.js deleted file mode 100644 index ebd8535572..0000000000 --- a/src/couchapps/WMStats/_attachments/js/Controller/T0/addCategoryMap.js +++ /dev/null @@ -1,2 +0,0 @@ -WMStats.CategorySummaryMap.add(WMStats.Controls.run, WMStats.RunSummary); -WMStats.CategoryTableMap.add(WMStats.Controls.run, WMStats.RunSummaryTable); diff --git a/src/couchapps/WMStats/_attachments/js/Controller/T1/addCategoryMap.js b/src/couchapps/WMStats/_attachments/js/Controller/T1/addCategoryMap.js deleted file mode 100644 index 8ee84933df..0000000000 --- a/src/couchapps/WMStats/_attachments/js/Controller/T1/addCategoryMap.js +++ /dev/null @@ -1,5 +0,0 @@ -//T1 specific categoryMaP -WMStats.CategorySummaryMap.add(WMStats.Controls.campaign, WMStats.CampaignSummary); -WMStats.CategoryTableMap.add(WMStats.Controls.campaign, WMStats.CampaignSummaryTable); -WMStats.CategorySummaryMap.add(WMStats.Controls.cmssw, WMStats.CMSSWSummary); -WMStats.CategoryTableMap.add(WMStats.Controls.cmssw, WMStats.CMSSWSummaryTable); \ No newline at end of file diff --git a/src/couchapps/WMStats/_attachments/js/Controller/WMStats.ActiveRequestController.js b/src/couchapps/WMStats/_attachments/js/Controller/WMStats.ActiveRequestController.js index 0cf3e4c77b..1894ac776a 100644 --- a/src/couchapps/WMStats/_attachments/js/Controller/WMStats.ActiveRequestController.js +++ b/src/couchapps/WMStats/_attachments/js/Controller/WMStats.ActiveRequestController.js @@ -1,218 +1,44 @@ WMStats.namespace("ActiveRequestController"); -function getActiveFilteredData(cacheFlag){ - var requestData = WMStats.ActiveRequestModel.getRequests(); - if (cacheFlag) { - return requestData.getFilteredRequests(); - } else { - return filterRequests(requestData) - } -} - -function filterRequests(requestData) { - var filter = WMStats.Controls.getFilter(); - requestData.setFilter(filter); - var filteredData = requestData.filterRequests(); - return filteredData; -} - -function getCategorizedData(category) { - - var categoryData; - - if (category != WMStats.Controls.requests) { - var filteredData = getActiveFilteredData(true); - var summaryStruct = WMStats.CategorySummaryMap.get(category); - categoryData = WMStats.RequestsByKey(category, summaryStruct); - categoryData.categorize(filteredData); - WMStats.Env.CategoryData = categoryData; - } else { - categoryData = filterRequests(WMStats.Env.CurrentRequestData); - } - return categoryData; -} - (function($){ var E = WMStats.CustomEvents; - // Request view filter event handler - function drawTotalRequestSummary() { - var requestData = WMStats.ActiveRequestModel.getRequests(); - WMStats.RequestSummaryList(requestData.getSummary(), "#summary_board"); - }; - - function drawFilteredRequestSummary() { - var filteredData = getActiveFilteredData(true); - WMStats.RequestSummaryList(filteredData.getSummary(), "#filter_summary"); - }; - - function drawDataBoard(viewSelector) { - if (!viewSelector) { - viewSelector = WMStats.Env.View; - } - //find which view needs to draw. - WMStats.GenericController.switchView(viewSelector); - var divSelector = viewSelector + " div.summary_data"; - var category = null; - if (viewSelector === "#category_view") { - // get category - category = WMStats.Env.CategorySelection - } else if (viewSelector === "#request_view") { - category = WMStats.Controls.requests; - } // maybe needs job view as well - - if (category) { - /* - // clean databoard - $(viewSelector + " div.detail_data").empty(); - $(divSelector).empty(); - */ - var data = getCategorizedData(category); - var view = WMStats.CategoryTableMap.get(category); - view(data, divSelector); - } - } + + var vm = WMStats.ViewModel; $(WMStats.Globals.Event).on(E.REQUESTS_LOADED, - function(event, requestData) { - var requestData = WMStats.ActiveRequestModel.getRequests(); - // draw alert - WMStats.RequestAlertGUI(requestData, "#request_alert"); - drawTotalRequestSummary() - //refresh filter cache. - getActiveFilteredData(); - drawFilteredRequestSummary(); - - // update CurrentRequestData only for the all_requests or initialize - if (WMStats.Env.CurrentRequestData === null || - WMStats.Env.RequestSelection === "all_requests") { - //WMStats.Env.CurrentRequestData = requestData.getFilteredRequests(); - WMStats.Env.CurrentRequestData = requestData; - } - drawDataBoard(); + function(event) { + vm.propagateUpdate(); }) $(WMStats.Globals.Event).on(E.AGENTS_LOADED, function(event, agentData) { - //refresh filter cache. - WMStats.AgentDetailList(agentData, '#agent_detail'); - if (agentData.agentNumber.error > 0) { - $('#linkTabs a[href="#agentInfoPage"] strong').text("(" + agentData.agentNumber.error + ")"); - } - //WMStats.AgentStatusGUI(agentData, "#agent_alert"); - }) - - $(WMStats.Globals.Event).on(E.CATEGORY_SUMMARY_READY, - function(event, data) { - $("#category_view div.detail_data").empty(); - drawDataBoard("#category_view"); - }) - - $(WMStats.Globals.Event).on(E.REQUEST_SUMMARY_READY, - function(event, data) { - $("#request_view div.detail_data").empty(); - if (data) { - WMStats.Env.CurrentRequestData = data; - } - drawDataBoard("#request_view"); + vm.propagateUpdate(); }) $(WMStats.Globals.Event).on(E.JOB_SUMMARY_READY, function(event, data) { - WMStats.RequestTitle(data, '#request_title'); - $("#job_view div.detail_data").empty(); - WMStats.Env.JobSummaryTable = WMStats.JobSummaryTable(data, "#job_view div.summary_data"); - WMStats.GenericController.switchView("#job_view"); - }) - - $(WMStats.Globals.Event).on(E.CATEGORY_DETAIL_READY, - function(event, categoryKey) { - var allData = WMStats.Env.CategoryData; - var data = allData.getData(categoryKey); - WMStats.CategoryDetailList(data, "#category_view div.detail_data"); - }) - - $(WMStats.Globals.Event).on(E.REQUEST_DETAIL_READY, - function(event, workflow) { - var allRequests = WMStats.ActiveRequestModel.getRequests(); - var reqDoc = allRequests.getDataByWorkflow(workflow); - var reqSummary = allRequests.getSummary(workflow); - var requests = {}; - requests[workflow] = reqDoc; - var data = {key: workflow, requests: requests, summary: reqSummary}; - //$("#request_view div.detail_data").show("slide", {direction: "down"}, 500); - WMStats.RequestDetailList(data, "#request_view div.detail_data"); + vm.JobView.updateDataAndChild(data); + //vm.AlertJobView.updateDataAndChild(data); }) $(WMStats.Globals.Event).on(E.JOB_DETAIL_READY, function(event, data) { - WMStats.JobDetailList(data, "#job_view div.detail_data"); - }) - - // filter control - $(document).on('keyup', "#filter_board input", - function() { - //refresh filter cache. - getActiveFilteredData(); - drawFilteredRequestSummary(); - drawDataBoard(); - }) -/* - $(document).on('change', 'input[name="category-select"][type="radio"]', function() { - drawDataBoard(); - }) -*/ - $(document).on('click', "#category_button li a", function(event){ - WMStats.Env.CategorySelection = this.hash.substring(1); - $(WMStats.Globals.Event).triggerHandler(E.CATEGORY_SUMMARY_READY); - $("#category_button li a").removeClass("nav-button-selected").addClass("button-unselected"); - $(this).removeClass("button-unselected").addClass("nav-button-selected"); - event.preventDefault(); + vm.JobDetail.data(data); }) - - $(document).on('click', "#all_requests li a", function(event){ - WMStats.Env.RequestSelection = "all_requests"; - var data = WMStats.ActiveRequestModel.getRequests(); - $(WMStats.Globals.Event).triggerHandler(E.REQUEST_SUMMARY_READY, data); - $(this).removeClass("button-unselected").addClass("nav-button-selected"); - event.preventDefault(); - }) - - $(document).on('click', "#view_switch_button li a", function(event){ - WMStats.Env.ViewSwitchSelection = this.hash.substring(1); - //TODO need to get the data - $(WMStats.Globals.Event).triggerHandler(E.REQUEST_SUMMARY_READY); - $(this).removeClass("button-unselected").addClass("nav-button-selected"); - event.preventDefault(); - }) - - $(document).on('click', 'a.requestAlert', function() { - var workflow = $(this).text(); - WMStats.JobSummaryModel.setRequest(workflow); - $(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START) - WMStats.JobSummaryModel.retrieveData(); - $(this).addClass('reviewed'); - }) - $(document).on('click', "#tab_board li a", function(event){ - drawDataBoard(this.hash); - event.preventDefault(); - }); - - $(document).on('click', "#jobDetailNav li a", function(event){ - $('div.jobDetailBox').hide(); - $(this.hash).show(); - $("#jobDetailNav li a").removeClass("button-selected").addClass("button-unselected"); - $(this).removeClass("button-unselected").addClass("button-selected"); - event.preventDefault(); - }) + $(WMStats.Globals.Event).on(E.RESUBMISSION_SUMMARY_READY, + function(event, data) { + var rData = vm.Resubmission.formatResubmissionData(data) + vm.Resubmission.data(rData); + }) $(WMStats.Globals.Event).on(E.LOADING_DIV_START, function(event, data) { // TODO: need to update when partial_request happens) - if (WMStats.Env.View === '#category_view' || - (WMStats.Env.View === '#request_view' && - WMStats.Env.RequestSelection === "all_requests")) { + var count = vm.ActiveRequestPage.refreshCount(); + vm.ActiveRequestPage.refreshCount(count + 1); + if (vm.page() === vm.ActiveRequestPage && vm.ActiveRequestPage.refreshCount() === 1) { $('#loading_page').show(); } }); @@ -227,14 +53,4 @@ function getCategorizedData(category) { $('#loading_page').show(); }); - $(WMStats.Globals.Event).on(E.RESUBMISSION_SUMMARY_READY, - function(event, data) { - var reqMgrReq = WMStats.ReqMgrRequestModel.getData().getData(); - var summary = WMStats.ViewModel.Resubmission; - summary.Memory = reqMgrReq.Memory; - summary.SizePerEvent = reqMgrReq.SizePerEvent; - summary.TimePerEvent = reqMgrReq.TimePerEvent; - //summary.Requestor = reqMgrReq.Requestor; - WMStats.ResubmissionList(summary, '#acdc_submission'); - }) })(jQuery); diff --git a/src/couchapps/WMStats/_attachments/js/Controller/WMStats.CategoryMap.js b/src/couchapps/WMStats/_attachments/js/Controller/WMStats.CategoryMap.js deleted file mode 100644 index 7bdceaa14d..0000000000 --- a/src/couchapps/WMStats/_attachments/js/Controller/WMStats.CategoryMap.js +++ /dev/null @@ -1,38 +0,0 @@ -WMStats.namespace("CategorySummaryMap"); -WMStats.namespace("CategoryTableMap"); - -WMStats.CategorySummaryMap = function(){ - var summaryMap = {}; - function add(category, summaryFunc) { - summaryMap[category] = summaryFunc; - } - function get(category) { - return summaryMap[category] - } - return {add: add, get: get} -}() - -WMStats.CategoryTableMap = function(){ - var tableMap = {}; - function add(category, view) { - tableMap[category] = view; - } - function get(category, view) { - if (category === WMStats.Controls.requests) { - return tableMap[category][WMStats.Env.ViewSwitchSelection] - }else { - return tableMap[category]; - } - - } - return {add: add, get: get} -}() - -//register mapping -WMStats.CategorySummaryMap.add(WMStats.Controls.sites, WMStats.SiteSummary); -WMStats.CategoryTableMap.add(WMStats.Controls.sites, WMStats.SiteSummaryTable); - -WMStats.CategoryTableMap.add(WMStats.Controls.requests, - {'progress': WMStats.ActiveRequestTable, - 'numJobs':WMStats.ActiveRequestTableWithJob}); -//WMStats.CategoryTableMap.add(WMStats.Controls.requests, WMStats.ActiveRequestTableWithJob); diff --git a/src/couchapps/WMStats/_attachments/js/Controller/WMStats.Env.js b/src/couchapps/WMStats/_attachments/js/Controller/WMStats.Env.js deleted file mode 100644 index 4c1a8fffce..0000000000 --- a/src/couchapps/WMStats/_attachments/js/Controller/WMStats.Env.js +++ /dev/null @@ -1,23 +0,0 @@ -/** abstract environment of the web page */ -WMStats.namespace("Env"); -// page view ("#activeRequestPage", "#workloadSummaryPage") -WMStats.Env.Page = "#activeRequestPage"; -// summary view ( contains #category_view, #request_view, #job_view) -WMStats.Env.View = "#category_view"; -// category view selection (different variation has different values, i.e. site, campaing) -WMStats.Env.CategorySelection = null; -// Request selection: all request or categorize request -WMStats.Env.RequestSelection = "all_requests"; -// s -WMStats.Env.ViewSwitchSelection = null; - -// place holder for current data in category_view -WMStats.Env.CategoryData = null; -// place holder for current data in request_view -WMStats.Env.CurrentRequestData = null; - -// env variable for request detail box status -WMStats.Env.RequestDetailOpen = false; - -// env variable for JobSummaryTable - hold data information -WMStats.Env.JobSummaryTable = null; diff --git a/src/couchapps/WMStats/_attachments/js/Controller/WMStats.GenericController.js b/src/couchapps/WMStats/_attachments/js/Controller/WMStats.GenericController.js index ca20d7d355..a2d6b34994 100644 --- a/src/couchapps/WMStats/_attachments/js/Controller/WMStats.GenericController.js +++ b/src/couchapps/WMStats/_attachments/js/Controller/WMStats.GenericController.js @@ -1,11 +1,12 @@ WMStats.namespace("GenericController"); (function($) { + var vm = WMStats.ViewModel; // collapsible bar function closeRequestDetail() { $("#request_view div.detail_data").hide('puff', {}, 500); $("#acdc_submission").hide('puff', {}, 500); - WMStats.Env.RequestDetailOpen = false; + vm.RequestDetail.open = false; }; $(document).on('click', 'div.caption img', function(event){ @@ -20,60 +21,18 @@ WMStats.namespace("GenericController"); }); $(document).keyup(function(event) { - if (WMStats.Env.RequestDetailOpen && event.keyCode == 27) { + if (vm.RequestDetail.open && event.keyCode == 27) { closeRequestDetail(); event.preventDefault(); } }) - - WMStats.GenericController.switchView = function (showSelector, hideSelectors) { - if (!showSelector) { - showSelector = WMStats.Env.View; - } else if (!hideSelectors) { - var viewList = ["#category_view", "#request_view", "#job_view"]; - for (var i in viewList) { - if (showSelector != viewList[i]){ - $(viewList[i]).hide(); - } - - } - } else { - for (var i in hideSelectors) { - $(hideSelectors[i]).hide(); - } - } - $(showSelector).show(); - WMStats.Env.View = showSelector; - // select the tab - $('#tab_board li').removeClass("tabs-selected"); - $('#tab_board a[href="' + showSelector +'"]').parent().addClass("tabs-selected") - }; - WMStats.GenericController.switchPage = function (showSelector, hideSelectors) { - if (!showSelector) { - showSelector = WMStats.Env.Page; - } else if (!hideSelectors) { - var pageList = ["#activeRequestPage", "#agentInfoPage", "#workloadSummaryPage"]; - for (var i in pageList) { - if (showSelector != pageList[i]){ - $(pageList[i]).hide(); - } - } - } else { - for (var i in hideSelectors) { + + WMStats.GenericController.switchDiv = function (showSelector, hideSelectors) { + for (var i in hideSelectors) { $(hideSelectors[i]).hide(); - } } $(showSelector).show(); - WMStats.Env.Page = showSelector; - // select the tab - $('#linkTabs li').removeClass("title-tab-selected").addClass("title-tab-hide"); - $('#linkTabs a[href="' + showSelector +'"]').parent().removeClass("title-tab-hide").addClass("title-tab-selected") }; - - $(document).on('click', "#linkTabs li a", function(event){ - WMStats.GenericController.switchPage(this.hash); - event.preventDefault(); - }); - + })(jQuery); diff --git a/src/couchapps/WMStats/_attachments/js/Controller/WMStats.WorkloadSummaryController.js b/src/couchapps/WMStats/_attachments/js/Controller/WMStats.WorkloadSummaryController.js index 2c95d2faab..7ffb16913e 100644 --- a/src/couchapps/WMStats/_attachments/js/Controller/WMStats.WorkloadSummaryController.js +++ b/src/couchapps/WMStats/_attachments/js/Controller/WMStats.WorkloadSummaryController.js @@ -1,41 +1,12 @@ WMStats.namespace("WorkloadSummaryController"); (function($){ - - $(document).on('click', '#WorkloadSummarySearchButton', function(event) { - var selectedSearch = $('#search_option_board select[name="SearchOptions"] :selected').val(); - var searchStr = $('input[name="workloadSummarySearch"]').val(); - var view; - var options = {'include_docs': true, 'reduce': false}; - if (selectedSearch === 'request') { - view = "allDocs"; - options.key = searchStr; - } else if (selectedSearch === 'outputdataset') { - view = "requestByOutputDataset"; - options.key = searchStr; - } else if (selectedSearch === 'inputdataset') { - view = "requestByInputDataset"; - options.key = searchStr; - } else if (selectedSearch === 'prep_id') { - view = "requestByPrepID"; - options.key = searchStr; - } else if (selectedSearch === 'request_date') { - view = "requestByDate"; - var beginDate = $('input[name="dateRange1"]').val().split("/"); - var endDate = $('input[name="dateRange2"]').val().split("/"); - options.startkey = [Number(beginDate[0]), Number(beginDate[1]), Number(beginDate[2])]; - options.endkey = [Number(endDate[0]), Number(endDate[1]), Number(endDate[2]), {}]; - } - WMStats.RequestSearchModel.retrieveData(view, options); - event.stopPropagation(); - }) - + var vm = WMStats.ViewModel; var E = WMStats.CustomEvents; $(WMStats.Globals.Event).on(E.WORKLOAD_SUMMARY_READY, function(event, data) { var data = WMStats.RequestSearchModel.getData(); - // draw alert - WMStats.WorkloadSummaryTable(data, "#search_result_board"); + vm.SearchPage.data(data); }) })(jQuery); diff --git a/src/couchapps/WMStats/_attachments/js/Controller/import.js b/src/couchapps/WMStats/_attachments/js/Controller/import.js index ded75fd97d..5603ebef04 100644 --- a/src/couchapps/WMStats/_attachments/js/Controller/import.js +++ b/src/couchapps/WMStats/_attachments/js/Controller/import.js @@ -1,22 +1,7 @@ WMStats.Globals.importScripts([ - "js/Controller/WMStats.Env.js", "js/Controller/WMStats.GenericController.js", "js/Controller/WMStats.ActiveRequestController.js", - "js/Controller/WMStats.CategoryMap.js", "js/Controller/WMStats.TableController.js", "js/Controller/WMStats.WorkloadSummaryController.js" ]) -if (WMStats.Globals.VARIANT == "tier1") { - //import tier1 specific table - WMStats.Globals.importScripts([ - "js/Controller/T1/addCategoryMap.js", - ]) -} else if (WMStats.Globals.VARIANT == "tier0") { - //import tie0 specific table - WMStats.Globals.importScripts(["js/Controller/T0/addCategoryMap.js"]) -} else if (WMStats.Globals.VARIANT == "analysis") { - //import analysis specific table - WMStats.Globals.importScripts(["js/Controller/Analysis/addCategoryMap.js"]) -}; - diff --git a/src/couchapps/WMStats/_attachments/js/DataStruct/Analysis/WMStats.UserSummary.js b/src/couchapps/WMStats/_attachments/js/DataStruct/Analysis/WMStats.UserSummary.js deleted file mode 100644 index d0db354bbf..0000000000 --- a/src/couchapps/WMStats/_attachments/js/DataStruct/Analysis/WMStats.UserSummary.js +++ /dev/null @@ -1,16 +0,0 @@ -WMStats.namespace("UserSummary"); - -WMStats.UserSummary = function() { - var userSummary = {numRequests: 0}; - var userSummary = new WMStats.GenericRequestsSummary(userSummary); - - userSummary.createSummaryFromRequestDoc = function(doc) { - var summary = WMStats.UserSummary(); - summary.summaryStruct.numRequests = 1; - summary.jobStatus = this._get(doc, 'status', {}) - - return summary; - }; - - return userSummary; -}; diff --git a/src/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.AgentRequestSummary.js b/src/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.AgentRequestSummary.js new file mode 100644 index 0000000000..d264a8b66d --- /dev/null +++ b/src/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.AgentRequestSummary.js @@ -0,0 +1,28 @@ +WMStats.namespace("AgentRequestSummary"); + +WMStats.AgentRequestSummary = function() { + var agenetRequestSummary = {totalEvents: 0, + totalLumis: 0, + processedEvents: 0, + numRequests: 0}; + var agenetRequestSummary = new WMStats.GenericRequestsSummary(agenetRequestSummary); + + agenetRequestSummary.createSummaryFromRequestDoc = function(doc) { + var summary = WMStats.AgentRequestSummary(); + summary.summaryStruct.totalEvents = Number(this._get(doc, "input_events", 0)); + summary.summaryStruct.totalLumis = Number(this._get(doc, "input_lumis", 0)); + summary.summaryStruct.processedEvents = this._get(doc, "output_progress.0.events", 0); + summary.summaryStruct.progress = this.getAvgProgressSummary(doc) + summary.summaryStruct.numRequests = 1; + summary.jobStatus = this._get(doc, 'status', {}) + + //support legacy code which had cooloff jobs instead cooloff.create, cooloff.submit + //cooloff.job + if ((typeof summary.jobStatus.cooloff) === "number") { + summary.jobStatus.cooloff = {create: 0, submit: 0, job: summary.jobStatus.cooloff} + } + return summary; + }; + + return agenetRequestSummary; +}; diff --git a/src/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.RequestSummary.js b/src/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.RequestSummary.js index 759f4cb250..fc93dc23d2 100644 --- a/src/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.RequestSummary.js +++ b/src/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.RequestSummary.js @@ -51,7 +51,7 @@ WMStats.Requests = function(noFilterFlag) { tier1Requests.estimateCompletionTime = function(request) { //TODO need to improve the algo // no infomation to calulate the estimate completion time - var aData = this.getDataByWorkflow(request); + var aData = WMStats.ActiveRequestModel.getData().getData(request); var reqSummary = this.getSummary(request); var completedJobs = reqSummary.getJobStatus("success") + reqSummary.getTotalFailure(); if (completedJobs == 0) return -1; @@ -63,7 +63,7 @@ WMStats.Requests = function(noFilterFlag) { if (lastStatus.status !== 'running' && lastStatus.status !== 'running-closed' && lastStatus.status !== 'running-open') return 0; - + var totalJobs = reqSummary.getWMBSTotalJobs() - reqSummary.getJobStatus("canceled"); // jobCompletion percentage var completionRatio = (completedJobs / totalJobs); @@ -72,11 +72,35 @@ WMStats.Requests = function(noFilterFlag) { var timeLeft = Math.round((duration / (completionRatio * queueInjectionRatio)) - duration); return timeLeft; + }; + + tier1Requests.getRequestAlerts = function() { + + var alertRequests = {}; + alertRequests['configError'] = [] + alertRequests['siteError'] = [] + for (var workflow in this.getData()) { + var reqSummary = this.getSummary(workflow); + var cooloff = reqSummary.getTotalCooloff(); + var paused = reqSummary.getTotalPaused(); + var failure = reqSummary.getTotalFailure(); + var success = reqSummary.getJobStatus("success"); + var totalFailed = cooloff + paused + failure; + if ( totalFailed > 0) { + if (success === 0) { + alertRequests['configError'].push(this.getData(workflow)); + } else if ((totalFailed / (totalFailed + success)) > 0.85) { + alertRequests['siteError'].push(this.getData(workflow)); + } + } + } + return alertRequests; } + tier1Requests.requestNotPulledAlert = function() { var alertRequests = []; - for (var workflow in this.getDataByWorkflow()) { + for (var workflow in this.getData()) { var reqStatusInfo = this.getRequestStatusAndTime(workflow); var currentTime = Math.round(new Date().getTime() / 1000); var timeThreshold = 600 // 10 min diff --git a/src/couchapps/WMStats/_attachments/js/DataStruct/WMStats.Agents.js b/src/couchapps/WMStats/_attachments/js/DataStruct/WMStats.Agents.js index 7679e3c2dd..732565e121 100644 --- a/src/couchapps/WMStats/_attachments/js/DataStruct/WMStats.Agents.js +++ b/src/couchapps/WMStats/_attachments/js/DataStruct/WMStats.Agents.js @@ -20,7 +20,7 @@ WMStats.Agents = function (couchData) { var currentTime = Math.round(new Date().getTime() / 1000); var dataList = this.getData(); var agentPollingCycle = 600; - agentNumber = {error: 0, stable:0}; + agentData.agentNumber = {error: 0, stable:0}; function getStatus(agentInfo) { var lastUpdatedDuration = currentTime - agentInfo.timestamp; @@ -44,5 +44,8 @@ WMStats.Agents = function (couchData) { } return dataList; } + // initial calculation + agentData.getAlertList(); + return agentData }; diff --git a/src/couchapps/WMStats/_attachments/js/DataStruct/WMStats.GenericRequests.js b/src/couchapps/WMStats/_attachments/js/DataStruct/WMStats.GenericRequests.js index afeb67f3b1..a8e2ac5534 100644 --- a/src/couchapps/WMStats/_attachments/js/DataStruct/WMStats.GenericRequests.js +++ b/src/couchapps/WMStats/_attachments/js/DataStruct/WMStats.GenericRequests.js @@ -172,22 +172,33 @@ WMStats.RequestStruct.prototype = { }, updateFromCouchDoc: function (doc) { + + function _tasksUpdateFunction (baseObj, addObj, field) { + if (field === "JobType") { + baseObj[field] = addObj[field]; + } else if (field === "updated"){ + baseObj[field] = Math.max(baseObj[field], addObj[field]); + } else { + baseObj[field] += addObj[field]; + } + }; + for (var field in doc) { - //handles when request is splited in more than one agents + //handles when request is split in more than one agents if (this[field] && (field == 'sites' || field == 'status')){ this._addJobs(this[field], doc[field]) + } else if (this[field] && field == 'tasks'){ + this._addJobs(this[field], doc[field], true, _tasksUpdateFunction) + } else if (this[field] && field == 'output_progress') { var outProgress = this.output_progress; for (var index in outProgress){ for (var prop in doc[field][index]) { outProgress[index][prop] += doc[field][index][prop]; - //TODO: need combine dataset separtely + //TODO: need combine dataset separately } } - } else if (this[field] && field == 'tasks'){ - //TODO need to handle the - //this._dataByWorkflow[doc.workflow][field] = doc[field]; } else if (field == 'agent_url') { if (this[field] === undefined) this[field] = []; WMStats.Utils.addToSet(this[field], doc[field]) @@ -209,6 +220,8 @@ WMStats.GenericRequests = function (noFilterFlag) { */ // request data by workflow name this._dataByWorkflow = {}; + // request data by agent - only contains information from agent + // i.e. job status. this._dataByWorkflowAgent = {} this._get = WMStats.Utils.get; this._filter = {}; @@ -226,7 +239,7 @@ WMStats.GenericRequests.prototype = { _getRequestObj: function (request) { if (typeof(request) == "string") { - return this.getDataByWorkflow(request); + return this.getData(request); } else { return request; } @@ -297,16 +310,28 @@ WMStats.GenericRequests.prototype = { }, updateRequest: function(doc) { - - var request = this.getDataByWorkflow(doc.workflow); - if (!request) { - this._dataByWorkflow[doc.workflow] = new WMStats.RequestStruct(doc.workflow); + /* + * + */ + var workflow = doc.workflow; + var agentURL = doc.agent_url; + + if (workflow && !this._dataByWorkflow[workflow]) { + this._dataByWorkflow[workflow] = new WMStats.RequestStruct(workflow);; } - this._dataByWorkflow[doc.workflow].updateFromCouchDoc(doc) - if (doc.agent_url) { - var requestWithAgent = this.getRequestByNameAndAgent(doc.workflow, doc.agent_url); - requestWithAgent.updateFromCouchDoc(doc); + if (agentURL && !this._dataByWorkflowAgent[workflow]) { + this._dataByWorkflowAgent[workflow] = {}; + } + //if it is new agent create one. + if (agentURL && !this._dataByWorkflowAgent[workflow][agentURL]){ + this._dataByWorkflowAgent[workflow][agentURL] = new WMStats.RequestStruct(workflow); + } + + // update both _databyWorkflow + this.getData(workflow).updateFromCouchDoc(doc); + if (agentURL) { + this.getData(workflow, agentURL).updateFromCouchDoc(doc); } }, @@ -319,67 +344,64 @@ WMStats.GenericRequests.prototype = { } }, - filterRequests: function() { - var requestData = this.getDataByWorkflow(); + filterRequests: function(filter) { + var requestData = this.getData(); var filteredData = {} + var requestWithAgentData = this.getDataWithAgent(); + var filteredDataWithAgent = {} + if (filter === undefined) {filter = this._filter;} for (var workflowName in requestData) { - if (this._andFilter(requestData[workflowName], this._filter)){ + if (this._andFilter(requestData[workflowName], filter)){ filteredData[workflowName] = requestData[workflowName]; + filteredDataWithAgent[workflowName] = requestWithAgentData[workflowName]; } } this._filteredRequests = WMStats.Requests(); - this._filteredRequests.setDataByWorkflow(filteredData); + this._filteredRequests.setDataByWorkflow(filteredData, filteredDataWithAgent); return this._filteredRequests; }, - - getRequestByNameAndAgent: function(workflow, agentUrl) { - // if ther in no agentUrl get all agent for given workflow - if (!agentUrl){ - return this._dataByWorkflowAgent[workflow]; - } - // if is new workflow, create one. - if (!this._dataByWorkflowAgent[workflow]) { - this._dataByWorkflowAgent[workflow] = {}; - } - //if it is new agent create one. - if (!this._dataByWorkflowAgent[workflow][agentUrl]){ - this._dataByWorkflowAgent[workflow][agentUrl] = new WMStats.RequestStruct(workflow); + getKeyValue: function(request, keyString, defaultVal) { + "keyString is opject property separte by ." + return this._get(this._dataByWorkflow[request], keyString, defaultVal); + }, + + getData: function(workflow, agentURL) { + if (workflow && (agentURL === "all" || agentURL === "NA" )) { + return this._dataByWorkflowAgent[workflow] + } else if (workflow && agentURL) { + return this._dataByWorkflowAgent[workflow][agentURL] + } else if (workflow){ + return this._dataByWorkflow[workflow]; + } else{ + return this._dataByWorkflow; } - return this._dataByWorkflowAgent[workflow][agentUrl]; }, - getDataByWorkflow: function(request, keyString, defaultVal) { - "keyString is opject property separte by ." - if (!request) return this._dataByWorkflow; - else if (!keyString) return this._dataByWorkflow[request]; - else return this._get(this._dataByWorkflow[request], keyString, defaultVal); - }, - - getData: function(workflow) { - if (workflow){ - var requestsObj = {}; - requestsObj[workflow] = this._dataByWorkflow[workflow] - return {requests: requestsObj, - summary: this.getSummary(workflow), - key: workflow} + getDataWithAgent: function(workflow, agentURL) { + if (workflow && (agentURL === "all" || agentURL === "NA" )) { + return this._dataByWorkflowAgent[workflow] + } else if (workflow && agentURL) { + return this._dataByWorkflowAgent[workflow][agentURL] + } else{ + return this._dataByWorkflowAgent; } - return this._dataByWorkflow; }, getFilteredRequests: function() { return this._filteredRequests; }, - setDataByWorkflow: function(data) { + setDataByWorkflow: function(data, agentData) { "keyString is opject property separte by ." this._dataByWorkflow = data; + this._dataByWorkflowAgent = agentData; }, getList: function(sortFunc) { var list = []; - for (var request in this.getDataByWorkflow()) { - list.push(this.getDataByWorkflow(request)) + for (var request in this.getData()) { + list.push(this.getData(request)) } if (sortFunc) { return list.sort(sortFunc); @@ -388,15 +410,16 @@ WMStats.GenericRequests.prototype = { } }, - getSummary: function(workflow) { - var summary = WMStats.RequestsSummary(); + getSummary: function(workflow, agentURL) { + var requests = this.getData(workflow, agentURL) if (workflow) { - return summary.createSummaryFromRequestDoc(this.getDataByWorkflow(workflow)); + return requests.getSummary() } else { + var summary = WMStats.RequestsSummary(); //TODO need to cache the information - for (var request in this.getDataByWorkflow()) { - summary.updateFromRequestDoc(this.getDataByWorkflow(request)); + for (var requestName in requests) { + summary.update(this.getData(requestName).getSummary()); } return summary; } @@ -404,7 +427,7 @@ WMStats.GenericRequests.prototype = { getAlertRequests: function() { var alertRequests = []; - for (var workflow in this.getDataByWorkflow()) { + for (var workflow in this.getData()) { var reqSummary = this.getSummary(workflow); var coolOff = reqSummary.getTotalCooloff(); var paused = reqSummary.getTotalPaused(); @@ -429,7 +452,27 @@ WMStats.RequestsByKey = function (category, summaryFunc) { function categorize(requestData) { - function _updateData(key, summaryBase) { + function _getRequestData(workflow, agentURL){ + if (_category === "agent" && agentURL !== "all" && agentURL !== "NA" ) { + return requestData.getData(workflow, agentURL); + } else { + return requestData.getData(workflow); + } + } + + function _getCategoryKey(workflow){ + if (_category === "agent") { + var agentCategory = requestData.getData(workflow, "all"); + if (agentCategory === undefined) { + return "NA"; + } else { + return agentCategory; + } + } else { + return requestData.getKeyValue(workflow, _category, "NA"); + } + } + function _updateData(key, workflow, summaryBase) { if (_data[key] === undefined) { //initial set up _data[key] = {}; @@ -437,33 +480,34 @@ WMStats.RequestsByKey = function (category, summaryFunc) { _data[key].summary = summaryFunc(); _data[key].key = key; } - _data[key].requests[workflow] = dataByWorkflow[workflow]; + var requestInfo = _getRequestData(workflow, key); + _data[key].requests[workflow] = requestInfo; _data[key].summary.updateFromRequestDoc(summaryBase) }; - + var dataByWorkflow = requestData.getData(); for (var workflow in dataByWorkflow) { - var key = _get(dataByWorkflow[workflow], _category, "NA"); + var key = _getCategoryKey(workflow); if (typeof key == 'object') { if (key.length) { // handles array case for (var index in key) { - _updateData(key[index], dataByWorkflow[workflow]) + _updateData(key[index], workflow, requestData.getData(workflow)) } } else { - // handles sites and tasks case + // handles agent, sites and tasks case for (var prop in key) { - _updateData(prop, key[prop]); + _updateData(prop, workflow, key[prop]); } } } else { - if (key == "NA" && _category == "sites" || _category == "tasks") { + if (key == "NA" && _category == "sites" || _category == "tasks" || _category == "agent") { // summary base shouldn't be higher level. since sites and tasks // has sub hierarchy - _updateData(key, {}); + _updateData(key, workflow, {}); } else { - _updateData(key, dataByWorkflow[workflow]); + _updateData(key, workflow, requestData.getData(workflow)); } } @@ -480,7 +524,9 @@ WMStats.RequestsByKey = function (category, summaryFunc) { function getRequestData(key){ var requestData = WMStats.Requests(); - requestData.setDataByWorkflow(_data[key].requests); + if (_data[key] !== undefined) { + requestData.setDataByWorkflow(_data[key].requests); + } return requestData; }; diff --git a/src/couchapps/WMStats/_attachments/js/DataStruct/import.js b/src/couchapps/WMStats/_attachments/js/DataStruct/import.js index 63d9f35d50..04e4a8999b 100644 --- a/src/couchapps/WMStats/_attachments/js/DataStruct/import.js +++ b/src/couchapps/WMStats/_attachments/js/DataStruct/import.js @@ -17,14 +17,10 @@ if (WMStats.Globals.VARIANT == "tier1") { WMStats.Globals.importScripts(["js/DataStruct/T1/WMStats.RequestSummary.js", "js/DataStruct/T1/WMStats.CampaignSummary.js", "js/DataStruct/T1/WMStats.CMSSWSummary.js", + "js/DataStruct/T1/WMStats.AgentRequestSummary.js", "js/DataStruct/T1/WMStats.ReqMgrRequest.js"]) } else if (WMStats.Globals.VARIANT == "tier0") { //import tie0 specific table WMStats.Globals.importScripts(["js/DataStruct/T0/WMStats.RequestSummary.js", "js/DataStruct/T0/WMStats.RunSummary.js"]) -} else if (WMStats.Globals.VARIANT == "analysis") { - //import analysis specific table - WMStats.Globals.importScripts(["js/DataStruct/T1/WMStats.RequestSummary.js", - "js/DataStruct/T1/WMStats.CampaignSummary.js", - "js/DataStruct/Analysis/WMStats.UserSummary.js"]) -}; +} diff --git a/src/couchapps/WMStats/_attachments/js/Models/import.js b/src/couchapps/WMStats/_attachments/js/Models/import.js index b77b2beed9..eddb879fea 100644 --- a/src/couchapps/WMStats/_attachments/js/Models/import.js +++ b/src/couchapps/WMStats/_attachments/js/Models/import.js @@ -14,6 +14,4 @@ if (WMStats.Globals.VARIANT == "tier1") { "js/Models/T1/WMStats.ReqMgrRequestModel.js"]); } else if (WMStats.Globals.VARIANT == "tier0") { WMStats.Globals.importScripts(["js/Models/T0/WMStats.ActiveRequestModel.js"]); -} else if (WMStats.Globals.VARIANT == "analysis") { - WMStats.Globals.importScripts(["js/Models/T1/WMStats.ActiveRequestModel.js"]); -}; +} diff --git a/src/couchapps/WMStats/_attachments/js/ViewModels/WMStats.ViewModel.js b/src/couchapps/WMStats/_attachments/js/ViewModels/WMStats.ViewModel.js new file mode 100644 index 0000000000..51de2b7b5f --- /dev/null +++ b/src/couchapps/WMStats/_attachments/js/ViewModels/WMStats.ViewModel.js @@ -0,0 +1,467 @@ +/** abstract environment of the web page */ +WMStats.namespace("_ViewModelBase"); + +WMStats._ViewModelBase = function (observableObj) { + this._eventObj = {}; + this._eventObjName = "_eventObj"; + // special observable property holding represented data + this.data = this.observable('data', null); + if (observableObj !== undefined) { + this._createObservableProperty(observableObj) + }; + this._selector = null; + this._data = null; +}; + +WMStats._ViewModelBase.prototype = { + + observable: function(property, defaultValue) { + + var _previousValue = defaultValue; + var _property = property; + + function publish(value, noTrigger) { + if (value !== undefined) { + _previousValue = value; + //TODO: check the equality + /* trigger parent object changed */ + if (!noTrigger) { + $(this._eventObj).triggerHandler(this._eventObjName, this); + /* trigger property changed */ + $(this._eventObj).triggerHandler(_property, value); + + } + return this; + } else { + return _previousValue; + } + } + return publish; + }, + + subscribe: function() { + /* + * takes 1 or 2 arguments + * if 1, it is callback function when this object changes + * if 2. 1st is property name and 2nd is callback function + * + */ + var callback; + var eventName; + if (arguments.length == 2) { + callback = arguments[1]; + eventName = arguments[0]; + } else if (arguments.length == 1) { + callback = arguments[0]; + eventName = this._eventObjName; + } + + $(this._eventObj).on(eventName, callback) + }, + + id: function(selector) { + // link the selector with the ViewModel + // may need to connect multiple selector + if (selector) { + this._selector = selector; + WMStats.ViewModel.Registry[selector] = this; + return this; + } else { + return this._selector; + } + }, + + _createObservableProperty: function(observableObj) { + for (var prop in observableObj) { + this[prop] = this.observable(prop, observableObj[prop]); + } + } +}; + +WMStats.namespace("ViewModel"); + +WMStats.ViewModel = (function (){ + var properties = {page: null}; + var vm = new WMStats._ViewModelBase(properties); + vm.propagateUpdate = function() { + if (vm.page().propagateUpdate) { + vm.page().propagateUpdate(); + } + }; + return vm; +})(); + +// create WMStats.ViewModel properties +(function(vm) { + + vm.Registry ={} + + vm.ActiveRequestPage = (function (){ + var properties = {view: null, + filter: {}, + filteredStats: null, + refreshCount: 0} + var requestPage = new WMStats._ViewModelBase(properties); + + requestPage.propagateUpdate = function() { + var requestData = WMStats.ActiveRequestModel.getData(); + if (requestData === null) { + return false; + } else { + var filter = vm.ActiveRequestPage.filter(); + vm.ActiveRequestPage.data(requestData.filterRequests(filter)); + if (requestPage.view().propagateUpdate) { + requestPage.view().propagateUpdate(); + } + return true; + } + }; + + return requestPage; + })(); + + vm.RequestAlertPage = (function (){ + var alertPage = new WMStats._ViewModelBase(); + + alertPage.propagateUpdate = function() { + var requestData = WMStats.ActiveRequestModel.getData(); + if (requestData === null) { + return false; + } else { + vm.RequestAlertPage.data(requestData); + return true; + } + }; + + return alertPage; + })(); + + vm.AgentPage = (function (){ + var agentPage =new WMStats._ViewModelBase(); + + agentPage.propagateUpdate = function() { + var agentData = WMStats.AgentModel.getData(); + if (agentData === null) { + return false; + } else { + vm.AgentPage.data(agentData); + return true; + } + }; + return agentPage; + })(); + + vm.SearchPage = (function (){ + /* + * keys contain {searchCategory: blah, searchValue: blah} + */ + var properties = {keys: null} + searchPage = new WMStats._ViewModelBase(properties); + + searchPage.retrieveData = function(keys) { + var selectedSearch = keys.searchCategory; + var searchStr = keys.searchValue; + var view; + var options = {'include_docs': true, 'reduce': false}; + if (selectedSearch === 'request') { + view = "allDocs"; + options.key = searchStr; + } else if (selectedSearch === 'outputdataset') { + view = "requestByOutputDataset"; + options.key = searchStr; + } else if (selectedSearch === 'inputdataset') { + view = "requestByInputDataset"; + options.key = searchStr; + } else if (selectedSearch === 'prep_id') { + view = "requestByPrepID"; + options.key = searchStr; + } else if (selectedSearch === 'request_date') { + view = "requestByDate"; + var beginDate = $('input[name="dateRange1"]').val().split("/"); + var endDate = $('input[name="dateRange2"]').val().split("/"); + options.startkey = [Number(beginDate[0]), Number(beginDate[1]), Number(beginDate[2])]; + options.endkey = [Number(endDate[0]), Number(endDate[1]), Number(endDate[2]), {}]; + } + + WMStats.RequestSearchModel.retrieveData(view, options); + } + return searchPage; + })(); + + vm.CategoryView = (function (){ + + var properties = {category: null, + detailView: null} + + var categoryView = new WMStats._ViewModelBase(properties); + + categoryView.convertToCategoryData = function (requestData) { + if (requestData === undefined) { + requestData = vm.ActiveRequestPage.data(); + } + var category = this.category().name(); + var summaryStruct = WMStats.CategorySummaryMap.get(this.category().name()); + var categoryData = WMStats.RequestsByKey(category, summaryStruct); + categoryData.categorize(requestData); + return categoryData; + }; + + categoryView.propagateUpdate = function() { + if (vm.ActiveRequestPage.data() === null) { + return false; + }; + categoryView.data(categoryView.convertToCategoryData()); + return true; + }; + + return categoryView; + })(); + + vm.RequestView = (function (){ + /* + * format is progress or numJobs - this is tied to name of the button + * un tie. + */ + + var properties = {categoryKey: "all", + format: null, + detailView: null} + + var requestView = new WMStats._ViewModelBase(properties); + + requestView.propagateUpdate = function() { + if (vm.ActiveRequestPage.data() === null) { + return false; + }; + if (requestView.categoryKey() == "all") { + requestView.data(vm.ActiveRequestPage.data()); + } else { + var categoryData = vm.CategoryView.convertToCategoryData(); + var data = categoryData.getRequestData(requestView.categoryKey()); + requestView.data(data); + }; + return true; + }; + //TODO: hack for assigning for category map + requestView.categoryName = "requests"; + return requestView; + })(); + + function createJobSummaryView(){ + var properties = {requestName: null, detail: null}; + var jobView = new WMStats._ViewModelBase(properties); + + jobView.retrieveData = function(requestName) { + WMStats.JobSummaryModel.setRequest(requestName); + WMStats.JobSummaryModel.retrieveData(); + }; + + jobView.propagateUpdate = function() { + + /* this part is needed if you want to refresh the job view when data is updated */ + if (jobView.requestName()) { + jobView.retrieveData(jobView.requestName()); + return false; + } else { + return false; + } + }; + + jobView.updateDataAndChild = function(data) { + if (data) {jobView.data(data)} ; + if (jobView.detail().propagateUpdate) { + jobView.detail().propagateUpdate(); + return true; + } + return false; + }; + + return jobView; + }; + + vm.JobView = createJobSummaryView(); + vm.AlertJobView = createJobSummaryView(); + + vm.CampaignCategory = (function (){ + return new WMStats._ViewModelBase({name: "campaign"}); + })(); + + vm.SiteCategory = (function (){ + return new WMStats._ViewModelBase({name: "sites"}); + })(); + + + vm.CMSSWCategory = (function (){ + return new WMStats._ViewModelBase({name: "cmssw"}); + })(); + + vm.AgentCategory = (function (){ + return new WMStats._ViewModelBase({name: "agent"}); + })(); + + /* request view summary format */ + vm.RequestProgress = (function (){ + return new WMStats._ViewModelBase({name: "progress"}); + })(); + + vm.RequestJobs = (function (){ + return new WMStats._ViewModelBase({name: "numJobs"}); + })(); + + /* request view job detail */ + vm.CategoryDetail = (function (){ + var properties = {categoryKey: null} + var categoryDetail = new WMStats._ViewModelBase(properties); + + categoryDetail.propagateUpdate = function() { + if (categoryDetail.categoryKey()) { + var allData = vm.CategoryView.data() + categoryDetail.data(allData.getData(categoryDetail.categoryKey())); + } + } + return categoryDetail; + })(); + + + vm.RequestDetail = (function (){ + var properties = {requestName: null} + var requestDetail = new WMStats._ViewModelBase(properties); + requestDetail.open = false; + return requestDetail; + })(); + + function createJobDetailView(){ + var properties = {keys: null, indexID: null}; + var jobDetail = new WMStats._ViewModelBase(properties); + + jobDetail.retrieveData = function(keys) { + WMStats.JobDetailModel.setOptions(keys); + WMStats.JobDetailModel.retrieveData(); + }; + + jobDetail.propagateUpdate = function() { + /* this part is needed if you want to refresh the job view when data is updated */ + if (jobDetail.keys() !== null) { + jobDetail.retrieveData(jobDetail.keys()); + return true; + } else { + return false; + } + }; + + return jobDetail; + }; + + vm.JobDetail = createJobDetailView(); + vm.AlertJobDetail = createJobDetailView(); + + vm.Resubmission = (function (){ + /* resubmission keys contains + * requestName and taskName and acdc url + * {requestName: blah, task: blah, acdcURL: blah} + * */ + + var properties = {keys: null}; + var resubmission = new WMStats._ViewModelBase(properties); + + resubmission.retrieveData = function(keys) { + WMStats.ReqMgrRequestModel.retrieveDoc(keys.requestName); + }; + + resubmission.formatResubmissionData = function(requestInfo) { + var summary = {}; + // from resubmission keys + summary.OriginalRequestName = resubmission.keys().requestName; + summary.InitialTaskPath = resubmission.keys().task; + if (resubmission.keys().acdcURL) { + //TODO: if there is not acdc_url don't create the button' + var acdcServiceUrl = WMStats.Utils.splitCouchServiceURL(resubmission.keys().acdcURL); + summary.ACDCServer = acdcServiceUrl.couchUrl; + summary.ACDCDatabase = acdcServiceUrl.couchdb; + } + + //from passing request info + summary.Memory = requestInfo.Memory; + summary.SizePerEvent = requestInfo.SizePerEvent; + summary.TimePerEvent = requestInfo.TimePerEvent; + + //TODO remove this line when requestInfo has all the information + requestInfo = WMStats.ActiveRequestModel.getData().getData(summary.OriginalRequestName); + + summary.DbsUrl = requestInfo.DbsUrl || "http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet"; + summary.Group = requestInfo.Group; + summary.RequestPriority = requestInfo.RequestPriority + summary.RequestString = WMStats.Utils.acdcRequestSting(summary.OriginalRequestName, requestInfo.Requestor) + summary.PrepID = requestInfo.PrepID; + summary.RequestType = "Resubmission"; + + return summary; + } + + resubmission.propagateUpdate = function() { + if (resubmission.keys() !== null) { + resubmission.retrieveData(resubmission.keys()); + return true; + } else { + return false; + } + }; + + return resubmission; + })(); + + vm.initialize = (function (){ + //default setting + vm.page(vm.ActiveRequestPage, true); + vm.ActiveRequestPage.view(vm.CategoryView, true); + vm.CategoryView.category(vm.CampaignCategory, true); + vm.RequestView.format(vm.RequestProgress, true); + vm.JobView.detail(vm.JobDetail, true); + })(); + +})(WMStats.ViewModel); + +// control inside the view model +(function(vm){ + // filter control + vm.ActiveRequestPage.subscribe("filter", function() { + vm.ActiveRequestPage.propagateUpdate(); + }); + + vm.SearchPage.subscribe("keys", function(){ + vm.SearchPage.retrieveData(vm.SearchPage.keys()); + }); + + vm.CategoryView.subscribe("category", function() { + vm.CategoryView.propagateUpdate(); + }); + + vm.RequestView.subscribe("categoryKey", function() { + vm.ActiveRequestPage.view(vm.RequestView); + }); + + vm.JobView.subscribe("requestName", function() { + vm.ActiveRequestPage.view(vm.JobView); + }); + + vm.AlertJobView.subscribe("requestName", function() { + vm.AlertJobView.retrieveData(vm.AlertJobView.requestName()); + }); + + vm.CategoryDetail.subscribe("categoryKey", function() { + vm.CategoryDetail.propagateUpdate(); + }); + + vm.JobDetail.subscribe("keys", function() { + vm.JobDetail.retrieveData(vm.JobDetail.keys()); + }); + + vm.AlertJobDetail.subscribe("keys", function() { + vm.AlertJobDetail.retrieveData(vm.AlertJobDetail.keys()); + }); + + vm.Resubmission.subscribe("keys", function() { + vm.Resubmission.retrieveData(vm.Resubmission.keys()); + }); + +})(WMStats.ViewModel); diff --git a/src/couchapps/WMStats/_attachments/js/ViewModels/import.js b/src/couchapps/WMStats/_attachments/js/ViewModels/import.js new file mode 100644 index 0000000000..7e22533e9f --- /dev/null +++ b/src/couchapps/WMStats/_attachments/js/ViewModels/import.js @@ -0,0 +1,2 @@ +//import common scripts +WMStats.Globals.importScripts(["js/ViewModels/WMStats.ViewModel.js"]) \ No newline at end of file diff --git a/src/couchapps/WMStats/_attachments/js/Views/Controls/Analysis/WMStats.Controls.js b/src/couchapps/WMStats/_attachments/js/Views/Controls/Analysis/WMStats.Controls.js deleted file mode 100644 index 188ebf98ca..0000000000 --- a/src/couchapps/WMStats/_attachments/js/Views/Controls/Analysis/WMStats.Controls.js +++ /dev/null @@ -1,68 +0,0 @@ -WMStats.namespace("Controls"); -WMStats.Controls = function($){ - - var _filterSelector; - var _categorySelector; - - function setFilter(selector) { - $(selector).append('
\ - campaign: \ - workflow: \ - type: \ - status: \ - user dn: \ -
'); - _filterSelector = selector + ' div[name="filter"] input'; - }; - - function setCategoryButton(selector) { - var categoryBottons = - ''; - - $(selector).append(categoryBottons); - WMStats.Env.CategorySelection = "user_dn"; - }; - - function setAllRequestButton(selector) { - var requestBottons = - ''; - - $(selector).append(requestBottons).addClass("button-group"); - WMStats.Env.RequestSelection = "all_requests"; - }; - - function getCategoryButtonValue() { - return WMStats.Env.CategorySelection; - }; - - function getFilter() { - return WMStats.Utils.createInputFilter(_filterSelector); - }; - - function setTabs(selector) { - var tabs = '' - $(selector).append(tabs).addClass("tabs"); - $(selector + " ul").addClass("tabs-nav"); - }; - - return { - setFilter: setFilter, - setTabs: setTabs, - setCategoryButton: setCategoryButton, - setAllRequestButton: setAllRequestButton, - getCategoryButtonValue: getCategoryButtonValue, - getFilter: getFilter, - requests: "requests", - sites: "sites", - userDN: "user_dn", - campaign: "campaign" - } -}(jQuery); diff --git a/src/couchapps/WMStats/_attachments/js/Views/Controls/T1/WMStats.Controls.js b/src/couchapps/WMStats/_attachments/js/Views/Controls/T1/WMStats.Controls.js index c41a7b208e..c5c23e474c 100644 --- a/src/couchapps/WMStats/_attachments/js/Views/Controls/T1/WMStats.Controls.js +++ b/src/couchapps/WMStats/_attachments/js/Views/Controls/T1/WMStats.Controls.js @@ -1,7 +1,9 @@ WMStats.namespace("Controls"); WMStats.Controls = function($){ - var _filterSelector; + var vm = WMStats.ViewModel; + var vmRegistry = WMStats.ViewModel.Registry; + var _categorySelector; function setFilter(selector) { @@ -15,7 +17,14 @@ WMStats.Controls = function($){
site whitelist:
\
agent:
\
'); - _filterSelector = selector + ' div[name="filter"] input'; + var _filterSelector = selector + ' div[name="filter"] input'; + + $(document).on('keyup', selector + " input", + function() { + //change the view model filter value + WMStats.ViewModel.ActiveRequestPage.filter(WMStats.Utils.createInputFilter(_filterSelector)); + + }) }; function setCategoryButton(selector) { @@ -23,13 +32,31 @@ WMStats.Controls = function($){ ''; $(selector).append(categoryBottons); - WMStats.Env.CategorySelection = "campaign"; + + $(document).on('click', selector + " li a", function(event){ + var category = this.hash.substring(1); + var vmCategory; + if (category === "campaign") { + vmCategory = vm.CampaignCategory; + } else if (category === "sites") { + vmCategory = vm.SiteCategory; + } else if (category === "cmssw") { + vmCategory = vm.CMSSWCategory; + } else if (category === "agent") { + vmCategory = vm.AgentCategory; + } + vm.CategoryView.category(vmCategory); + $(selector + " li a").removeClass("nav-button-selected").addClass("button-unselected"); + $(this).addClass("nav-button-selected"); + event.preventDefault(); + }); }; - + function setViewSwitchButton(selector) { var viewSwitchBottons = ''; $(selector).append(viewSwitchBottons); - WMStats.Env.ViewSwitchSelection = "progress"; + + $(document).on('click', "#view_switch_button li a", function(event){ + // format is either progress or numJobs need to decouple the name + var buttonName = this.hash.substring(1); + var requestFormat; + if (buttonName === "progress") { + requestFormat = vm.RequestProgress; + } else if (buttonName === "numJobs") { + requestFormat = vm.RequestJobs; + } + + vm.RequestView.format(requestFormat); + // this might not be the efficient way. or directly update the table. + vm.RequestView.propagateUpdate(); + $("#view_switch_button li a").removeClass("nav-button-selected").addClass("button-unselected"); + $(this).addClass("nav-button-selected"); + event.preventDefault(); + }) + }; function setAllRequestButton(selector) { @@ -48,25 +93,47 @@ WMStats.Controls = function($){ '; $(selector).append(requestBottons).addClass("button-group"); - WMStats.Env.RequestSelection = "all_requests"; - }; - - function getCategoryButtonValue() { - return WMStats.Env.CategorySelection; - }; - - function getFilter() { - return WMStats.Utils.createInputFilter(_filterSelector); + + $(document).on('click', "#all_requests li a", function(event){ + vm.RequestView.categoryKey("all"); + event.preventDefault(); + }) + + vm.RequestView.subscribe("categoryKey", function(){ + var buttonSelector = "#all_requests li a"; + if (vm.RequestView.categoryKey() === "all") { + $(buttonSelector).removeClass("button-unselected").addClass("nav-button-selected"); + } else { + $(buttonSelector).removeClass("nav-button-selected").addClass("button-unselected"); + } + }) }; - + + /* set the view tab and control*/ function setTabs(selector) { var tabs = '' $(selector).append(tabs).addClass("tabs"); $(selector + " ul").addClass("tabs-nav"); + + // add controller for this view + function changeTab(event, data) { + $(selector + ' li').removeClass("tabs-selected"); + $(selector + ' a[href="' + data.id() +'"]').parent().addClass("tabs-selected"); + } + // viewModel -> view control + vm.ActiveRequestPage.subscribe("view", changeTab); + + // view -> viewModel control + $(document).on('click', selector + " li a", function(event){ + vm.ActiveRequestPage.view(vmRegistry[this.hash]); + event.preventDefault(); + }); + }; + function setExternalLink(selector) { var outsideLink = ' agent alert '; @@ -74,15 +141,14 @@ WMStats.Controls = function($){ $(selector).append(outsideLink); }; + return { setFilter: setFilter, setTabs: setTabs, setCategoryButton: setCategoryButton, setAllRequestButton: setAllRequestButton, - getCategoryButtonValue: getCategoryButtonValue, setViewSwitchButton: setViewSwitchButton, setExternalLink: setExternalLink, - getFilter: getFilter, requests: "requests", sites: "sites", campaign: "campaign", diff --git a/src/couchapps/WMStats/_attachments/js/Views/Controls/WMStats.CommonControls.js b/src/couchapps/WMStats/_attachments/js/Views/Controls/WMStats.CommonControls.js index 8bb3c40e35..5909cabe0e 100644 --- a/src/couchapps/WMStats/_attachments/js/Views/Controls/WMStats.CommonControls.js +++ b/src/couchapps/WMStats/_attachments/js/Views/Controls/WMStats.CommonControls.js @@ -1,6 +1,9 @@ WMStats.namespace("CommonControls"); WMStats.CommonControls = function($){ + var vm = WMStats.ViewModel; + var vmRegistry = WMStats.ViewModel.Registry; + function setUTCClock(selector) { setInterval(function() { $(selector).text(WMStats.Utils.utcClock()); @@ -11,12 +14,28 @@ WMStats.CommonControls = function($){ var linkTabs = ''; $(selector).append(linkTabs); + + // add controller for this view + function changeTab(event, data) { + $('#linkTabs li').removeClass("title-tab-selected").addClass("title-tab-hide"); + $('#linkTabs a[href="' + data.id() +'"]').parent().removeClass("title-tab-hide").addClass("title-tab-selected") + } + // viewModel -> view control + vm.subscribe("page", changeTab); + + // view -> viewModel control + $(document).on('click', "#linkTabs li a", function(event){ + vm.page(vmRegistry[this.hash]) + event.preventDefault(); + }); }; + function setWorkloadSummarySearch(selector) { var searchOption = '
\ @@ -41,25 +60,35 @@ WMStats.CommonControls = function($){
'; $(selector).append(searchOption); + + // change the search options + $(document).on('change', 'select[name="SearchOptions"]',function(){ + var filterType = $(':selected', this).attr('data-search-type'); + var searchBox = $('#searchPane .SearchBox'); + $(searchBox).empty(); + $('div.template.'+ filterType).children().clone().appendTo('#searchPane .SearchBox'); + $('#searchPane .SearchBox input[name="dateRange1"]').datepicker({ + altField: 'input[name="dateRange1"]', + altFormat: "yy/mm/dd", + changeYear: true, + yearRange: "2012:c"}); + $('#searchPane .SearchBox input[name="dateRange2"]').datepicker({ + altField: 'input[name="dateRange2"]', + altFormat: "yy/mm/dd", + changeYear: true, + yearRange: "2012:c"}); + }); + + // control submit button + $(document).on('click', '#WorkloadSummarySearchButton', function(event) { + var keys = {}; + keys.searchCategory = $('#search_option_board select[name="SearchOptions"] :selected').val(); + keys.searchValue = $('input[name="workloadSummarySearch"]').val(); + vm.SearchPage.keys(keys); + event.stopPropagation(); + }) }; - $(document).on('change', 'select[name="SearchOptions"]',function(){ - var filterType = $(':selected', this).attr('data-search-type'); - var searchBox = $('#searchPane .SearchBox'); - $(searchBox).empty(); - $('div.template.'+ filterType).children().clone().appendTo('#searchPane .SearchBox'); - $('#searchPane .SearchBox input[name="dateRange1"]').datepicker({ - altField: 'input[name="dateRange1"]', - altFormat: "yy/mm/dd", - changeYear: true, - yearRange: "2012:c"}); - $('#searchPane .SearchBox input[name="dateRange2"]').datepicker({ - altField: 'input[name="dateRange2"]', - altFormat: "yy/mm/dd", - changeYear: true, - yearRange: "2012:c"}); - }); - return { setUTCClock: setUTCClock, setLinkTabs: setLinkTabs, diff --git a/src/couchapps/WMStats/_attachments/js/Views/Controls/import.js b/src/couchapps/WMStats/_attachments/js/Views/Controls/import.js index a606a45a52..2367906f23 100644 --- a/src/couchapps/WMStats/_attachments/js/Views/Controls/import.js +++ b/src/couchapps/WMStats/_attachments/js/Views/Controls/import.js @@ -7,7 +7,4 @@ if (WMStats.Globals.VARIANT == "tier1") { } else if (WMStats.Globals.VARIANT == "tier0") { //import tie0 specific table WMStats.Globals.importScripts( ["js/Views/Controls/T0/WMStats.Controls.js"]) -} else if (WMStats.Globals.VARIANT == "analysis") { - //import analysis specific table - WMStats.Globals.importScripts([ "js/Views/Controls/Analysis/WMStats.Controls.js"]) -}; +} \ No newline at end of file diff --git a/src/couchapps/WMStats/_attachments/js/Views/HTMLList/Analysis/WMStats.CategoryDetailList.js b/src/couchapps/WMStats/_attachments/js/Views/HTMLList/Analysis/WMStats.CategoryDetailList.js deleted file mode 100644 index a8c609ca98..0000000000 --- a/src/couchapps/WMStats/_attachments/js/Views/HTMLList/Analysis/WMStats.CategoryDetailList.js +++ /dev/null @@ -1,45 +0,0 @@ -WMStats.namespace('CategoryDetailList'); -(function() { - var format = function (requestStruct) { - var htmlstr = ''; - var reqDoc = requestStruct.requests[requestStruct.key]; - var reqSummary = requestStruct.summary; - - htmlstr += "
" - htmlstr += ""; - htmlstr += "
"; - return htmlstr; - } - - WMStats.CategoryDetailList = function (data, containerDiv) { - $(containerDiv).html(format(data)); - } -})(); diff --git a/src/couchapps/WMStats/_attachments/js/Views/HTMLList/Analysis/WMStats.RequestDetailList.js b/src/couchapps/WMStats/_attachments/js/Views/HTMLList/Analysis/WMStats.RequestDetailList.js deleted file mode 100644 index 2ee7326dd8..0000000000 --- a/src/couchapps/WMStats/_attachments/js/Views/HTMLList/Analysis/WMStats.RequestDetailList.js +++ /dev/null @@ -1,45 +0,0 @@ -WMStats.namespace('RequestDetailList'); -(function() { - var format = function (requestStruct) { - var htmlstr = '
X
'; - var reqDoc = requestStruct.requests[requestStruct.key]; - var reqSummary = requestStruct.summary; - - htmlstr += "
" - htmlstr += ""; - htmlstr += "
"; - return htmlstr; - } - - WMStats.RequestDetailList = function (data, containerDiv) { - $(containerDiv).html(format(data)); - } -})(); diff --git a/src/couchapps/WMStats/_attachments/js/Views/HTMLList/T0/WMStats.CategoryDetailList.js b/src/couchapps/WMStats/_attachments/js/Views/HTMLList/T0/WMStats.CategoryDetailList.js index a910ffdbd4..e48865b310 100644 --- a/src/couchapps/WMStats/_attachments/js/Views/HTMLList/T0/WMStats.CategoryDetailList.js +++ b/src/couchapps/WMStats/_attachments/js/Views/HTMLList/T0/WMStats.CategoryDetailList.js @@ -5,7 +5,6 @@ WMStats.namespace('CategoryDetailList'); var reqDoc = requestStruct.requests; var reqSummary = requestStruct.summary; - //var allRequests.getDataByWorkflow = allRequests.getDataByWorkflow htmlstr += "
" htmlstr += "
"; + errorFlag = true; + } + + $(containerDiv).addClass("request_error_box"); + if (errorFlag) { $(containerDiv).removeClass("stable warning").addClass("error").html(htmlList); } else { $(containerDiv).removeClass("warning error").addClass("stable").html("request alarm"); } }; + +// controller for request alert view +(function() { + + var vm = WMStats.ViewModel; + vm.RequestAlertPage.subscribe("data", function(){ + var divSelector = vm.RequestAlertPage.id() + " div.summary_data"; + WMStats.RequestAlertGUI(vm.RequestAlertPage.data(), divSelector); + }); + + $(document).on('click', 'a.requestAlert', function() { + var workflow = $(this).text(); + + vm.ActiveRequestPage.view(vm.JobView); + vm.page(vm.ActiveRequestPage); + vm.JobView.requestName(workflow); + $(this).addClass('reviewed'); + }); +})(); diff --git a/src/couchapps/WMStats/_attachments/js/Views/HTMLList/T1/WMStats.RequestDetailList.js b/src/couchapps/WMStats/_attachments/js/Views/HTMLList/T1/WMStats.RequestDetailList.js index d4676d02a9..87fe628217 100644 --- a/src/couchapps/WMStats/_attachments/js/Views/HTMLList/T1/WMStats.RequestDetailList.js +++ b/src/couchapps/WMStats/_attachments/js/Views/HTMLList/T1/WMStats.RequestDetailList.js @@ -1,6 +1,7 @@ WMStats.namespace('RequestDetailList'); (function() { + var vm = WMStats.ViewModel; var progressFormat = function(progressStat, totalEvents, totalLumis) { var formatStr = "";for(var index in jobDetails){var jobDoc=jobDetails[index];if(index==="0"){htmlstr+="
"}else{htmlstr+="
"}htmlstr+="";htmlstr+="
"}return htmlstr};WMStats.JobDetailList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("AgentStatusGUI");WMStats.AgentStatusGUI=function(data,containerDiv){var dataList=data.getAlertList();var collectiveStatus="ok";function setStatus(status){if(collectiveStatus=="ok"){collectiveStatus=status}else if(collectiveStatus=="warning"&&status=="error"){collectiveStatus="error"}}var htmlList="";if(collectiveStatus=="ok"){$(containerDiv).removeClass("warning error").addClass("stable")}else if(collectiveStatus=="warning"){$(containerDiv).removeClass("stable error").addClass("warning").html(htmlList)}else if(collectiveStatus=="error"){$(containerDiv).removeClass("stable warning").addClass("error").html(htmlList)}};WMStats.namespace("AgentDetailList");(function(){var statusInterpretator=function(alertStatus){if(alertStatus=="agent_down"){message="Data is not updated: AnalyticsDataCollector Down"}else if(alertStatus=="component_down"){message="Components or Thread down"}else{message="OK"}return message};var componentFormat=function(componentList){var formatStr="";for(var i in componentList){formatStr+="
"+componentList[i].name+"
"}return formatStr};var agentErrorFormat=function(agentInfo){var htmlstr="";htmlstr+="
";htmlstr+="";htmlstr+="
";return htmlstr};var agentStableFormat=function(agentInfo){var htmlstr="";htmlstr+="
";htmlstr+="";htmlstr+="
";return htmlstr};var format=function(agentData){var htmlstr="";var agentsWithWarning=agentData.getAlertList();for(i in agentsWithWarning){if(agentsWithWarning[i].alert&&agentsWithWarning[i].alert.status!=="ok"){htmlstr+=agentErrorFormat(agentsWithWarning[i])}else{htmlstr+=agentStableFormat(agentsWithWarning[i])}}return htmlstr};WMStats.AgentDetailList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("WMStats.CategoryTitle");(function(){var format=function(data){var categoryKey=data;var htmlstr="";htmlstr+="
";htmlstr+="";htmlstr+="
";return htmlstr};WMStats.CategoryTitle=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("WMStats.RequestTitle");(function(){var format=function(data){var workflow;var dataType;if(typeof data==="string"){workflow=data;dataType=0}else{workflow=data.getData().workflow;dataType=1}var requestInfo=WMStats.ActiveRequestModel.getData().getDataByWorkflow(workflow);var htmlstr="";htmlstr+="
";htmlstr+="";htmlstr+="
";return htmlstr};WMStats.RequestTitle=function(data,containerDiv){if(typeof data==="string"||typeof data==="object"&&data.getData().workflow!==undefined){$(containerDiv).html(format(data))}}})();WMStats.namespace("SiteHistoryGraph");WMStats.SiteHistoryGraph=function(historyData,containerDiv){var siteHistory=JSON.stringify(historyData);var htmlList="
"+siteHistory+"
";$(containerDiv).html(htmlList)};WMStats.namespace("Controls");WMStats.Controls=function($){var _filterSelector;var _categorySelector;function setFilter(selector){var inputFilter='
workflow: status: run:
';$(selector).append(inputFilter);_filterSelector=selector+' div[name="filter"] input'}function setCategoryButton(selector){WMStats.Env.CategorySelection="run"}function setViewSwitchButton(selector){WMStats.Env.ViewSwitchSelection="progress"}function setAllRequestButton(selector){var requestBottons='';$(selector).append(requestBottons).addClass("button-group");WMStats.Env.RequestSelection="all_requests"}function getCategoryButtonValue(){return WMStats.Env.CategorySelection}function getFilter(){return WMStats.Utils.createInputFilter(_filterSelector)}function setTabs(selector){var tabs='';$(selector).append(tabs).addClass("tabs");$(selector+" ul").addClass("tabs-nav")}return{setFilter:setFilter,setTabs:setTabs,setCategoryButton:setCategoryButton,setAllRequestButton:setAllRequestButton,getCategoryButtonValue:getCategoryButtonValue,setViewSwitchButton:setViewSwitchButton,getFilter:getFilter,requests:"requests",sites:"sites",run:"run"}}(jQuery);WMStats.namespace("ActiveRequestTable");WMStats.ActiveRequestTable=function(requestData,containerDiv){var formatReqDetailUrl=WMStats.Utils.formatReqDetailUrl;var formatWorkloadSummarylUrl=WMStats.Utils.formatWorkloadSummarylUrl;var tableConfig={iDisplayLength:25,sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"workflow",sTitle:"workflow"},{mDataProp:function(source,type,val){return source.request_status[source.request_status.length-1].status},sTitle:"status",fnRender:function(o,val){return formatWorkloadSummarylUrl(o.aData.workflow,o.aData.request_status[o.aData.request_status.length-1].status)},bUseRendered:false},{mDataProp:function(source,type,val){return source.request_status[source.request_status.length-1].update_time},sTitle:"duration",fnRender:function(o,val){var currentTime=Math.round((new Date).getTime()/1e3);var startTime=o.aData.request_status[o.aData.request_status.length-1].update_time;return WMStats.Utils.foramtDuration(currentTime-startTime)},bUseRendered:false},{sDefaultContent:0,sTitle:"job progress",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);var totalJobs=reqSummary.getWMBSTotalJobs()||1;var result=(reqSummary.getJobStatus("success")+reqSummary.getTotalFailure())/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"submitted",fnRender:function(o,val){var result=requestData.getDataByWorkflow(o.aData.workflow,"status.submitted.first",0);result+=requestData.getDataByWorkflow(o.aData.workflow,"status.submitted.retry",0);return result}},{sDefaultContent:0,sTitle:"pending",fnRender:function(o,val){var result=requestData.getDataByWorkflow(o.aData.workflow,"status.submitted.pending",0);return result}},{sDefaultContent:0,sTitle:"running",fnRender:function(o,val){var result=requestData.getDataByWorkflow(o.aData.workflow,"status.submitted.running",0);return result}},{sDefaultContent:0,sTitle:"cool off ",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);return reqSummary.getTotalCooloff()}},{sDefaultContent:0,sTitle:"paused",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);return reqSummary.getTotalPaused()}},{sDefaultContent:0,sTitle:"run",fnRender:function(o,val){return requestData.getDataByWorkflow(o.aData.workflow,"run",0)}}]};function runNumerDesc(a,b){return Number(b.run)-Number(a.run)}tableConfig.aaData=requestData.getList(runNumerDesc);return WMStats.Table(tableConfig).create(containerDiv,null)};WMStats.namespace("RunSummaryTable");WMStats.RunSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:25,sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"key",sTitle:"run"},{mDataProp:function(source,type,val){return source.summary.summaryStruct.numRequests},sTitle:"requests",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.summaryStruct.runStatus},sTitle:"run status",sDefaultContent:"Active"},{mDataProp:function(source,type,val){return source.summary.getJobStatus("success")},sTitle:"success",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getTotalFailure()},sTitle:"failure",sDefaultContent:0},{sDefaultContent:0,sTitle:"job progress",mDataProp:function(source,type,val){var totalJobs=source.summary.getWMBSTotalJobs()||1;var result=(source.summary.getJobStatus("success")+source.summary.getTotalFailure())/totalJobs*100;if(type==="display"){return result.toFixed(1)+"%"}return result.toFixed(1)}},{mDataProp:function(source,type,val){return source.summary.getJobStatus("submitted.pending")},sTitle:"pending",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getJobStatus("submitted.running")},sTitle:"running",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getTotalCooloff()},sTitle:"cool off",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getTotalPaused()},sTitle:"paused",sDefaultContent:0}]};function runNumerDesc(a,b){return Number(b.key)-Number(a.key)}tableConfig.aaData=data.getList(runNumerDesc);var filterConfig={};return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("RequestDetailList");(function(){var transitionFormat=function(dataArray,maxLength,summaryStr){var htmlstr="";if(dataArray==undefined||dataArray.length==undefined||dataArray.length<=maxLength){htmlstr+=dataArray}else{htmlstr+="
"+summaryStr+"
"}return htmlstr};var format=function(requestStruct){var htmlstr='
X
';var reqDoc=requestStruct.requests;var reqSummary=requestStruct.summary;htmlstr+="
";htmlstr+="";htmlstr+="
";return htmlstr};WMStats.RequestDetailList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("RequestAlertGUI");WMStats.RequestAlertGUI=function(requestData,containerDiv){function mapType(workflowName){var workflowType=workflowName.split("_")[0].toLowerCase();if(workflowType=="express"){return 1}else if(workflowType=="repack"){return 2}else if(workflowType=="promptreco"){return 3}return 4}function alertSort(a,b){var aRun=a.requests[a.key].run;var bRun=b.requests[b.key].run;if(aRun==bRun){var aType=mapType(a.key);var bType=mapType(b.key);if(aType==bType){var aJobs=a.summary.getTotalPaused()+a.summary.getTotalCooloff();var bJobs=b.summary.getTotalPaused()+b.summary.getTotalCooloff();return bJobs-aJobs}else{return aType-bType}}else{return aRun-bRun}}var alertRequests=requestData.getAlertRequests();if(alertRequests.length>0){var htmlList="";$(containerDiv).removeClass("stable warning").addClass("error").html(htmlList)}else{$(containerDiv).removeClass("warning error").addClass("stable").html("request alarm")}};WMStats.namespace("CategoryDetailList");(function(){var format=function(requestStruct){var htmlstr="";var reqDoc=requestStruct.requests;var reqSummary=requestStruct.summary;htmlstr+="
";htmlstr+="";htmlstr+="
";return htmlstr};WMStats.CategoryDetailList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("RequestSummaryList");(function(){var format=function(summary){var summaryStruct=summary.summaryStruct;var htmlstr="";htmlstr+="
";htmlstr+="";htmlstr+="
";return htmlstr};WMStats.RequestSummaryList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("RequestDataList");(function(){var format=function(summary){var summaryStruct=summary.summaryStruct;var htmlstr="";htmlstr+="
";htmlstr+="";htmlstr+="
";return htmlstr};WMStats.RequestDataList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("_ModelBase");WMStats._ModelBase=function(initView,options,dataStruct){this._initialView=initView;this._options=options;this._dataStruct=dataStruct;this._trigger=null;this._data=null;this._dbSource=WMStats.Couch};WMStats._ModelBase.prototype={setTrigger:function(triggerName){this._trigger=triggerName},getData:function(){return this._data},dataReady:function(data){this._data=this._dataStruct(data);if(this._trigger instanceof Array){for(var i in this._trigger){jQuery(WMStats.Globals.Event).triggerHandler(this._trigger[i],this._data)}}else{jQuery(WMStats.Globals.Event).triggerHandler(this._trigger,this._data)}},retrieveData:function(view,options){if(options===undefined){var options=this._options}if(view===undefined){var view=this._initialView}if(view==="allDocs"){return this.retrieveAllDocs(options)}else if(view==="doc"){return this.retrieveDoc(options)}else{return this._dbSource.view(view,options,jQuery.proxy(this.callback,this))}},retrieveAllDocs:function(options){if(options===undefined){var options=this._options}return this._dbSource.allDocs(options,jQuery.proxy(this.callback,this))},retrieveDoc:function(docID){return this._dbSource.openDoc(docID,jQuery.proxy(this.callback,this))},setDBSource:function(dbSource){this._dbSource=dbSource},callback:function(data){return this.dataReady(data)},clearData:function(){delete this._data}};WMStats.namespace("_RequestModelBase");WMStats._RequestModelBase=function(initView,options){this._initialView=initView||"requestByCampaignAndDate";this._options=options||{include_docs:true};this._data=null;this._trigger="requestReady"};WMStats._RequestModelBase.keysFromIDs=function(data){var keys=[];for(var i in data.rows){if(data.rows[i].value&&data.rows[i].value.id){keys.push(data.rows[i].value.id)}else{keys.push(data.rows[i].id)}}return keys};WMStats._RequestModelBase.requestAgentUrlKeys=function(requestList,requestAgentData){var keys={};var requestAgentUrlList=[];for(var i in requestAgentData.rows){var request=requestAgentData.rows[i].key[0];if(!keys[request]){keys[request]=[]}keys[request].push(requestAgentData.rows[i].key[1])}for(var j=0;j0){$('#linkTabs a[href="#agentInfoPage"] strong').text("("+agentData.agentNumber.error+")")}});$(WMStats.Globals.Event).on(E.CATEGORY_SUMMARY_READY,function(event,data){$("#category_view div.detail_data").empty();drawDataBoard("#category_view")});$(WMStats.Globals.Event).on(E.REQUEST_SUMMARY_READY,function(event,data){$("#request_view div.detail_data").empty();if(data){WMStats.Env.CurrentRequestData=data}drawDataBoard("#request_view")});$(WMStats.Globals.Event).on(E.JOB_SUMMARY_READY,function(event,data){WMStats.RequestTitle(data,"#request_title");$("#job_view div.detail_data").empty();WMStats.Env.JobSummaryTable=WMStats.JobSummaryTable(data,"#job_view div.summary_data");WMStats.GenericController.switchView("#job_view")});$(WMStats.Globals.Event).on(E.CATEGORY_DETAIL_READY,function(event,categoryKey){var allData=WMStats.Env.CategoryData;var data=allData.getData(categoryKey);WMStats.CategoryDetailList(data,"#category_view div.detail_data")});$(WMStats.Globals.Event).on(E.REQUEST_DETAIL_READY,function(event,workflow){var allRequests=WMStats.ActiveRequestModel.getRequests();var reqDoc=allRequests.getDataByWorkflow(workflow);var reqSummary=allRequests.getSummary(workflow);var requests={};requests[workflow]=reqDoc;var data={key:workflow,requests:requests,summary:reqSummary};WMStats.RequestDetailList(data,"#request_view div.detail_data")});$(WMStats.Globals.Event).on(E.JOB_DETAIL_READY,function(event,data){WMStats.JobDetailList(data,"#job_view div.detail_data")});$(document).on("keyup","#filter_board input",function(){getActiveFilteredData();drawFilteredRequestSummary();drawDataBoard()});$(document).on("click","#category_button li a",function(event){WMStats.Env.CategorySelection=this.hash.substring(1);$(WMStats.Globals.Event).triggerHandler(E.CATEGORY_SUMMARY_READY);$("#category_button li a").removeClass("nav-button-selected").addClass("button-unselected");$(this).removeClass("button-unselected").addClass("nav-button-selected");event.preventDefault()});$(document).on("click","#all_requests li a",function(event){WMStats.Env.RequestSelection="all_requests";var data=WMStats.ActiveRequestModel.getRequests();$(WMStats.Globals.Event).triggerHandler(E.REQUEST_SUMMARY_READY,data);$(this).removeClass("button-unselected").addClass("nav-button-selected");event.preventDefault()});$(document).on("click","#view_switch_button li a",function(event){WMStats.Env.ViewSwitchSelection=this.hash.substring(1);$(WMStats.Globals.Event).triggerHandler(E.REQUEST_SUMMARY_READY);$(this).removeClass("button-unselected").addClass("nav-button-selected");event.preventDefault()});$(document).on("click","a.requestAlert",function(){var workflow=$(this).text();WMStats.JobSummaryModel.setRequest(workflow);$(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START);WMStats.JobSummaryModel.retrieveData();$(this).addClass("reviewed")});$(document).on("click","#tab_board li a",function(event){drawDataBoard(this.hash);event.preventDefault()});$(document).on("click","#jobDetailNav li a",function(event){$("div.jobDetailBox").hide();$(this.hash).show();$("#jobDetailNav li a").removeClass("button-selected").addClass("button-unselected");$(this).removeClass("button-unselected").addClass("button-selected");event.preventDefault()});$(WMStats.Globals.Event).on(E.LOADING_DIV_START,function(event,data){if(WMStats.Env.View==="#category_view"||WMStats.Env.View==="#request_view"&&WMStats.Env.RequestSelection==="all_requests"){$("#loading_page").show()}});$(WMStats.Globals.Event).on(E.LOADING_DIV_END,function(event,data){$("#loading_page").hide()});$(WMStats.Globals.Event).on(E.AJAX_LOADING_START,function(event,data){$("#loading_page").show()});$(WMStats.Globals.Event).on(E.RESUBMISSION_SUMMARY_READY,function(event,data){var reqMgrReq=WMStats.ReqMgrRequestModel.getData().getData();var summary=WMStats.ViewModel.Resubmission;summary.Memory=reqMgrReq.Memory;summary.SizePerEvent=reqMgrReq.SizePerEvent;summary.TimePerEvent=reqMgrReq.TimePerEvent;WMStats.ResubmissionList(summary,"#acdc_submission")})})(jQuery);WMStats.namespace("CategorySummaryMap");WMStats.namespace("CategoryTableMap");WMStats.CategorySummaryMap=function(){var summaryMap={};function add(category,summaryFunc){summaryMap[category]=summaryFunc}function get(category){return summaryMap[category]}return{add:add,get:get}}();WMStats.CategoryTableMap=function(){var tableMap={};function add(category,view){tableMap[category]=view}function get(category,view){if(category===WMStats.Controls.requests){return tableMap[category][WMStats.Env.ViewSwitchSelection]}else{return tableMap[category]}}return{add:add,get:get}}();WMStats.CategorySummaryMap.add(WMStats.Controls.sites,WMStats.SiteSummary);WMStats.CategoryTableMap.add(WMStats.Controls.sites,WMStats.SiteSummaryTable);WMStats.CategoryTableMap.add(WMStats.Controls.requests,{progress:WMStats.ActiveRequestTable,numJobs:WMStats.ActiveRequestTableWithJob});(function($){var E=WMStats.CustomEvents;var COL_INDEX={};function TableEventHandler(containerID,populateRequestTable){this.containerID=containerID;if(populateRequestTable){this.populateRequestTable=populateRequestTable}}TableEventHandler.highlightRow=function(selector,currenElement){$(selector).removeClass("mouseclickRow");$(currenElement).addClass("mouseclickRow")};TableEventHandler.prototype={constructor:TableEventHandler,tableRowBind:function(bind,parentSelector,func){var currentObj=this;var selector=parentSelector+" table tbody tr";$(document).on(bind,selector,function(){TableEventHandler.highlightRow(selector,this);currentObj[func](this)})},tableColumnBind:function(bind,parentSelector,name,func){var currentObj=this;var selector=parentSelector+' table tbody tr td div[name="'+name+'"]';var rowSelector=parentSelector+" table tbody tr";$(document).on(bind,selector,function(){var currentRow=$(this).closest("tr")[0];TableEventHandler.highlightRow(rowSelector,currentRow);currentObj[func](currentRow); -event.preventDefault()})},populateRequestSummary:function(currentElement){var nTds=$("td",currentElement);var categoryKey=$(nTds[2]).text();var category=WMStats.Controls.getCategoryButtonValue();var categoryData=getCategorizedData(category);var requestData=categoryData.getRequestData(categoryKey);WMStats.CategoryTitle(categoryKey,"#category_title");WMStats.Env.RequestSelection="partial_requests";$(WMStats.Globals.Event).triggerHandler(E.REQUEST_SUMMARY_READY,requestData);$("#all_requests li a").removeClass("nav-button-selected").addClass("button-unselected")},populateJobSummary:function(currentElement){var nTds=$("td",currentElement);var requestName=$(nTds[2]).text();WMStats.RequestTitle(requestName,"#request_title");WMStats.JobSummaryModel.setRequest(requestName);$(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START);WMStats.JobSummaryModel.retrieveData()},populateRequestDetail:function(currentElement){var nTds=$("td",currentElement);var workflowName=$(nTds[2]).text();$(WMStats.Globals.Event).triggerHandler(E.REQUEST_DETAIL_READY,workflowName)},populateCategoryDetail:function(currentElement){var nTds=$("td",currentElement);var categoryKey=$(nTds[2]).text();$(WMStats.Globals.Event).triggerHandler(E.CATEGORY_DETAIL_READY,categoryKey)},populateJobDetail:function(currentElement){var summary={};summary.workflow=$("#job_view div.summary_data").data("workflow");var currentRow=$(currentElement).closest("tr")[0];var currentRowData=WMStats.Env.JobSummaryTable.fnGetData(currentElement);summary.task=currentRowData.task;summary.status=currentRowData.status;summary.site=currentRowData.site;if(summary.site==="{}"){summary.site={}}summary.acdcURL=currentRowData.acdcURL;summary.exitCode=currentRowData.exitCode;WMStats.JobDetailModel.setOptions(summary);$(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START);WMStats.JobDetailModel.retrieveData()},createACDCResubmission:function(currentElement){var workflow=$("#job_view div.summary_data").data("workflow");var summary=WMStats.ViewModel.Resubmission;summary.OriginalRequestName=workflow;var requestData=WMStats.ActiveRequestModel.getData().getDataByWorkflow(summary.OriginalRequestName);summary.RequestString=WMStats.Utils.acdcRequestSting(summary.OriginalRequestName,requestData.requestor);var currentRow=$(currentElement).closest("tr")[0];var currentRowData=WMStats.Env.JobSummaryTable.fnGetData(currentElement);summary.InitialTaskPath=currentRowData.task;if(currentRowData.acdcURL){var acdcServiceUrl=WMStats.Utils.splitCouchServiceURL(currentRowData.acdcURL);summary.ACDCServer=acdcServiceUrl.couchUrl;summary.ACDCDatabase=acdcServiceUrl.couchdb}summary.Group=requestData.group;summary.PrepID=requestData.prep_id;summary.RequestPriority=requestData.priority;summary.DbsUrl=requestData.dbs_url||"http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet";summary.Memory=requestData.Memory||2394967;summary.SizePerEvent=requestData.SizePerEvent||5e3;summary.TimePerEvent=requestData.TimePerEvent||60;summary.RequestType="Resubmission";WMStats.ReqMgrRequestModel.retrieveDoc(workflow)}};var ActiveModelHandler=new TableEventHandler;ActiveModelHandler.tableColumnBind("click","#category_view div.summary_data","drill","populateRequestSummary");ActiveModelHandler.tableColumnBind("click","#request_view div.summary_data","drill","populateJobSummary");ActiveModelHandler.tableColumnBind("click","#job_view div.summary_data","drill","populateJobDetail");ActiveModelHandler.tableColumnBind("click","#job_view div.summary_data","acdc","createACDCResubmission");ActiveModelHandler.tableColumnBind("click","#category_view div.summary_data","detail","populateCategoryDetail");ActiveModelHandler.tableColumnBind("click","#request_view div.summary_data","detail","populateRequestDetail");$(document).on("mouseover","tr",function(event){$(this).addClass("mouseoverRow")});$(document).on("mouseout","tr",function(event){$(this).removeClass("mouseoverRow")})})(jQuery);WMStats.namespace("WorkloadSummaryController");(function($){$(document).on("click","#WorkloadSummarySearchButton",function(event){var selectedSearch=$('#search_option_board select[name="SearchOptions"] :selected').val();var searchStr=$('input[name="workloadSummarySearch"]').val();var view;var options={include_docs:true,reduce:false};if(selectedSearch==="request"){view="allDocs";options.key=searchStr}else if(selectedSearch==="outputdataset"){view="requestByOutputDataset";options.key=searchStr}else if(selectedSearch==="inputdataset"){view="requestByInputDataset";options.key=searchStr}else if(selectedSearch==="prep_id"){view="requestByPrepID";options.key=searchStr}else if(selectedSearch==="request_date"){view="requestByDate";var beginDate=$('input[name="dateRange1"]').val().split("/");var endDate=$('input[name="dateRange2"]').val().split("/");options.startkey=[Number(beginDate[0]),Number(beginDate[1]),Number(beginDate[2])];options.endkey=[Number(endDate[0]),Number(endDate[1]),Number(endDate[2]),{}]}WMStats.RequestSearchModel.retrieveData(view,options);event.stopPropagation()});var E=WMStats.CustomEvents;$(WMStats.Globals.Event).on(E.WORKLOAD_SUMMARY_READY,function(event,data){var data=WMStats.RequestSearchModel.getData();WMStats.WorkloadSummaryTable(data,"#search_result_board")})})(jQuery);WMStats.CategorySummaryMap.add(WMStats.Controls.run,WMStats.RunSummary);WMStats.CategoryTableMap.add(WMStats.Controls.run,WMStats.RunSummaryTable); \ No newline at end of file +WMStats.namespace("_StructBase");WMStats._StructBase=function(){this._data=null};WMStats._StructBase.prototype={getData:function(){return this._data},setData:function(couchData){this._data=this.convertCouchData(couchData)},getDataByKey:function(key,combineFunc){var data={};var dataList=this._data;for(var i in dataList){if(data[dataList[i][key]]===undefined){data[dataList[i][key]]=dataList[i]}else if(combineFuc===undefined){data[dataList[i][key]]=dataList[i]}else{data[dataList[i][key]]=combineFunc(data[dataList[i][key]],dataList[i])}}return data},convertCouchData:function(couchData){return couchData}};WMStats.namespace("GenericRequests");WMStats.namespace("GenericRequestsSummary");WMStats.namespace("RequestsByKey");WMStats.GenericRequestsSummary=function(summaryStruct){this._get=WMStats.Utils.get;this.summaryStruct={length:0};this.jobStatus={success:0,canceled:0,transition:0,queued:{first:0,retry:0},submitted:{first:0,retry:0},submitted:{pending:0,running:0},failure:{create:0,submit:0,exception:0},cooloff:{create:0,submit:0,job:0},paused:{create:0,submit:0,job:0}};if(summaryStruct){this.summaryStruct=WMStats.Utils.cloneObj(summaryStruct)}};WMStats.GenericRequestsSummary.prototype={getJobStatus:function(statusStr){return WMStats.Utils.get(this.jobStatus,statusStr,0)},getAvgProgressSummary:function(doc){var progressStat={};var datasets={};var numDataset=0;for(var task in doc.tasks){for(var site in doc.tasks[task].sites){for(var outputDS in doc.tasks[task].sites[site].dataset){if(datasets[outputDS]===undefined){numDataset+=1;datasets[outputDS]=true}WMStats.Utils.updateObj(progressStat,doc.tasks[task].sites[site].dataset[outputDS])}}}for(var prop in progressStat){progressStat[prop]=progressStat[prop]/numDataset}progressStat.numDataset=numDataset;return progressStat},getAvgEvents:function(){if(this.summaryStruct.progress===undefined||this.summaryStruct.progress.events===undefined){return this.summaryStruct.processedEvents}else{return this.summaryStruct.progress.events}},getAvgLumis:function(){if(this.summaryStruct.progress.totalLumis===undefined){return 0}else{return this.summaryStruct.progress.totalLumis}},getSummary:function(){return this.summaryStruct},summaryStructUpdateFuction:null,update:function(summary){WMStats.Utils.updateObj(this.summaryStruct,summary.summaryStruct,true,this.summaryStructUpdateFuction);WMStats.Utils.updateObj(this.jobStatus,summary.jobStatus)},updateFromRequestDoc:function(doc){var summary=this.createSummaryFromRequestDoc(doc);this.update(summary)},getWMBSTotalJobs:function(){return this.getJobStatus("success")+this.getJobStatus("canceled")+this.getJobStatus("transition")+this.getTotalFailure()+this.getTotalCooloff()+this.getTotalPaused()+this.getTotalQueued()+this.getTotalSubmitted()},getTotalFailure:function(){return this.getJobStatus("failure.create")+this.getJobStatus("failure.submit")+this.getJobStatus("failure.exception")},getTotalSubmitted:function(){return this.getJobStatus("submitted.first")+this.getJobStatus("submitted.retry")},getRunning:function(){return this.getJobStatus("submitted.running")},getPending:function(){return this.getJobStatus("submitted.pending")},getTotalCooloff:function(){return this.getJobStatus("cooloff.create")+this.getJobStatus("cooloff.submit")+this.getJobStatus("cooloff.job")},getTotalPaused:function(){return this.getJobStatus("paused.create")+this.getJobStatus("paused.submit")+this.getJobStatus("paused.job")},getTotalQueued:function(){return this.getJobStatus("queued.first")+this.getJobStatus("queued.retry")},createSummaryFromRequestDoc:function(doc){var summary=WMStats.RequestsSummary();summary.summaryStruct.length=1;summary.jobStatus=this._get(doc,"status",{});return summary}};WMStats.RequestStruct=function(requestName){this._workflow=requestName;this._summary=WMStats.RequestsSummary();this._addJobs=WMStats.Utils.updateObj};WMStats.RequestStruct.prototype={getProgressStat:function(){var progressStat={};for(var task in this.tasks){for(var site in this.tasks[task].sites){WMStats.Utils.updateObj(progressStat,this.tasks[task].sites[site].dataset)}}return progressStat},getName:function(){return this._workflow},getSummary:function(){return this._summary.createSummaryFromRequestDoc(this)},updateFromCouchDoc:function(doc){function _tasksUpdateFunction(baseObj,addObj,field){if(field==="JobType"){baseObj[field]=addObj[field]}else if(field==="updated"){baseObj[field]=Math.max(baseObj[field],addObj[field])}else{baseObj[field]+=addObj[field]}}for(var field in doc){if(this[field]&&(field=="sites"||field=="status")){this._addJobs(this[field],doc[field])}else if(this[field]&&field=="tasks"){this._addJobs(this[field],doc[field],true,_tasksUpdateFunction)}else if(this[field]&&field=="output_progress"){var outProgress=this.output_progress;for(var index in outProgress){for(var prop in doc[field][index]){outProgress[index][prop]+=doc[field][index][prop]}}}else if(field=="agent_url"){if(this[field]===undefined)this[field]=[];WMStats.Utils.addToSet(this[field],doc[field])}else{this[field]=doc[field]}}}};WMStats.GenericRequests=function(noFilterFlag){this._dataByWorkflow={};this._dataByWorkflowAgent={};this._get=WMStats.Utils.get;this._filter={};this._filteredRequests=null};WMStats.GenericRequests.prototype={_mapProperty:function(workflowData,property){if(property=="request_status"){return workflowData[property][workflowData[property].length-1].status}return workflowData[property]},_getRequestObj:function(request){if(typeof request=="string"){return this.getData(request)}else{return request}},_getStatusObj:function(request,level){var requestObj=this._getRequestObj(request);if(level=="task"){return requestObj.tasks.status}else if(level=="site"){return requestObj.sites}else{return requestObj.status}},_requestDateSort:function(a,b){for(var i in a.request_date){if(b.request_date[i]!=a.request_date[i]){return Number(b.request_date[i])-Number(a.request_date[i])}}return 0},_andFilter:function(base,filter){var includeFlag=true;for(var property in filter){if(!filter[property]){continue}else if(this._mapProperty(base,property)!==undefined&&this._contains(this._mapProperty(base,property),filter[property])){continue}else{includeFlag=false;break}}return includeFlag},_contains:function(a,b){if(typeof a==="string")return a.toLowerCase().indexOf(b.toLowerCase())!==-1;else if(typeof a=="number")return Number(b)==a;else if(a instanceof Array){for(var i in a){if(this._contains(a[i],b))return true}return false}else{alert("value need to be either number or string")}},getProgressStat:function(request){var requestObj=this._getRequestObj(request);return requestObj.getProgressStat()},getFilter:function(){return this._filter},setFilter:function(filter){this._filter=filter},updateRequest:function(doc){var workflow=doc.workflow;var agentURL=doc.agent_url;if(workflow&&!this._dataByWorkflow[workflow]){this._dataByWorkflow[workflow]=new WMStats.RequestStruct(workflow)}if(agentURL&&!this._dataByWorkflowAgent[workflow]){this._dataByWorkflowAgent[workflow]={}}if(agentURL&&!this._dataByWorkflowAgent[workflow][agentURL]){this._dataByWorkflowAgent[workflow][agentURL]=new WMStats.RequestStruct(workflow)}this.getData(workflow).updateFromCouchDoc(doc);if(agentURL){this.getData(workflow,agentURL).updateFromCouchDoc(doc)}},updateBulkRequests:function(docList){for(var row in docList){if(docList[row].doc){this.updateRequest(docList[row].doc)}}},filterRequests:function(filter){var requestData=this.getData();var filteredData={};var requestWithAgentData=this.getDataWithAgent();var filteredDataWithAgent={};if(filter===undefined){filter=this._filter}for(var workflowName in requestData){if(this._andFilter(requestData[workflowName],filter)){filteredData[workflowName]=requestData[workflowName];filteredDataWithAgent[workflowName]=requestWithAgentData[workflowName]}}this._filteredRequests=WMStats.Requests();this._filteredRequests.setDataByWorkflow(filteredData,filteredDataWithAgent);return this._filteredRequests},getKeyValue:function(request,keyString,defaultVal){"keyString is opject property separte by .";return this._get(this._dataByWorkflow[request],keyString,defaultVal)},getData:function(workflow,agentURL){if(workflow&&(agentURL==="all"||agentURL==="NA")){return this._dataByWorkflowAgent[workflow]}else if(workflow&&agentURL){return this._dataByWorkflowAgent[workflow][agentURL]}else if(workflow){return this._dataByWorkflow[workflow]}else{return this._dataByWorkflow}},getDataWithAgent:function(workflow,agentURL){if(workflow&&(agentURL==="all"||agentURL==="NA")){return this._dataByWorkflowAgent[workflow]}else if(workflow&&agentURL){return this._dataByWorkflowAgent[workflow][agentURL]}else{return this._dataByWorkflowAgent}},getFilteredRequests:function(){return this._filteredRequests},setDataByWorkflow:function(data,agentData){"keyString is opject property separte by .";this._dataByWorkflow=data;this._dataByWorkflowAgent=agentData},getList:function(sortFunc){var list=[];for(var request in this.getData()){list.push(this.getData(request))}if(sortFunc){return list.sort(sortFunc)}else{return list.sort(this._requestDateSort)}},getSummary:function(workflow,agentURL){var requests=this.getData(workflow,agentURL);if(workflow){return requests.getSummary()}else{var summary=WMStats.RequestsSummary();for(var requestName in requests){summary.update(this.getData(requestName).getSummary())}return summary}},getAlertRequests:function(){var alertRequests=[];for(var workflow in this.getData()){var reqSummary=this.getSummary(workflow);var coolOff=reqSummary.getTotalCooloff();var paused=reqSummary.getTotalPaused();if(coolOff>0||paused>0){alertRequests.push(this.getData(workflow))}}return alertRequests},getRequestStatusAndTime:function(workflowName){var workflowData=this._dataByWorkflow[workflowName];return workflowData["request_status"][workflowData["request_status"].length-1]}};WMStats.RequestsByKey=function(category,summaryFunc){var _data={};var _category=category;var _get=WMStats.Utils.get;function categorize(requestData){function _getRequestData(workflow,agentURL){if(_category==="agent"&&agentURL!=="all"&&agentURL!=="NA"){return requestData.getData(workflow,agentURL)}else{return requestData.getData(workflow)}}function _getCategoryKey(workflow){if(_category==="agent"){var agentCategory=requestData.getData(workflow,"all");if(agentCategory===undefined){return"NA"}else{return agentCategory}}else{return requestData.getKeyValue(workflow,_category,"NA")}}function _updateData(key,workflow,summaryBase){if(_data[key]===undefined){_data[key]={};_data[key].requests={};_data[key].summary=summaryFunc();_data[key].key=key}var requestInfo=_getRequestData(workflow,key);_data[key].requests[workflow]=requestInfo;_data[key].summary.updateFromRequestDoc(summaryBase)}var dataByWorkflow=requestData.getData();for(var workflow in dataByWorkflow){var key=_getCategoryKey(workflow);if(typeof key=="object"){if(key.length){for(var index in key){_updateData(key[index],workflow,requestData.getData(workflow))}}else{for(var prop in key){_updateData(prop,workflow,key[prop])}}}else{if(key=="NA"&&_category=="sites"||_category=="tasks"||_category=="agent"){_updateData(key,workflow,{})}else{_updateData(key,workflow,requestData.getData(workflow))}}}}function getData(key){if(key===undefined){return _data}else{return _data[key]}}function getRequestData(key){var requestData=WMStats.Requests();if(_data[key]!==undefined){requestData.setDataByWorkflow(_data[key].requests)}return requestData}function getList(sortFunc){var list=[];for(var key in _data){list.push(_data[key])}if(sortFunc){return list.sort(sortFunc)}else{return list}}return{categorize:categorize,getData:getData,getRequestData:getRequestData,category:_category,getList:getList}};WMStats.namespace("Agents");WMStats.Agents=function(couchData){var agentData=new WMStats._StructBase;agentData.agentNumber={error:0,stable:0};agentData.convertCouchData=function(data){var dataRows=data.rows;var rows=[];for(var i in dataRows){var tableRow=dataRows[i].value;rows.push(tableRow)}return rows};if(couchData)agentData.setData(couchData);agentData.getAlertList=function(){var currentTime=Math.round((new Date).getTime()/1e3);var dataList=this.getData();var agentPollingCycle=600;agentData.agentNumber={error:0,stable:0};function getStatus(agentInfo){var lastUpdatedDuration=currentTime-agentInfo.timestamp;if(lastUpdatedDuration>agentPollingCycle*2){agentData.agentNumber.error+=1;return{status:"agent_down",message:WMStats.Utils.foramtDuration(lastUpdatedDuration)}}else if(agentInfo.down_components.length>0){agentData.agentNumber.error+=1;return{status:"component_down",message:agentInfo.down_components}}else{agentData.agentNumber.stable+=1;return{status:"ok",message:WMStats.Utils.foramtDuration(lastUpdatedDuration)}}}for(var index in dataList){dataList[index]["alert"]=getStatus(dataList[index])}return dataList};agentData.getAlertList();return agentData};WMStats.namespace("Sites");WMStats.Sites=function(couchData){var _data;var baseColumns=["timestamp","site","agent_url"];var siteData=new WMStats._StructBase;siteData.convertCouchData=function(data){var dataRows=data.rows;var rows=[];for(var i in dataRows){var tableRow=dataRows[i].value;for(var j=0;jWMStats.RunStatus.indexOf(additionObj[field])){baseObj[field]=additionObj[field]}}else{baseObj[field]+=additionObj[field]}};runSummary.createSummaryFromRequestDoc=function(doc){var summary=WMStats.RunSummary();summary.summaryStruct.numRequests=1;summary.summaryStruct.runStatus=getRunStatus(doc);summary.jobStatus=this._get(doc,"status",{});return summary};return runSummary};WMStats.namespace("_ViewModelBase");WMStats._ViewModelBase=function(observableObj){this._eventObj={};this._eventObjName="_eventObj";this.data=this.observable("data",null);if(observableObj!==undefined){this._createObservableProperty(observableObj)}this._selector=null;this._data=null};WMStats._ViewModelBase.prototype={observable:function(property,defaultValue){var _previousValue=defaultValue;var _property=property;function publish(value,noTrigger){if(value!==undefined){_previousValue=value;if(!noTrigger){$(this._eventObj).triggerHandler(this._eventObjName,this);$(this._eventObj).triggerHandler(_property,value)}return this}else{return _previousValue}}return publish},subscribe:function(){var callback;var eventName;if(arguments.length==2){callback=arguments[1];eventName=arguments[0]}else if(arguments.length==1){callback=arguments[0];eventName=this._eventObjName}$(this._eventObj).on(eventName,callback)},id:function(selector){if(selector){this._selector=selector;WMStats.ViewModel.Registry[selector]=this;return this}else{return this._selector}},_createObservableProperty:function(observableObj){for(var prop in observableObj){this[prop]=this.observable(prop,observableObj[prop])}}};WMStats.namespace("ViewModel");WMStats.ViewModel=function(){var properties={page:null};var vm=new WMStats._ViewModelBase(properties);vm.propagateUpdate=function(){if(vm.page().propagateUpdate){vm.page().propagateUpdate()}};return vm}();(function(vm){vm.Registry={};vm.ActiveRequestPage=function(){var properties={view:null,filter:{},filteredStats:null,refreshCount:0};var requestPage=new WMStats._ViewModelBase(properties);requestPage.propagateUpdate=function(){var requestData=WMStats.ActiveRequestModel.getData();if(requestData===null){return false}else{var filter=vm.ActiveRequestPage.filter();vm.ActiveRequestPage.data(requestData.filterRequests(filter));if(requestPage.view().propagateUpdate){requestPage.view().propagateUpdate()}return true}};return requestPage}();vm.RequestAlertPage=function(){var alertPage=new WMStats._ViewModelBase;alertPage.propagateUpdate=function(){var requestData=WMStats.ActiveRequestModel.getData();if(requestData===null){return false}else{vm.RequestAlertPage.data(requestData);return true}};return alertPage}();vm.AgentPage=function(){var agentPage=new WMStats._ViewModelBase;agentPage.propagateUpdate=function(){var agentData=WMStats.AgentModel.getData();if(agentData===null){return false}else{vm.AgentPage.data(agentData);return true}};return agentPage}();vm.SearchPage=function(){var properties={keys:null};searchPage=new WMStats._ViewModelBase(properties);searchPage.retrieveData=function(keys){var selectedSearch=keys.searchCategory;var searchStr=keys.searchValue;var view;var options={include_docs:true,reduce:false};if(selectedSearch==="request"){view="allDocs";options.key=searchStr}else if(selectedSearch==="outputdataset"){view="requestByOutputDataset";options.key=searchStr}else if(selectedSearch==="inputdataset"){view="requestByInputDataset";options.key=searchStr}else if(selectedSearch==="prep_id"){view="requestByPrepID";options.key=searchStr}else if(selectedSearch==="request_date"){view="requestByDate";var beginDate=$('input[name="dateRange1"]').val().split("/");var endDate=$('input[name="dateRange2"]').val().split("/");options.startkey=[Number(beginDate[0]),Number(beginDate[1]),Number(beginDate[2])];options.endkey=[Number(endDate[0]),Number(endDate[1]),Number(endDate[2]),{}]}WMStats.RequestSearchModel.retrieveData(view,options)};return searchPage}();vm.CategoryView=function(){var properties={category:null,detailView:null};var categoryView=new WMStats._ViewModelBase(properties);categoryView.convertToCategoryData=function(requestData){if(requestData===undefined){requestData=vm.ActiveRequestPage.data()}var category=this.category().name();var summaryStruct=WMStats.CategorySummaryMap.get(this.category().name());var categoryData=WMStats.RequestsByKey(category,summaryStruct);categoryData.categorize(requestData);return categoryData};categoryView.propagateUpdate=function(){if(vm.ActiveRequestPage.data()===null){return false}categoryView.data(categoryView.convertToCategoryData());return true};return categoryView}();vm.RequestView=function(){var properties={categoryKey:"all",format:null,detailView:null};var requestView=new WMStats._ViewModelBase(properties);requestView.propagateUpdate=function(){if(vm.ActiveRequestPage.data()===null){return false}if(requestView.categoryKey()=="all"){requestView.data(vm.ActiveRequestPage.data())}else{var categoryData=vm.CategoryView.convertToCategoryData();var data=categoryData.getRequestData(requestView.categoryKey());requestView.data(data)}return true};requestView.categoryName="requests";return requestView}();function createJobSummaryView(){var properties={requestName:null,detail:null};var jobView=new WMStats._ViewModelBase(properties);jobView.retrieveData=function(requestName){WMStats.JobSummaryModel.setRequest(requestName);WMStats.JobSummaryModel.retrieveData()};jobView.propagateUpdate=function(){if(jobView.requestName()){jobView.retrieveData(jobView.requestName());return false}else{return false}};jobView.updateDataAndChild=function(data){if(data){jobView.data(data)}if(jobView.detail().propagateUpdate){jobView.detail().propagateUpdate();return true}return false};return jobView}vm.JobView=createJobSummaryView();vm.AlertJobView=createJobSummaryView();vm.CampaignCategory=function(){return new WMStats._ViewModelBase({name:"campaign"})}();vm.SiteCategory=function(){return new WMStats._ViewModelBase({name:"sites"})}();vm.CMSSWCategory=function(){return new WMStats._ViewModelBase({name:"cmssw"})}();vm.AgentCategory=function(){return new WMStats._ViewModelBase({name:"agent"})}();vm.RequestProgress=function(){return new WMStats._ViewModelBase({name:"progress"})}();vm.RequestJobs=function(){return new WMStats._ViewModelBase({name:"numJobs"})}();vm.CategoryDetail=function(){var properties={categoryKey:null};var categoryDetail=new WMStats._ViewModelBase(properties);categoryDetail.propagateUpdate=function(){if(categoryDetail.categoryKey()){var allData=vm.CategoryView.data();categoryDetail.data(allData.getData(categoryDetail.categoryKey()))}};return categoryDetail}();vm.RequestDetail=function(){var properties={requestName:null};var requestDetail=new WMStats._ViewModelBase(properties);requestDetail.open=false;return requestDetail}();function createJobDetailView(){var properties={keys:null,indexID:null};var jobDetail=new WMStats._ViewModelBase(properties);jobDetail.retrieveData=function(keys){WMStats.JobDetailModel.setOptions(keys);WMStats.JobDetailModel.retrieveData()};jobDetail.propagateUpdate=function(){if(jobDetail.keys()!==null){jobDetail.retrieveData(jobDetail.keys());return true}else{return false}};return jobDetail}vm.JobDetail=createJobDetailView();vm.AlertJobDetail=createJobDetailView();vm.Resubmission=function(){var properties={keys:null};var resubmission=new WMStats._ViewModelBase(properties);resubmission.retrieveData=function(keys){WMStats.ReqMgrRequestModel.retrieveDoc(keys.requestName)};resubmission.formatResubmissionData=function(requestInfo){var summary={};summary.OriginalRequestName=resubmission.keys().requestName;summary.InitialTaskPath=resubmission.keys().task;if(resubmission.keys().acdcURL){var acdcServiceUrl=WMStats.Utils.splitCouchServiceURL(resubmission.keys().acdcURL);summary.ACDCServer=acdcServiceUrl.couchUrl;summary.ACDCDatabase=acdcServiceUrl.couchdb}summary.Memory=requestInfo.Memory;summary.SizePerEvent=requestInfo.SizePerEvent;summary.TimePerEvent=requestInfo.TimePerEvent;requestInfo=WMStats.ActiveRequestModel.getData().getData(summary.OriginalRequestName);summary.DbsUrl=requestInfo.DbsUrl||"http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet";summary.Group=requestInfo.Group;summary.RequestPriority=requestInfo.RequestPriority;summary.RequestString=WMStats.Utils.acdcRequestSting(summary.OriginalRequestName,requestInfo.Requestor);summary.PrepID=requestInfo.PrepID;summary.RequestType="Resubmission";return summary};resubmission.propagateUpdate=function(){if(resubmission.keys()!==null){resubmission.retrieveData(resubmission.keys());return true}else{return false}};return resubmission}();vm.initialize=function(){vm.page(vm.ActiveRequestPage,true);vm.ActiveRequestPage.view(vm.CategoryView,true);vm.CategoryView.category(vm.CampaignCategory,true);vm.RequestView.format(vm.RequestProgress,true);vm.JobView.detail(vm.JobDetail,true)}()})(WMStats.ViewModel);(function(vm){vm.ActiveRequestPage.subscribe("filter",function(){vm.ActiveRequestPage.propagateUpdate()});vm.SearchPage.subscribe("keys",function(){vm.SearchPage.retrieveData(vm.SearchPage.keys())});vm.CategoryView.subscribe("category",function(){vm.CategoryView.propagateUpdate()});vm.RequestView.subscribe("categoryKey",function(){vm.ActiveRequestPage.view(vm.RequestView)});vm.JobView.subscribe("requestName",function(){vm.ActiveRequestPage.view(vm.JobView)});vm.AlertJobView.subscribe("requestName",function(){vm.AlertJobView.retrieveData(vm.AlertJobView.requestName())});vm.CategoryDetail.subscribe("categoryKey",function(){vm.CategoryDetail.propagateUpdate()});vm.JobDetail.subscribe("keys",function(){vm.JobDetail.retrieveData(vm.JobDetail.keys())});vm.AlertJobDetail.subscribe("keys",function(){vm.AlertJobDetail.retrieveData(vm.AlertJobDetail.keys())});vm.Resubmission.subscribe("keys",function(){vm.Resubmission.retrieveData(vm.Resubmission.keys())})})(WMStats.ViewModel);WMStats.namespace("CategorySummaryMap");WMStats.namespace("CategoryTableMap");WMStats.CategorySummaryMap=function(){var summaryMap={};function add(category,summaryFunc){summaryMap[category]=summaryFunc}function get(category){return summaryMap[category]}return{add:add,get:get}}();WMStats.CategoryTableMap=function(){var tableMap={};var vm=WMStats.ViewModel;function add(category,view){tableMap[category]=view}function get(category,view){if(category===vm.RequestView.categoryName){return tableMap[category][vm.RequestView.format().name()]}else{return tableMap[category]}}return{add:add,get:get}}();(function(vm){vm.CategoryView.subscribe("data",function(){var view=WMStats.CategoryTableMap.get(vm.CategoryView.category().name());view(vm.CategoryView.data(),vm.CategoryView.category().id())});vm.RequestView.subscribe("data",function(){var view=WMStats.CategoryTableMap.get(vm.RequestView.categoryName);view(vm.RequestView.data(),vm.RequestView.format().id())})})(WMStats.ViewModel);WMStats.namespace("View");WMStats.View.IndexHTML=function(){function applyTemplate(){var viewPane=$("#data_board div.viewPane");$("div.viewTemplate").children().clone().appendTo(viewPane)}function retrieveData(){WMStats.ActiveRequestModel.retrieveData();WMStats.AgentModel.retrieveData()}$(document).ready(function(){$("#loading_page").addClass("front").show();WMStats.CommonControls.setLinkTabs("#link_tabs");WMStats.Controls.setExternalLink("#external_link");WMStats.CommonControls.setUTCClock("#clock");WMStats.CommonControls.setWorkloadSummarySearch("#search_option_board");WMStats.Controls.setFilter("#filter_board");WMStats.Controls.setAllRequestButton("#status_board");WMStats.Controls.setTabs("#tab_board");WMStats.Controls.setCategoryButton("#category_bar");WMStats.Controls.setViewSwitchButton("#view_switch_bar");var vm=WMStats.ViewModel;vm.ActiveRequestPage.id("#activeRequestPage");vm.AgentPage.id("#agentInfoPage");vm.RequestAlertPage.id("#requestAlertPage");vm.SearchPage.id("#workloadSummaryPage");vm.CategoryView.id("#category_view");vm.RequestView.id("#request_view");vm.JobView.id("#job_view");vm.CampaignCategory.id("#category_view div.summary_data");vm.SiteCategory.id("#category_view div.summary_data");vm.CMSSWCategory.id("#category_view div.summary_data");vm.AgentCategory.id("#category_view div.summary_data");vm.RequestProgress.id("#request_view div.summary_data");vm.RequestJobs.id("#request_view div.summary_data");vm.CategoryDetail.id("#category_view div.detail_data");vm.RequestDetail.id("#request_view div.detail_data");vm.JobDetail.id("#job_view div.detail_data");vm.Resubmission.id("#acdc_submission");vm.AlertJobView.id("#alert_job_summary");vm.AlertJobDetail.id("#alert_job_detail");var wsControl=WMStats.GenericController;function switchPage(event,data){wsControl.switchDiv(data.id(),["#activeRequestPage","#requestAlertPage","#agentInfoPage","#workloadSummaryPage"]);vm.propagateUpdate()}function switchView(event,data){wsControl.switchDiv(data.id(),["#category_view","#request_view","#job_view"]); +vm.ActiveRequestPage.view().propagateUpdate()}vm.subscribe("page",switchPage);vm.ActiveRequestPage.subscribe("view",switchView);vm.RequestView.subscribe("categoryKey",function(event,categoryKey){WMStats.CategoryTitle(categoryKey,"#category_title")});vm.JobView.subscribe("requestName",function(event,requestName){WMStats.RequestTitle(requestName,"#request_title")});var E=WMStats.CustomEvents;$(WMStats.Globals.Event).on(E.AGENTS_LOADED,function(event,agentData){if(agentData.agentNumber.error>0){$('#linkTabs a[href="#agentInfoPage"] strong').text("("+agentData.agentNumber.error+")")}});$(WMStats.Globals.Event).on(E.REQUESTS_LOADED,function(event){var alertData=WMStats.ActiveRequestModel.getData().getRequestAlerts();var numAlert=0;for(var error in alertData){numAlert+=alertData[error].length}if(numAlert>0){$('#linkTabs a[href="#requestAlertPage"] strong').text("("+numAlert+")")}});vm.page(vm.ActiveRequestPage);vm.ActiveRequestPage.view(vm.CategoryView);retrieveData();setInterval(retrieveData,3e5)})};WMStats.namespace("CommonControls");WMStats.CommonControls=function($){var vm=WMStats.ViewModel;var vmRegistry=WMStats.ViewModel.Registry;function setUTCClock(selector){setInterval(function(){$(selector).text(WMStats.Utils.utcClock())},100)}function setLinkTabs(selector){var linkTabs='';$(selector).append(linkTabs);function changeTab(event,data){$("#linkTabs li").removeClass("title-tab-selected").addClass("title-tab-hide");$('#linkTabs a[href="'+data.id()+'"]').parent().removeClass("title-tab-hide").addClass("title-tab-selected")}vm.subscribe("page",changeTab);$(document).on("click","#linkTabs li a",function(event){vm.page(vmRegistry[this.hash]);event.preventDefault()})}function setWorkloadSummarySearch(selector){var searchOption='
Search WorkloadSummary
';$(selector).append(searchOption);$(document).on("change",'select[name="SearchOptions"]',function(){var filterType=$(":selected",this).attr("data-search-type");var searchBox=$("#searchPane .SearchBox");$(searchBox).empty();$("div.template."+filterType).children().clone().appendTo("#searchPane .SearchBox");$('#searchPane .SearchBox input[name="dateRange1"]').datepicker({altField:'input[name="dateRange1"]',altFormat:"yy/mm/dd",changeYear:true,yearRange:"2012:c"});$('#searchPane .SearchBox input[name="dateRange2"]').datepicker({altField:'input[name="dateRange2"]',altFormat:"yy/mm/dd",changeYear:true,yearRange:"2012:c"})});$(document).on("click","#WorkloadSummarySearchButton",function(event){var keys={};keys.searchCategory=$('#search_option_board select[name="SearchOptions"] :selected').val();keys.searchValue=$('input[name="workloadSummarySearch"]').val();vm.SearchPage.keys(keys);event.stopPropagation()})}return{setUTCClock:setUTCClock,setLinkTabs:setLinkTabs,setWorkloadSummarySearch:setWorkloadSummarySearch}}(jQuery);WMStats.namespace("Table");WMStats.Table=function(config,tableSetting){var tableSetting=tableSetting||'
';var tableConfig={bStateSave:true,bProcessing:true,sDom:'<"top"pl>rt<"bottom"ip>',aaSorting:[],bAutoWidth:true,bJQueryUI:true};function updateConfig(config){for(var prop in config){tableConfig[prop]=config[prop]}}function _footer(){var footer="";for(var i in tableConfig.aoColumns){if(tableConfig.aoColumns[i].bVisible!=false){footer+=""+tableConfig.aoColumns[i]["sTitle"]+""}}footer+="";return footer}function create(selector,filterConfig){$(selector).empty();$(selector).html(tableSetting);var oTable=$(selector+" table").dataTable(tableConfig);if(oTable.length>0){oTable.fnAdjustColumnSizing()}jQuery(WMStats.Globals.Event).triggerHandler(WMStats.CustomEvents.LOADING_DIV_END);if(filterConfig){return oTable.columnFilter(filterConfig)}else{return oTable}}if(config){updateConfig(config)}return{config:tableConfig,updateConfig:updateConfig,create:create}};WMStats.namespace("JobSummaryTable");WMStats.JobSummaryTable=function(data,containerDiv){var tableConfig={sDom:'<"top"plf>rt<"bottom"ip>',iDisplayLength:25,aoColumns:[{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:function(source,type,val){if(type=="display"){var taskList=source.task.split("/");return taskList[taskList.length-1]}return source.task},sTitle:"task",sWidth:"150px"},{mDataProp:"status",sTitle:"status"},{mDataProp:"site",sTitle:"site"},{mDataProp:"exitCode",sTitle:"exit code"},{mDataProp:"count",sTitle:"jobs"},{mDataProp:"errorMsg",sTitle:"error mesage",sDefaultContent:""},{sTitle:"acdc",sDefaultContent:"",sWidth:"15px",mDataProp:function(source,type,val){if(type=="display"){var taskList=source.task.split("/");var endTask=taskList[taskList.length-1];if(source.status!=="success"&&!endTask.match(/LogCollect$/)&&!endTask.match(/Cleanup$/)){return WMStats.Utils.formatDetailButton("acdc")}}return""}}],aaSorting:[[1,"asc"]]};tableConfig.aaData=data.getData().status;var filterConfig={};$(containerDiv).data("workflow",data.getData().workflow);WMStats.JobSummaryTable.data=WMStats.Table(tableConfig).create(containerDiv,filterConfig);return WMStats.JobSummaryTable.data};(function(){var vm=WMStats.ViewModel;vm.JobView.subscribe("data",function(){var divSelector=vm.JobView.id()+" div.summary_data";WMStats.JobSummaryTable(vm.JobView.data(),divSelector)})})();WMStats.namespace("SiteSummaryTable");WMStats.SiteSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:50,sDom:'<"top"plf>rt<"bottom"ip>',sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"key",sTitle:"site"},{mDataProp:function(source,type,val){return source.summary.summaryStruct.numRequests},sTitle:"requests",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getJobStatus("submitted.pending")},sTitle:"pending",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getJobStatus("submitted.running")},sTitle:"running",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getTotalCooloff()},sTitle:"cool off",sDefaultContent:0},{sDefaultContent:0,sTitle:"failure rate",mDataProp:function(source,type,val){var failJobs=source.summary.getTotalFailure();var successJobs=source.summary.getJobStatus("success");var totalCompleteJobs=successJobs+failJobs||1;var result=failJobs/totalCompleteJobs*100;return result.toFixed(1)+"%"}}]};tableConfig.aaData=data.getList();var filterConfig={};return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("WorkloadSummaryTable");WMStats.WorkloadSummaryTable=function(data,containerDiv){var formatReqDetailUrl=WMStats.Utils.formatReqDetailUrl;var formatWorkloadSummarylUrl=WMStats.Utils.formatWorkloadSummarylUrl;var tableConfig={iDisplayLength:25,sScrollX:"",sDom:"lfrtip",bAutoWidth:false,aoColumns:[{mDataProp:"workflow",sTitle:"workflow",fnRender:function(o,val){return formatReqDetailUrl(o.aData._id)},bUseRendered:false,sWidth:"150px"},{mDataProp:function(source,type,val){return source.request_status[source.request_status.length-1].status},sTitle:"status",fnRender:function(o,val){return formatWorkloadSummarylUrl(o.aData._id,o.aData.request_status[o.aData.request_status.length-1].status)},bUseRendered:false},{mDataProp:"request_type",sTitle:"type",sDefaultContent:""},{mDataProp:"priority",sTitle:"priority",sDefaultContent:0},{mDataProp:"campaign",sTitle:"campaign",sDefaultContent:""}]};var filterConfig={};tableConfig.aaData=data.getData();return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};(function(){var vm=WMStats.ViewModel;vm.SearchPage.subscribe("data",function(){WMStats.WorkloadSummaryTable(vm.SearchPage.data(),"#search_result_board")})})();(function($){var E=WMStats.CustomEvents;var vm=WMStats.ViewModel;function TableEventHandler(containerID,populateRequestTable){this.containerID=containerID;if(populateRequestTable){this.populateRequestTable=populateRequestTable}}TableEventHandler.highlightRow=function(selector,currenElement){$(selector).removeClass("mouseclickRow");$(currenElement).addClass("mouseclickRow")};TableEventHandler.prototype={constructor:TableEventHandler,tableRowBind:function(bind,parentSelector,func){var currentObj=this;var selector=parentSelector+" table tbody tr";$(document).on(bind,selector,function(){TableEventHandler.highlightRow(selector,this);currentObj[func](this)})},tableColumnBind:function(bind,parentSelector,name,func){var currentObj=this;var selector=parentSelector+' table tbody tr td div[name="'+name+'"]';var rowSelector=parentSelector+" table tbody tr";$(document).on(bind,selector,function(){var currentRow=$(this).closest("tr")[0];TableEventHandler.highlightRow(rowSelector,currentRow);currentObj[func](currentRow);event.preventDefault()})},populateRequestSummary:function(currentElement){var nTds=$("td",currentElement);vm.RequestView.categoryKey($(nTds[2]).text())},populateJobSummary:function(currentElement){vm.JobDetail.keys(null,true);$(vm.JobDetail.id()).empty();$(vm.Resubmission.id()).empty();var nTds=$("td",currentElement);vm.JobView.requestName($(nTds[2]).text());$(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START)},populateRequestDetail:function(currentElement){var nTds=$("td",currentElement);vm.RequestDetail.requestName($(nTds[2]).text())},populateCategoryDetail:function(currentElement){var nTds=$("td",currentElement);vm.CategoryDetail.categoryKey($(nTds[2]).text())},populateJobDetail:function(currentElement){var summary={};summary.workflow=$("#job_view div.summary_data").data("workflow");var currentRow=$(currentElement).closest("tr")[0];var currentRowData=WMStats.JobSummaryTable.data.fnGetData(currentElement);summary.task=currentRowData.task;summary.status=currentRowData.status;summary.site=currentRowData.site;if(summary.site==="{}"){summary.site={}}summary.acdcURL=currentRowData.acdcURL;summary.exitCode=currentRowData.exitCode;vm.JobDetail.keys(summary);$(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START)},createACDCResubmission:function(currentElement){var workflow=$("#job_view div.summary_data").data("workflow");var summary={};summary.requestName=workflow;var currentRowData=WMStats.JobSummaryTable.data.fnGetData(currentElement);summary.task=currentRowData.task;summary.acdcURL=currentRowData.acdcURL;vm.Resubmission.keys(summary)}};var ActiveModelHandler=new TableEventHandler;ActiveModelHandler.tableColumnBind("click","#category_view div.summary_data","drill","populateRequestSummary");ActiveModelHandler.tableColumnBind("click","#request_view div.summary_data","drill","populateJobSummary");ActiveModelHandler.tableColumnBind("click","#job_view div.summary_data","drill","populateJobDetail");ActiveModelHandler.tableColumnBind("click","#job_view div.summary_data","acdc","createACDCResubmission");ActiveModelHandler.tableColumnBind("click","#category_view div.summary_data","detail","populateCategoryDetail");ActiveModelHandler.tableColumnBind("click","#request_view div.summary_data","detail","populateRequestDetail");$(document).on("mouseover","tr",function(event){$(this).addClass("mouseoverRow")});$(document).on("mouseout","tr",function(event){$(this).removeClass("mouseoverRow")})})(jQuery);WMStats.namespace("JobDetailList");(function(){var stateTransitionFormat=function(state){return""+state["newstate"]+": "+WMStats.Utils.utcClock(new Date(state["timestamp"]*1e3))+", "+state["location"]};var inputFileFormat=function(inputFile){return inputFile["lfn"]};var lumiFormat=function(lumis){function lumiRangeFormat(){if(startLumi==preLumi){lumiFormat.push("["+startLumi+"]")}else{lumiFormat.push("["+startLumi+" - "+preLumi+"]")}}var preLumi=null;var startLumi=null;var lumiFormat=new Array;for(var i in lumis){for(var j in lumis[i]){for(var k in lumis[i][j]){var currentLumi=Number(lumis[i][j][k]);if(startLumi===null){startLumi=currentLumi}else if(preLumi+1!==currentLumi){lumiRangeFormat();startLumi=currentLumi}preLumi=currentLumi}}}if(startLumi!==null){lumiRangeFormat()}return lumiFormat};var logArchiveFormat=function(archiveObj,key){return key};var format=function(data){var jobDetails=data.getData();var requestData=WMStats.ActiveRequestModel.getData();var htmlstr='
";for(var index in jobDetails){var jobDoc=jobDetails[index];if(index==="0"){htmlstr+="
"}else{htmlstr+="
"}htmlstr+="
    ";htmlstr+="
  • Job Name: "+jobDoc._id+"
  • ";htmlstr+="
  • WMBS job id: "+jobDoc.wmbsid+"
  • ";htmlstr+="
  • Workflow: "+jobDoc.workflow+"
  • ";htmlstr+="
  • Task: "+jobDoc.task+"
  • ";htmlstr+="
  • Status: "+jobDoc.state+"
  • ";htmlstr+="
  • Input dataset: "+requestData.getKeyValue(jobDoc.workflow,"inputdataset","")+"
  • ";if(typeof jobDoc.site=="object"){htmlstr+="
  • Site: N/A
  • "}else{htmlstr+="
  • Site: "+jobDoc.site+"
  • "}htmlstr+="
  • Agent: "+jobDoc.agent_name+"
  • ";htmlstr+="
  • ACDC URL: "+jobDoc.acdc_url+"
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(jobDoc.state_history,"State Transition",stateTransitionFormat)+"
  • ";htmlstr+="
  • Exit code: "+jobDoc.exitcode+"
  • ";htmlstr+="
  • Retry count: "+jobDoc.retrycount+"
  • ";htmlstr+="
  • Errors: ";for(var errorType in jobDoc.errors){htmlstr+="
      ";htmlstr+="
    • "+errorType+"
    • ";for(var i in jobDoc.errors[errorType]){htmlstr+="
        ";htmlstr+="
      • "+jobDoc.errors[errorType][i].type+" (Exit Code: "+jobDoc.errors[errorType][i].exitCode+")
      • ";htmlstr+="
          ";htmlstr+="
        • "+jobDoc.errors[errorType][i].details+"
        • ";htmlstr+="
        ";htmlstr+="
      "}htmlstr+="
    "}htmlstr+="
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(jobDoc.inputfiles,"Input files",inputFileFormat)+"
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(lumiFormat(jobDoc.lumis),"Lumis")+"
  • ";htmlstr+="
  • Output: ";for(var i in jobDoc.output){htmlstr+="
      ";htmlstr+="
    • "+jobDoc.output[i].type+"
    • ";htmlstr+="
        ";htmlstr+="
      • lfn: "+jobDoc.output[i].lfn+"
      • ";htmlstr+="
      • location: ";htmlstr+=jobDoc.output[i].location;if(jobDoc.output[i].type==="logArchive"){htmlstr+="
      • pfn: "}htmlstr+="
      • ";htmlstr+="
      • checksums: adler32: "+jobDoc.output[i].checksums.adler32+", cksum: "+jobDoc.output[i].checksums.cksum+"
      • ";htmlstr+="
      • size: "+jobDoc.output[i].size+"
      • ";htmlstr+="
      ";htmlstr+="
    "}htmlstr+="
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(jobDoc.logArchiveLFN,"log archive",logArchiveFormat)+"
  • ";htmlstr+="
";htmlstr+="
"}return htmlstr};WMStats.JobDetailList=function(data,containerDiv){$(containerDiv).html(format(data))};var vm=WMStats.ViewModel;vm.JobDetail.subscribe("data",function(){WMStats.JobDetailList(vm.JobDetail.data(),vm.JobDetail.id())});$(document).on("click","#jobDetailNav li a",function(event){$("div.jobDetailBox").hide();$(this.hash).show();$("#jobDetailNav li a").removeClass("button-selected").addClass("button-unselected");$(this).removeClass("button-unselected").addClass("button-selected");event.preventDefault()});$(WMStats.Globals.Event).on(WMStats.CustomEvents.PHEDEX_PFN_SUCCESS,function(event,requestName){$("#acdc_submission div.requestDetailBox").append(WMStats.Utils.formatReqDetailUrl(requestName))})})();WMStats.namespace("AgentDetailList");(function(){var statusInterpretator=function(alertStatus){if(alertStatus=="agent_down"){message="Data is not updated: AnalyticsDataCollector Down"}else if(alertStatus=="component_down"){message="Components or Thread down"}else{message="OK"}return message};var componentFormat=function(componentList){var formatStr="";for(var i in componentList){formatStr+="
"+componentList[i].name+"
    ";formatStr+="
  • "+componentList[i].worker_name+"
  • ";formatStr+="
  • status: "+componentList[i].state+"
  • ";formatStr+="
  • error: "+WMStats.Utils.utcClock(new Date(componentList[i].last_error*1e3))+"
  • ";formatStr+="
  • error message:
    "+componentList[i].error_message+"
  • ";formatStr+="
  • pid: "+componentList[i].pid+"
  • ";formatStr+="
"}return formatStr};var agentErrorFormat=function(agentInfo){var htmlstr="";htmlstr+="
";htmlstr+="
    ";if(agentInfo){htmlstr+="
  • agent: "+agentInfo.agent_url+"
  • ";htmlstr+="
  • last_updated: "+WMStats.Utils.utcClock(new Date(agentInfo.timestamp*1e3))+" : "+agentInfo.alert.message+"
  • ";htmlstr+="
  • status: "+statusInterpretator(agentInfo.alert.status)+"
  • ";htmlstr+="
  • team: "+agentInfo.agent_team+"
  • "}var detailInfo=agentInfo.down_component_detail;if(detailInfo&&detailInfo.length>0){htmlstr+="
  • component errors: ";htmlstr+=componentFormat(detailInfo);htmlstr+="
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};var agentStableFormat=function(agentInfo){var htmlstr="";htmlstr+="
";htmlstr+="
    ";if(agentInfo){htmlstr+="
  • agent: "+agentInfo.agent_url+"
  • ";htmlstr+="
  • last_updated: "+agentInfo.alert.message+"
  • ";htmlstr+="
  • status: "+statusInterpretator(agentInfo.alert.status)+"
  • ";htmlstr+="
  • team "+agentInfo.agent_team+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};var format=function(agentData){var htmlstr="";var agentsWithWarning=agentData.getAlertList();for(i in agentsWithWarning){if(agentsWithWarning[i].alert&&agentsWithWarning[i].alert.status!=="ok"){htmlstr+=agentErrorFormat(agentsWithWarning[i])}else{htmlstr+=agentStableFormat(agentsWithWarning[i])}}return htmlstr};WMStats.AgentDetailList=function(data,containerDiv){$(containerDiv).html(format(data))};var vm=WMStats.ViewModel;vm.AgentPage.subscribe("data",function(){var divID="#agent_detail";WMStats.AgentDetailList(vm.AgentPage.data(),divID)})})();WMStats.namespace("WMStats.CategoryTitle");(function(){var format=function(data){var categoryKey=data;var htmlstr="";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • Category: "+categoryKey+"
  • ";htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.CategoryTitle=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("WMStats.RequestTitle");(function(){var format=function(data){var workflow;var dataType;if(typeof data==="string"){workflow=data;dataType=0}else{workflow=data.getData().workflow;dataType=1}var requestInfo=WMStats.ActiveRequestModel.getData().getData(workflow);var htmlstr="";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • "+workflow+"
  • ";if(dataType==1){htmlstr+="
  • agent: "+requestInfo.agent_url+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestTitle=function(data,containerDiv){if(typeof data==="string"||typeof data==="object"&&data.getData().workflow!==undefined){$(containerDiv).html(format(data))}}})();WMStats.namespace("SiteHistoryGraph");WMStats.SiteHistoryGraph=function(historyData,containerDiv){var siteHistory=JSON.stringify(historyData);var htmlList="
"+siteHistory+"
";$(containerDiv).html(htmlList)};WMStats.namespace("Controls");WMStats.Controls=function($){var _filterSelector;var _categorySelector;function setFilter(selector){var inputFilter='
workflow: status: run:
';$(selector).append(inputFilter);_filterSelector=selector+' div[name="filter"] input'}function setCategoryButton(selector){WMStats.Env.CategorySelection="run"}function setViewSwitchButton(selector){WMStats.Env.ViewSwitchSelection="progress"}function setAllRequestButton(selector){var requestBottons='';$(selector).append(requestBottons).addClass("button-group");WMStats.Env.RequestSelection="all_requests"}function getCategoryButtonValue(){return WMStats.Env.CategorySelection}function getFilter(){return WMStats.Utils.createInputFilter(_filterSelector)}function setTabs(selector){var tabs='';$(selector).append(tabs).addClass("tabs");$(selector+" ul").addClass("tabs-nav")}return{setFilter:setFilter,setTabs:setTabs,setCategoryButton:setCategoryButton,setAllRequestButton:setAllRequestButton,getCategoryButtonValue:getCategoryButtonValue,setViewSwitchButton:setViewSwitchButton,getFilter:getFilter,requests:"requests",sites:"sites",run:"run"}}(jQuery);WMStats.namespace("ActiveRequestTable");WMStats.ActiveRequestTable=function(requestData,containerDiv){var formatReqDetailUrl=WMStats.Utils.formatReqDetailUrl;var formatWorkloadSummarylUrl=WMStats.Utils.formatWorkloadSummarylUrl;var tableConfig={iDisplayLength:25,sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"workflow",sTitle:"workflow"},{mDataProp:function(source,type,val){return source.request_status[source.request_status.length-1].status},sTitle:"status",fnRender:function(o,val){return formatWorkloadSummarylUrl(o.aData.workflow,o.aData.request_status[o.aData.request_status.length-1].status)},bUseRendered:false},{mDataProp:function(source,type,val){return source.request_status[source.request_status.length-1].update_time},sTitle:"duration",fnRender:function(o,val){var currentTime=Math.round((new Date).getTime()/1e3);var startTime=o.aData.request_status[o.aData.request_status.length-1].update_time;return WMStats.Utils.foramtDuration(currentTime-startTime)},bUseRendered:false},{sDefaultContent:0,sTitle:"job progress",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);var totalJobs=reqSummary.getWMBSTotalJobs()||1;var result=(reqSummary.getJobStatus("success")+reqSummary.getTotalFailure())/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"submitted",fnRender:function(o,val){var result=requestData.getKeyValue(o.aData.workflow,"status.submitted.first",0);result+=requestData.getKeyValue(o.aData.workflow,"status.submitted.retry",0);return result}},{sDefaultContent:0,sTitle:"pending",fnRender:function(o,val){var result=requestData.getKeyValue(o.aData.workflow,"status.submitted.pending",0);return result}},{sDefaultContent:0,sTitle:"running",fnRender:function(o,val){var result=requestData.getKeyValue(o.aData.workflow,"status.submitted.running",0);return result}},{sDefaultContent:0,sTitle:"cool off ",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);return reqSummary.getTotalCooloff()}},{sDefaultContent:0,sTitle:"paused",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);return reqSummary.getTotalPaused()}},{sDefaultContent:0,sTitle:"run",fnRender:function(o,val){return requestData.getKeyValue(o.aData.workflow,"run",0)}}]};function runNumerDesc(a,b){return Number(b.run)-Number(a.run)}tableConfig.aaData=requestData.getList(runNumerDesc);return WMStats.Table(tableConfig).create(containerDiv,null)};WMStats.namespace("RunSummaryTable");WMStats.RunSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:25,sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"key",sTitle:"run"},{mDataProp:function(source,type,val){return source.summary.summaryStruct.numRequests},sTitle:"requests",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.summaryStruct.runStatus},sTitle:"run status",sDefaultContent:"Active"},{mDataProp:function(source,type,val){return source.summary.getJobStatus("success")},sTitle:"success",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getTotalFailure()},sTitle:"failure",sDefaultContent:0},{sDefaultContent:0,sTitle:"job progress",mDataProp:function(source,type,val){var totalJobs=source.summary.getWMBSTotalJobs()||1;var result=(source.summary.getJobStatus("success")+source.summary.getTotalFailure())/totalJobs*100;if(type==="display"){return result.toFixed(1)+"%"}return result.toFixed(1)}},{mDataProp:function(source,type,val){return source.summary.getJobStatus("submitted.pending")},sTitle:"pending",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getJobStatus("submitted.running")},sTitle:"running",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getTotalCooloff()},sTitle:"cool off",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getTotalPaused()},sTitle:"paused",sDefaultContent:0}]};function runNumerDesc(a,b){return Number(b.key)-Number(a.key)}tableConfig.aaData=data.getList(runNumerDesc);var filterConfig={};return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};(function(vm){WMStats.CategorySummaryMap.add(vm.SiteCategory.name(),WMStats.SiteSummary);WMStats.CategoryTableMap.add(vm.SiteCategory.name(),WMStats.SiteSummaryTable);WMStats.CategoryTableMap.add(vm.RequestView.categoryName,{progress:WMStats.ActiveRequestTable});WMStats.CategorySummaryMap.add(WMStats.Controls.run,WMStats.RunSummary);WMStats.CategoryTableMap.add(WMStats.Controls.run,WMStats.RunSummaryTable)})(WMStats.ViewModel);WMStats.namespace("RequestDetailList");(function(){var vm=WMStats.ViewModel;var transitionFormat=function(dataArray,maxLength,summaryStr){var htmlstr="";if(dataArray==undefined||dataArray.length==undefined||dataArray.length<=maxLength){htmlstr+=dataArray}else{htmlstr+="
"+summaryStr+"
    ";for(var i in dataArray){htmlstr+="
  • "+dataArray[i].status+": "+WMStats.Utils.utcClock(new Date(dataArray[i].update_time*1e3))+"
  • "}htmlstr+="
"}return htmlstr};var format=function(requestStruct){var htmlstr='
X
';var reqDoc=requestStruct.requests;var reqSummary=requestStruct.summary;htmlstr+="
";htmlstr+="
    ";if(reqDoc){htmlstr+="
  • category: "+requestStruct.key+"
  • ";htmlstr+="
  • state transition "+transitionFormat(reqDoc[requestStruct.key].request_status,0,"State List")+"
  • ";htmlstr+="
  • queued (first): "+reqSummary.getJobStatus("queued.first",0)+"
  • ";htmlstr+="
  • queued (retried): "+reqSummary.getJobStatus("queued.retry",0)+"
  • ";htmlstr+="
  • created: "+reqSummary.getWMBSTotalJobs()+"
  • ";htmlstr+="
  • paused jobs: "+reqSummary.getTotalPaused()+"
  • ";htmlstr+="
  • cooloff jobs: "+reqSummary.getTotalCooloff()+"
  • ";htmlstr+="
  • submitted: "+reqSummary.getTotalSubmitted()+"
  • ";htmlstr+="
  • pending: "+reqSummary.getJobStatus("submitted.pending",0)+"
  • ";htmlstr+="
  • running: "+reqSummary.getJobStatus("submitted.running",0)+"
  • ";htmlstr+="
  • failure: "+reqSummary.getTotalFailure()+"
  • ";htmlstr+="
  • success: "+reqSummary.getJobStatus("success",0)+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestDetailList=function(workflow,containerDiv){var allRequests=vm.ActiveRequestPage.data();var reqDoc=allRequests.getData(workflow);var reqSummary=allRequests.getSummary(workflow);var requests={};requests[workflow]=reqDoc;var data={key:workflow,requests:requests,summary:reqSummary};$(containerDiv).html(format(data))}})();WMStats.namespace("RequestAlertGUI");WMStats.RequestAlertGUI=function(requestData,containerDiv){function mapType(workflowName){var workflowType=workflowName.split("_")[0].toLowerCase();if(workflowType=="express"){return 1}else if(workflowType=="repack"){return 2}else if(workflowType=="promptreco"){return 3}return 4}function alertSort(a,b){var aRun=a.requests[a.key].run;var bRun=b.requests[b.key].run;if(aRun==bRun){var aType=mapType(a.key);var bType=mapType(b.key);if(aType==bType){var aJobs=a.summary.getTotalPaused()+a.summary.getTotalCooloff();var bJobs=b.summary.getTotalPaused()+b.summary.getTotalCooloff();return bJobs-aJobs}else{return aType-bType}}else{return aRun-bRun}}var alertRequests=requestData.getAlertRequests();if(alertRequests.length>0){var htmlList="
    ";alertRequests=alertRequests.sort(alertSort);for(var i in alertRequests){var key=alertRequests[i].key;var summary=alertRequests[i].summary;var jobs=summary.getTotalPaused()+summary.getTotalCooloff();htmlList+='
  • '+key+":"+jobs+"
  • "}htmlList+="
";$(containerDiv).removeClass("stable warning").addClass("error").html(htmlList)}else{$(containerDiv).removeClass("warning error").addClass("stable").html("request alarm")}};WMStats.namespace("CategoryDetailList");(function(){var format=function(requestStruct){var htmlstr="";var reqDoc=requestStruct.requests;var reqSummary=requestStruct.summary;htmlstr+="
";htmlstr+="
    ";if(reqDoc){htmlstr+="
  • category: "+requestStruct.key+"
  • ";htmlstr+="
  • queued (first): "+reqSummary.getJobStatus("queued.first",0)+"
  • ";htmlstr+="
  • queued (retried): "+reqSummary.getJobStatus("queued.retry",0)+"
  • ";htmlstr+="
  • created: "+reqSummary.getWMBSTotalJobs()+"
  • ";htmlstr+="
  • paused jobs: "+reqSummary.getTotalPaused()+"
  • "; +htmlstr+="
  • cooloff jobs: "+reqSummary.getTotalCooloff()+"
  • ";htmlstr+="
  • submitted: "+reqSummary.getTotalSubmitted()+"
  • ";htmlstr+="
  • pending: "+reqSummary.getJobStatus("submitted.pending",0)+"
  • ";htmlstr+="
  • running: "+reqSummary.getJobStatus("submitted.running",0)+"
  • ";htmlstr+="
  • failure: "+reqSummary.getTotalFailure()+"
  • ";htmlstr+="
  • success: "+reqSummary.getJobStatus("success",0)+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.CategoryDetailList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("RequestSummaryList");(function(){var format=function(summary){var summaryStruct=summary.summaryStruct;var htmlstr="";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • requests: "+summary.summaryStruct.length+"
  • ";htmlstr+="
  • created: "+summary.getWMBSTotalJobs()+"
  • ";htmlstr+="
  • cooloff: "+summary.getTotalCooloff()+"
  • ";htmlstr+="
  • success: "+summary.getJobStatus("success")+"
  • ";htmlstr+="
  • failure: "+summary.getTotalFailure()+"
  • ";htmlstr+="
  • queued: "+summary.getTotalQueued()+"
  • ";htmlstr+="
  • running: "+summary.getJobStatus("submitted.running")+"
  • ";htmlstr+="
  • pending: "+summary.getJobStatus("submitted.pending")+"
  • ";htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestSummaryList=function(data,containerDiv){$(containerDiv).html(format(data))};var vm=WMStats.ViewModel;vm.ActiveRequestPage.subscribe("data",function(){var filteredData=vm.ActiveRequestPage.data();WMStats.RequestSummaryList(filteredData.getSummary(),"#filter_summary")})})();WMStats.namespace("RequestDataList");(function(){var format=function(summary){var summaryStruct=summary.summaryStruct;var htmlstr="";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • requests: "+summary.summaryStruct.length+"
  • ";htmlstr+="
  • total created: "+summary.getWMBSTotalJobs()+"
  • ";htmlstr+="
  • paused: "+summary.getTotalPaused()+"
  • ";htmlstr+="
  • cooloff: "+summary.getTotalCooloff()+"
  • ";htmlstr+="
  • success: "+summary.getJobStatus("success")+"
  • ";htmlstr+="
  • failure: "+summary.getTotalFailure()+"
  • ";htmlstr+="
  • queued: "+summary.getTotalQueued()+"
  • ";htmlstr+="
  • running: "+summary.getJobStatus("submitted.running")+"
  • ";htmlstr+="
  • pending: "+summary.getJobStatus("submitted.pending")+"
  • ";htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestDataList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("_ModelBase");WMStats._ModelBase=function(initView,options,dataStruct){this._initialView=initView;this._options=options;this._dataStruct=dataStruct;this._trigger=null;this._data=null;this._dbSource=WMStats.Couch};WMStats._ModelBase.prototype={setTrigger:function(triggerName){this._trigger=triggerName},getData:function(){return this._data},dataReady:function(data){this._data=this._dataStruct(data);if(this._trigger instanceof Array){for(var i in this._trigger){jQuery(WMStats.Globals.Event).triggerHandler(this._trigger[i],this._data)}}else{jQuery(WMStats.Globals.Event).triggerHandler(this._trigger,this._data)}},retrieveData:function(view,options){if(options===undefined){var options=this._options}if(view===undefined){var view=this._initialView}if(view==="allDocs"){return this.retrieveAllDocs(options)}else if(view==="doc"){return this.retrieveDoc(options)}else{return this._dbSource.view(view,options,jQuery.proxy(this.callback,this))}},retrieveAllDocs:function(options){if(options===undefined){var options=this._options}return this._dbSource.allDocs(options,jQuery.proxy(this.callback,this))},retrieveDoc:function(docID){return this._dbSource.openDoc(docID,jQuery.proxy(this.callback,this))},setDBSource:function(dbSource){this._dbSource=dbSource},callback:function(data){return this.dataReady(data)},clearData:function(){delete this._data}};WMStats.namespace("_RequestModelBase");WMStats._RequestModelBase=function(initView,options){this._initialView=initView||"requestByCampaignAndDate";this._options=options||{include_docs:true};this._data=null;this._trigger="requestReady"};WMStats._RequestModelBase.keysFromIDs=function(data){var keys=[];for(var i in data.rows){if(data.rows[i].value&&data.rows[i].value.id){keys.push(data.rows[i].value.id)}else{keys.push(data.rows[i].id)}}return keys};WMStats._RequestModelBase.requestAgentUrlKeys=function(requestList,requestAgentData){var keys={};var requestAgentUrlList=[];for(var i in requestAgentData.rows){var request=requestAgentData.rows[i].key[0];if(!keys[request]){keys[request]=[]}keys[request].push(requestAgentData.rows[i].key[1])}for(var j=0;j0||paused>0){alertRequests.push(this.getData(workflow))}}return alertRequests},getRequestStatusAndTime:function(workflowName){var workflowData=this._dataByWorkflow[workflowName];return workflowData["request_status"][workflowData["request_status"].length-1]}};WMStats.RequestsByKey=function(category,summaryFunc){var _data={};var _category=category;var _get=WMStats.Utils.get;function categorize(requestData){function _updateData(key,summaryBase){if(_data[key]===undefined){_data[key]={};_data[key].requests={};_data[key].summary=summaryFunc();_data[key].key=key}_data[key].requests[workflow]=dataByWorkflow[workflow];_data[key].summary.updateFromRequestDoc(summaryBase)}var dataByWorkflow=requestData.getData();for(var workflow in dataByWorkflow){var key=_get(dataByWorkflow[workflow],_category,"NA");if(typeof key=="object"){if(key.length){for(var index in key){_updateData(key[index],dataByWorkflow[workflow])}}else{for(var prop in key){_updateData(prop,key[prop])}}}else{if(key=="NA"&&_category=="sites"||_category=="tasks"){_updateData(key,{})}else{_updateData(key,dataByWorkflow[workflow])}}}}function getData(key){if(key===undefined){return _data}else{return _data[key]}}function getRequestData(key){var requestData=WMStats.Requests();requestData.setDataByWorkflow(_data[key].requests);return requestData}function getList(sortFunc){var list=[];for(var key in _data){list.push(_data[key])}if(sortFunc){return list.sort(sortFunc)}else{return list}}return{categorize:categorize,getData:getData,getRequestData:getRequestData,category:_category,getList:getList}};WMStats.namespace("Agents");WMStats.Agents=function(couchData){var agentData=new WMStats._StructBase;agentData.agentNumber={error:0,stable:0};agentData.convertCouchData=function(data){var dataRows=data.rows;var rows=[];for(var i in dataRows){var tableRow=dataRows[i].value;rows.push(tableRow)}return rows};if(couchData)agentData.setData(couchData);agentData.getAlertList=function(){var currentTime=Math.round((new Date).getTime()/1e3);var dataList=this.getData();var agentPollingCycle=600;agentNumber={error:0,stable:0};function getStatus(agentInfo){var lastUpdatedDuration=currentTime-agentInfo.timestamp;if(lastUpdatedDuration>agentPollingCycle*2){agentData.agentNumber.error+=1;return{status:"agent_down",message:WMStats.Utils.foramtDuration(lastUpdatedDuration)}}else if(agentInfo.down_components.length>0){agentData.agentNumber.error+=1;return{status:"component_down",message:agentInfo.down_components}}else{agentData.agentNumber.stable+=1;return{status:"ok",message:WMStats.Utils.foramtDuration(lastUpdatedDuration)}}}for(var index in dataList){dataList[index]["alert"]=getStatus(dataList[index])}return dataList};return agentData};WMStats.namespace("Sites");WMStats.Sites=function(couchData){var _data;var baseColumns=["timestamp","site","agent_url"];var siteData=new WMStats._StructBase;siteData.convertCouchData=function(data){var dataRows=data.rows;var rows=[];for(var i in dataRows){var tableRow=dataRows[i].value;for(var j=0;jtimeThreshold){alertRequests.push({request:this.getData(workflow),message:"not pulled by GQ"})}}if(reqStatusInfo.status=="acquired"){if(currentTime-reqStatusInfo.update_time>timeThreshold){alertRequests.push({request:this.getData(workflow),message:"not pulled by LQ"})}}}return alertRequests};return tier1Requests};WMStats.namespace("CampaignSummary");WMStats.CampaignSummary=function(){var campaignSummary={totalEvents:0,totalLumis:0,processedEvents:0,numRequests:0};var campaignSummary=new WMStats.GenericRequestsSummary(campaignSummary);campaignSummary.createSummaryFromRequestDoc=function(doc){var summary=WMStats.CampaignSummary();summary.summaryStruct.totalEvents=Number(this._get(doc,"input_events",0));summary.summaryStruct.totalLumis=Number(this._get(doc,"input_lumis",0));summary.summaryStruct.processedEvents=this._get(doc,"output_progress.0.events",0);summary.summaryStruct.progress=this.getAvgProgressSummary(doc);summary.summaryStruct.numRequests=1;summary.jobStatus=this._get(doc,"status",{});if(typeof summary.jobStatus.cooloff==="number"){summary.jobStatus.cooloff={create:0,submit:0,job:summary.jobStatus.cooloff}}return summary};return campaignSummary};WMStats.namespace("CMSSWSummary");WMStats.CMSSWSummary=function(){var cmsswSummary={totalEvents:0,totalLumis:0,processedEvents:0,numRequests:0};var cmsswSummary=new WMStats.GenericRequestsSummary(cmsswSummary);cmsswSummary.createSummaryFromRequestDoc=function(doc){var summary=WMStats.CMSSWSummary();summary.summaryStruct.totalEvents=Number(this._get(doc,"input_events",0));summary.summaryStruct.totalLumis=Number(this._get(doc,"input_lumis",0));summary.summaryStruct.processedEvents=this._get(doc,"output_progress.0.events",0);summary.summaryStruct.progress=this.getAvgProgressSummary(doc);summary.summaryStruct.numRequests=1;summary.jobStatus=this._get(doc,"status",{});if(typeof summary.jobStatus.cooloff==="number"){summary.jobStatus.cooloff={create:0,submit:0,job:summary.jobStatus.cooloff}}return summary};return cmsswSummary};WMStats.namespace("ReqMgrRequest");WMStats.ReqMgrRequest=function(couchData){var requestData=new WMStats._StructBase;if(couchData)requestData.setData(couchData);return requestData};WMStats.namespace("CommonControls");WMStats.CommonControls=function($){function setUTCClock(selector){setInterval(function(){$(selector).text(WMStats.Utils.utcClock())},100)}function setLinkTabs(selector){var linkTabs='';$(selector).append(linkTabs)}function setWorkloadSummarySearch(selector){var searchOption='
Search WorkloadSummary
';$(selector).append(searchOption)}$(document).on("change",'select[name="SearchOptions"]',function(){var filterType=$(":selected",this).attr("data-search-type");var searchBox=$("#searchPane .SearchBox");$(searchBox).empty();$("div.template."+filterType).children().clone().appendTo("#searchPane .SearchBox");$('#searchPane .SearchBox input[name="dateRange1"]').datepicker({altField:'input[name="dateRange1"]',altFormat:"yy/mm/dd",changeYear:true,yearRange:"2012:c"});$('#searchPane .SearchBox input[name="dateRange2"]').datepicker({altField:'input[name="dateRange2"]',altFormat:"yy/mm/dd",changeYear:true,yearRange:"2012:c"})});return{setUTCClock:setUTCClock,setLinkTabs:setLinkTabs,setWorkloadSummarySearch:setWorkloadSummarySearch}}(jQuery);WMStats.namespace("Table");WMStats.Table=function(config,tableSetting){var tableSetting=tableSetting||'
';var tableConfig={bStateSave:true,bProcessing:true,sDom:'<"top"pl>rt<"bottom"ip>',aaSorting:[],bAutoWidth:true,bJQueryUI:true};function updateConfig(config){for(var prop in config){tableConfig[prop]=config[prop]}}function _footer(){var footer="";for(var i in tableConfig.aoColumns){if(tableConfig.aoColumns[i].bVisible!=false){footer+=""+tableConfig.aoColumns[i]["sTitle"]+""}}footer+="";return footer}function create(selector,filterConfig){$(selector).empty();$(selector).html(tableSetting);var oTable=$(selector+" table").dataTable(tableConfig);if(oTable.length>0){oTable.fnAdjustColumnSizing()}jQuery(WMStats.Globals.Event).triggerHandler(WMStats.CustomEvents.LOADING_DIV_END);if(filterConfig){return oTable.columnFilter(filterConfig)}else{return oTable}}if(config){updateConfig(config)}return{config:tableConfig,updateConfig:updateConfig,create:create}};WMStats.namespace("JobSummaryTable");WMStats.JobSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:25,aoColumns:[{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:function(source,type,val){if(type=="display"){var taskList=source.task.split("/");return taskList[taskList.length-1]}return source.task},sTitle:"task",sWidth:"150px"},{mDataProp:"status",sTitle:"status"},{mDataProp:"site",sTitle:"site"},{mDataProp:"exitCode",sTitle:"exit code"},{mDataProp:"count",sTitle:"jobs"},{mDataProp:"errorMsg",sTitle:"error mesage",sDefaultContent:""},{sTitle:"acdc",sDefaultContent:"",sWidth:"15px",mDataProp:function(source,type,val){if(type=="display"){var taskList=source.task.split("/");var endTask=taskList[taskList.length-1];if(source.status!=="success"&&!endTask.match(/LogCollect$/)&&!endTask.match(/Cleanup$/)){return WMStats.Utils.formatDetailButton("acdc")}}return""}}],aaSorting:[[1,"asc"]]};tableConfig.aaData=data.getData().status;var filterConfig={};$(containerDiv).data("workflow",data.getData().workflow);return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("SiteSummaryTable");WMStats.SiteSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:50,sDom:'<"top"plf>rt<"bottom"ip>',sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"key",sTitle:"site"},{mDataProp:function(source,type,val){return source.summary.summaryStruct.numRequests},sTitle:"requests",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getJobStatus("submitted.pending")},sTitle:"pending",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getJobStatus("submitted.running")},sTitle:"running",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getTotalCooloff()},sTitle:"cool off",sDefaultContent:0},{sDefaultContent:0,sTitle:"failure rate",mDataProp:function(source,type,val){var failJobs=source.summary.getTotalFailure();var successJobs=source.summary.getJobStatus("success");var totalCompleteJobs=successJobs+failJobs||1;var result=failJobs/totalCompleteJobs*100;return result.toFixed(1)+"%"}}]};tableConfig.aaData=data.getList();var filterConfig={};return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("WorkloadSummaryTable");WMStats.WorkloadSummaryTable=function(data,containerDiv){var formatReqDetailUrl=WMStats.Utils.formatReqDetailUrl;var formatWorkloadSummarylUrl=WMStats.Utils.formatWorkloadSummarylUrl;var tableConfig={iDisplayLength:25,sScrollX:"",sDom:"lfrtip",bAutoWidth:false,aoColumns:[{mDataProp:"workflow",sTitle:"workflow",fnRender:function(o,val){return formatReqDetailUrl(o.aData._id)},bUseRendered:false,sWidth:"150px"},{mDataProp:function(source,type,val){return source.request_status[source.request_status.length-1].status},sTitle:"status",fnRender:function(o,val){return formatWorkloadSummarylUrl(o.aData._id,o.aData.request_status[o.aData.request_status.length-1].status)},bUseRendered:false},{mDataProp:"request_type",sTitle:"type",sDefaultContent:""},{mDataProp:"priority",sTitle:"priority",sDefaultContent:0},{mDataProp:"campaign",sTitle:"campaign",sDefaultContent:""}]};var filterConfig={};tableConfig.aaData=data.getData();return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("JobDetailList");(function(){var stateTransitionFormat=function(state){return""+state["newstate"]+": "+WMStats.Utils.utcClock(new Date(state["timestamp"]*1e3))+", "+state["location"]};var inputFileFormat=function(inputFile){return inputFile["lfn"]};var lumiFormat=function(lumis){function lumiRangeFormat(){if(startLumi==preLumi){lumiFormat.push("["+startLumi+"]")}else{lumiFormat.push("["+startLumi+" - "+preLumi+"]")}}var preLumi=null;var startLumi=null;var lumiFormat=new Array;for(var i in lumis){for(var j in lumis[i]){for(var k in lumis[i][j]){var currentLumi=Number(lumis[i][j][k]);if(startLumi===null){startLumi=currentLumi}else if(preLumi+1!==currentLumi){lumiRangeFormat();startLumi=currentLumi}preLumi=currentLumi}}}if(startLumi!==null){lumiRangeFormat()}return lumiFormat};var logArchiveFormat=function(archiveObj,key){return key};var format=function(data){var jobDetails=data.getData();var requestData=WMStats.ActiveRequestModel.getData();var htmlstr='
";for(var index in jobDetails){var jobDoc=jobDetails[index];if(index==="0"){htmlstr+="
"}else{htmlstr+="
"}htmlstr+="
    ";htmlstr+="
  • Job Name: "+jobDoc._id+"
  • ";htmlstr+="
  • WMBS job id: "+jobDoc.wmbsid+"
  • ";htmlstr+="
  • Workflow: "+jobDoc.workflow+"
  • ";htmlstr+="
  • Task: "+jobDoc.task+"
  • ";htmlstr+="
  • Status: "+jobDoc.state+"
  • ";htmlstr+="
  • Input dataset: "+requestData.getDataByWorkflow(jobDoc.workflow,"inputdataset","")+"
  • ";if(typeof jobDoc.site=="object"){htmlstr+="
  • Site: N/A
  • "}else{htmlstr+="
  • Site: "+jobDoc.site+"
  • "}htmlstr+="
  • Agent: "+jobDoc.agent_name+"
  • ";htmlstr+="
  • ACDC URL: "+jobDoc.acdc_url+"
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(jobDoc.state_history,"State Transition",stateTransitionFormat)+"
  • ";htmlstr+="
  • Exit code: "+jobDoc.exitcode+"
  • ";htmlstr+="
  • Retry count: "+jobDoc.retrycount+"
  • ";htmlstr+="
  • Errors: ";for(var errorType in jobDoc.errors){htmlstr+="
      ";htmlstr+="
    • "+errorType+"
    • ";for(var i in jobDoc.errors[errorType]){htmlstr+="
        ";htmlstr+="
      • "+jobDoc.errors[errorType][i].type+" (Exit Code: "+jobDoc.errors[errorType][i].exitCode+")
      • ";htmlstr+="
          ";htmlstr+="
        • "+jobDoc.errors[errorType][i].details+"
        • ";htmlstr+="
        ";htmlstr+="
      "}htmlstr+="
    "}htmlstr+="
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(jobDoc.inputfiles,"Input files",inputFileFormat)+"
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(lumiFormat(jobDoc.lumis),"Lumis")+"
  • ";htmlstr+="
  • Output: ";for(var i in jobDoc.output){htmlstr+="
      ";htmlstr+="
    • "+jobDoc.output[i].type+"
    • ";htmlstr+="
        ";htmlstr+="
      • lfn: "+jobDoc.output[i].lfn+"
      • ";htmlstr+="
      • location: ";htmlstr+=jobDoc.output[i].location;htmlstr+="
      • ";htmlstr+="
      • checksums: adler32: "+jobDoc.output[i].checksums.adler32+", cksum: "+jobDoc.output[i].checksums.cksum+"
      • ";htmlstr+="
      • size: "+jobDoc.output[i].size+"
      • ";htmlstr+="
      ";htmlstr+="
    "}htmlstr+="
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(jobDoc.logArchiveLFN,"log archive",logArchiveFormat)+"
  • "; -htmlstr+="
";htmlstr+="
"}return htmlstr};WMStats.JobDetailList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("AgentStatusGUI");WMStats.AgentStatusGUI=function(data,containerDiv){var dataList=data.getAlertList();var collectiveStatus="ok";function setStatus(status){if(collectiveStatus=="ok"){collectiveStatus=status}else if(collectiveStatus=="warning"&&status=="error"){collectiveStatus="error"}}var htmlList="
    ";for(var index in dataList){var statusInfo=dataList[index].alert;if(statusInfo.status=="agent_down"){setStatus("error");htmlList+="
  • "+dataList[index].agent_url+": "+statusInfo.message+"
  • "}else if(statusInfo.status=="component_down"){setStatus("warning");htmlList+="
  • "+dataList[index].agent_url+": "+statusInfo.message+"
  • "}}htmlList+="
";if(collectiveStatus=="ok"){$(containerDiv).removeClass("warning error").addClass("stable")}else if(collectiveStatus=="warning"){$(containerDiv).removeClass("stable error").addClass("warning").html(htmlList)}else if(collectiveStatus=="error"){$(containerDiv).removeClass("stable warning").addClass("error").html(htmlList)}};WMStats.namespace("AgentDetailList");(function(){var statusInterpretator=function(alertStatus){if(alertStatus=="agent_down"){message="Data is not updated: AnalyticsDataCollector Down"}else if(alertStatus=="component_down"){message="Components or Thread down"}else{message="OK"}return message};var componentFormat=function(componentList){var formatStr="";for(var i in componentList){formatStr+="
"+componentList[i].name+"
    ";formatStr+="
  • "+componentList[i].worker_name+"
  • ";formatStr+="
  • status: "+componentList[i].state+"
  • ";formatStr+="
  • error: "+WMStats.Utils.utcClock(new Date(componentList[i].last_error*1e3))+"
  • ";formatStr+="
  • error message:
    "+componentList[i].error_message+"
  • ";formatStr+="
  • pid: "+componentList[i].pid+"
  • ";formatStr+="
"}return formatStr};var agentErrorFormat=function(agentInfo){var htmlstr="";htmlstr+="
";htmlstr+="
    ";if(agentInfo){htmlstr+="
  • agent: "+agentInfo.agent_url+"
  • ";htmlstr+="
  • last_updated: "+WMStats.Utils.utcClock(new Date(agentInfo.timestamp*1e3))+" : "+agentInfo.alert.message+"
  • ";htmlstr+="
  • status: "+statusInterpretator(agentInfo.alert.status)+"
  • ";htmlstr+="
  • team: "+agentInfo.agent_team+"
  • "}var detailInfo=agentInfo.down_component_detail;if(detailInfo&&detailInfo.length>0){htmlstr+="
  • component errors: ";htmlstr+=componentFormat(detailInfo);htmlstr+="
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};var agentStableFormat=function(agentInfo){var htmlstr="";htmlstr+="
";htmlstr+="
    ";if(agentInfo){htmlstr+="
  • agent: "+agentInfo.agent_url+"
  • ";htmlstr+="
  • last_updated: "+agentInfo.alert.message+"
  • ";htmlstr+="
  • status: "+statusInterpretator(agentInfo.alert.status)+"
  • ";htmlstr+="
  • team "+agentInfo.agent_team+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};var format=function(agentData){var htmlstr="";var agentsWithWarning=agentData.getAlertList();for(i in agentsWithWarning){if(agentsWithWarning[i].alert&&agentsWithWarning[i].alert.status!=="ok"){htmlstr+=agentErrorFormat(agentsWithWarning[i])}else{htmlstr+=agentStableFormat(agentsWithWarning[i])}}return htmlstr};WMStats.AgentDetailList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("WMStats.CategoryTitle");(function(){var format=function(data){var categoryKey=data;var htmlstr="";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • Category: "+categoryKey+"
  • ";htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.CategoryTitle=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("WMStats.RequestTitle");(function(){var format=function(data){var workflow;var dataType;if(typeof data==="string"){workflow=data;dataType=0}else{workflow=data.getData().workflow;dataType=1}var requestInfo=WMStats.ActiveRequestModel.getData().getDataByWorkflow(workflow);var htmlstr="";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • "+workflow+"
  • ";if(dataType==1){htmlstr+="
  • agent: "+requestInfo.agent_url+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestTitle=function(data,containerDiv){if(typeof data==="string"||typeof data==="object"&&data.getData().workflow!==undefined){$(containerDiv).html(format(data))}}})();WMStats.namespace("SiteHistoryGraph");WMStats.SiteHistoryGraph=function(historyData,containerDiv){var siteHistory=JSON.stringify(historyData);var htmlList="
"+siteHistory+"
";$(containerDiv).html(htmlList)};WMStats.namespace("Controls");WMStats.Controls=function($){var _filterSelector;var _categorySelector;function setFilter(selector){$(selector).append('filter
campaign:
workflow:
type:
status:
input dataset:
output dataset:
site whitelist:
agent:
');_filterSelector=selector+' div[name="filter"] input'}function setCategoryButton(selector){var categoryBottons='';$(selector).append(categoryBottons);WMStats.Env.CategorySelection="campaign"}function setViewSwitchButton(selector){var viewSwitchBottons='';$(selector).append(viewSwitchBottons);WMStats.Env.ViewSwitchSelection="progress"}function setAllRequestButton(selector){var requestBottons='';$(selector).append(requestBottons).addClass("button-group");WMStats.Env.RequestSelection="all_requests"}function getCategoryButtonValue(){return WMStats.Env.CategorySelection}function getFilter(){return WMStats.Utils.createInputFilter(_filterSelector)}function setTabs(selector){var tabs='';$(selector).append(tabs).addClass("tabs");$(selector+" ul").addClass("tabs-nav")}function setExternalLink(selector){var outsideLink=' agent alert ';$(selector).append(outsideLink)}return{setFilter:setFilter,setTabs:setTabs,setCategoryButton:setCategoryButton,setAllRequestButton:setAllRequestButton,getCategoryButtonValue:getCategoryButtonValue,setViewSwitchButton:setViewSwitchButton,setExternalLink:setExternalLink,getFilter:getFilter,requests:"requests",sites:"sites",campaign:"campaign",cmssw:"cmssw"}}(jQuery);WMStats.namespace("ActiveRequestTable");WMStats.ActiveRequestTable=function(requestData,containerDiv){var formatReqDetailUrl=WMStats.Utils.formatReqDetailUrl;var formatWorkloadSummarylUrl=WMStats.Utils.formatWorkloadSummarylUrl;var tableConfig={iDisplayLength:25,sScrollX:"",bAutoWidth:false,aoColumns:[{sTitle:"D",sDefaultContent:0,sWidth:"15px",fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,sWidth:"15px",fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"workflow",sTitle:"workflow",fnRender:function(o,val){return formatReqDetailUrl(o.aData.workflow)},bUseRendered:false,sWidth:"150px"},{mDataProp:function(source,type,val){return source.request_status[source.request_status.length-1].status},sTitle:"status",fnRender:function(o,val){return formatWorkloadSummarylUrl(o.aData.workflow,o.aData.request_status[o.aData.request_status.length-1].status)},bUseRendered:false},{mDataProp:"request_type",sTitle:"type",sDefaultContent:""},{mDataProp:"priority",sTitle:"priority",sDefaultContent:0},{sDefaultContent:0,sTitle:"queue injection",fnRender:function(o,val){var result=requestData.getDataByWorkflow(o.aData.workflow,"status.inWMBS",0)/requestData.getDataByWorkflow(o.aData.workflow,"total_jobs",1)*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"job progress",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);var totalJobs=reqSummary.getWMBSTotalJobs()||1;var result=(reqSummary.getJobStatus("success")+reqSummary.getTotalFailure())/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"event progress",fnRender:function(o,val){var inputEvents=Number(requestData.getDataByWorkflow(o.aData.workflow,"input_events",1))||1;var outputEvents=requestData.getSummary(o.aData.workflow).getAvgEvents();var result=outputEvents/inputEvents*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"lumi progress",fnRender:function(o,val){var inputLumis=Number(requestData.getDataByWorkflow(o.aData.workflow,"input_lumis",1))||1;var outputLumis=requestData.getSummary(o.aData.workflow).getAvgLumis();var result=outputLumis/inputLumis*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"failure rate",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);var totalFailure=reqSummary.getTotalFailure();var totalJobs=reqSummary.getJobStatus("success")+totalFailure||1;var result=totalFailure/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"Eestimated Completion",fnRender:function(o,val){return WMStats.Utils.foramtDuration(requestData.estimateCompletionTime(o.aData.workflow))}},{sDefaultContent:0,sTitle:"cool off ",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);return reqSummary.getTotalCooloff()}}]};var filterConfig={};tableConfig.aaData=requestData.getList();return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("ActiveRequestTableWithJob");WMStats.ActiveRequestTableWithJob=function(requestData,containerDiv){var formatReqDetailUrl=WMStats.Utils.formatReqDetailUrl;var formatWorkloadSummarylUrl=WMStats.Utils.formatWorkloadSummarylUrl;var tableConfig={iDisplayLength:25,sScrollX:"",bAutoWidth:false,aoColumns:[{sTitle:"D",sDefaultContent:0,sWidth:"15px",fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,sWidth:"15px",fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"workflow",sTitle:"workflow",fnRender:function(o,val){return formatReqDetailUrl(o.aData.workflow)},bUseRendered:false,sWidth:"150px"},{mDataProp:function(source,type,val){return source.request_status[source.request_status.length-1].status},sTitle:"status",fnRender:function(o,val){return formatWorkloadSummarylUrl(o.aData.workflow,o.aData.request_status[o.aData.request_status.length-1].status)},bUseRendered:false},{sDefaultContent:0,sTitle:"created",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);return reqSummary.getWMBSTotalJobs()}},{sDefaultContent:0,sTitle:"queued",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);return reqSummary.getTotalQueued()}},{sDefaultContent:0,sTitle:"pending ",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getPending();if(type==="display"){return WMStats.Globals.formatJobLink(jobs,source.agent_url,source.workflow,"pending")}return jobs}},{sDefaultContent:0,sTitle:"running ",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getRunning();if(type==="display"){return WMStats.Globals.formatJobLink(jobs,source.agent_url,source.workflow,"running")}return jobs}},{sDefaultContent:0,sTitle:"success ",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getJobStatus("success");if(type==="display"){return WMStats.Globals.formatJobLink(jobs,source.agent_url,source.workflow,"success")}return jobs}},{sDefaultContent:0,sTitle:"failure ",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getTotalFailure();if(type==="display"){return WMStats.Globals.formatJobLink(jobs,source.agent_url,source.workflow,"failed")}return jobs}},{sDefaultContent:0,sTitle:"cool off ",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getTotalCooloff();if(type==="display"){return WMStats.Globals.formatJobLink(jobs,source.agent_url,source.workflow,"cooloff")}return jobs}}]};var filterConfig={};tableConfig.aaData=requestData.getList();return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("CampaignSummaryTable");WMStats.CampaignSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:50,sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"key",sTitle:"campaign"},{mDataProp:function(source,type,val){return source.summary.summaryStruct.numRequests},sTitle:"requests",sDefaultContent:0},{sDefaultContent:0,sTitle:"job progress",mDataProp:function(source,type,val){var campaignSummary=source.summary;var totalJobs=campaignSummary.getWMBSTotalJobs()||1;var result=(campaignSummary.getJobStatus("success")+campaignSummary.getTotalFailure())/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"event progress",mDataProp:function(source,type,val){var totalEvents=source.summary.summaryStruct.totalEvents||1;var result=source.summary.getAvgEvents()/totalEvents*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"lumi progress",mDataProp:function(source,type,val){var totalLumis=source.summary.summaryStruct.totalLumis||1;var result=source.summary.getAvgLumis()/totalLumis*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"failure rate",mDataProp:function(source,type,val){var campaignSummary=source.summary;var totalFailure=campaignSummary.getTotalFailure();var totalJobs=campaignSummary.getJobStatus("success")+totalFailure||1;var result=totalFailure/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"cool off ",mDataProp:function(source,type,val){var campaignSummary=source.summary;return campaignSummary.getTotalCooloff()}}]};tableConfig.aaData=data.getList();var filterConfig={};return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("CMSSWSummaryTable");WMStats.CMSSWSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:50,sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"key",sTitle:"cmssw"},{mDataProp:function(source,type,val){return source.summary.summaryStruct.numRequests},sTitle:"requests",sDefaultContent:0},{sDefaultContent:0,sTitle:"job progress",mDataProp:function(source,type,val){var cmsswSummary=source.summary;var totalJobs=cmsswSummary.getWMBSTotalJobs()||1;var result=(cmsswSummary.getJobStatus("success")+cmsswSummary.getTotalFailure())/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"event progress",mDataProp:function(source,type,val){var totalEvents=source.summary.summaryStruct.totalEvents||1;var result=source.summary.getAvgEvents()/totalEvents*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"lumi progress",mDataProp:function(source,type,val){var totalLumis=source.summary.summaryStruct.totalLumis||1;var result=source.summary.getAvgLumis()/totalLumis*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"failure rate",mDataProp:function(source,type,val){var cmsswSummary=source.summary;var totalFailure=cmsswSummary.getTotalFailure();var totalJobs=cmsswSummary.getJobStatus("success")+totalFailure||1;var result=totalFailure/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"cool off ",mDataProp:function(source,type,val){var cmsswSummary=source.summary;return cmsswSummary.getTotalCooloff()}}]};tableConfig.aaData=data.getList();var filterConfig={};return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("RequestDetailList");(function(){var progressFormat=function(progressStat,totalEvents,totalLumis){var formatStr="
    ";for(var output in progressStat){var processedEvents=progressStat[output].events||0;var processedLumis=progressStat[output].totalLumis||0;var eventPercent=(processedEvents/totalEvents*100).toFixed(1)+"%";var lumiPercent=(processedLumis/totalLumis*100).toFixed(1)+"%";formatStr+="
  • "+output+": event: "+eventPercent+", lumi: "+lumiPercent+"
  • "}formatStr+="
";return formatStr};var expandFormat=function(dataArray,maxLength,summaryStr){var htmlstr="";if(dataArray==undefined||dataArray.length==undefined||dataArray.length<=maxLength){htmlstr+=dataArray}else{htmlstr+="
"+summaryStr+"
    ";for(var i in dataArray){htmlstr+="
  • "+dataArray[i]+"
  • "}htmlstr+="
"}return htmlstr};var format=function(requestStruct){var htmlstr='
X
';var reqDoc=requestStruct.requests[requestStruct.key];var reqSummary=requestStruct.summary;htmlstr+="
";htmlstr+="
    ";if(reqDoc){htmlstr+="
  • campaign: "+reqDoc.campaign+"
  • ";htmlstr+="
  • workflow: "+WMStats.Utils.formatReqDetailUrl(reqDoc.workflow)+"
  • ";htmlstr+="
  • agent url: "+reqDoc.agent_url+"
  • ";htmlstr+="
  • prep id: "+reqDoc.prep_id+"
  • ";htmlstr+="
  • teams: "+reqDoc.teams+"
  • ";htmlstr+="
  • requetor: "+reqDoc.requestor+"
  • ";htmlstr+="
  • request date: "+reqDoc.request_date+"
  • ";htmlstr+="
  • request type: "+reqDoc.request_type+"
  • ";htmlstr+="
  • CMSSW: "+reqDoc.cmssw+"
  • ";htmlstr+="
  • user dn: "+reqDoc.user_dn+"
  • ";htmlstr+="
  • vo role: "+reqDoc.vo_role+"
  • ";htmlstr+="
  • vo group: "+reqDoc.vo_group+"
  • ";htmlstr+="
  • status: "+WMStats.Utils.formatWorkloadSummarylUrl(reqDoc.workflow,reqDoc.request_status[reqDoc.request_status.length-1].status)+"
  • ";htmlstr+="
  • input dataset: "+reqDoc.inputdataset+"
  • ";htmlstr+="
  • input events: "+reqDoc.input_events+"
  • ";htmlstr+="
  • site white list: "+expandFormat(reqDoc.site_white_list,4,"Multiple Sites")+"
  • ";htmlstr+="
  • output datasets: "+expandFormat(reqDoc.outputdatasets,1,"Multiple Datasets")+"
  • ";htmlstr+="
  • progress: "+progressFormat(reqDoc.getProgressStat(),Number(reqDoc.input_events),Number(reqDoc.input_lumis))+"
  • "}if(reqSummary){htmlstr+="
  • output events: "+reqSummary.summaryStruct.processedEvents+"
  • ";htmlstr+="
  • queued (first): "+reqSummary.getJobStatus("queued.first",0)+"
  • ";htmlstr+="
  • queued (retried): "+reqSummary.getJobStatus("queued.retry",0)+"
  • ";htmlstr+="
  • cooloff jobs: "+reqSummary.getTotalCooloff()+"
  • ";htmlstr+="
  • pending: "+reqSummary.getJobStatus("submitted.pending",0)+"
  • ";htmlstr+="
  • running: "+reqSummary.getJobStatus("submitted.running",0)+"
  • ";htmlstr+="
  • failure:"+reqSummary.getTotalFailure()+"
  • ";htmlstr+="
  • success: "+reqSummary.getJobStatus("success",0)+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestDetailList=function(data,containerDiv){$(containerDiv).html(format(data));$(containerDiv).show("slide",{},500);WMStats.Env.RequestDetailOpen=true}})();WMStats.namespace("RequestAlertGUI");WMStats.RequestAlertGUI=function(requestData,containerDiv){var alertRequests=requestData.getAlertRequests();var notPulledRequests=requestData.requestNotPulledAlert();if(alertRequests.length>0||notPulledRequests.length>0){var htmlList="
    ";for(var i in alertRequests){var key=alertRequests[i].key;var summary=alertRequests[i].summary;var jobs=summary.getTotalPaused()+summary.getTotalCooloff();htmlList+='
  • '+key+":"+jobs+"
  • "}for(var i in notPulledRequests){var key=notPulledRequests[i].request.key;htmlList+="
  • "+key+":"+notPulledRequests[i].message+"
  • "}htmlList+="
";$(containerDiv).removeClass("stable warning").addClass("error").html(htmlList)}else{$(containerDiv).removeClass("warning error").addClass("stable").html("request alarm")}};WMStats.namespace("CategoryDetailList");(function(){var format=function(requestStruct){var htmlstr="";var reqDoc=requestStruct.requests[requestStruct.key];var reqSummary=requestStruct.summary;htmlstr+="
";htmlstr+="
    ";if(reqDoc){htmlstr+="
  • campaign: "+reqDoc.campaign+"
  • ";htmlstr+="
  • workflow: "+WMStats.Utils.formatReqDetailUrl(reqDoc.workflow)+"
  • ";htmlstr+="
  • requetor: "+reqDoc.requestor+"
  • ";htmlstr+="
  • request date: "+reqDoc.request_date+"
  • ";htmlstr+="
  • request type: "+reqDoc.request_type+"
  • ";htmlstr+="
  • user dn: "+reqDoc.user_dn+"
  • ";htmlstr+="
  • vo role: "+reqDoc.vo_role+"
  • ";htmlstr+="
  • vo group: "+reqDoc.vo_group+"
  • ";htmlstr+="
  • status: "+WMStats.Utils.formatWorkloadSummarylUrl(reqDoc.workflow,reqDoc.request_status[reqDoc.request_status.length-1].status)+"
  • ";htmlstr+="
  • input dataset: "+reqDoc.inputdataset+"
  • ";htmlstr+="
  • input events: "+reqDoc.input_events+"
  • ";htmlstr+="
  • site white list: "+reqDoc.site_white_list+"
  • ";htmlstr+="
  • output datasets: "+reqDoc.outputdatasets+"
  • "}if(reqSummary){htmlstr+="
  • output events: "+reqSummary.summaryStruct.processedEvents+"
  • ";htmlstr+="
  • queued (first): "+reqSummary.getJobStatus("queued.first",0)+"
  • ";htmlstr+="
  • queued (retried): "+reqSummary.getJobStatus("queued.retry",0)+"
  • ";htmlstr+="
  • cooloff jobs: "+reqSummary.getTotalCooloff()+"
  • ";htmlstr+="
  • pending: "+reqSummary.getJobStatus("submitted.pending",0)+"
  • ";htmlstr+="
  • running: "+reqSummary.getJobStatus("submitted.running",0)+"
  • ";htmlstr+="
  • failure:"+reqSummary.getTotalFailure()+"
  • ";htmlstr+="
  • success: "+reqSummary.getJobStatus("success",0)+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.CategoryDetailList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("RequestSummaryList");(function(){var numFormat=WMStats.Utils.largeNumberFormat;var format=function(summary){var summaryStruct=summary.summaryStruct;var htmlstr="";htmlstr+="filtered stats";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • requests: "+summary.summaryStruct.length+"
  • ";htmlstr+="
  • total events: "+numFormat(summary.summaryStruct.totalEvents)+"
  • ";htmlstr+="
  • processed events: "+numFormat(summary.getAvgEvents())+"
  • ";htmlstr+="
  • created: "+numFormat(summary.getWMBSTotalJobs())+"
  • ";htmlstr+="
  • cooloff: "+numFormat(summary.getTotalCooloff())+"
  • ";htmlstr+="
  • success: "+numFormat(summary.getJobStatus("success"))+"
  • ";htmlstr+="
  • failure: "+numFormat(summary.getTotalFailure())+"
  • ";htmlstr+="
  • queued: "+numFormat(summary.getTotalQueued())+"
  • ";htmlstr+="
  • running: "+numFormat(summary.getJobStatus("submitted.running"))+"
  • ";htmlstr+="
  • pending: "+numFormat(summary.getJobStatus("submitted.pending"))+"
  • ";htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestSummaryList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("RequestDataList");(function(){var format=function(summary){var summaryStruct=summary.summaryStruct;var htmlstr="";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • requests: "+summary.summaryStruct.length+"
  • ";htmlstr+="
  • total events: "+summary.summaryStruct.totalEvents+"
  • ";htmlstr+="
  • processed events: "+summary.summaryStruct.processedEvents+"
  • ";htmlstr+="
  • created: "+summary.getWMBSTotalJobs()+"
  • ";htmlstr+="
  • cooloff: "+summary.getTotalCooloff()+"
  • ";htmlstr+="
  • success: "+summary.getJobStatus("success")+"
  • ";htmlstr+="
  • failure: "+summary.getTotalFailure()+"
  • ";htmlstr+="
  • queued: "+summary.getTotalQueued()+"
  • ";htmlstr+="
  • running: "+summary.getJobStatus("submitted.running")+"
  • ";htmlstr+="
  • pending: "+summary.getJobStatus("submitted.pending")+"
  • ";htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestDataList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("ResubmissionList");(function(){var format=function(summary){var htmlstr="";htmlstr+="Resubmission";htmlstr='
X
';htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • Request String: :
  • ";htmlstr+="
  • Original Request Name: :"+summary.OriginalRequestName+"
  • ";htmlstr+="
  • Initial Task Path: "+summary.InitialTaskPath+"
  • ";if(summary.ACDCServer){htmlstr+="
  • ACDC Server URL: "+summary.ACDCServer+"
  • ";htmlstr+="
  • ACDC DB Name: "+summary.ACDCDatabase+"
  • "}else{htmlstr+="
  • ACDC Server URL:
  • ";htmlstr+="
  • ACDC DB Name:
  • "}htmlstr+="
  • Group: "+summary.Group+"
  • ";htmlstr+="
  • PrepID: "+summary.PrepID+"
  • ";htmlstr+="
  • RequestPriority: "+summary.RequestPriority+"
  • ";htmlstr+="
  • DBSURL: "+summary.DbsUrl+"
  • ";htmlstr+="
  • Memory: "+summary.Memory+"
  • ";htmlstr+="
  • SizePerEven: "+summary.SizePerEvent+"
  • ";htmlstr+="
  • TimePerEvent: "+summary.TimePerEvent+"
  • ";htmlstr+="
  • RequestType: "+summary.RequestType+"
  • ";htmlstr+="
";htmlstr+="";htmlstr+="
";return htmlstr};WMStats.ResubmissionList=function(data,containerDiv){$(containerDiv).html(format(data));$(containerDiv).show("slide",{},500)};$(document).on("click","#acdc_submission button",function(event){WMStats.ViewModel.Resubmission.RequestString=$('#acdc_submission input[name="RequestString"]').val();if(WMStats.ViewModel.Resubmission.ACDCServer===undefined){WMStats.ViewModel.Resubmission.ACDCServer=$('#acdc_submission input[name="ACDCServer"]').val()}if(WMStats.ViewModel.Resubmission.ACDCDatabase===undefined){WMStats.ViewModel.Resubmission.ACDCDatabase=$('#acdc_submission input[name="ACDCDatabase"]').val()}WMStats.Ajax.requestMgr.putRequest(WMStats.ViewModel.Resubmission);event.preventDefault()});$(WMStats.Globals.Event).on(WMStats.CustomEvents.RESUBMISSION_SUCCESS,function(event,requestName){$("#acdc_submission div.requestDetailBox").append(WMStats.Utils.formatReqDetailUrl(requestName))})})();WMStats.namespace("_ModelBase");WMStats._ModelBase=function(initView,options,dataStruct){this._initialView=initView;this._options=options;this._dataStruct=dataStruct;this._trigger=null;this._data=null;this._dbSource=WMStats.Couch};WMStats._ModelBase.prototype={setTrigger:function(triggerName){this._trigger=triggerName},getData:function(){return this._data},dataReady:function(data){this._data=this._dataStruct(data);if(this._trigger instanceof Array){for(var i in this._trigger){jQuery(WMStats.Globals.Event).triggerHandler(this._trigger[i],this._data)}}else{jQuery(WMStats.Globals.Event).triggerHandler(this._trigger,this._data)}},retrieveData:function(view,options){if(options===undefined){var options=this._options}if(view===undefined){var view=this._initialView}if(view==="allDocs"){return this.retrieveAllDocs(options)}else if(view==="doc"){return this.retrieveDoc(options)}else{return this._dbSource.view(view,options,jQuery.proxy(this.callback,this))}},retrieveAllDocs:function(options){if(options===undefined){var options=this._options}return this._dbSource.allDocs(options,jQuery.proxy(this.callback,this))},retrieveDoc:function(docID){return this._dbSource.openDoc(docID,jQuery.proxy(this.callback,this))},setDBSource:function(dbSource){this._dbSource=dbSource},callback:function(data){return this.dataReady(data)},clearData:function(){delete this._data}};WMStats.namespace("_RequestModelBase");WMStats._RequestModelBase=function(initView,options){this._initialView=initView||"requestByCampaignAndDate";this._options=options||{include_docs:true};this._data=null;this._trigger="requestReady"};WMStats._RequestModelBase.keysFromIDs=function(data){var keys=[];for(var i in data.rows){if(data.rows[i].value&&data.rows[i].value.id){keys.push(data.rows[i].value.id)}else{keys.push(data.rows[i].id)}}return keys};WMStats._RequestModelBase.requestAgentUrlKeys=function(requestList,requestAgentData){var keys={};var requestAgentUrlList=[];for(var i in requestAgentData.rows){var request=requestAgentData.rows[i].key[0];if(!keys[request]){keys[request]=[]}keys[request].push(requestAgentData.rows[i].key[1])}for(var j=0;j0){$('#linkTabs a[href="#agentInfoPage"] strong').text("("+agentData.agentNumber.error+")")}});$(WMStats.Globals.Event).on(E.CATEGORY_SUMMARY_READY,function(event,data){$("#category_view div.detail_data").empty();drawDataBoard("#category_view")});$(WMStats.Globals.Event).on(E.REQUEST_SUMMARY_READY,function(event,data){$("#request_view div.detail_data").empty();if(data){WMStats.Env.CurrentRequestData=data}drawDataBoard("#request_view")});$(WMStats.Globals.Event).on(E.JOB_SUMMARY_READY,function(event,data){WMStats.RequestTitle(data,"#request_title");$("#job_view div.detail_data").empty();WMStats.Env.JobSummaryTable=WMStats.JobSummaryTable(data,"#job_view div.summary_data");WMStats.GenericController.switchView("#job_view")});$(WMStats.Globals.Event).on(E.CATEGORY_DETAIL_READY,function(event,categoryKey){var allData=WMStats.Env.CategoryData;var data=allData.getData(categoryKey);WMStats.CategoryDetailList(data,"#category_view div.detail_data")});$(WMStats.Globals.Event).on(E.REQUEST_DETAIL_READY,function(event,workflow){var allRequests=WMStats.ActiveRequestModel.getRequests();var reqDoc=allRequests.getDataByWorkflow(workflow);var reqSummary=allRequests.getSummary(workflow);var requests={};requests[workflow]=reqDoc;var data={key:workflow,requests:requests,summary:reqSummary};WMStats.RequestDetailList(data,"#request_view div.detail_data")});$(WMStats.Globals.Event).on(E.JOB_DETAIL_READY,function(event,data){WMStats.JobDetailList(data,"#job_view div.detail_data")});$(document).on("keyup","#filter_board input",function(){getActiveFilteredData();drawFilteredRequestSummary();drawDataBoard()});$(document).on("click","#category_button li a",function(event){WMStats.Env.CategorySelection=this.hash.substring(1);$(WMStats.Globals.Event).triggerHandler(E.CATEGORY_SUMMARY_READY);$("#category_button li a").removeClass("nav-button-selected").addClass("button-unselected");$(this).removeClass("button-unselected").addClass("nav-button-selected");event.preventDefault()});$(document).on("click","#all_requests li a",function(event){WMStats.Env.RequestSelection="all_requests";var data=WMStats.ActiveRequestModel.getRequests();$(WMStats.Globals.Event).triggerHandler(E.REQUEST_SUMMARY_READY,data);$(this).removeClass("button-unselected").addClass("nav-button-selected");event.preventDefault()});$(document).on("click","#view_switch_button li a",function(event){WMStats.Env.ViewSwitchSelection=this.hash.substring(1);$(WMStats.Globals.Event).triggerHandler(E.REQUEST_SUMMARY_READY);$(this).removeClass("button-unselected").addClass("nav-button-selected");event.preventDefault()});$(document).on("click","a.requestAlert",function(){var workflow=$(this).text();WMStats.JobSummaryModel.setRequest(workflow);$(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START);WMStats.JobSummaryModel.retrieveData();$(this).addClass("reviewed")});$(document).on("click","#tab_board li a",function(event){drawDataBoard(this.hash);event.preventDefault()});$(document).on("click","#jobDetailNav li a",function(event){$("div.jobDetailBox").hide();$(this.hash).show();$("#jobDetailNav li a").removeClass("button-selected").addClass("button-unselected");$(this).removeClass("button-unselected").addClass("button-selected");event.preventDefault()});$(WMStats.Globals.Event).on(E.LOADING_DIV_START,function(event,data){if(WMStats.Env.View==="#category_view"||WMStats.Env.View==="#request_view"&&WMStats.Env.RequestSelection==="all_requests"){$("#loading_page").show()}});$(WMStats.Globals.Event).on(E.LOADING_DIV_END,function(event,data){$("#loading_page").hide()});$(WMStats.Globals.Event).on(E.AJAX_LOADING_START,function(event,data){$("#loading_page").show()});$(WMStats.Globals.Event).on(E.RESUBMISSION_SUMMARY_READY,function(event,data){var reqMgrReq=WMStats.ReqMgrRequestModel.getData().getData();var summary=WMStats.ViewModel.Resubmission;summary.Memory=reqMgrReq.Memory;summary.SizePerEvent=reqMgrReq.SizePerEvent;summary.TimePerEvent=reqMgrReq.TimePerEvent;WMStats.ResubmissionList(summary,"#acdc_submission")})})(jQuery);WMStats.namespace("CategorySummaryMap");WMStats.namespace("CategoryTableMap");WMStats.CategorySummaryMap=function(){var summaryMap={};function add(category,summaryFunc){summaryMap[category]=summaryFunc}function get(category){return summaryMap[category]}return{add:add,get:get}}();WMStats.CategoryTableMap=function(){var tableMap={};function add(category,view){tableMap[category]=view}function get(category,view){if(category===WMStats.Controls.requests){return tableMap[category][WMStats.Env.ViewSwitchSelection]}else{return tableMap[category]}}return{add:add,get:get}}();WMStats.CategorySummaryMap.add(WMStats.Controls.sites,WMStats.SiteSummary);WMStats.CategoryTableMap.add(WMStats.Controls.sites,WMStats.SiteSummaryTable);WMStats.CategoryTableMap.add(WMStats.Controls.requests,{progress:WMStats.ActiveRequestTable,numJobs:WMStats.ActiveRequestTableWithJob});(function($){var E=WMStats.CustomEvents;var COL_INDEX={};function TableEventHandler(containerID,populateRequestTable){this.containerID=containerID;if(populateRequestTable){this.populateRequestTable=populateRequestTable}}TableEventHandler.highlightRow=function(selector,currenElement){$(selector).removeClass("mouseclickRow");$(currenElement).addClass("mouseclickRow")};TableEventHandler.prototype={constructor:TableEventHandler,tableRowBind:function(bind,parentSelector,func){var currentObj=this;var selector=parentSelector+" table tbody tr";$(document).on(bind,selector,function(){TableEventHandler.highlightRow(selector,this);currentObj[func](this)})},tableColumnBind:function(bind,parentSelector,name,func){var currentObj=this;var selector=parentSelector+' table tbody tr td div[name="'+name+'"]';var rowSelector=parentSelector+" table tbody tr";$(document).on(bind,selector,function(){var currentRow=$(this).closest("tr")[0];TableEventHandler.highlightRow(rowSelector,currentRow);currentObj[func](currentRow);event.preventDefault()})},populateRequestSummary:function(currentElement){var nTds=$("td",currentElement);var categoryKey=$(nTds[2]).text();var category=WMStats.Controls.getCategoryButtonValue();var categoryData=getCategorizedData(category);var requestData=categoryData.getRequestData(categoryKey);WMStats.CategoryTitle(categoryKey,"#category_title");WMStats.Env.RequestSelection="partial_requests";$(WMStats.Globals.Event).triggerHandler(E.REQUEST_SUMMARY_READY,requestData);$("#all_requests li a").removeClass("nav-button-selected").addClass("button-unselected")},populateJobSummary:function(currentElement){var nTds=$("td",currentElement);var requestName=$(nTds[2]).text();WMStats.RequestTitle(requestName,"#request_title");WMStats.JobSummaryModel.setRequest(requestName);$(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START);WMStats.JobSummaryModel.retrieveData()},populateRequestDetail:function(currentElement){var nTds=$("td",currentElement);var workflowName=$(nTds[2]).text();$(WMStats.Globals.Event).triggerHandler(E.REQUEST_DETAIL_READY,workflowName)},populateCategoryDetail:function(currentElement){var nTds=$("td",currentElement);var categoryKey=$(nTds[2]).text();$(WMStats.Globals.Event).triggerHandler(E.CATEGORY_DETAIL_READY,categoryKey)},populateJobDetail:function(currentElement){var summary={};summary.workflow=$("#job_view div.summary_data").data("workflow");var currentRow=$(currentElement).closest("tr")[0];var currentRowData=WMStats.Env.JobSummaryTable.fnGetData(currentElement);summary.task=currentRowData.task;summary.status=currentRowData.status;summary.site=currentRowData.site;if(summary.site==="{}"){summary.site={}}summary.acdcURL=currentRowData.acdcURL;summary.exitCode=currentRowData.exitCode;WMStats.JobDetailModel.setOptions(summary);$(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START);WMStats.JobDetailModel.retrieveData()},createACDCResubmission:function(currentElement){var workflow=$("#job_view div.summary_data").data("workflow");var summary=WMStats.ViewModel.Resubmission;summary.OriginalRequestName=workflow;var requestData=WMStats.ActiveRequestModel.getData().getDataByWorkflow(summary.OriginalRequestName);summary.RequestString=WMStats.Utils.acdcRequestSting(summary.OriginalRequestName,requestData.requestor);var currentRow=$(currentElement).closest("tr")[0];var currentRowData=WMStats.Env.JobSummaryTable.fnGetData(currentElement);summary.InitialTaskPath=currentRowData.task;if(currentRowData.acdcURL){var acdcServiceUrl=WMStats.Utils.splitCouchServiceURL(currentRowData.acdcURL);summary.ACDCServer=acdcServiceUrl.couchUrl;summary.ACDCDatabase=acdcServiceUrl.couchdb}summary.Group=requestData.group;summary.PrepID=requestData.prep_id;summary.RequestPriority=requestData.priority;summary.DbsUrl=requestData.dbs_url||"http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet";summary.Memory=requestData.Memory||2394967;summary.SizePerEvent=requestData.SizePerEvent||5e3;summary.TimePerEvent=requestData.TimePerEvent||60;summary.RequestType="Resubmission";WMStats.ReqMgrRequestModel.retrieveDoc(workflow)}};var ActiveModelHandler=new TableEventHandler;ActiveModelHandler.tableColumnBind("click","#category_view div.summary_data","drill","populateRequestSummary");ActiveModelHandler.tableColumnBind("click","#request_view div.summary_data","drill","populateJobSummary");ActiveModelHandler.tableColumnBind("click","#job_view div.summary_data","drill","populateJobDetail");ActiveModelHandler.tableColumnBind("click","#job_view div.summary_data","acdc","createACDCResubmission");ActiveModelHandler.tableColumnBind("click","#category_view div.summary_data","detail","populateCategoryDetail");ActiveModelHandler.tableColumnBind("click","#request_view div.summary_data","detail","populateRequestDetail");$(document).on("mouseover","tr",function(event){$(this).addClass("mouseoverRow")});$(document).on("mouseout","tr",function(event){$(this).removeClass("mouseoverRow")})})(jQuery);WMStats.namespace("WorkloadSummaryController");(function($){$(document).on("click","#WorkloadSummarySearchButton",function(event){var selectedSearch=$('#search_option_board select[name="SearchOptions"] :selected').val();var searchStr=$('input[name="workloadSummarySearch"]').val();var view;var options={include_docs:true,reduce:false};if(selectedSearch==="request"){view="allDocs";options.key=searchStr}else if(selectedSearch==="outputdataset"){view="requestByOutputDataset";options.key=searchStr}else if(selectedSearch==="inputdataset"){view="requestByInputDataset";options.key=searchStr}else if(selectedSearch==="prep_id"){view="requestByPrepID";options.key=searchStr}else if(selectedSearch==="request_date"){view="requestByDate";var beginDate=$('input[name="dateRange1"]').val().split("/");var endDate=$('input[name="dateRange2"]').val().split("/");options.startkey=[Number(beginDate[0]),Number(beginDate[1]),Number(beginDate[2])];options.endkey=[Number(endDate[0]),Number(endDate[1]),Number(endDate[2]),{}]}WMStats.RequestSearchModel.retrieveData(view,options);event.stopPropagation()});var E=WMStats.CustomEvents;$(WMStats.Globals.Event).on(E.WORKLOAD_SUMMARY_READY,function(event,data){var data=WMStats.RequestSearchModel.getData();WMStats.WorkloadSummaryTable(data,"#search_result_board")})})(jQuery);WMStats.CategorySummaryMap.add(WMStats.Controls.campaign,WMStats.CampaignSummary);WMStats.CategoryTableMap.add(WMStats.Controls.campaign,WMStats.CampaignSummaryTable);WMStats.CategorySummaryMap.add(WMStats.Controls.cmssw,WMStats.CMSSWSummary);WMStats.CategoryTableMap.add(WMStats.Controls.cmssw,WMStats.CMSSWSummaryTable); \ No newline at end of file +WMStats.namespace("_StructBase");WMStats._StructBase=function(){this._data=null};WMStats._StructBase.prototype={getData:function(){return this._data},setData:function(couchData){this._data=this.convertCouchData(couchData)},getDataByKey:function(key,combineFunc){var data={};var dataList=this._data;for(var i in dataList){if(data[dataList[i][key]]===undefined){data[dataList[i][key]]=dataList[i]}else if(combineFuc===undefined){data[dataList[i][key]]=dataList[i]}else{data[dataList[i][key]]=combineFunc(data[dataList[i][key]],dataList[i])}}return data},convertCouchData:function(couchData){return couchData}};WMStats.namespace("GenericRequests");WMStats.namespace("GenericRequestsSummary");WMStats.namespace("RequestsByKey");WMStats.GenericRequestsSummary=function(summaryStruct){this._get=WMStats.Utils.get;this.summaryStruct={length:0};this.jobStatus={success:0,canceled:0,transition:0,queued:{first:0,retry:0},submitted:{first:0,retry:0},submitted:{pending:0,running:0},failure:{create:0,submit:0,exception:0},cooloff:{create:0,submit:0,job:0},paused:{create:0,submit:0,job:0}};if(summaryStruct){this.summaryStruct=WMStats.Utils.cloneObj(summaryStruct)}};WMStats.GenericRequestsSummary.prototype={getJobStatus:function(statusStr){return WMStats.Utils.get(this.jobStatus,statusStr,0)},getAvgProgressSummary:function(doc){var progressStat={};var datasets={};var numDataset=0;for(var task in doc.tasks){for(var site in doc.tasks[task].sites){for(var outputDS in doc.tasks[task].sites[site].dataset){if(datasets[outputDS]===undefined){numDataset+=1;datasets[outputDS]=true}WMStats.Utils.updateObj(progressStat,doc.tasks[task].sites[site].dataset[outputDS])}}}for(var prop in progressStat){progressStat[prop]=progressStat[prop]/numDataset}progressStat.numDataset=numDataset;return progressStat},getAvgEvents:function(){if(this.summaryStruct.progress===undefined||this.summaryStruct.progress.events===undefined){return this.summaryStruct.processedEvents}else{return this.summaryStruct.progress.events}},getAvgLumis:function(){if(this.summaryStruct.progress.totalLumis===undefined){return 0}else{return this.summaryStruct.progress.totalLumis}},getSummary:function(){return this.summaryStruct},summaryStructUpdateFuction:null,update:function(summary){WMStats.Utils.updateObj(this.summaryStruct,summary.summaryStruct,true,this.summaryStructUpdateFuction);WMStats.Utils.updateObj(this.jobStatus,summary.jobStatus)},updateFromRequestDoc:function(doc){var summary=this.createSummaryFromRequestDoc(doc);this.update(summary)},getWMBSTotalJobs:function(){return this.getJobStatus("success")+this.getJobStatus("canceled")+this.getJobStatus("transition")+this.getTotalFailure()+this.getTotalCooloff()+this.getTotalPaused()+this.getTotalQueued()+this.getTotalSubmitted()},getTotalFailure:function(){return this.getJobStatus("failure.create")+this.getJobStatus("failure.submit")+this.getJobStatus("failure.exception")},getTotalSubmitted:function(){return this.getJobStatus("submitted.first")+this.getJobStatus("submitted.retry")},getRunning:function(){return this.getJobStatus("submitted.running")},getPending:function(){return this.getJobStatus("submitted.pending")},getTotalCooloff:function(){return this.getJobStatus("cooloff.create")+this.getJobStatus("cooloff.submit")+this.getJobStatus("cooloff.job")},getTotalPaused:function(){return this.getJobStatus("paused.create")+this.getJobStatus("paused.submit")+this.getJobStatus("paused.job")},getTotalQueued:function(){return this.getJobStatus("queued.first")+this.getJobStatus("queued.retry")},createSummaryFromRequestDoc:function(doc){var summary=WMStats.RequestsSummary();summary.summaryStruct.length=1;summary.jobStatus=this._get(doc,"status",{});return summary}};WMStats.RequestStruct=function(requestName){this._workflow=requestName;this._summary=WMStats.RequestsSummary();this._addJobs=WMStats.Utils.updateObj};WMStats.RequestStruct.prototype={getProgressStat:function(){var progressStat={};for(var task in this.tasks){for(var site in this.tasks[task].sites){WMStats.Utils.updateObj(progressStat,this.tasks[task].sites[site].dataset)}}return progressStat},getName:function(){return this._workflow},getSummary:function(){return this._summary.createSummaryFromRequestDoc(this)},updateFromCouchDoc:function(doc){function _tasksUpdateFunction(baseObj,addObj,field){if(field==="JobType"){baseObj[field]=addObj[field]}else if(field==="updated"){baseObj[field]=Math.max(baseObj[field],addObj[field])}else{baseObj[field]+=addObj[field]}}for(var field in doc){if(this[field]&&(field=="sites"||field=="status")){this._addJobs(this[field],doc[field])}else if(this[field]&&field=="tasks"){this._addJobs(this[field],doc[field],true,_tasksUpdateFunction)}else if(this[field]&&field=="output_progress"){var outProgress=this.output_progress;for(var index in outProgress){for(var prop in doc[field][index]){outProgress[index][prop]+=doc[field][index][prop]}}}else if(field=="agent_url"){if(this[field]===undefined)this[field]=[];WMStats.Utils.addToSet(this[field],doc[field])}else{this[field]=doc[field]}}}};WMStats.GenericRequests=function(noFilterFlag){this._dataByWorkflow={};this._dataByWorkflowAgent={};this._get=WMStats.Utils.get;this._filter={};this._filteredRequests=null};WMStats.GenericRequests.prototype={_mapProperty:function(workflowData,property){if(property=="request_status"){return workflowData[property][workflowData[property].length-1].status}return workflowData[property]},_getRequestObj:function(request){if(typeof request=="string"){return this.getData(request)}else{return request}},_getStatusObj:function(request,level){var requestObj=this._getRequestObj(request);if(level=="task"){return requestObj.tasks.status}else if(level=="site"){return requestObj.sites}else{return requestObj.status}},_requestDateSort:function(a,b){for(var i in a.request_date){if(b.request_date[i]!=a.request_date[i]){return Number(b.request_date[i])-Number(a.request_date[i])}}return 0},_andFilter:function(base,filter){var includeFlag=true;for(var property in filter){if(!filter[property]){continue}else if(this._mapProperty(base,property)!==undefined&&this._contains(this._mapProperty(base,property),filter[property])){continue}else{includeFlag=false;break}}return includeFlag},_contains:function(a,b){if(typeof a==="string")return a.toLowerCase().indexOf(b.toLowerCase())!==-1;else if(typeof a=="number")return Number(b)==a;else if(a instanceof Array){for(var i in a){if(this._contains(a[i],b))return true}return false}else{alert("value need to be either number or string")}},getProgressStat:function(request){var requestObj=this._getRequestObj(request);return requestObj.getProgressStat()},getFilter:function(){return this._filter},setFilter:function(filter){this._filter=filter},updateRequest:function(doc){var workflow=doc.workflow;var agentURL=doc.agent_url;if(workflow&&!this._dataByWorkflow[workflow]){this._dataByWorkflow[workflow]=new WMStats.RequestStruct(workflow)}if(agentURL&&!this._dataByWorkflowAgent[workflow]){this._dataByWorkflowAgent[workflow]={}}if(agentURL&&!this._dataByWorkflowAgent[workflow][agentURL]){this._dataByWorkflowAgent[workflow][agentURL]=new WMStats.RequestStruct(workflow)}this.getData(workflow).updateFromCouchDoc(doc);if(agentURL){this.getData(workflow,agentURL).updateFromCouchDoc(doc)}},updateBulkRequests:function(docList){for(var row in docList){if(docList[row].doc){this.updateRequest(docList[row].doc)}}},filterRequests:function(filter){var requestData=this.getData();var filteredData={};var requestWithAgentData=this.getDataWithAgent();var filteredDataWithAgent={};if(filter===undefined){filter=this._filter}for(var workflowName in requestData){if(this._andFilter(requestData[workflowName],filter)){filteredData[workflowName]=requestData[workflowName];filteredDataWithAgent[workflowName]=requestWithAgentData[workflowName]}}this._filteredRequests=WMStats.Requests();this._filteredRequests.setDataByWorkflow(filteredData,filteredDataWithAgent);return this._filteredRequests},getKeyValue:function(request,keyString,defaultVal){"keyString is opject property separte by .";return this._get(this._dataByWorkflow[request],keyString,defaultVal)},getData:function(workflow,agentURL){if(workflow&&(agentURL==="all"||agentURL==="NA")){return this._dataByWorkflowAgent[workflow]}else if(workflow&&agentURL){return this._dataByWorkflowAgent[workflow][agentURL]}else if(workflow){return this._dataByWorkflow[workflow]}else{return this._dataByWorkflow}},getDataWithAgent:function(workflow,agentURL){if(workflow&&(agentURL==="all"||agentURL==="NA")){return this._dataByWorkflowAgent[workflow]}else if(workflow&&agentURL){return this._dataByWorkflowAgent[workflow][agentURL]}else{return this._dataByWorkflowAgent}},getFilteredRequests:function(){return this._filteredRequests},setDataByWorkflow:function(data,agentData){"keyString is opject property separte by .";this._dataByWorkflow=data;this._dataByWorkflowAgent=agentData},getList:function(sortFunc){var list=[];for(var request in this.getData()){list.push(this.getData(request))}if(sortFunc){return list.sort(sortFunc)}else{return list.sort(this._requestDateSort)}},getSummary:function(workflow,agentURL){var requests=this.getData(workflow,agentURL);if(workflow){return requests.getSummary()}else{var summary=WMStats.RequestsSummary();for(var requestName in requests){summary.update(this.getData(requestName).getSummary())}return summary}},getAlertRequests:function(){var alertRequests=[];for(var workflow in this.getData()){var reqSummary=this.getSummary(workflow);var coolOff=reqSummary.getTotalCooloff();var paused=reqSummary.getTotalPaused();if(coolOff>0||paused>0){alertRequests.push(this.getData(workflow))}}return alertRequests},getRequestStatusAndTime:function(workflowName){var workflowData=this._dataByWorkflow[workflowName];return workflowData["request_status"][workflowData["request_status"].length-1]}};WMStats.RequestsByKey=function(category,summaryFunc){var _data={};var _category=category;var _get=WMStats.Utils.get;function categorize(requestData){function _getRequestData(workflow,agentURL){if(_category==="agent"&&agentURL!=="all"&&agentURL!=="NA"){return requestData.getData(workflow,agentURL)}else{return requestData.getData(workflow)}}function _getCategoryKey(workflow){if(_category==="agent"){var agentCategory=requestData.getData(workflow,"all");if(agentCategory===undefined){return"NA"}else{return agentCategory}}else{return requestData.getKeyValue(workflow,_category,"NA")}}function _updateData(key,workflow,summaryBase){if(_data[key]===undefined){_data[key]={};_data[key].requests={};_data[key].summary=summaryFunc();_data[key].key=key}var requestInfo=_getRequestData(workflow,key);_data[key].requests[workflow]=requestInfo;_data[key].summary.updateFromRequestDoc(summaryBase)}var dataByWorkflow=requestData.getData();for(var workflow in dataByWorkflow){var key=_getCategoryKey(workflow);if(typeof key=="object"){if(key.length){for(var index in key){_updateData(key[index],workflow,requestData.getData(workflow))}}else{for(var prop in key){_updateData(prop,workflow,key[prop])}}}else{if(key=="NA"&&_category=="sites"||_category=="tasks"||_category=="agent"){_updateData(key,workflow,{})}else{_updateData(key,workflow,requestData.getData(workflow))}}}}function getData(key){if(key===undefined){return _data}else{return _data[key]}}function getRequestData(key){var requestData=WMStats.Requests();if(_data[key]!==undefined){requestData.setDataByWorkflow(_data[key].requests)}return requestData}function getList(sortFunc){var list=[];for(var key in _data){list.push(_data[key])}if(sortFunc){return list.sort(sortFunc)}else{return list}}return{categorize:categorize,getData:getData,getRequestData:getRequestData,category:_category,getList:getList}};WMStats.namespace("Agents");WMStats.Agents=function(couchData){var agentData=new WMStats._StructBase;agentData.agentNumber={error:0,stable:0};agentData.convertCouchData=function(data){var dataRows=data.rows;var rows=[];for(var i in dataRows){var tableRow=dataRows[i].value;rows.push(tableRow)}return rows};if(couchData)agentData.setData(couchData);agentData.getAlertList=function(){var currentTime=Math.round((new Date).getTime()/1e3);var dataList=this.getData();var agentPollingCycle=600;agentData.agentNumber={error:0,stable:0};function getStatus(agentInfo){var lastUpdatedDuration=currentTime-agentInfo.timestamp;if(lastUpdatedDuration>agentPollingCycle*2){agentData.agentNumber.error+=1;return{status:"agent_down",message:WMStats.Utils.foramtDuration(lastUpdatedDuration)}}else if(agentInfo.down_components.length>0){agentData.agentNumber.error+=1;return{status:"component_down",message:agentInfo.down_components}}else{agentData.agentNumber.stable+=1;return{status:"ok",message:WMStats.Utils.foramtDuration(lastUpdatedDuration)}}}for(var index in dataList){dataList[index]["alert"]=getStatus(dataList[index])}return dataList};agentData.getAlertList();return agentData};WMStats.namespace("Sites");WMStats.Sites=function(couchData){var _data;var baseColumns=["timestamp","site","agent_url"];var siteData=new WMStats._StructBase;siteData.convertCouchData=function(data){var dataRows=data.rows;var rows=[];for(var i in dataRows){var tableRow=dataRows[i].value;for(var j=0;j0){if(success===0){alertRequests["configError"].push(this.getData(workflow))}else if(totalFailed/(totalFailed+success)>.85){alertRequests["siteError"].push(this.getData(workflow))}}}return alertRequests};tier1Requests.requestNotPulledAlert=function(){var alertRequests=[];for(var workflow in this.getData()){var reqStatusInfo=this.getRequestStatusAndTime(workflow);var currentTime=Math.round((new Date).getTime()/1e3);var timeThreshold=600;if(reqStatusInfo.status=="assigned"){if(currentTime-reqStatusInfo.update_time>timeThreshold){alertRequests.push({request:this.getData(workflow),message:"not pulled by GQ"})}}if(reqStatusInfo.status=="acquired"){if(currentTime-reqStatusInfo.update_time>timeThreshold){alertRequests.push({request:this.getData(workflow),message:"not pulled by LQ"})}}}return alertRequests};return tier1Requests};WMStats.namespace("CampaignSummary");WMStats.CampaignSummary=function(){var campaignSummary={totalEvents:0,totalLumis:0,processedEvents:0,numRequests:0};var campaignSummary=new WMStats.GenericRequestsSummary(campaignSummary);campaignSummary.createSummaryFromRequestDoc=function(doc){var summary=WMStats.CampaignSummary();summary.summaryStruct.totalEvents=Number(this._get(doc,"input_events",0));summary.summaryStruct.totalLumis=Number(this._get(doc,"input_lumis",0));summary.summaryStruct.processedEvents=this._get(doc,"output_progress.0.events",0);summary.summaryStruct.progress=this.getAvgProgressSummary(doc);summary.summaryStruct.numRequests=1;summary.jobStatus=this._get(doc,"status",{});if(typeof summary.jobStatus.cooloff==="number"){summary.jobStatus.cooloff={create:0,submit:0,job:summary.jobStatus.cooloff}}return summary};return campaignSummary};WMStats.namespace("CMSSWSummary");WMStats.CMSSWSummary=function(){var cmsswSummary={totalEvents:0,totalLumis:0,processedEvents:0,numRequests:0};var cmsswSummary=new WMStats.GenericRequestsSummary(cmsswSummary);cmsswSummary.createSummaryFromRequestDoc=function(doc){var summary=WMStats.CMSSWSummary();summary.summaryStruct.totalEvents=Number(this._get(doc,"input_events",0));summary.summaryStruct.totalLumis=Number(this._get(doc,"input_lumis",0));summary.summaryStruct.processedEvents=this._get(doc,"output_progress.0.events",0);summary.summaryStruct.progress=this.getAvgProgressSummary(doc);summary.summaryStruct.numRequests=1;summary.jobStatus=this._get(doc,"status",{});if(typeof summary.jobStatus.cooloff==="number"){summary.jobStatus.cooloff={create:0,submit:0,job:summary.jobStatus.cooloff}}return summary};return cmsswSummary};WMStats.namespace("AgentRequestSummary");WMStats.AgentRequestSummary=function(){var agenetRequestSummary={totalEvents:0,totalLumis:0,processedEvents:0,numRequests:0};var agenetRequestSummary=new WMStats.GenericRequestsSummary(agenetRequestSummary);agenetRequestSummary.createSummaryFromRequestDoc=function(doc){var summary=WMStats.AgentRequestSummary();summary.summaryStruct.totalEvents=Number(this._get(doc,"input_events",0));summary.summaryStruct.totalLumis=Number(this._get(doc,"input_lumis",0));summary.summaryStruct.processedEvents=this._get(doc,"output_progress.0.events",0);summary.summaryStruct.progress=this.getAvgProgressSummary(doc);summary.summaryStruct.numRequests=1;summary.jobStatus=this._get(doc,"status",{});if(typeof summary.jobStatus.cooloff==="number"){summary.jobStatus.cooloff={create:0,submit:0,job:summary.jobStatus.cooloff}}return summary};return agenetRequestSummary};WMStats.namespace("ReqMgrRequest");WMStats.ReqMgrRequest=function(couchData){var requestData=new WMStats._StructBase;if(couchData)requestData.setData(couchData);return requestData};WMStats.namespace("_ViewModelBase");WMStats._ViewModelBase=function(observableObj){this._eventObj={};this._eventObjName="_eventObj";this.data=this.observable("data",null);if(observableObj!==undefined){this._createObservableProperty(observableObj)}this._selector=null;this._data=null};WMStats._ViewModelBase.prototype={observable:function(property,defaultValue){var _previousValue=defaultValue;var _property=property;function publish(value,noTrigger){if(value!==undefined){_previousValue=value;if(!noTrigger){$(this._eventObj).triggerHandler(this._eventObjName,this);$(this._eventObj).triggerHandler(_property,value)}return this}else{return _previousValue}}return publish},subscribe:function(){var callback;var eventName;if(arguments.length==2){callback=arguments[1];eventName=arguments[0]}else if(arguments.length==1){callback=arguments[0];eventName=this._eventObjName}$(this._eventObj).on(eventName,callback)},id:function(selector){if(selector){this._selector=selector;WMStats.ViewModel.Registry[selector]=this;return this}else{return this._selector}},_createObservableProperty:function(observableObj){for(var prop in observableObj){this[prop]=this.observable(prop,observableObj[prop])}}};WMStats.namespace("ViewModel");WMStats.ViewModel=function(){var properties={page:null};var vm=new WMStats._ViewModelBase(properties);vm.propagateUpdate=function(){if(vm.page().propagateUpdate){vm.page().propagateUpdate()}};return vm}();(function(vm){vm.Registry={};vm.ActiveRequestPage=function(){var properties={view:null,filter:{},filteredStats:null,refreshCount:0};var requestPage=new WMStats._ViewModelBase(properties);requestPage.propagateUpdate=function(){var requestData=WMStats.ActiveRequestModel.getData();if(requestData===null){return false}else{var filter=vm.ActiveRequestPage.filter();vm.ActiveRequestPage.data(requestData.filterRequests(filter));if(requestPage.view().propagateUpdate){requestPage.view().propagateUpdate()}return true}};return requestPage}();vm.RequestAlertPage=function(){var alertPage=new WMStats._ViewModelBase;alertPage.propagateUpdate=function(){var requestData=WMStats.ActiveRequestModel.getData();if(requestData===null){return false}else{vm.RequestAlertPage.data(requestData);return true}};return alertPage}();vm.AgentPage=function(){var agentPage=new WMStats._ViewModelBase;agentPage.propagateUpdate=function(){var agentData=WMStats.AgentModel.getData();if(agentData===null){return false}else{vm.AgentPage.data(agentData);return true}};return agentPage}();vm.SearchPage=function(){var properties={keys:null};searchPage=new WMStats._ViewModelBase(properties);searchPage.retrieveData=function(keys){var selectedSearch=keys.searchCategory;var searchStr=keys.searchValue;var view;var options={include_docs:true,reduce:false};if(selectedSearch==="request"){view="allDocs";options.key=searchStr}else if(selectedSearch==="outputdataset"){view="requestByOutputDataset";options.key=searchStr}else if(selectedSearch==="inputdataset"){view="requestByInputDataset";options.key=searchStr}else if(selectedSearch==="prep_id"){view="requestByPrepID";options.key=searchStr}else if(selectedSearch==="request_date"){view="requestByDate";var beginDate=$('input[name="dateRange1"]').val().split("/");var endDate=$('input[name="dateRange2"]').val().split("/");options.startkey=[Number(beginDate[0]),Number(beginDate[1]),Number(beginDate[2])];options.endkey=[Number(endDate[0]),Number(endDate[1]),Number(endDate[2]),{}]}WMStats.RequestSearchModel.retrieveData(view,options)};return searchPage}();vm.CategoryView=function(){var properties={category:null,detailView:null};var categoryView=new WMStats._ViewModelBase(properties);categoryView.convertToCategoryData=function(requestData){if(requestData===undefined){requestData=vm.ActiveRequestPage.data()}var category=this.category().name();var summaryStruct=WMStats.CategorySummaryMap.get(this.category().name());var categoryData=WMStats.RequestsByKey(category,summaryStruct);categoryData.categorize(requestData);return categoryData};categoryView.propagateUpdate=function(){if(vm.ActiveRequestPage.data()===null){return false}categoryView.data(categoryView.convertToCategoryData());return true};return categoryView}();vm.RequestView=function(){var properties={categoryKey:"all",format:null,detailView:null};var requestView=new WMStats._ViewModelBase(properties);requestView.propagateUpdate=function(){if(vm.ActiveRequestPage.data()===null){return false}if(requestView.categoryKey()=="all"){requestView.data(vm.ActiveRequestPage.data())}else{var categoryData=vm.CategoryView.convertToCategoryData();var data=categoryData.getRequestData(requestView.categoryKey());requestView.data(data)}return true};requestView.categoryName="requests";return requestView}();function createJobSummaryView(){var properties={requestName:null,detail:null};var jobView=new WMStats._ViewModelBase(properties);jobView.retrieveData=function(requestName){WMStats.JobSummaryModel.setRequest(requestName);WMStats.JobSummaryModel.retrieveData()};jobView.propagateUpdate=function(){if(jobView.requestName()){jobView.retrieveData(jobView.requestName());return false}else{return false}};jobView.updateDataAndChild=function(data){if(data){jobView.data(data)}if(jobView.detail().propagateUpdate){jobView.detail().propagateUpdate();return true}return false};return jobView}vm.JobView=createJobSummaryView();vm.AlertJobView=createJobSummaryView();vm.CampaignCategory=function(){return new WMStats._ViewModelBase({name:"campaign"})}();vm.SiteCategory=function(){return new WMStats._ViewModelBase({name:"sites"})}();vm.CMSSWCategory=function(){return new WMStats._ViewModelBase({name:"cmssw"})}();vm.AgentCategory=function(){return new WMStats._ViewModelBase({name:"agent"})}();vm.RequestProgress=function(){return new WMStats._ViewModelBase({name:"progress"})}();vm.RequestJobs=function(){return new WMStats._ViewModelBase({name:"numJobs"})}();vm.CategoryDetail=function(){var properties={categoryKey:null};var categoryDetail=new WMStats._ViewModelBase(properties);categoryDetail.propagateUpdate=function(){if(categoryDetail.categoryKey()){var allData=vm.CategoryView.data();categoryDetail.data(allData.getData(categoryDetail.categoryKey()))}};return categoryDetail}();vm.RequestDetail=function(){var properties={requestName:null};var requestDetail=new WMStats._ViewModelBase(properties);requestDetail.open=false;return requestDetail}();function createJobDetailView(){var properties={keys:null,indexID:null};var jobDetail=new WMStats._ViewModelBase(properties);jobDetail.retrieveData=function(keys){WMStats.JobDetailModel.setOptions(keys);WMStats.JobDetailModel.retrieveData()};jobDetail.propagateUpdate=function(){if(jobDetail.keys()!==null){jobDetail.retrieveData(jobDetail.keys());return true}else{return false}};return jobDetail}vm.JobDetail=createJobDetailView();vm.AlertJobDetail=createJobDetailView();vm.Resubmission=function(){var properties={keys:null};var resubmission=new WMStats._ViewModelBase(properties);resubmission.retrieveData=function(keys){WMStats.ReqMgrRequestModel.retrieveDoc(keys.requestName)};resubmission.formatResubmissionData=function(requestInfo){var summary={};summary.OriginalRequestName=resubmission.keys().requestName;summary.InitialTaskPath=resubmission.keys().task;if(resubmission.keys().acdcURL){var acdcServiceUrl=WMStats.Utils.splitCouchServiceURL(resubmission.keys().acdcURL);summary.ACDCServer=acdcServiceUrl.couchUrl;summary.ACDCDatabase=acdcServiceUrl.couchdb}summary.Memory=requestInfo.Memory;summary.SizePerEvent=requestInfo.SizePerEvent;summary.TimePerEvent=requestInfo.TimePerEvent;requestInfo=WMStats.ActiveRequestModel.getData().getData(summary.OriginalRequestName);summary.DbsUrl=requestInfo.DbsUrl||"http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet";summary.Group=requestInfo.Group;summary.RequestPriority=requestInfo.RequestPriority;summary.RequestString=WMStats.Utils.acdcRequestSting(summary.OriginalRequestName,requestInfo.Requestor);summary.PrepID=requestInfo.PrepID;summary.RequestType="Resubmission";return summary};resubmission.propagateUpdate=function(){if(resubmission.keys()!==null){resubmission.retrieveData(resubmission.keys());return true}else{return false}};return resubmission}();vm.initialize=function(){vm.page(vm.ActiveRequestPage,true);vm.ActiveRequestPage.view(vm.CategoryView,true);vm.CategoryView.category(vm.CampaignCategory,true);vm.RequestView.format(vm.RequestProgress,true); +vm.JobView.detail(vm.JobDetail,true)}()})(WMStats.ViewModel);(function(vm){vm.ActiveRequestPage.subscribe("filter",function(){vm.ActiveRequestPage.propagateUpdate()});vm.SearchPage.subscribe("keys",function(){vm.SearchPage.retrieveData(vm.SearchPage.keys())});vm.CategoryView.subscribe("category",function(){vm.CategoryView.propagateUpdate()});vm.RequestView.subscribe("categoryKey",function(){vm.ActiveRequestPage.view(vm.RequestView)});vm.JobView.subscribe("requestName",function(){vm.ActiveRequestPage.view(vm.JobView)});vm.AlertJobView.subscribe("requestName",function(){vm.AlertJobView.retrieveData(vm.AlertJobView.requestName())});vm.CategoryDetail.subscribe("categoryKey",function(){vm.CategoryDetail.propagateUpdate()});vm.JobDetail.subscribe("keys",function(){vm.JobDetail.retrieveData(vm.JobDetail.keys())});vm.AlertJobDetail.subscribe("keys",function(){vm.AlertJobDetail.retrieveData(vm.AlertJobDetail.keys())});vm.Resubmission.subscribe("keys",function(){vm.Resubmission.retrieveData(vm.Resubmission.keys())})})(WMStats.ViewModel);WMStats.namespace("CategorySummaryMap");WMStats.namespace("CategoryTableMap");WMStats.CategorySummaryMap=function(){var summaryMap={};function add(category,summaryFunc){summaryMap[category]=summaryFunc}function get(category){return summaryMap[category]}return{add:add,get:get}}();WMStats.CategoryTableMap=function(){var tableMap={};var vm=WMStats.ViewModel;function add(category,view){tableMap[category]=view}function get(category,view){if(category===vm.RequestView.categoryName){return tableMap[category][vm.RequestView.format().name()]}else{return tableMap[category]}}return{add:add,get:get}}();(function(vm){vm.CategoryView.subscribe("data",function(){var view=WMStats.CategoryTableMap.get(vm.CategoryView.category().name());view(vm.CategoryView.data(),vm.CategoryView.category().id())});vm.RequestView.subscribe("data",function(){var view=WMStats.CategoryTableMap.get(vm.RequestView.categoryName);view(vm.RequestView.data(),vm.RequestView.format().id())})})(WMStats.ViewModel);WMStats.namespace("View");WMStats.View.IndexHTML=function(){function applyTemplate(){var viewPane=$("#data_board div.viewPane");$("div.viewTemplate").children().clone().appendTo(viewPane)}function retrieveData(){WMStats.ActiveRequestModel.retrieveData();WMStats.AgentModel.retrieveData()}$(document).ready(function(){$("#loading_page").addClass("front").show();WMStats.CommonControls.setLinkTabs("#link_tabs");WMStats.Controls.setExternalLink("#external_link");WMStats.CommonControls.setUTCClock("#clock");WMStats.CommonControls.setWorkloadSummarySearch("#search_option_board");WMStats.Controls.setFilter("#filter_board");WMStats.Controls.setAllRequestButton("#status_board");WMStats.Controls.setTabs("#tab_board");WMStats.Controls.setCategoryButton("#category_bar");WMStats.Controls.setViewSwitchButton("#view_switch_bar");var vm=WMStats.ViewModel;vm.ActiveRequestPage.id("#activeRequestPage");vm.AgentPage.id("#agentInfoPage");vm.RequestAlertPage.id("#requestAlertPage");vm.SearchPage.id("#workloadSummaryPage");vm.CategoryView.id("#category_view");vm.RequestView.id("#request_view");vm.JobView.id("#job_view");vm.CampaignCategory.id("#category_view div.summary_data");vm.SiteCategory.id("#category_view div.summary_data");vm.CMSSWCategory.id("#category_view div.summary_data");vm.AgentCategory.id("#category_view div.summary_data");vm.RequestProgress.id("#request_view div.summary_data");vm.RequestJobs.id("#request_view div.summary_data");vm.CategoryDetail.id("#category_view div.detail_data");vm.RequestDetail.id("#request_view div.detail_data");vm.JobDetail.id("#job_view div.detail_data");vm.Resubmission.id("#acdc_submission");vm.AlertJobView.id("#alert_job_summary");vm.AlertJobDetail.id("#alert_job_detail");var wsControl=WMStats.GenericController;function switchPage(event,data){wsControl.switchDiv(data.id(),["#activeRequestPage","#requestAlertPage","#agentInfoPage","#workloadSummaryPage"]);vm.propagateUpdate()}function switchView(event,data){wsControl.switchDiv(data.id(),["#category_view","#request_view","#job_view"]);vm.ActiveRequestPage.view().propagateUpdate()}vm.subscribe("page",switchPage);vm.ActiveRequestPage.subscribe("view",switchView);vm.RequestView.subscribe("categoryKey",function(event,categoryKey){WMStats.CategoryTitle(categoryKey,"#category_title")});vm.JobView.subscribe("requestName",function(event,requestName){WMStats.RequestTitle(requestName,"#request_title")});var E=WMStats.CustomEvents;$(WMStats.Globals.Event).on(E.AGENTS_LOADED,function(event,agentData){if(agentData.agentNumber.error>0){$('#linkTabs a[href="#agentInfoPage"] strong').text("("+agentData.agentNumber.error+")")}});$(WMStats.Globals.Event).on(E.REQUESTS_LOADED,function(event){var alertData=WMStats.ActiveRequestModel.getData().getRequestAlerts();var numAlert=0;for(var error in alertData){numAlert+=alertData[error].length}if(numAlert>0){$('#linkTabs a[href="#requestAlertPage"] strong').text("("+numAlert+")")}});vm.page(vm.ActiveRequestPage);vm.ActiveRequestPage.view(vm.CategoryView);retrieveData();setInterval(retrieveData,3e5)})};WMStats.namespace("CommonControls");WMStats.CommonControls=function($){var vm=WMStats.ViewModel;var vmRegistry=WMStats.ViewModel.Registry;function setUTCClock(selector){setInterval(function(){$(selector).text(WMStats.Utils.utcClock())},100)}function setLinkTabs(selector){var linkTabs='';$(selector).append(linkTabs);function changeTab(event,data){$("#linkTabs li").removeClass("title-tab-selected").addClass("title-tab-hide");$('#linkTabs a[href="'+data.id()+'"]').parent().removeClass("title-tab-hide").addClass("title-tab-selected")}vm.subscribe("page",changeTab);$(document).on("click","#linkTabs li a",function(event){vm.page(vmRegistry[this.hash]);event.preventDefault()})}function setWorkloadSummarySearch(selector){var searchOption='
Search WorkloadSummary
';$(selector).append(searchOption);$(document).on("change",'select[name="SearchOptions"]',function(){var filterType=$(":selected",this).attr("data-search-type");var searchBox=$("#searchPane .SearchBox");$(searchBox).empty();$("div.template."+filterType).children().clone().appendTo("#searchPane .SearchBox");$('#searchPane .SearchBox input[name="dateRange1"]').datepicker({altField:'input[name="dateRange1"]',altFormat:"yy/mm/dd",changeYear:true,yearRange:"2012:c"});$('#searchPane .SearchBox input[name="dateRange2"]').datepicker({altField:'input[name="dateRange2"]',altFormat:"yy/mm/dd",changeYear:true,yearRange:"2012:c"})});$(document).on("click","#WorkloadSummarySearchButton",function(event){var keys={};keys.searchCategory=$('#search_option_board select[name="SearchOptions"] :selected').val();keys.searchValue=$('input[name="workloadSummarySearch"]').val();vm.SearchPage.keys(keys);event.stopPropagation()})}return{setUTCClock:setUTCClock,setLinkTabs:setLinkTabs,setWorkloadSummarySearch:setWorkloadSummarySearch}}(jQuery);WMStats.namespace("Table");WMStats.Table=function(config,tableSetting){var tableSetting=tableSetting||'
';var tableConfig={bStateSave:true,bProcessing:true,sDom:'<"top"pl>rt<"bottom"ip>',aaSorting:[],bAutoWidth:true,bJQueryUI:true};function updateConfig(config){for(var prop in config){tableConfig[prop]=config[prop]}}function _footer(){var footer="";for(var i in tableConfig.aoColumns){if(tableConfig.aoColumns[i].bVisible!=false){footer+=""+tableConfig.aoColumns[i]["sTitle"]+""}}footer+="";return footer}function create(selector,filterConfig){$(selector).empty();$(selector).html(tableSetting);var oTable=$(selector+" table").dataTable(tableConfig);if(oTable.length>0){oTable.fnAdjustColumnSizing()}jQuery(WMStats.Globals.Event).triggerHandler(WMStats.CustomEvents.LOADING_DIV_END);if(filterConfig){return oTable.columnFilter(filterConfig)}else{return oTable}}if(config){updateConfig(config)}return{config:tableConfig,updateConfig:updateConfig,create:create}};WMStats.namespace("JobSummaryTable");WMStats.JobSummaryTable=function(data,containerDiv){var tableConfig={sDom:'<"top"plf>rt<"bottom"ip>',iDisplayLength:25,aoColumns:[{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:function(source,type,val){if(type=="display"){var taskList=source.task.split("/");return taskList[taskList.length-1]}return source.task},sTitle:"task",sWidth:"150px"},{mDataProp:"status",sTitle:"status"},{mDataProp:"site",sTitle:"site"},{mDataProp:"exitCode",sTitle:"exit code"},{mDataProp:"count",sTitle:"jobs"},{mDataProp:"errorMsg",sTitle:"error mesage",sDefaultContent:""},{sTitle:"acdc",sDefaultContent:"",sWidth:"15px",mDataProp:function(source,type,val){if(type=="display"){var taskList=source.task.split("/");var endTask=taskList[taskList.length-1];if(source.status!=="success"&&!endTask.match(/LogCollect$/)&&!endTask.match(/Cleanup$/)){return WMStats.Utils.formatDetailButton("acdc")}}return""}}],aaSorting:[[1,"asc"]]};tableConfig.aaData=data.getData().status;var filterConfig={};$(containerDiv).data("workflow",data.getData().workflow);WMStats.JobSummaryTable.data=WMStats.Table(tableConfig).create(containerDiv,filterConfig);return WMStats.JobSummaryTable.data};(function(){var vm=WMStats.ViewModel;vm.JobView.subscribe("data",function(){var divSelector=vm.JobView.id()+" div.summary_data";WMStats.JobSummaryTable(vm.JobView.data(),divSelector)})})();WMStats.namespace("SiteSummaryTable");WMStats.SiteSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:50,sDom:'<"top"plf>rt<"bottom"ip>',sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"key",sTitle:"site"},{mDataProp:function(source,type,val){return source.summary.summaryStruct.numRequests},sTitle:"requests",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getJobStatus("submitted.pending")},sTitle:"pending",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getJobStatus("submitted.running")},sTitle:"running",sDefaultContent:0},{mDataProp:function(source,type,val){return source.summary.getTotalCooloff()},sTitle:"cool off",sDefaultContent:0},{sDefaultContent:0,sTitle:"failure rate",mDataProp:function(source,type,val){var failJobs=source.summary.getTotalFailure();var successJobs=source.summary.getJobStatus("success");var totalCompleteJobs=successJobs+failJobs||1;var result=failJobs/totalCompleteJobs*100;return result.toFixed(1)+"%"}}]};tableConfig.aaData=data.getList();var filterConfig={};return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("WorkloadSummaryTable");WMStats.WorkloadSummaryTable=function(data,containerDiv){var formatReqDetailUrl=WMStats.Utils.formatReqDetailUrl;var formatWorkloadSummarylUrl=WMStats.Utils.formatWorkloadSummarylUrl;var tableConfig={iDisplayLength:25,sScrollX:"",sDom:"lfrtip",bAutoWidth:false,aoColumns:[{mDataProp:"workflow",sTitle:"workflow",fnRender:function(o,val){return formatReqDetailUrl(o.aData._id)},bUseRendered:false,sWidth:"150px"},{mDataProp:function(source,type,val){return source.request_status[source.request_status.length-1].status},sTitle:"status",fnRender:function(o,val){return formatWorkloadSummarylUrl(o.aData._id,o.aData.request_status[o.aData.request_status.length-1].status)},bUseRendered:false},{mDataProp:"request_type",sTitle:"type",sDefaultContent:""},{mDataProp:"priority",sTitle:"priority",sDefaultContent:0},{mDataProp:"campaign",sTitle:"campaign",sDefaultContent:""}]};var filterConfig={};tableConfig.aaData=data.getData();return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};(function(){var vm=WMStats.ViewModel;vm.SearchPage.subscribe("data",function(){WMStats.WorkloadSummaryTable(vm.SearchPage.data(),"#search_result_board")})})();(function($){var E=WMStats.CustomEvents;var vm=WMStats.ViewModel;function TableEventHandler(containerID,populateRequestTable){this.containerID=containerID;if(populateRequestTable){this.populateRequestTable=populateRequestTable}}TableEventHandler.highlightRow=function(selector,currenElement){$(selector).removeClass("mouseclickRow");$(currenElement).addClass("mouseclickRow")};TableEventHandler.prototype={constructor:TableEventHandler,tableRowBind:function(bind,parentSelector,func){var currentObj=this;var selector=parentSelector+" table tbody tr";$(document).on(bind,selector,function(){TableEventHandler.highlightRow(selector,this);currentObj[func](this)})},tableColumnBind:function(bind,parentSelector,name,func){var currentObj=this;var selector=parentSelector+' table tbody tr td div[name="'+name+'"]';var rowSelector=parentSelector+" table tbody tr";$(document).on(bind,selector,function(){var currentRow=$(this).closest("tr")[0];TableEventHandler.highlightRow(rowSelector,currentRow);currentObj[func](currentRow);event.preventDefault()})},populateRequestSummary:function(currentElement){var nTds=$("td",currentElement);vm.RequestView.categoryKey($(nTds[2]).text())},populateJobSummary:function(currentElement){vm.JobDetail.keys(null,true);$(vm.JobDetail.id()).empty();$(vm.Resubmission.id()).empty();var nTds=$("td",currentElement);vm.JobView.requestName($(nTds[2]).text());$(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START)},populateRequestDetail:function(currentElement){var nTds=$("td",currentElement);vm.RequestDetail.requestName($(nTds[2]).text())},populateCategoryDetail:function(currentElement){var nTds=$("td",currentElement);vm.CategoryDetail.categoryKey($(nTds[2]).text())},populateJobDetail:function(currentElement){var summary={};summary.workflow=$("#job_view div.summary_data").data("workflow");var currentRow=$(currentElement).closest("tr")[0];var currentRowData=WMStats.JobSummaryTable.data.fnGetData(currentElement);summary.task=currentRowData.task;summary.status=currentRowData.status;summary.site=currentRowData.site;if(summary.site==="{}"){summary.site={}}summary.acdcURL=currentRowData.acdcURL;summary.exitCode=currentRowData.exitCode;vm.JobDetail.keys(summary);$(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START)},createACDCResubmission:function(currentElement){var workflow=$("#job_view div.summary_data").data("workflow");var summary={};summary.requestName=workflow;var currentRowData=WMStats.JobSummaryTable.data.fnGetData(currentElement);summary.task=currentRowData.task;summary.acdcURL=currentRowData.acdcURL;vm.Resubmission.keys(summary)}};var ActiveModelHandler=new TableEventHandler;ActiveModelHandler.tableColumnBind("click","#category_view div.summary_data","drill","populateRequestSummary");ActiveModelHandler.tableColumnBind("click","#request_view div.summary_data","drill","populateJobSummary");ActiveModelHandler.tableColumnBind("click","#job_view div.summary_data","drill","populateJobDetail");ActiveModelHandler.tableColumnBind("click","#job_view div.summary_data","acdc","createACDCResubmission");ActiveModelHandler.tableColumnBind("click","#category_view div.summary_data","detail","populateCategoryDetail");ActiveModelHandler.tableColumnBind("click","#request_view div.summary_data","detail","populateRequestDetail");$(document).on("mouseover","tr",function(event){$(this).addClass("mouseoverRow")});$(document).on("mouseout","tr",function(event){$(this).removeClass("mouseoverRow")})})(jQuery);WMStats.namespace("JobDetailList");(function(){var stateTransitionFormat=function(state){return""+state["newstate"]+": "+WMStats.Utils.utcClock(new Date(state["timestamp"]*1e3))+", "+state["location"]};var inputFileFormat=function(inputFile){return inputFile["lfn"]};var lumiFormat=function(lumis){function lumiRangeFormat(){if(startLumi==preLumi){lumiFormat.push("["+startLumi+"]")}else{lumiFormat.push("["+startLumi+" - "+preLumi+"]")}}var preLumi=null;var startLumi=null;var lumiFormat=new Array;for(var i in lumis){for(var j in lumis[i]){for(var k in lumis[i][j]){var currentLumi=Number(lumis[i][j][k]);if(startLumi===null){startLumi=currentLumi}else if(preLumi+1!==currentLumi){lumiRangeFormat();startLumi=currentLumi}preLumi=currentLumi}}}if(startLumi!==null){lumiRangeFormat()}return lumiFormat};var logArchiveFormat=function(archiveObj,key){return key};var format=function(data){var jobDetails=data.getData();var requestData=WMStats.ActiveRequestModel.getData();var htmlstr='
";for(var index in jobDetails){var jobDoc=jobDetails[index];if(index==="0"){htmlstr+="
"}else{htmlstr+="
"}htmlstr+="
    ";htmlstr+="
  • Job Name: "+jobDoc._id+"
  • ";htmlstr+="
  • WMBS job id: "+jobDoc.wmbsid+"
  • ";htmlstr+="
  • Workflow: "+jobDoc.workflow+"
  • ";htmlstr+="
  • Task: "+jobDoc.task+"
  • ";htmlstr+="
  • Status: "+jobDoc.state+"
  • ";htmlstr+="
  • Input dataset: "+requestData.getKeyValue(jobDoc.workflow,"inputdataset","")+"
  • ";if(typeof jobDoc.site=="object"){htmlstr+="
  • Site: N/A
  • "}else{htmlstr+="
  • Site: "+jobDoc.site+"
  • "}htmlstr+="
  • Agent: "+jobDoc.agent_name+"
  • ";htmlstr+="
  • ACDC URL: "+jobDoc.acdc_url+"
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(jobDoc.state_history,"State Transition",stateTransitionFormat)+"
  • ";htmlstr+="
  • Exit code: "+jobDoc.exitcode+"
  • ";htmlstr+="
  • Retry count: "+jobDoc.retrycount+"
  • ";htmlstr+="
  • Errors: ";for(var errorType in jobDoc.errors){htmlstr+="
      ";htmlstr+="
    • "+errorType+"
    • ";for(var i in jobDoc.errors[errorType]){htmlstr+="
        ";htmlstr+="
      • "+jobDoc.errors[errorType][i].type+" (Exit Code: "+jobDoc.errors[errorType][i].exitCode+")
      • ";htmlstr+="
          ";htmlstr+="
        • "+jobDoc.errors[errorType][i].details+"
        • ";htmlstr+="
        ";htmlstr+="
      "}htmlstr+="
    "}htmlstr+="
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(jobDoc.inputfiles,"Input files",inputFileFormat)+"
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(lumiFormat(jobDoc.lumis),"Lumis")+"
  • ";htmlstr+="
  • Output: ";for(var i in jobDoc.output){htmlstr+="
      ";htmlstr+="
    • "+jobDoc.output[i].type+"
    • ";htmlstr+="
        ";htmlstr+="
      • lfn: "+jobDoc.output[i].lfn+"
      • ";htmlstr+="
      • location: ";htmlstr+=jobDoc.output[i].location;if(jobDoc.output[i].type==="logArchive"){htmlstr+="
      • pfn: "}htmlstr+="
      • ";htmlstr+="
      • checksums: adler32: "+jobDoc.output[i].checksums.adler32+", cksum: "+jobDoc.output[i].checksums.cksum+"
      • ";htmlstr+="
      • size: "+jobDoc.output[i].size+"
      • ";htmlstr+="
      ";htmlstr+="
    "}htmlstr+="
  • ";htmlstr+="
  • "+WMStats.Utils.expandFormat(jobDoc.logArchiveLFN,"log archive",logArchiveFormat)+"
  • ";htmlstr+="
";htmlstr+="
"}return htmlstr};WMStats.JobDetailList=function(data,containerDiv){$(containerDiv).html(format(data))};var vm=WMStats.ViewModel;vm.JobDetail.subscribe("data",function(){WMStats.JobDetailList(vm.JobDetail.data(),vm.JobDetail.id())});$(document).on("click","#jobDetailNav li a",function(event){$("div.jobDetailBox").hide();$(this.hash).show();$("#jobDetailNav li a").removeClass("button-selected").addClass("button-unselected");$(this).removeClass("button-unselected").addClass("button-selected");event.preventDefault()});$(WMStats.Globals.Event).on(WMStats.CustomEvents.PHEDEX_PFN_SUCCESS,function(event,requestName){$("#acdc_submission div.requestDetailBox").append(WMStats.Utils.formatReqDetailUrl(requestName))})})();WMStats.namespace("AgentDetailList");(function(){var statusInterpretator=function(alertStatus){if(alertStatus=="agent_down"){message="Data is not updated: AnalyticsDataCollector Down"}else if(alertStatus=="component_down"){message="Components or Thread down"}else{message="OK"}return message};var componentFormat=function(componentList){var formatStr="";for(var i in componentList){formatStr+="
"+componentList[i].name+"
    ";formatStr+="
  • "+componentList[i].worker_name+"
  • ";formatStr+="
  • status: "+componentList[i].state+"
  • ";formatStr+="
  • error: "+WMStats.Utils.utcClock(new Date(componentList[i].last_error*1e3))+"
  • ";formatStr+="
  • error message:
    "+componentList[i].error_message+"
  • ";formatStr+="
  • pid: "+componentList[i].pid+"
  • ";formatStr+="
"}return formatStr};var agentErrorFormat=function(agentInfo){var htmlstr="";htmlstr+="
";htmlstr+="
    ";if(agentInfo){htmlstr+="
  • agent: "+agentInfo.agent_url+"
  • ";htmlstr+="
  • last_updated: "+WMStats.Utils.utcClock(new Date(agentInfo.timestamp*1e3))+" : "+agentInfo.alert.message+"
  • ";htmlstr+="
  • status: "+statusInterpretator(agentInfo.alert.status)+"
  • ";htmlstr+="
  • team: "+agentInfo.agent_team+"
  • "}var detailInfo=agentInfo.down_component_detail;if(detailInfo&&detailInfo.length>0){htmlstr+="
  • component errors: ";htmlstr+=componentFormat(detailInfo);htmlstr+="
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};var agentStableFormat=function(agentInfo){var htmlstr="";htmlstr+="
";htmlstr+="
    ";if(agentInfo){htmlstr+="
  • agent: "+agentInfo.agent_url+"
  • ";htmlstr+="
  • last_updated: "+agentInfo.alert.message+"
  • ";htmlstr+="
  • status: "+statusInterpretator(agentInfo.alert.status)+"
  • ";htmlstr+="
  • team "+agentInfo.agent_team+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};var format=function(agentData){var htmlstr="";var agentsWithWarning=agentData.getAlertList();for(i in agentsWithWarning){if(agentsWithWarning[i].alert&&agentsWithWarning[i].alert.status!=="ok"){htmlstr+=agentErrorFormat(agentsWithWarning[i])}else{htmlstr+=agentStableFormat(agentsWithWarning[i])}}return htmlstr};WMStats.AgentDetailList=function(data,containerDiv){$(containerDiv).html(format(data))};var vm=WMStats.ViewModel;vm.AgentPage.subscribe("data",function(){var divID="#agent_detail";WMStats.AgentDetailList(vm.AgentPage.data(),divID)})})();WMStats.namespace("WMStats.CategoryTitle");(function(){var format=function(data){var categoryKey=data;var htmlstr="";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • Category: "+categoryKey+"
  • ";htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.CategoryTitle=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("WMStats.RequestTitle");(function(){var format=function(data){var workflow;var dataType;if(typeof data==="string"){workflow=data;dataType=0}else{workflow=data.getData().workflow;dataType=1}var requestInfo=WMStats.ActiveRequestModel.getData().getData(workflow);var htmlstr="";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • "+workflow+"
  • ";if(dataType==1){htmlstr+="
  • agent: "+requestInfo.agent_url+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestTitle=function(data,containerDiv){if(typeof data==="string"||typeof data==="object"&&data.getData().workflow!==undefined){$(containerDiv).html(format(data))}}})();WMStats.namespace("SiteHistoryGraph");WMStats.SiteHistoryGraph=function(historyData,containerDiv){var siteHistory=JSON.stringify(historyData);var htmlList="
"+siteHistory+"
";$(containerDiv).html(htmlList)};WMStats.namespace("Controls");WMStats.Controls=function($){var vm=WMStats.ViewModel;var vmRegistry=WMStats.ViewModel.Registry;var _categorySelector;function setFilter(selector){$(selector).append('filter
campaign:
workflow:
type:
status:
input dataset:
output dataset:
site whitelist:
agent:
');var _filterSelector=selector+' div[name="filter"] input';$(document).on("keyup",selector+" input",function(){WMStats.ViewModel.ActiveRequestPage.filter(WMStats.Utils.createInputFilter(_filterSelector))})}function setCategoryButton(selector){var categoryBottons='';$(selector).append(categoryBottons);$(document).on("click",selector+" li a",function(event){var category=this.hash.substring(1);var vmCategory;if(category==="campaign"){vmCategory=vm.CampaignCategory}else if(category==="sites"){vmCategory=vm.SiteCategory}else if(category==="cmssw"){vmCategory=vm.CMSSWCategory}else if(category==="agent"){vmCategory=vm.AgentCategory}vm.CategoryView.category(vmCategory);$(selector+" li a").removeClass("nav-button-selected").addClass("button-unselected");$(this).addClass("nav-button-selected");event.preventDefault()})}function setViewSwitchButton(selector){var viewSwitchBottons='';$(selector).append(viewSwitchBottons);$(document).on("click","#view_switch_button li a",function(event){var buttonName=this.hash.substring(1);var requestFormat;if(buttonName==="progress"){requestFormat=vm.RequestProgress}else if(buttonName==="numJobs"){requestFormat=vm.RequestJobs}vm.RequestView.format(requestFormat);vm.RequestView.propagateUpdate();$("#view_switch_button li a").removeClass("nav-button-selected").addClass("button-unselected");$(this).addClass("nav-button-selected");event.preventDefault()})}function setAllRequestButton(selector){var requestBottons='';$(selector).append(requestBottons).addClass("button-group");$(document).on("click","#all_requests li a",function(event){vm.RequestView.categoryKey("all");event.preventDefault()});vm.RequestView.subscribe("categoryKey",function(){var buttonSelector="#all_requests li a";if(vm.RequestView.categoryKey()==="all"){$(buttonSelector).removeClass("button-unselected").addClass("nav-button-selected")}else{$(buttonSelector).removeClass("nav-button-selected").addClass("button-unselected")}})}function setTabs(selector){var tabs='';$(selector).append(tabs).addClass("tabs");$(selector+" ul").addClass("tabs-nav");function changeTab(event,data){$(selector+" li").removeClass("tabs-selected");$(selector+' a[href="'+data.id()+'"]').parent().addClass("tabs-selected")}vm.ActiveRequestPage.subscribe("view",changeTab);$(document).on("click",selector+" li a",function(event){vm.ActiveRequestPage.view(vmRegistry[this.hash]);event.preventDefault()})}function setExternalLink(selector){var outsideLink=' agent alert ';$(selector).append(outsideLink)}return{setFilter:setFilter,setTabs:setTabs,setCategoryButton:setCategoryButton,setAllRequestButton:setAllRequestButton,setViewSwitchButton:setViewSwitchButton,setExternalLink:setExternalLink,requests:"requests",sites:"sites",campaign:"campaign",cmssw:"cmssw"}}(jQuery);WMStats.namespace("ActiveRequestTable");WMStats.ActiveRequestTable=function(requestData,containerDiv){var formatReqDetailUrl=WMStats.Utils.formatReqDetailUrl;var formatWorkloadSummarylUrl=WMStats.Utils.formatWorkloadSummarylUrl;var _activePageData=WMStats.ViewModel.ActiveRequestPage.data();var tableConfig={iDisplayLength:25,sScrollX:"",bAutoWidth:false,aoColumns:[{sTitle:"D",sDefaultContent:0,sWidth:"15px",fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,sWidth:"15px",fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"workflow",sTitle:"workflow",fnRender:function(o,val){return formatReqDetailUrl(o.aData.workflow)},bUseRendered:false,sWidth:"150px"},{mDataProp:function(source,type,val){var requestInfo=_activePageData.getData(source.workflow);return requestInfo.request_status[requestInfo.request_status.length-1].status},sTitle:"status",fnRender:function(o,val){var requestInfo=_activePageData.getData(o.aData.workflow);return formatWorkloadSummarylUrl(o.aData.workflow,requestInfo.request_status[requestInfo.request_status.length-1].status)},bUseRendered:false},{mDataProp:"request_type",sTitle:"type",sDefaultContent:""},{mDataProp:"priority",sTitle:"priority",sDefaultContent:0},{sDefaultContent:0,sTitle:"queue injection",fnRender:function(o,val){var result=_activePageData.getKeyValue(o.aData.workflow,"status.inWMBS",0)/_activePageData.getKeyValue(o.aData.workflow,"total_jobs",1)*100; +return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"job progress",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);var totalJobs=reqSummary.getWMBSTotalJobs()||1;var result=(reqSummary.getJobStatus("success")+reqSummary.getTotalFailure())/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"event progress",fnRender:function(o,val){var inputEvents=Number(_activePageData.getKeyValue(o.aData.workflow,"input_events",1))||1;var outputEvents=requestData.getSummary(o.aData.workflow).getAvgEvents();var result=outputEvents/inputEvents*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"lumi progress",fnRender:function(o,val){var inputLumis=Number(_activePageData.getKeyValue(o.aData.workflow,"input_lumis",1))||1;var outputLumis=requestData.getSummary(o.aData.workflow).getAvgLumis();var result=outputLumis/inputLumis*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"failure rate",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);var totalFailure=reqSummary.getTotalFailure();var totalJobs=reqSummary.getJobStatus("success")+totalFailure||1;var result=totalFailure/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"Eestimated Completion",fnRender:function(o,val){return WMStats.Utils.foramtDuration(requestData.estimateCompletionTime(o.aData.workflow))}},{sDefaultContent:0,sTitle:"cool off ",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);return reqSummary.getTotalCooloff()}}]};var filterConfig={};tableConfig.aaData=requestData.getList();return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("ActiveRequestTableWithJob");WMStats.ActiveRequestTableWithJob=function(requestData,containerDiv){var formatReqDetailUrl=WMStats.Utils.formatReqDetailUrl;var formatWorkloadSummarylUrl=WMStats.Utils.formatWorkloadSummarylUrl;var _activePageData=WMStats.ViewModel.ActiveRequestPage.data();var tableConfig={iDisplayLength:25,sScrollX:"",bAutoWidth:false,aoColumns:[{sTitle:"D",sDefaultContent:0,sWidth:"15px",fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,sWidth:"15px",fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"workflow",sTitle:"workflow",fnRender:function(o,val){return formatReqDetailUrl(o.aData.workflow)},bUseRendered:false,sWidth:"150px"},{mDataProp:function(source,type,val){var requestInfo=_activePageData.getData(source.workflow);return requestInfo.request_status[requestInfo.request_status.length-1].status},sTitle:"status",fnRender:function(o,val){var requestInfo=_activePageData.getData(o.aData.workflow);return formatWorkloadSummarylUrl(o.aData.workflow,requestInfo.request_status[requestInfo.request_status.length-1].status)},bUseRendered:false},{sDefaultContent:0,sTitle:"created",fnRender:function(o,val){var reqSummary=requestData.getSummary(o.aData.workflow);return reqSummary.getWMBSTotalJobs()}},{sDefaultContent:0,sTitle:"queued",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getTotalQueued();if(type==="display"){var requestInfo=_activePageData.getData(source.workflow);return WMStats.Globals.formatJobLink(jobs,requestInfo.agent_url,source.workflow,"pending")}return jobs}},{sDefaultContent:0,sTitle:"pending ",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getPending();if(type==="display"){var requestInfo=_activePageData.getData(source.workflow);return WMStats.Globals.formatJobLink(jobs,requestInfo.agent_url,source.workflow,"running")}return jobs}},{sDefaultContent:0,sTitle:"running ",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getRunning();if(type==="display"){var requestInfo=_activePageData.getData(source.workflow);return WMStats.Globals.formatJobLink(jobs,requestInfo.agent_url,source.workflow,"running")}return jobs}},{sDefaultContent:0,sTitle:"success ",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getJobStatus("success");if(type==="display"){var requestInfo=_activePageData.getData(source.workflow);return WMStats.Globals.formatJobLink(jobs,requestInfo.agent_url,source.workflow,"success")}return jobs}},{sDefaultContent:0,sTitle:"failure ",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getTotalFailure();var requestInfo=_activePageData.getData(source.workflow);if(type==="display"){return WMStats.Globals.formatJobLink(jobs,requestInfo.agent_url,source.workflow,"failed")}return jobs}},{sDefaultContent:0,sTitle:"cool off ",mDataProp:function(source,type,val){var reqSummary=requestData.getSummary(source.workflow);var jobs=reqSummary.getTotalCooloff();var requestInfo=_activePageData.getData(source.workflow);if(type==="display"){return WMStats.Globals.formatJobLink(jobs,requestInfo.agent_url,source.workflow,"cooloff")}return jobs}}]};var filterConfig={};tableConfig.aaData=requestData.getList();return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("CampaignSummaryTable");WMStats.CampaignSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:50,sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"key",sTitle:"campaign"},{mDataProp:function(source,type,val){return source.summary.summaryStruct.numRequests},sTitle:"requests",sDefaultContent:0},{sDefaultContent:0,sTitle:"job progress",mDataProp:function(source,type,val){var campaignSummary=source.summary;var totalJobs=campaignSummary.getWMBSTotalJobs()||1;var result=(campaignSummary.getJobStatus("success")+campaignSummary.getTotalFailure())/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"event progress",mDataProp:function(source,type,val){var totalEvents=source.summary.summaryStruct.totalEvents||1;var result=source.summary.getAvgEvents()/totalEvents*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"lumi progress",mDataProp:function(source,type,val){var totalLumis=source.summary.summaryStruct.totalLumis||1;var result=source.summary.getAvgLumis()/totalLumis*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"failure rate",mDataProp:function(source,type,val){var campaignSummary=source.summary;var totalFailure=campaignSummary.getTotalFailure();var totalJobs=campaignSummary.getJobStatus("success")+totalFailure||1;var result=totalFailure/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"cool off ",mDataProp:function(source,type,val){var campaignSummary=source.summary;return campaignSummary.getTotalCooloff()}}]};tableConfig.aaData=data.getList();var filterConfig={};return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("CMSSWSummaryTable");WMStats.CMSSWSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:50,sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"key",sTitle:"cmssw"},{mDataProp:function(source,type,val){return source.summary.summaryStruct.numRequests},sTitle:"requests",sDefaultContent:0},{sDefaultContent:0,sTitle:"job progress",mDataProp:function(source,type,val){var cmsswSummary=source.summary;var totalJobs=cmsswSummary.getWMBSTotalJobs()||1;var result=(cmsswSummary.getJobStatus("success")+cmsswSummary.getTotalFailure())/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"event progress",mDataProp:function(source,type,val){var totalEvents=source.summary.summaryStruct.totalEvents||1;var result=source.summary.getAvgEvents()/totalEvents*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"lumi progress",mDataProp:function(source,type,val){var totalLumis=source.summary.summaryStruct.totalLumis||1;var result=source.summary.getAvgLumis()/totalLumis*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"failure rate",mDataProp:function(source,type,val){var cmsswSummary=source.summary;var totalFailure=cmsswSummary.getTotalFailure();var totalJobs=cmsswSummary.getJobStatus("success")+totalFailure||1;var result=totalFailure/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"cool off ",mDataProp:function(source,type,val){var cmsswSummary=source.summary;return cmsswSummary.getTotalCooloff()}}]};tableConfig.aaData=data.getList();var filterConfig={};return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};WMStats.namespace("AgentRequestSummaryTable");WMStats.AgentRequestSummaryTable=function(data,containerDiv){var tableConfig={iDisplayLength:50,sScrollX:"",aoColumns:[{sTitle:"D",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("detail")}},{sTitle:"L",sDefaultContent:0,fnRender:function(o,val){return WMStats.Utils.formatDetailButton("drill")}},{mDataProp:"key",sTitle:"agent"},{mDataProp:function(source,type,val){return source.summary.summaryStruct.numRequests},sTitle:"requests",sDefaultContent:0},{sDefaultContent:0,sTitle:"job progress",mDataProp:function(source,type,val){var agentRequestSummary=source.summary;var totalJobs=agentRequestSummary.getWMBSTotalJobs()||1;var result=(agentRequestSummary.getJobStatus("success")+agentRequestSummary.getTotalFailure())/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"failure rate",mDataProp:function(source,type,val){var agentRequestSummary=source.summary;var totalFailure=agentRequestSummary.getTotalFailure();var totalJobs=agentRequestSummary.getJobStatus("success")+totalFailure||1;var result=totalFailure/totalJobs*100;return result.toFixed(1)+"%"}},{sDefaultContent:0,sTitle:"cool off ",mDataProp:function(source,type,val){var agentRequestSummary=source.summary;return agentRequestSummary.getTotalCooloff()}}]};tableConfig.aaData=data.getList();var filterConfig={};return WMStats.Table(tableConfig).create(containerDiv,filterConfig)};(function(vm){WMStats.CategorySummaryMap.add(vm.SiteCategory.name(),WMStats.SiteSummary);WMStats.CategoryTableMap.add(vm.SiteCategory.name(),WMStats.SiteSummaryTable);WMStats.CategoryTableMap.add(vm.RequestView.categoryName,{progress:WMStats.ActiveRequestTable,numJobs:WMStats.ActiveRequestTableWithJob});WMStats.CategorySummaryMap.add(vm.CampaignCategory.name(),WMStats.CampaignSummary);WMStats.CategoryTableMap.add(vm.CampaignCategory.name(),WMStats.CampaignSummaryTable);WMStats.CategorySummaryMap.add(vm.CMSSWCategory.name(),WMStats.CMSSWSummary);WMStats.CategoryTableMap.add(vm.CMSSWCategory.name(),WMStats.CMSSWSummaryTable);WMStats.CategorySummaryMap.add(vm.AgentCategory.name(),WMStats.AgentRequestSummary);WMStats.CategoryTableMap.add(vm.AgentCategory.name(),WMStats.AgentRequestSummaryTable)})(WMStats.ViewModel);WMStats.namespace("RequestDetailList");(function(){var vm=WMStats.ViewModel;var progressFormat=function(progressStat,totalEvents,totalLumis){var formatStr="
    ";for(var output in progressStat){var processedEvents=progressStat[output].events||0;var processedLumis=progressStat[output].totalLumis||0;var eventPercent=(processedEvents/totalEvents*100).toFixed(1)+"%";var lumiPercent=(processedLumis/totalLumis*100).toFixed(1)+"%";formatStr+="
  • "+output+": event: "+eventPercent+", lumi: "+lumiPercent+"
  • "}formatStr+="
";return formatStr};var expandFormat=function(dataArray,maxLength,summaryStr){var htmlstr="";if(dataArray==undefined||dataArray.length==undefined||dataArray.length<=maxLength){htmlstr+=dataArray}else{htmlstr+="
"+summaryStr+"
    ";for(var i in dataArray){htmlstr+="
  • "+dataArray[i]+"
  • "}htmlstr+="
"}return htmlstr};var format=function(requestStruct){var htmlstr='
X
';var reqDoc=requestStruct.requests[requestStruct.key];var reqSummary=requestStruct.summary;htmlstr+="
";htmlstr+="
    ";if(reqDoc){htmlstr+="
  • campaign: "+reqDoc.campaign+"
  • ";htmlstr+="
  • workflow: "+WMStats.Utils.formatReqDetailUrl(reqDoc.workflow)+"
  • ";htmlstr+="
  • agent url: "+reqDoc.agent_url+"
  • ";htmlstr+="
  • prep id: "+reqDoc.prep_id+"
  • ";htmlstr+="
  • teams: "+reqDoc.teams+"
  • ";htmlstr+="
  • requetor: "+reqDoc.requestor+"
  • ";htmlstr+="
  • request date: "+reqDoc.request_date+"
  • ";htmlstr+="
  • request type: "+reqDoc.request_type+"
  • ";htmlstr+="
  • CMSSW: "+reqDoc.cmssw+"
  • ";htmlstr+="
  • user dn: "+reqDoc.user_dn+"
  • ";htmlstr+="
  • vo role: "+reqDoc.vo_role+"
  • ";htmlstr+="
  • vo group: "+reqDoc.vo_group+"
  • ";htmlstr+="
  • status: "+WMStats.Utils.formatWorkloadSummarylUrl(reqDoc.workflow,reqDoc.request_status[reqDoc.request_status.length-1].status)+"
  • ";htmlstr+="
  • input dataset: "+reqDoc.inputdataset+"
  • ";htmlstr+="
  • input events: "+reqDoc.input_events+"
  • ";htmlstr+="
  • site white list: "+expandFormat(reqDoc.site_white_list,4,"Multiple Sites")+"
  • ";htmlstr+="
  • output datasets: "+expandFormat(reqDoc.outputdatasets,1,"Multiple Datasets")+"
  • ";htmlstr+="
  • progress: "+progressFormat(reqDoc.getProgressStat(),Number(reqDoc.input_events),Number(reqDoc.input_lumis))+"
  • "}if(reqSummary){htmlstr+="
  • output events: "+reqSummary.summaryStruct.processedEvents+"
  • ";htmlstr+="
  • queued (first): "+reqSummary.getJobStatus("queued.first",0)+"
  • ";htmlstr+="
  • queued (retried): "+reqSummary.getJobStatus("queued.retry",0)+"
  • ";htmlstr+="
  • cooloff jobs: "+reqSummary.getTotalCooloff()+"
  • ";htmlstr+="
  • pending: "+reqSummary.getJobStatus("submitted.pending",0)+"
  • ";htmlstr+="
  • running: "+reqSummary.getJobStatus("submitted.running",0)+"
  • ";htmlstr+="
  • failure:"+reqSummary.getTotalFailure()+"
  • ";htmlstr+="
  • success: "+reqSummary.getJobStatus("success",0)+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestDetailList=function(workflow,containerDiv){var allRequests=vm.ActiveRequestPage.data();var reqDoc=allRequests.getData(workflow);var reqSummary=allRequests.getSummary(workflow);var requests={};requests[workflow]=reqDoc;var data={key:workflow,requests:requests,summary:reqSummary};$(containerDiv).html(format(data));$(containerDiv).show("slide",{},500);WMStats.Env.RequestDetailOpen=true};var vm=WMStats.ViewModel;vm.RequestDetail.subscribe("requestName",function(){WMStats.RequestDetailList(vm.RequestDetail.requestName(),vm.RequestDetail.id())})})();WMStats.namespace("RequestAlertGUI");WMStats.RequestAlertGUI=function(requestData,containerDiv){var alertRequests=requestData.getRequestAlerts();var notPulledRequests=requestData.requestNotPulledAlert();var configError=alertRequests.configError;var siteError=alertRequests.siteError;var errorFlag=false;var numError=configError.length+siteError.length;var htmlList="";if(configError.length>0){htmlList="
Config Error
    ";for(var i in configError){var workflow=configError[i].getName();var summary=configError[i].getSummary();var cooloff=summary.getTotalCooloff();var failure=summary.getTotalFailure();var success=summary.getJobStatus("success");htmlList+='
  • '+workflow+": cooloff "+cooloff+" failure:"+failure+" success:"+success+"
  • "}htmlList+="
";errorFlag=true}if(siteError.length>0){htmlList+="
Site Error
    ";for(var i in siteError){var workflow=siteError[i].getName();var summary=siteError[i].getSummary();var cooloff=summary.getTotalCooloff();var failure=summary.getTotalFailure();var success=summary.getJobStatus("success");htmlList+='
  • '+workflow+": cooloff "+cooloff+" failure:"+failure+" success:"+success+"
  • "}htmlList+="
";errorFlag=true}$(containerDiv).addClass("request_error_box");if(errorFlag){$(containerDiv).removeClass("stable warning").addClass("error").html(htmlList)}else{$(containerDiv).removeClass("warning error").addClass("stable").html("request alarm")}};(function(){var vm=WMStats.ViewModel;vm.RequestAlertPage.subscribe("data",function(){var divSelector=vm.RequestAlertPage.id()+" div.summary_data";WMStats.RequestAlertGUI(vm.RequestAlertPage.data(),divSelector)});$(document).on("click","a.requestAlert",function(){var workflow=$(this).text();vm.ActiveRequestPage.view(vm.JobView);vm.page(vm.ActiveRequestPage);vm.JobView.requestName(workflow);$(this).addClass("reviewed")})})();WMStats.namespace("CategoryDetailList");(function(){var format=function(requestStruct){var htmlstr="";var reqDoc=requestStruct.requests[requestStruct.key];var reqSummary=requestStruct.summary;htmlstr+="
";htmlstr+="
    ";if(reqDoc){htmlstr+="
  • campaign: "+reqDoc.campaign+"
  • ";htmlstr+="
  • workflow: "+WMStats.Utils.formatReqDetailUrl(reqDoc.workflow)+"
  • ";htmlstr+="
  • requetor: "+reqDoc.requestor+"
  • ";htmlstr+="
  • request date: "+reqDoc.request_date+"
  • ";htmlstr+="
  • request type: "+reqDoc.request_type+"
  • ";htmlstr+="
  • user dn: "+reqDoc.user_dn+"
  • ";htmlstr+="
  • vo role: "+reqDoc.vo_role+"
  • ";htmlstr+="
  • vo group: "+reqDoc.vo_group+"
  • ";htmlstr+="
  • status: "+WMStats.Utils.formatWorkloadSummarylUrl(reqDoc.workflow,reqDoc.request_status[reqDoc.request_status.length-1].status)+"
  • ";htmlstr+="
  • input dataset: "+reqDoc.inputdataset+"
  • ";htmlstr+="
  • input events: "+reqDoc.input_events+"
  • ";htmlstr+="
  • site white list: "+reqDoc.site_white_list+"
  • ";htmlstr+="
  • output datasets: "+reqDoc.outputdatasets+"
  • "}if(reqSummary){htmlstr+="
  • output events: "+reqSummary.summaryStruct.processedEvents+"
  • ";htmlstr+="
  • queued (first): "+reqSummary.getJobStatus("queued.first",0)+"
  • ";htmlstr+="
  • queued (retried): "+reqSummary.getJobStatus("queued.retry",0)+"
  • ";htmlstr+="
  • cooloff jobs: "+reqSummary.getTotalCooloff()+"
  • ";htmlstr+="
  • pending: "+reqSummary.getJobStatus("submitted.pending",0)+"
  • ";htmlstr+="
  • running: "+reqSummary.getJobStatus("submitted.running",0)+"
  • ";htmlstr+="
  • failure:"+reqSummary.getTotalFailure()+"
  • ";htmlstr+="
  • success: "+reqSummary.getJobStatus("success",0)+"
  • "}htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.CategoryDetailList=function(data,containerDiv){$(containerDiv).html(format(data))};var vm=WMStats.ViewModel;vm.CategoryDetail.subscribe("data",function(){WMStats.CategoryDetailList(vm.CategoryDetail.data(),vm.CategoryDetail.id())})})();WMStats.namespace("RequestSummaryList");(function(){var numFormat=WMStats.Utils.largeNumberFormat;var format=function(summary){var summaryStruct=summary.summaryStruct;var htmlstr="";htmlstr+="filtered stats";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • requests: "+summary.summaryStruct.length+"
  • ";htmlstr+="
  • total events: "+numFormat(summary.summaryStruct.totalEvents)+"
  • ";htmlstr+="
  • processed events: "+numFormat(summary.getAvgEvents())+"
  • ";htmlstr+="
  • created: "+numFormat(summary.getWMBSTotalJobs())+"
  • ";htmlstr+="
  • cooloff: "+numFormat(summary.getTotalCooloff())+"
  • ";htmlstr+="
  • success: "+numFormat(summary.getJobStatus("success"))+"
  • ";htmlstr+="
  • failure: "+numFormat(summary.getTotalFailure())+"
  • ";htmlstr+="
  • queued: "+numFormat(summary.getTotalQueued())+"
  • ";htmlstr+="
  • running: "+numFormat(summary.getJobStatus("submitted.running"))+"
  • ";htmlstr+="
  • pending: "+numFormat(summary.getJobStatus("submitted.pending"))+"
  • ";htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestSummaryList=function(data,containerDiv){$(containerDiv).html(format(data))};var vm=WMStats.ViewModel;vm.ActiveRequestPage.subscribe("data",function(){var filteredData=vm.ActiveRequestPage.data();WMStats.RequestSummaryList(filteredData.getSummary(),"#filter_summary")})})();WMStats.namespace("RequestDataList");(function(){var format=function(summary){var summaryStruct=summary.summaryStruct;var htmlstr="";htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • requests: "+summary.summaryStruct.length+"
  • ";htmlstr+="
  • total events: "+summary.summaryStruct.totalEvents+"
  • ";htmlstr+="
  • processed events: "+summary.summaryStruct.processedEvents+"
  • ";htmlstr+="
  • created: "+summary.getWMBSTotalJobs()+"
  • ";htmlstr+="
  • cooloff: "+summary.getTotalCooloff()+"
  • ";htmlstr+="
  • success: "+summary.getJobStatus("success")+"
  • ";htmlstr+="
  • failure: "+summary.getTotalFailure()+"
  • ";htmlstr+="
  • queued: "+summary.getTotalQueued()+"
  • ";htmlstr+="
  • running: "+summary.getJobStatus("submitted.running")+"
  • ";htmlstr+="
  • pending: "+summary.getJobStatus("submitted.pending")+"
  • ";htmlstr+="
";htmlstr+="
";return htmlstr};WMStats.RequestDataList=function(data,containerDiv){$(containerDiv).html(format(data))}})();WMStats.namespace("ResubmissionList");(function(){var format=function(summary){var htmlstr="";htmlstr+="Resubmission";htmlstr='
X
';htmlstr+="
";htmlstr+="
    ";htmlstr+="
  • Request String: :
  • ";htmlstr+="
  • Original Request Name: :"+summary.OriginalRequestName+"
  • ";htmlstr+="
  • Initial Task Path: "+summary.InitialTaskPath+"
  • ";if(summary.ACDCServer){htmlstr+="
  • ACDC Server URL: "+summary.ACDCServer+"
  • ";htmlstr+="
  • ACDC DB Name: "+summary.ACDCDatabase+"
  • "}else{htmlstr+="
  • ACDC Server URL:
  • ";htmlstr+="
  • ACDC DB Name:
  • "}htmlstr+="
  • Group: "+summary.Group+"
  • ";htmlstr+="
  • PrepID: "+summary.PrepID+"
  • ";htmlstr+="
  • RequestPriority: "+summary.RequestPriority+"
  • ";htmlstr+="
  • DBSURL: "+summary.DbsUrl+"
  • ";htmlstr+="
  • Memory: "+summary.Memory+"
  • ";htmlstr+="
  • SizePerEven: "+summary.SizePerEvent+"
  • ";htmlstr+="
  • TimePerEvent: "+summary.TimePerEvent+"
  • ";htmlstr+="
  • RequestType: "+summary.RequestType+"
  • ";htmlstr+="
";htmlstr+="";htmlstr+="
";return htmlstr};WMStats.ResubmissionList=function(data,containerDiv){$(containerDiv).html(format(data));$(containerDiv).show("slide",{},500)};var vm=WMStats.ViewModel;vm.Resubmission.subscribe("data",function(){WMStats.ResubmissionList(vm.Resubmission.data(),vm.Resubmission.id())});$(document).on("click","#acdc_submission button",function(event){var resubmissionData=WMStats.ViewModel.Resubmission.data();resubmissionData.RequestString=$('#acdc_submission input[name="RequestString"]').val();if(resubmissionData.ACDCServer===undefined){resubmissionData.ACDCServer=$('#acdc_submission input[name="ACDCServer"]').val()}if(resubmissionData.ACDCDatabase===undefined){resubmissionData.ACDCDatabase=$('#acdc_submission input[name="ACDCDatabase"]').val()}WMStats.Ajax.requestMgr.putRequest(resubmissionData);event.preventDefault()});$(WMStats.Globals.Event).on(WMStats.CustomEvents.RESUBMISSION_SUCCESS,function(event,requestName){$("#acdc_submission div.requestDetailBox").append(WMStats.Utils.formatReqDetailUrl(requestName))})})();WMStats.namespace("_ModelBase");WMStats._ModelBase=function(initView,options,dataStruct){this._initialView=initView;this._options=options;this._dataStruct=dataStruct;this._trigger=null;this._data=null;this._dbSource=WMStats.Couch};WMStats._ModelBase.prototype={setTrigger:function(triggerName){this._trigger=triggerName},getData:function(){return this._data},dataReady:function(data){this._data=this._dataStruct(data);if(this._trigger instanceof Array){for(var i in this._trigger){jQuery(WMStats.Globals.Event).triggerHandler(this._trigger[i],this._data)}}else{jQuery(WMStats.Globals.Event).triggerHandler(this._trigger,this._data)}},retrieveData:function(view,options){if(options===undefined){var options=this._options}if(view===undefined){var view=this._initialView}if(view==="allDocs"){return this.retrieveAllDocs(options)}else if(view==="doc"){return this.retrieveDoc(options)}else{return this._dbSource.view(view,options,jQuery.proxy(this.callback,this))}},retrieveAllDocs:function(options){if(options===undefined){var options=this._options}return this._dbSource.allDocs(options,jQuery.proxy(this.callback,this))},retrieveDoc:function(docID){return this._dbSource.openDoc(docID,jQuery.proxy(this.callback,this))},setDBSource:function(dbSource){this._dbSource=dbSource},callback:function(data){return this.dataReady(data)},clearData:function(){delete this._data}};WMStats.namespace("_RequestModelBase");WMStats._RequestModelBase=function(initView,options){this._initialView=initView||"requestByCampaignAndDate";this._options=options||{include_docs:true};this._data=null;this._trigger="requestReady"};WMStats._RequestModelBase.keysFromIDs=function(data){var keys=[];for(var i in data.rows){if(data.rows[i].value&&data.rows[i].value.id){keys.push(data.rows[i].value.id)}else{keys.push(data.rows[i].id)}}return keys};WMStats._RequestModelBase.requestAgentUrlKeys=function(requestList,requestAgentData){var keys={};var requestAgentUrlList=[];for(var i in requestAgentData.rows){var request=requestAgentData.rows[i].key[0];if(!keys[request]){keys[request]=[]}keys[request].push(requestAgentData.rows[i].key[1])}for(var j=0;j