-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #473 from AlbertRossJoh/feature/exn-api-to-frontend
Dashboard with Exceptions as json
- Loading branch information
Showing
8 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from flask_monitoringdashboard.database.exception_info import get_exceptions_with_timestamps | ||
|
||
def get_exceptions_with_timestamp(session): | ||
""" | ||
:param session: session for the database | ||
:param endpoints: a list of endpoints, encoded by their name | ||
:return: for every endpoint in endpoints, a list with the performance | ||
""" | ||
|
||
return [ | ||
{ | ||
'type': exception.exception_type, | ||
'message': exception.exception_msg, | ||
'timestamp': exception.time_requested | ||
} | ||
for exception in get_exceptions_with_timestamps(session) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
flask_monitoringdashboard/frontend/js/controllers/exceptionInfo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// dette er frontend, husk "npm run build" fra frontend/ for at kunne se dine ændringer | ||
// Opsætning første gang: npm install --save-dev webpack webpack-cli babel-loader @babel/core @babel/preset-env | ||
|
||
export function ExceptionController ($scope, $http, menuService, endpointService) { | ||
endpointService.reset(); | ||
// Hvis værdien 'new_dashboard' nedenfor ændres skal den også ændres i menuService, men den bruges ingen andre steder | ||
menuService.reset('new_dashboard'); // Fokus når man klikker på den i menuen (den bliver hvid og de andre bliver grå) | ||
|
||
// Route http://127.0.0.1:4200/dashboard/new_dashboard sættes i frontend/app.js | ||
|
||
$scope.message = "Welcome to the New Dashboard!"; // scope bruges i static/pages/new_dashboard.html | ||
$scope.table = []; | ||
// Hvis static/pages/new_dashboard.html filen skal renames, skal frontend/app.js lige opdateres | ||
|
||
/* | ||
API og frontend virker til at køre på samme port så vidt jeg har forstået, og API routing specificeres i view layer | ||
API specificeres lige nu i views/endpoint.py som bruger metoder fra database/ core/ og controllers/ | ||
vi bør rykke API ud i en views/excpetion.py i stedet, men da jeg selv forsøgte dette kunne http://127.0.0.1:4200/dashboard/api/exception_info ikke findes | ||
filer der muliggør API lige nu (fra bunden og op): | ||
database/exception_info -> controllers/exceptions -> views/endpoint.py --api--> frontend/js/controllers/exceptionInfo.js | ||
*/ | ||
$http.get('api/exception_info').then(function (response) { | ||
console.log("DATA START"); | ||
console.log(response.data); | ||
console.log("DATA SLUT"); | ||
$scope.table = response.data; | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div> | ||
<h1>New Dashboard</h1> | ||
<p>{{ message }}</p> | ||
<p>{{ table }}</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters