[ML] Fix missing $applyAsync() in AnomalyExplorer and Time Series Viewer (#28237)

Part of #28189. Removes custom Promise code and fixes missing $applyAsync()s in AnomalyExplorer and Time Series Viewer.
This commit is contained in:
Walter Rafelsberger 2019-01-09 13:48:05 +01:00 committed by GitHub
parent c80870ff41
commit 5f7c9c077f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View file

@ -117,6 +117,7 @@ module.directive('mlJobSelectList', function (Private) {
} else {
$scope.noJobsCreated = true;
}
$scope.$applyAsync();
}).catch((resp) => {
console.log('mlJobSelectList controller - error getting job info from ES:', resp);
});

View file

@ -25,7 +25,6 @@ import 'plugins/ml/components/job_select_list';
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
import { parseInterval } from 'ui/utils/parse_interval';
import { initPromise } from 'plugins/ml/util/promise';
import template from './explorer.html';
import uiRoutes from 'ui/routes';
@ -66,7 +65,6 @@ uiRoutes
CheckLicense: checkFullLicense,
privileges: checkGetJobsPrivilege,
indexPatterns: loadIndexPatterns,
initPromise: initPromise(true)
}
});
@ -199,6 +197,7 @@ module.controller('MlExplorerController', function (
$scope.loading = false;
}
$scope.$applyAsync();
}).catch((resp) => {
console.log('Explorer - error getting job info from elasticsearch:', resp);
});
@ -294,6 +293,7 @@ module.controller('MlExplorerController', function (
restoreCellDataFromAppState();
updateExplorer();
}
$scope.$applyAsync();
});
};
@ -650,6 +650,7 @@ module.controller('MlExplorerController', function (
loadTopInfluencers(jobIds, earliestMs, latestMs, filterInfluencers);
}
$scope.$applyAsync();
});
}
@ -824,10 +825,12 @@ module.controller('MlExplorerController', function (
).then((resp) => {
// TODO - sort the influencers keys so that the partition field(s) are first.
$scope.influencers = resp.influencers;
$scope.$applyAsync();
console.log('Explorer top influencers data set:', $scope.influencers);
});
} else {
$scope.influencers = {};
$scope.$applyAsync();
}
}

View file

@ -50,7 +50,6 @@ import { mlFieldFormatService } from 'plugins/ml/services/field_format_service';
import { JobSelectServiceProvider } from 'plugins/ml/components/job_select_list/job_select_service';
import { mlForecastService } from 'plugins/ml/services/forecast_service';
import { mlTimeSeriesSearchService } from 'plugins/ml/timeseriesexplorer/timeseries_search_service';
import { initPromise } from 'plugins/ml/util/promise';
import {
ANNOTATIONS_TABLE_DEFAULT_QUERY_SIZE,
ANOMALIES_TABLE_DEFAULT_QUERY_SIZE
@ -69,7 +68,6 @@ uiRoutes
privileges: checkGetJobsPrivilege,
indexPatterns: loadIndexPatterns,
mlNodeCount: getMlNodeCount,
initPromise: initPromise(true)
}
});
@ -195,6 +193,7 @@ module.controller('MlTimeSeriesExplorerController', function (
$scope.loading = false;
}
$scope.$applyAsync();
}).catch((resp) => {
console.log('Time series explorer - error getting job info from elasticsearch:', resp);
});
@ -247,6 +246,10 @@ module.controller('MlTimeSeriesExplorerController', function (
$timeout(() => {
$scope.$broadcast('render');
}, 0);
} else {
// Call $applyAsync() if for any reason the upper condition doesn't trigger the $timeout.
// We still want to trigger a scope update about the changes above the condition.
$scope.$applyAsync();
}
}
@ -845,6 +848,7 @@ module.controller('MlTimeSeriesExplorerController', function (
entity.fieldValues = _.chain(resp.records).pluck('by_field_value').uniq().value();
}
});
$scope.$applyAsync();
}
});