harleyjj commented on a change in pull request #5593:
URL: https://github.com/apache/incubator-pinot/pull/5593#discussion_r445312041
##########
File path: thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js
##########
@@ -27,213 +21,44 @@ export default Route.extend(AuthenticatedRouteMixin, {
model() {
return hash({
- applications: fetch('/thirdeye/entity/APPLICATION').then(checkStatus),
- detectionAlertConfig:
fetch('/detection/subscription-groups').then(checkStatus),
- polishedDetectionYaml: fetch('/yaml/list').then(checkStatus)
+ polishedDetectionYaml:
fetch(yamlAPI.getPaginatedAlertsUrl()).then(checkStatus),
+ rules: fetch(entityMappingApi.getRulesUrl)
+ .then(checkStatus)
+ .then(rules => rules.map(r => r.type))
});
},
afterModel(model) {
this._super(model);
- // Fetch all the detection alerts
- const alerts = model.polishedDetectionYaml;
- for (let yamlAlert of alerts) {
- let dimensions = '';
- let dimensionsArray = yamlAlert.dimensionExploration ?
yamlAlert.dimensionExploration.dimensions : null;
- if (Array.isArray(dimensionsArray)) {
- dimensionsArray.forEach(dim => {
- dimensions = dimensions + `${dim}, `;
- });
- dimensions = dimensions.substring(0, dimensions.length-2);
- }
- Object.assign(yamlAlert, {
- functionName: yamlAlert.name,
- collection: yamlAlert.datasetNames.toString(),
- granularity: yamlAlert.monitoringGranularity.toString(),
- type: this._detectionType(yamlAlert),
- exploreDimensions: dimensions,
- filters: formatYamlFilter(yamlAlert.filters),
- isNewPipeline: true
- });
- }
+ const alertsFromResponse = (model.polishedDetectionYaml || {}).elements;
- // Iterate through detection alerter to enhance all yaml alert with extra
properties (group name, application)
- for (let subscriptionGroup of model.detectionAlertConfig){
- const detectionConfigIds = subscriptionGroup.detectionConfigIds;
- for (let id of detectionConfigIds) {
- let foundAlert = alerts.find(yamlAlert => yamlAlert.id === id);
- if (foundAlert) {
- Object.assign(foundAlert, {
- application: foundAlert.application ? foundAlert.application + ",
" + subscriptionGroup.application : subscriptionGroup.application,
- group: foundAlert.group ? foundAlert.group + ", " +
subscriptionGroup.name : subscriptionGroup.name
- });
- }
- }
- }
- // Perform initial filters for our 'primary' filter types and add counts
- const user = getWithDefault(get(this, 'session'),
'data.authenticated.name', null);
- const myAlertIds = user ? this._findAlertIdsByUserGroup(user,
model.detectionAlertConfig) : [];
- const ownedAlerts = alerts.filter(alert => alert.createdBy === user);
- const subscribedAlerts = alerts.filter(alert =>
myAlertIds.includes(alert.id));
- const totalCounts = [subscribedAlerts.length, ownedAlerts.length,
alerts.length];
- // Add these filtered arrays to the model (they are only assigne once)
- Object.assign(model, { alerts, ownedAlerts, subscribedAlerts, totalCounts
});
- },
+ const alerts = enrichAlertResponseObject(alertsFromResponse);
- setupController(controller, model) {
+ let user = getWithDefault(get(this, 'session'), 'data.authenticated.name',
null);
+ let token = config.userNameSplitToken;
- // This filter category is "global" in nature. When selected, they reset
the rest of the filters
- const filterBlocksGlobal = [
- {
- name: 'primary',
- type: 'link',
- preventCollapse: true,
- totals: model.totalCounts,
- selected: ['All alerts'],
- filterKeys: ['Alerts I subscribe to', 'Alerts I own', 'All alerts']
- }
- ];
+ user = user ? user.split(token)[0] : user;
Review comment:
@jihaozh Here, we can extract the username by setting userNameSplitToken
to '@' in environment.js
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]