From 51ffe5aac386b1513d33c42539efee4edf8b8b4a Mon Sep 17 00:00:00 2001 From: Aref Shafaei Date: Mon, 25 Mar 2019 16:24:57 -0700 Subject: [PATCH 01/11] fix log issues --- common/export.js | 9 ++- common/faceting.js | 29 +++++++-- common/utils.js | 15 ++++- docs/user-docs/logging.md | 123 +++++++++++++++++++++++--------------- record/index.html.in | 2 +- record/record.utils.js | 10 ++-- recordset/index.html.in | 2 +- viewer/viewer.app.js | 52 +++++++++++----- 8 files changed, 161 insertions(+), 81 deletions(-) diff --git a/common/export.js b/common/export.js index 2214bb5c6..39dcedec8 100644 --- a/common/export.js +++ b/common/export.js @@ -80,8 +80,12 @@ _cancelExport(scope); }); scope.isLoading = true; + var action = logActions.recordExport; + if (scope.parent === "recordset") { + action = logActions.recordsetExport; + } - scope.exporter.run({action: logActions.export}).then(function (response) { + scope.exporter.run({action: action}).then(function (response) { // if it was canceled, just ignore the result if (response.canceled) return; @@ -110,7 +114,8 @@ scope: { reference: "=", allowExport: "=", - disabled: "=" + disabled: "=", + parent: "@" }, link: function (scope, element, attributes) { scope.isLoading = false; diff --git a/common/faceting.js b/common/faceting.js index fc79f0906..2647a3cd3 100644 --- a/common/faceting.js +++ b/common/faceting.js @@ -511,6 +511,20 @@ } }; + /** + * Generate the object that we want to be logged alongside the action + * This function does not attach action, after calling this function + * we should attach the action. + * @param {object} scope the scope object + */ + function getDefaultLogInfo(scope) { + var res = scope.facetColumn.sourceReference.defaultLogInfo; + res.referrer = scope.facetColumn.reference.defaultLogInfo; + res.source = scope.facetColumn.dataSource; + res.column = scope.facetColumn.column.name; + return res; + } + // range is defined by the x values of the bar graph because layout.xaxis.type is `linear` or 'category' function setHistogramRange() { if (isColumnOfType("timestamp")) { @@ -584,7 +598,9 @@ var requestMin = isColumnOfType("timestamp") ? dateTimeToTimestamp(scope.rangeOptions.absMin) : scope.rangeOptions.absMin, requestMax = isColumnOfType("timestamp") ? dateTimeToTimestamp(scope.rangeOptions.absMax) : scope.rangeOptions.absMax; - scope.facetColumn.column.groupAggregate.histogram(numBuckets, requestMin, requestMax).read().then(function (response) { + var facetLog = getDefaultLogInfo(scope); + facetLog.action = logActions.recordsetFacetHistogram; + scope.facetColumn.column.groupAggregate.histogram(numBuckets, requestMin, requestMax).read(facetLog).then(function (response) { if (scope.facetColumn.sourceReference.uri !== uri) { // return breaks out of the current callback function defer.resolve(false); @@ -642,10 +658,8 @@ agg.maxAgg ]; - var facetLog = scope.facetColumn.sourceReference.defaultLogInfo; - facetLog.referrer = scope.facetColumn.reference.defaultLogInfo; - facetLog.source = scope.facetColumn.dataSource; - facetLog.action = logActions.recordsetFacetRead, + var facetLog = getDefaultLogInfo(scope); + facetLog.action = logActions.recordsetFacetRead; scope.facetColumn.sourceReference.getAggregates(aggregateList, facetLog).then(function(response) { if (scope.facetColumn.sourceReference.uri !== uri) { // return false to defer.resolve() in .then() callback @@ -894,6 +908,8 @@ if (scope.facetColumn.hasNullFilter) { scope.facetModel.appliedFilters.push(facetingUtils.getNullFilter(true)); } + var facetLog = getDefaultLogInfo(scope); + facetLog.action = logActions.recordsetFacetInit; scope.facetColumn.getChoiceDisplaynames().then(function (filters) { filters.forEach(function (f) { scope.facetModel.appliedFilters.push({ @@ -1091,6 +1107,9 @@ var res = scope.facetColumn.sourceReference.defaultLogInfo; res.referrer = scope.facetColumn.reference.defaultLogInfo; res.source = scope.facetColumn.dataSource; + if (!scope.facetColumn.isEntityMode) { + res.column = scope.facetColumn.column.name; + } return res; } diff --git a/common/utils.js b/common/utils.js index 08826bc97..c0c6aeb91 100644 --- a/common/utils.js +++ b/common/utils.js @@ -112,7 +112,8 @@ }) .constant("logActions", { - "recordRead": "record/main", // read the main entity (record) + "recordRead": "record/main/load", // read the main entity (record) + "recordUpdate": "record/main/update", // read the main entity (record) "recordRelatedRead": "record/related", // secondary "recordRelatedUpdate": "record/related/update", // secondary "recordRelatedAggregate": "record/related/aggregate", // secondary @@ -150,13 +151,21 @@ "recordsetFacet": "recordset/main/facet", // recordset main data read on changing facet (recordset) "recordsetFacetDetails": "recordset/viewmore", // getting facet details in modal (recordset) "recordsetFacetRead": "recordset/facet", // secondary + "recordsetFacetInit": "recordset/facet/init", // secondary (getting the rowname of preselected facets) + "recordsetFacetHistogram": "recordset/facet/histogram", // secondary (getting the histogrma buckets) "recordDelete": "delete/record", // delete record (record) "recordEditDelete": "delete/recordedit", // delete record (recordedit) "recordsetDelete": "delete/recordset", // delete a row (recordset) - "recordRelatedDelete": "delete/recordset/related", // delete a row from related entities (record) has referrer + "recordRelatedDelete": "delete/record/related", // delete a row from related entities (record) has referrer - "export": "recordset/export" + "recordExport": "export/record", + "recordsetExport": "export/recordset", + + "viewerMain": "viewer/main", + "viewerAnnotation": "viewer/annotation", + "viewerComment": "viewer/comment", + "viewerAnatomy": "viewer/anatomy" }) diff --git a/docs/user-docs/logging.md b/docs/user-docs/logging.md index 133cf7e91..f45f89b93 100644 --- a/docs/user-docs/logging.md +++ b/docs/user-docs/logging.md @@ -49,53 +49,61 @@ The following are the optional attributes that you might find on requests: The table below summarizes all the requests that we currently are logging in chaise and their respective `action`. -| # | App | Description | Action | Extra | Notes | -|----|------------|---------------------------------------------|-----------------------------------------|------------------|-------------------------| -| 1 | record | load main entity | record/main/load | | CNG ACT | -| 2 | | update main entity | record/main/update | | MISSING | -| 3 | | load aggregates in main entity | record/aggregate | | | -| 4 | | update aggregates in main entity | record/aggregate/update | | | -| 5 | | load inline entities | record/inline | | | -| 6 | | update inline entities | record/inline/update | | | -| 7 | | load aggregates in inline entities | record/inline/aggregate | | | -| 8 | | update aggregates in inline entities | record/inline/aggregate/update | | | -| 9 | | load related entities | record/related | referrer | | -| 10 | | update related entities | record/related/update | referrer | | -| 11 | | load aggregates in related entities | record/related/aggregate | | | -| 12 | | update aggregates in related entities | record/related/aggregate/update | | | -| 13 | | read p&b values to add | pre-create/prefill/association | | | -| 14 | | read pre selected p&b values to add | pre-create/prefill/association/disabled | | | -| 15 | | create p&b | create/prefill/association | | | -| | | | | | | -| | | requests in modal in record? | | | | -| | | | | | | -| 1 | recordedit | create record | create/new | | | -| 2 | | read the foreignkey values for prefill | pre-create/prefill | | | -| 3 | | create by add button on fk modal | create/prefill | | | -| 4 | | read the current row for copy | pre-create/copy | | | -| 5 | | create record from copy | create/copy | | | -| 6 | | creating row by clicking on add in fk modal | create/modal | | | -| 7 | | read entities to be updated | pre-update | | page_size is inaccurate | -| 8 | | update entities | update | | | -| 9 | | get default value for fks | recordedit/default | | | -| | | | | | | -| | | requests in fk modal picker? | | | | -| | | | | | | -| 1 | recordset | recordset main data read on load | recordset/main/load | | | -| 2 | | recordset main data read on update | recordset/main/update | | | -| 3 | | recordset main data read on page change | recordset/main/page | sort, page | | -| 4 | | recordset main data read on sort change | recordset/main/sort | sort | | -| 5 | | recordset main data read on limit change | recordset/main/limit | | | -| 6 | | recordset main data read on facet change | recordset/main/facet | | | -| 7 | | recordset get main count | recordset/main/count | | | -| 8 | | recordset get aggregated values | recordset/main/aggregate | | | -| 9 | | recordset read facet | recordset/facet | referrer, source | | -| 10 | | recordset click on show details | recordset/viewmore | referrer, source | | -| | | | | | | -| 1 | | delete from record | delete/record | | | -| 2 | | delete from recordedit | delete/recordedit | | | -| 3 | | delete row from recordset table | delete/recordset | | | -| 4 | | delete related entity rows | delete/recorset/related | | | +| App | Description | Action | Extra | Notes | +|-----------------------------|------------------------------------------------|-----------------------------------------|------------------|-------------------------| +| chaise-wide | get catalog information | model/catalog | | | +| chaise-wide | get catalog schemas information | model/schema | | | +| record | load main entity | record/main/load | | | +| | update main entity | record/main/update | | | +| | load aggregates in main entity | record/aggregate | | | +| | update aggregates in main entity | record/aggregate/update | | | +| | load inline entities | record/inline | | | +| | update inline entities | record/inline/update | | | +| | load aggregates in inline entities | record/inline/aggregate | | | +| | update aggregates in inline entities | record/inline/aggregate/update | | | +| | load related entities | record/related | referrer | | +| | update related entities | record/related/update | referrer | | +| | load aggregates in related entities | record/related/aggregate | | | +| | update aggregates in related entities | record/related/aggregate/update | | | +| | read p&b values to add | pre-create/prefill/association | | | +| | read pre selected p&b values to add | pre-create/prefill/association/disabled | | | +| | create p&b | create/prefill/association | | | +| | | | | | +| recordedit | create record | create/new | | | +| | read the foreignkey values for prefill | pre-create/prefill | | | +| | create by add button on fk modal | create/prefill | | | +| | read the current row for copy | pre-create/copy | | | +| | create record from copy | create/copy | | | +| | creating row by clicking on add in fk modal | create/modal | | | +| | read entities to be updated | pre-update | | page_size is inaccurate | +| | update entities | update | | | +| | get default value for fks | recordedit/default | | | +| | | | | | +| recordset | recordset main data read on load | recordset/main/load | | | +| recordset/record/recordedit | recordset main data read on update | recordset/main/update | | | +| recordset/record/recordedit | recordset main data read on page change | recordset/main/page | sort, page, type | | +| recordset/record/recordedit | recordset main data read on sort change | recordset/main/sort | sort | | +| recordset/record/recordedit | recordset main data read on limit change | recordset/main/limit | | | +| recordset/record/recordedit | recordset main data read on facet change | recordset/main/facet | | | +| recordset/record/recordedit | recordset get main count | recordset/main/count | | | +| recordset/record/recordedit | recordset get aggregated values | recordset/main/aggregate | | | +| recordset/record/recordedit | recordset read facet | recordset/facet | referrer, source | | +| recordset/record/recordedit | recordset initialize preselected entity facets | recordset/facet/init | referrer, source | | +| recordset/record/recordedit | recordset get buckets for a facet | recordset/facet/histogram | referrer, source | | +| recordset/record/recordedit | recordset click on show details | recordset/viewmore | referrer, source | | +| | | | | | +| record | export from recordset | export/recordset | | | +| recordset | export from record | export/record | | | +| | | | | | +| record | delete from record | delete/record | | | +| recordedit | delete from recordedit | delete/recordedit | | | +| record/recordset/recordedit | delete row from recordset table | delete/recordset | | | +| record | delete related entity rows | delete/record/related | | | +| | | | | | +| viewer | main request | viewer/main | | | +| | get annotation table | viewer/annotation | | | +| | get annotation comments | viewer/comment | | | +| | get anatomy data | viewer/anatomy | | | | ## Error Log @@ -116,7 +124,24 @@ The object that we want to log might be lengthy so we should truncate this objec ## Change Log -#### March 8, 2019 +#### March 25, 2019 + +###### Changed +- Fixed the action of scalar column requests. +- Changed the action for removing related entity rows from `delete/recordset/related` to `delete/record/related`. +- Fixed the issue of reporting both load and update requests of record page as `record/main`. Now they are being logged with proper action. +- `recordset/export` was used as action for export from both record and recordset. Now `export/record` and `export/recordset` are going to be reported. +- Fixed a bug that would cause record load requests to be reported as update. -- [Bug fix] We realized that the first request of adding pure and binary is not using the correct action. It was using the `recordset/main/load`. We changed it to use the appropriate `pre-create/prefill/association` action with `referred` information. +###### Added +- Added proper `dcctx` logging to viewer app. +- New actions have been attached to schema (`"model/schema"`) and catalog (`"model/catalog"`) requests. +- `catalog` has been added to all the requests. +- `column` has been added to requests for getting a scalar facet data. +- If there are preselected facets, in entity mode we have to get the row-name corresponding to the selected value. Customized action (`recordset/facet/init`) has been added for this request. +- Added proper action `recordset/facet/histogram` to the request for getting buckets of a range picker facet. + +#### March 8, 2019 +###### Changed + - We realized that the first request of adding pure and binary is not using the correct action. It was using the `recordset/main/load`. We changed it to use the appropriate `pre-create/prefill/association` action with `referred` information. diff --git a/record/index.html.in b/record/index.html.in index d814189b0..55bc37ced 100644 --- a/record/index.html.in +++ b/record/index.html.in @@ -45,7 +45,7 @@    - +    Share diff --git a/record/record.utils.js b/record/record.utils.js index aa41953b9..bb1f9e901 100644 --- a/record/record.utils.js +++ b/record/record.utils.js @@ -34,9 +34,10 @@ */ function _processRequests(isUpdate) { if (!_haveFreeSlot() || $rootScope.pauseRequests) return; + isUpdate = (typeof isUpdate === "boolean") ? isUpdate : false; if ($rootScope.isMainDirty) { - readMainEntity().then(function (tuple) { + readMainEntity(isUpdate).then(function (tuple) { $rootScope.isMainDirty = false; _processRequests(isUpdate); }).catch(genericErrorCatch); @@ -89,12 +90,13 @@ /** * Read data for the main entity + * @param {boolean} isUpdate whether this is update request or load * @returns {Promise} It will be resolved with Page object. */ - function readMainEntity() { + function readMainEntity(isUpdate) { var defer = $q.defer(); - - $rootScope.reference.read(1, {action: logActions.recordRead}).then(function (page) { + var action = isUpdate ? logActions.recordUpdate : logActions.recordRead; + $rootScope.reference.read(1, {action: action}).then(function (page) { $log.info("Page: ", page); /* diff --git a/recordset/index.html.in b/recordset/index.html.in index 25ee7e87b..31d931ba5 100644 --- a/recordset/index.html.in +++ b/recordset/index.html.in @@ -35,7 +35,7 @@ Edit    - +       - +    Share diff --git a/record/record.app.js b/record/record.app.js index a8b7e202d..9997efcfc 100644 --- a/record/record.app.js +++ b/record/record.app.js @@ -118,6 +118,12 @@ }).then(function (page) { var tuple = page.tuples[0]; + + // update the window location with tuple to remove query params + var url = tuple.reference.contextualize.detailed.appLink; + url = url.substring(0, url.lastIndexOf("?")); + $window.history.replaceState('', '', url); + // related references var related = $rootScope.reference.related(tuple); diff --git a/recordedit/recordEdit.app.js b/recordedit/recordEdit.app.js index df72f334d..af0a2151f 100644 --- a/recordedit/recordEdit.app.js +++ b/recordedit/recordEdit.app.js @@ -123,6 +123,8 @@ var res = UriUtils.chaiseURItoErmrestURI($window.location); var ermrestUri = res.ermrestUri, pcid = res.pcid, ppid = res.ppid; + + $rootScope.context = context; // will be used to determine the app mode (edit, create, or copy) diff --git a/recordset/index.html.in b/recordset/index.html.in index 31d931ba5..25ee7e87b 100644 --- a/recordset/index.html.in +++ b/recordset/index.html.in @@ -35,7 +35,7 @@ Edit    - +