Skip to content

Commit

Permalink
#1815 Add a platform status page
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Mar 4, 2021
1 parent 543ef49 commit 14a678c
Show file tree
Hide file tree
Showing 7 changed files with 383 additions and 6 deletions.
2 changes: 2 additions & 0 deletions frontend/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<script src="scripts/controllers/admin/organisation/OrgModalCtrl.js"></script>
<script src="scripts/controllers/admin/organisation/OrgUserModalCtrl.js"></script>
<script src="scripts/controllers/admin/organisation/OrgUsersCtrl.js"></script>
<script src="scripts/controllers/admin/platform/PlatformStatusCtrl.js"></script>
<script src="scripts/controllers/admin/profile/ProfileListCtrl.js"></script>
<script src="scripts/controllers/admin/profile/ProfileModalCtrl.js"></script>
<script src="scripts/controllers/admin/taxonomy/TaxonomyListCtrl.js"></script>
Expand Down Expand Up @@ -306,6 +307,7 @@
<script src="scripts/services/api/MispSrv.js"></script>
<script src="scripts/services/api/ObservableTypeSrv.js"></script>
<script src="scripts/services/api/OrganisationSrv.js"></script>
<script src="scripts/services/api/PlatformSrv.js"></script>
<script src="scripts/services/api/ProcedureSrv.js"></script>
<script src="scripts/services/api/ProfileSrv.js"></script>
<script src="scripts/services/api/TagSrv.js"></script>
Expand Down
15 changes: 15 additions & 0 deletions frontend/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,21 @@ angular.module('thehive', [
url: 'administration',
template: '<ui-view/>'
})
.state('app.administration.platform', {
url: '/platform',
templateUrl: 'views/partials/admin/platform/status.html',
controller: 'PlatformStatusCtrl',
controllerAs: '$vm',
title: 'Platform administration',
resolve: {
appConfig: function(VersionSrv) {
return VersionSrv.get();
}
},
guard: {
permissions: ['managePlatform']
}
})
.state('app.administration.profiles', {
url: '/profiles',
templateUrl: 'views/partials/admin/profile/list.html',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
(function() {
'use strict';

angular.module('theHiveControllers').controller('PlatformStatusCtrl', function(PlatformSrv, NotificationSrv, appConfig) {
var self = this;

self.appConfig = appConfig;
self.indexStatus = {};
self.checkStats = {};

self.loading = {
index: false,
check: false
}

this.loadIndexStatus = function() {
self.indexStatus = {};
self.loading.index = true;

PlatformSrv.getIndexStatus()
.then(function(response) {
self.indexStatus = response.data;
self.loading.index = false;
});
}

this.loadCheckStats = function() {
self.loading.check = true;

PlatformSrv.getCheckStats()
.then(function(response) {
self.checkStats = response.data;
self.loading.check = false;
})
}

this.$onInit = function() {
self.loadIndexStatus();
self.loadCheckStats();
};

this.exportReport = function() {
var date = new moment().format('YYYYMMDD-HH:mmZ');
var fileName = 'Platform-Status-Report-'+date+'.json';


var content = {
indexStatus: self.indexStatus,
checkStatus: self.checkStats,
schemaStatus: self.appConfig.schemaStatus
};

// Create a blob of the data
var fileToSave = new Blob([JSON.stringify(content)], {
type: 'application/json',
name: fileName
});

// Save the file
saveAs(fileToSave, fileName);
}

this.reindex = function(indexName) {
PlatformSrv.runReindex(indexName)
.then(function(response) {
NotificationSrv.log('Reindexing of ' + indexName + ' started sucessfully', 'success');
});
};

this.checkControl = function(checkName) {
PlatformSrv.runCheck(checkName)
.then(function(response) {
NotificationSrv.log('Integrity check of ' + checkName + ' started sucessfully', 'success');
});
}

});
})();
23 changes: 23 additions & 0 deletions frontend/app/scripts/services/api/PlatformSrv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(function() {
'use strict';
angular.module('theHiveServices')
.service('PlatformSrv', function($http) {

this.getIndexStatus = function() {
return $http.get('./api/v1/admin/index/status')
}

this.runReindex = function(indexName) {
return $http.get('./api/v1/admin/index/'+indexName+'/reindex');
}

this.getCheckStats = function() {
return $http.get('./api/v1/admin/check/stats')
}

this.runCheck = function(checkName) {
return $http.get('./api/v1/admin/check/'+checkName+'/trigger');
}

});
})();
95 changes: 94 additions & 1 deletion frontend/app/styles/flex-table.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
div.flex-header {
/* div.flex-header {
background-color: #fff;
border-bottom: 2px solid #ecf0f5;
font-size: 16px;
Expand Down Expand Up @@ -114,4 +114,97 @@ div.flex-header > div.flex-col.flex-icon {
div.flex-row > div.flex-col.flex-icon i,
div.flex-header > div.flex-col.flex-icon i {
margin-right: 5px;
} */

div.flex-header {
background-color: #fff;
border-bottom: 2px solid #ecf0f5;
font-size: 16px;
padding-top: 8px;
padding-bottom: 8px;
}
div.flex-row:hover {
border: 1px dotted #3c8dbc !important;
}
div.flex-row, div.flex-header {
display: flex;
justify-content: space-between;
align-items: stretch;
}
div.flex-row:nth-child(odd), div.flex-header:nth-child(odd) {
background: #f9f9f9;
border: 1px dotted #f9f9f9;
}
div.flex-row:nth-child(even), div.flex-header:nth-child(even) {
background: #ecf0f5;
border: 1px dotted #ecf0f5;
}
div.flex-row > div.flex-col, div.flex-header > div.flex-col {
margin: 0 5px;
padding: 4px;
}
div.flex-row > div.flex-col .label.label-lg, div.flex-header > div.flex-col .label.label-lg {
font-size: 13px;
font-weight: normal;
line-height: 1;
}
div.flex-row > div.flex-col > *, div.flex-header > div.flex-col > * {
flex: 1;
}
div.flex-row > div.flex-col > span.label, div.flex-header > div.flex-col > span.label {
flex: none;
}
div.flex-row > div.flex-col.vertical, div.flex-header > div.flex-col.vertical {
display: flex;
align-items: center;
}
div.flex-row > div.flex-col.vertical.centered, div.flex-header > div.flex-col.vertical.centered {
justify-content: center;
}
div.flex-row > div.flex-col:first-child, div.flex-header > div.flex-col:first-child {
margin-left: 0;
}
div.flex-row > div.flex-col:last-child, div.flex-header > div.flex-col:last-child {
margin-right: 0;
}
div.flex-row > div.flex-col.flex-1, div.flex-header > div.flex-col.flex-1 {
flex: 1;
}
div.flex-row > div.flex-col.flex-2, div.flex-header > div.flex-col.flex-2 {
flex: 2;
}
div.flex-row > div.flex-col.flex-3, div.flex-header > div.flex-col.flex-3 {
flex: 3;
}
div.flex-row > div.flex-col.flex-4, div.flex-header > div.flex-col.flex-4 {
flex: 4;
}
div.flex-row > div.flex-col.flex-5, div.flex-header > div.flex-col.flex-5 {
flex: 5;
}
div.flex-row > div.flex-col.flex-w-80, div.flex-header > div.flex-col.flex-w-80 {
width: 80px;
}
div.flex-row > div.flex-col.flex-w-100, div.flex-header > div.flex-col.flex-w-100 {
width: 100px;
}
div.flex-row > div.flex-col.flex-w-120, div.flex-header > div.flex-col.flex-w-120 {
width: 120px;
}
div.flex-row > div.flex-col.flex-w-150, div.flex-header > div.flex-col.flex-w-150 {
width: 150px;
}
div.flex-row > div.flex-col.flex-w-200, div.flex-header > div.flex-col.flex-w-200 {
width: 200px;
}
div.flex-row > div.flex-col.flex-icon, div.flex-header > div.flex-col.flex-icon {
padding-left: 10px;
padding-right: 10px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
div.flex-row > div.flex-col.flex-icon i, div.flex-header > div.flex-col.flex-icon i {
margin-right: 5px;
}
11 changes: 6 additions & 5 deletions frontend/app/views/components/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@
<span class="hpad5">ATT&CK Patterns</span>
</a>
</li>
<!-- <li>
<a ui-sref="app.administration.ui-settings">
<i class="fa fa-cogs"></i>
<span class="hpad5">UI settings</span>
<li class="divider"></li>
<li>
<a ui-sref="app.administration.platform">
<i class="fa fa-wrench"></i>
<span class="hpad5">Platform Status</span>
</a>
</li> -->
</li>
</ul>
</li>

Expand Down
Loading

0 comments on commit 14a678c

Please sign in to comment.