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

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 14:32:04 +01:00 committed by GitHub
parent a79a845556
commit aafab73465
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';
@ -64,7 +63,6 @@ uiRoutes
CheckLicense: checkFullLicense,
privileges: checkGetJobsPrivilege,
indexPatterns: loadIndexPatterns,
initPromise: initPromise(true)
}
});
@ -196,6 +194,7 @@ module.controller('MlExplorerController', function (
$scope.loading = false;
}
$scope.$applyAsync();
}).catch((resp) => {
console.log('Explorer - error getting job info from elasticsearch:', resp);
});
@ -291,6 +290,7 @@ module.controller('MlExplorerController', function (
restoreCellDataFromAppState();
updateExplorer();
}
$scope.$applyAsync();
});
};
@ -647,6 +647,7 @@ module.controller('MlExplorerController', function (
loadTopInfluencers(jobIds, earliestMs, latestMs, filterInfluencers);
}
$scope.$applyAsync();
});
}
@ -821,10 +822,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

@ -49,7 +49,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
@ -67,7 +66,6 @@ uiRoutes
privileges: checkGetJobsPrivilege,
indexPatterns: loadIndexPatterns,
mlNodeCount: getMlNodeCount,
initPromise: initPromise(true)
}
});
@ -193,6 +191,7 @@ module.controller('MlTimeSeriesExplorerController', function (
$scope.loading = false;
}
$scope.$applyAsync();
}).catch((resp) => {
console.log('Time series explorer - error getting job info from elasticsearch:', resp);
});
@ -245,6 +244,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();
}
}
@ -843,6 +846,7 @@ module.controller('MlTimeSeriesExplorerController', function (
entity.fieldValues = _.chain(resp.records).pluck('by_field_value').uniq().value();
}
});
$scope.$applyAsync();
}
});