Fix scope use in logs.js and terminal.js

This commit is contained in:
Girish Ramakrishnan
2018-05-07 14:33:35 -07:00
parent ed57e701bc
commit 791f5af3e0
2 changed files with 69 additions and 55 deletions

View File

@@ -94,40 +94,47 @@ app.controller('LogsController', ['$scope', '$timeout', '$location', 'Client', f
return;
}
Client.refreshConfig(function (error) {
// check version and force reload if needed
if (!localStorage.version) {
localStorage.version = status.version;
} else if (localStorage.version !== status.version) {
localStorage.version = status.version;
window.location.reload(true);
}
console.log('Running log version ', localStorage.version);
// get user profile as the first thing. this populates the "scope" and affects subsequent API calls
Client.refreshUserInfo(function (error) {
if (error) return $scope.error(error);
// check version and force reload if needed
if (!localStorage.version) {
localStorage.version = Client.getConfig().version;
} else if (localStorage.version !== Client.getConfig().version) {
localStorage.version = Client.getConfig().version;
window.location.reload(true);
}
Client.refreshInstalledApps(function (error) {
Client.refreshConfig(function (error) {
if (error) return $scope.error(error);
Client.getInstalledApps().forEach(function (app) {
$scope.logs.push({
type: 'app',
value: app.id,
name: app.fqdn + ' (' + app.manifest.title + ')',
url: Client.makeURL('/api/v1/apps/' + app.id + '/logs'),
addons: app.manifest.addons
Client.refreshInstalledApps(function (error) {
if (error) return $scope.error(error);
Client.getInstalledApps().forEach(function (app) {
$scope.logs.push({
type: 'app',
value: app.id,
name: app.fqdn + ' (' + app.manifest.title + ')',
url: Client.makeURL('/api/v1/apps/' + app.id + '/logs'),
addons: app.manifest.addons
});
});
// activate pre-selected log from query otherwise choose the first one
$scope.selected = $scope.logs.find(function (e) { return e.value === search.id; });
if (!$scope.selected) $scope.selected = $scope.logs[0];
// now mark the Client to be ready
Client.setReady();
$scope.initialized = true;
showLogs();
});
// activate pre-selected log from query otherwise choose the first one
$scope.selected = $scope.logs.find(function (e) { return e.value === search.id; });
if (!$scope.selected) $scope.selected = $scope.logs[0];
// now mark the Client to be ready
Client.setReady();
$scope.initialized = true;
showLogs();
});
});
});