Skip to content

Commit

Permalink
[ML] Fix missing $applyAsync() in AnomalyExplorer and Time Series Vie…
Browse files Browse the repository at this point in the history
…wer (#28237) (#28339)

Part of #28189. Removes custom Promise code and fixes missing $applyAsync()s in AnomalyExplorer and Time Series Viewer.
  • Loading branch information
walterra authored Jan 9, 2019
1 parent a79a845 commit aafab73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
7 changes: 5 additions & 2 deletions x-pack/plugins/ml/public/explorer/explorer_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -64,7 +63,6 @@ uiRoutes
CheckLicense: checkFullLicense,
privileges: checkGetJobsPrivilege,
indexPatterns: loadIndexPatterns,
initPromise: initPromise(true)
}
});

Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -291,6 +290,7 @@ module.controller('MlExplorerController', function (
restoreCellDataFromAppState();
updateExplorer();
}
$scope.$applyAsync();
});
};

Expand Down Expand Up @@ -647,6 +647,7 @@ module.controller('MlExplorerController', function (

loadTopInfluencers(jobIds, earliestMs, latestMs, filterInfluencers);
}
$scope.$applyAsync();
});
}

Expand Down Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -67,7 +66,6 @@ uiRoutes
privileges: checkGetJobsPrivilege,
indexPatterns: loadIndexPatterns,
mlNodeCount: getMlNodeCount,
initPromise: initPromise(true)
}
});

Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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();
}

}
Expand Down Expand Up @@ -843,6 +846,7 @@ module.controller('MlTimeSeriesExplorerController', function (
entity.fieldValues = _.chain(resp.records).pluck('by_field_value').uniq().value();
}
});
$scope.$applyAsync();
}

});
Expand Down

0 comments on commit aafab73

Please sign in to comment.