forked from apache/pinot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TE] frontend - aaronucsd/added new custom component for Resolution
1. Added new resolution custom component 2. fixed the icon issue on resolution select for model table 3. Updated styling for the fix in apache#2 4. Added new method to anomaly util file and moved a few needed anomaly methods from app/pods/manage/alert/explore/controller.js 5. Moved anomalyResponseObj constant to anomaly util from app/pods/manage/alert/explore/route.js 6. Updated app/pods/manage/alert/explore/* to use the methods from anomaly util 7. updated anomaly util unit test and ran all tests for sanity 8. Added new api anomaly file and unit test
- Loading branch information
Long Huynh
committed
Mar 19, 2018
1 parent
a893483
commit acef124
Showing
13 changed files
with
246 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
thirdeye/thirdeye-frontend/app/pods/custom/anomalies-table/resolution/component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Custom model table component | ||
* Constructs the select box for the resolution | ||
* @module custom/anomalies-table/resolution | ||
* | ||
* @example for usage in models table columns definitions | ||
* { | ||
* propertyName: 'feedback', | ||
* component: 'custom/anomalies-table/resolution', | ||
* title: 'Resolution', | ||
* className: 'anomalies-table__column', | ||
* disableFiltering: true | ||
* }, | ||
*/ | ||
import Component from "@ember/component"; | ||
import { getWithDefault } from '@ember/object'; | ||
import * as anomalyUtil from 'thirdeye-frontend/utils/anomaly'; | ||
import { set, setProperties } from '@ember/object'; | ||
import { getAnomalyDataUrl } from 'thirdeye-frontend/utils/api/anomaly'; | ||
|
||
export default Component.extend({ | ||
tagName: '',//using tagless so i can add my own in hbs | ||
anomalyResponseNames: anomalyUtil.anomalyResponseObj.mapBy('name'), | ||
anomalyDataUrl: getAnomalyDataUrl(), | ||
|
||
actions: { | ||
/** | ||
* Handle dynamically saving anomaly feedback responses | ||
* @method onChangeAnomalyResponse | ||
* @param {Object} anomalyRecord - the anomaly being responded to | ||
* @param {String} selectedResponse - user-selected anomaly feedback option | ||
* @param {Object} inputObj - the selection object | ||
*/ | ||
onChangeAnomalyResponse: async function(anomalyRecord, selectedResponse, inputObj) { | ||
const responseObj = anomalyUtil.anomalyResponseObj.find(res => res.name === selectedResponse); | ||
set(inputObj, 'selected', selectedResponse); | ||
let res; | ||
try { | ||
// Save anomaly feedback | ||
res = await anomalyUtil.updateAnomalyFeedback(anomalyRecord.anomalyId, responseObj.value) | ||
// We make a call to ensure our new response got saved | ||
res = await anomalyUtil.verifyAnomalyFeedback(anomalyRecord.anomalyId, responseObj.status) | ||
const filterMap = getWithDefault(res, 'searchFilters.statusFilterMap', null); | ||
if (filterMap && filterMap.hasOwnProperty(responseObj.status)) { | ||
setProperties(anomalyRecord, { | ||
anomalyFeedback: selectedResponse, | ||
showResponseSaved: true | ||
}); | ||
} else { | ||
return Promise.reject(new Error('Response not saved')); | ||
} | ||
} catch (err) { | ||
setProperties(anomalyRecord, { | ||
showResponseFailed: true, | ||
showResponseSaved: false | ||
}); | ||
} | ||
} | ||
} | ||
}); |
23 changes: 23 additions & 0 deletions
23
thirdeye/thirdeye-frontend/app/pods/custom/anomalies-table/resolution/template.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div class="anomalies-table__column-cell"> | ||
{{#if record.showResponseSaved}} | ||
<i class="{{if record.showResponseSaved "te-anomaly-table__icon--status-no-margin" "te-anomaly-table__icon--hidden"}} glyphicon glyphicon-ok-circle" ></i> | ||
{{else}} | ||
<i class="{{if record.showResponseFailed "te-anomaly-table__icon--status-no-margin" "te-anomaly-table__icon--hidden"}} glyphicon glyphicon-remove-circle" ></i> | ||
{{/if}} | ||
|
||
{{#if record.isUserReported}} | ||
<span class="te-anomaly-table__text">User Reported</span> | ||
{{else}} | ||
{{#power-select | ||
triggerId=record.anomalyId | ||
triggerClass="te-anomaly-table__select te-anomaly-table__select--margin-left" | ||
options=anomalyResponseNames | ||
searchEnabled=false | ||
selected=record.anomalyFeedback | ||
onchange=(action "onChangeAnomalyResponse" record) | ||
as |response| | ||
}} | ||
{{response}} | ||
{{/power-select}} | ||
{{/if}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.