1
0
Fork 0
mirror of https://github.com/mmumshad/ansible-playable.git synced 2025-02-13 10:11:53 +00:00
ansible-playable/client/app/admin/admin.controller.js
2017-07-11 11:58:56 -04:00

41 lines
1.1 KiB
JavaScript

'use strict';
export default class AdminController {
/*@ngInject*/
constructor($scope, $sce, User, system, ansi2html) {
'ngInject';
const admin_ctrl = this;
// Use the User $resource to fetch all users
this.users = User.query();
/**
* Fetch Server Logs
*/
this.fetchServerLogs = function(){
system.getLogs('server', (response) => {
admin_ctrl.logsServer = $scope.result = $sce.trustAsHtml(ansi2html.toHtml(response.data).replace(/\n/g, "<br>"));
}, (response) => {
admin_ctrl.logsServer = $scope.result = $sce.trustAsHtml(ansi2html.toHtml(response.data).replace(/\n/g, "<br>"));
});
};
/**
* Fetch API Logs
*/
this.fetchAPILogs = function(){
system.getLogs('api', (response) => {
admin_ctrl.logsAPI = $scope.result = $sce.trustAsHtml(ansi2html.toHtml(response.data).replace(/\n/g, "<br>"));
}, (response) => {
admin_ctrl.logsAPI = $scope.result = $sce.trustAsHtml(ansi2html.toHtml(response.data).replace(/\n/g, "<br>"));
})
}
}
delete(user) {
user.$remove();
this.users.splice(this.users.indexOf(user), 1);
}
}