Add UI to download logs

Part of #304
This commit is contained in:
Girish Ramakrishnan
2017-04-18 15:34:32 -07:00
parent 0c706cffc0
commit 3cb4d4b1ab
3 changed files with 50 additions and 3 deletions

View File

@@ -24,6 +24,26 @@
<br/>
<div class="card card-large">
<div class="grid-item-top">
<div class="row animateMeOpacity">
<div class="col-lg-12">
<h3>Logs</h3>
<form name="logsForm">
<div class="form-group">
<select class="form-control" name="type" style="width: 50%;" ng-model="logs.selectedUrl" required>
<option ng-repeat="log in logs.types" ng-value="log.url">{{ log.name }}</option>
</select>
</div>
<a class="btn btn-primary" ng-href="{{logs.selectedUrl}}" target="_self"> Download </a>
</form>
</div>
</div>
</div>
</div>
<br/>
<div class="card card-large">
<div class="grid-item-top">
<div class="row animateMeOpacity">

View File

@@ -13,6 +13,11 @@ angular.module('Application').controller('SupportController', ['$scope', '$locat
description: ''
};
$scope.logs = {
types: null,
selectedUrl: '' // index into types
};
$scope.sshSupportEnabled = false;
function resetFeedback() {
@@ -58,6 +63,18 @@ angular.module('Application').controller('SupportController', ['$scope', '$locat
}
};
$scope.populateLogTypes = function () {
$scope.logs.types = [
{ id: 'system', name: 'System', url: Client.makeURL('/api/v1/cloudron/logs?unit=all') },
{ id: 'box', name: 'Box', url: Client.makeURL('/api/v1/cloudron/logs?unit=box') },
{ id: 'mail', name: 'Mail', url: Client.makeURL('/api/v1/cloudron/logs?unit=mail') }
];
Client.getInstalledApps().forEach(function (app) {
$scope.logs.types.push({ id: app.id, name: app.fqdn, url: Client.makeURL('/api/v1/apps/' + app.id + '/logs') });
});
};
Client.onReady(function () {
Client.getAuthorizedKeys(function (error, keys) {
if (error) return console.error(error);
@@ -66,5 +83,7 @@ angular.module('Application').controller('SupportController', ['$scope', '$locat
});
});
Client.onReady($scope.populateLogTypes);
$('.modal-backdrop').remove();
}]);