Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display API monitoring history #3533

Merged
merged 14 commits into from
Aug 7, 2018
Merged

Display API monitoring history #3533

merged 14 commits into from
Aug 7, 2018

Conversation

vinaytech
Copy link
Collaborator

@vinaytech vinaytech commented Jul 26, 2018

Closes #3521

Changes

Describe your changes here as a bulleted list:

  • change in file monitoring collection and permission to remove the bug
  • change now save date in response object

Developer checklist

This checklist is to be completed by the PR developer:

  • Alternative solutions were compared/discussed before writing code
    • trade-offs with this solution are considered acceptable
  • Code in this PR adheres to the project styleguide
  • This pull request does not decrease project test coverage
  • If the code changes existing database collection(s), migration has been written
  • If UI texts are added or changed, all texts are internationalized

Reviewer checklist

Reviewed by: @55

This list is to be completed by the pull request reviewer:

  • Code works as described/expected
  • Code seems to be error free
    • no browser console errors visible
    • no server console errors visible
    • passes CI build
  • Code is written in a way that promotes maintainability
    • easy to understand
    • well organized
    • follows project coding standards and conventions
    • well documented

@ghost ghost assigned vinaytech Jul 26, 2018
@ghost ghost added the in progress label Jul 26, 2018
@vinaytech vinaytech removed their assignment Jul 26, 2018
@55 55 self-requested a review July 26, 2018 11:02
Copy link
Contributor

@55 55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solution is incomplete. Table is missing. Please check this #3521 (comment).

@ghost ghost assigned vinaytech Jul 31, 2018
@55
Copy link
Contributor

55 commented Aug 1, 2018

@matleppa review the code, I will do the layout.

@55 55 requested a review from matleppa August 1, 2018 11:25
Copy link
Member

@matleppa matleppa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes needed.
In addition to that, I commented the issue 3521 about inputting here only (API base path and) the endpoint. And about displaying the endpoint in monitoring table.

Meteor.publish('getApiStatuRecordsData', (apiId) => {
// Make sure apiId is a string
check(apiId, String);
// Find all API Backends
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change comment to be:
Find monitoring data from previous 24 hours

// Find all API Backends
const startDate = new Date();
const lastDate = new Date();
lastDate.setDate(lastDate.getDate() - 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get only last 24 hours
--> lastDate.setDate(lastDate.getDate() - 1);

@@ -11,6 +11,17 @@ import { check } from 'meteor/check';
import Apis from '/apinf_packages/apis/collection';
import { MonitoringData } from '/apinf_packages/monitoring/collection';

Meteor.publish('getApiStatuRecordsData', (apiId) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'getApiStatuRecordsData'
-->
'getApiStatusRecordData'

@@ -145,6 +145,7 @@
"apiIntro_steps_settings_intro": "Edit API settings from this tab. You can also delete API here.",
"apiIntro_steps_welcome_intro": "Welcome",
"apiIntro_skipLabel": "Skip",
"apiIntro_steps_monitoring_data": "Monitoring data",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--> "Start and stop API monitoring. When monitoring is on, the response statuses during latest 24 hours are displayed."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace value "Monitoring data" with text "Start and stop API monitoring. When monitoring is on, the response statuses during latest 24 hours are displayed."


{{> afQuickField name='enabled' }}
{{# if apiMonitoringSettings.enabled }}
<h2 style="font-size:1.4em;margin-top:0;">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use style classes instead of direct style in element.

<h2 style="font-size:1.4em;margin-top:0;">
Status Messages
</h2>
<p style="color:#6d859e;">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use style classes instead of direct style in element.

</tbody>
</table>

<hr style="color: rgba(59, 59, 88, 0.15); margin-right: -20px; margin-left: -20px; margin-top: 2em; margin-bottom: 2em;">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use style classes instead of direct style in element.

<h3 style="font-size:16px; margin-top:0;">
{{_ "apiMonitoring_panelTitle_Monitoring" }}
</h3>
<p style="color:#6d859e;">{{_ "apiMonitoring_helpIcon_text" }}</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use style classes instead of direct style in element.

@@ -18,8 +18,8 @@ Template.apiMonitoring.onCreated(function () {

// Subscribe on Monitoring collection
instance.subscribe('monitoringSettings', apiId);
instance.subscribe('getApiStatuRecordsData', apiId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'getApiStatuRecordsData'
-->
'getApiStatusRecordData'


MonitoringData.allow({
insert () {
// Get API document
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary comment

// Get API ID
const apiId = this.api._id;
const monitoringDatas = MonitoringData.findOne({ apiId });
return monitoringDatas.responses;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add checking and return monitoringDatas.responses only in case monitoringData was found.

@@ -28,6 +28,10 @@
{{> apiFeedback api=api feedbackItems=feedbackItems }}
</div> <!-- /api-feedback -->

<div id="api-monitoring" class="tab-pane fade">
{{> apiMonitoring api=api }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two space indentation.

Historical data on API availability
</p>
<table id="rtable">
<tr>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct indentations to two spaces.

<label for="endpoint-monitor-field">
{{ afFieldLabelText name='url' }}
</label>
{{> afFieldInput name='url' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary indentation.

Copy link
Member

@matleppa matleppa Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary indentation for the input field.

@import "/apinf_packages/core/client/style/bootstrap-variables.less";

#rtable {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct indentations to two spaces.

…d with data = false is found, create a record for API in question into MonitoringData and fill the id of created record into field data in MonitoringSettings.
Copy link
Member

@matleppa matleppa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality seems to be correct. I also verified, that the migration works as expected.
Good work!

There still are a few minor findings. After you have corrected them, I'll approve this PR.

In original issue there are comments about displaying also the endpoint, against what the API status is checked.
I'll make another issue about them, so we get this one closed.

@@ -11,6 +11,17 @@ import { check } from 'meteor/check';
import Apis from '/apinf_packages/apis/collection';
import { MonitoringData } from '/apinf_packages/monitoring/collection';

Meteor.publish('getApiStatuRecordData', (apiId) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getApiStatuRecordData
-->
getApiStatusRecordData

@@ -145,6 +145,7 @@
"apiIntro_steps_settings_intro": "Edit API settings from this tab. You can also delete API here.",
"apiIntro_steps_welcome_intro": "Welcome",
"apiIntro_skipLabel": "Skip",
"apiIntro_steps_monitoring_data": "Monitoring data",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace value "Monitoring data" with text "Start and stop API monitoring. When monitoring is on, the response statuses during latest 24 hours are displayed."

<label for="endpoint-monitor-field">
{{ afFieldLabelText name='url' }}
</label>
{{> afFieldInput name='url' }}
Copy link
Member

@matleppa matleppa Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary indentation for the input field.

@@ -18,8 +18,8 @@ Template.apiMonitoring.onCreated(function () {

// Subscribe on Monitoring collection
instance.subscribe('monitoringSettings', apiId);
instance.subscribe('getApiStatuRecordData', apiId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getApiStatuRecordData
-->
getApiStatusRecordData

Copy link
Member

@matleppa matleppa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality as expected.

@matleppa matleppa changed the title Apinf/monitoring history 3521 Display API monitoring history Aug 6, 2018
@matleppa
Copy link
Member

matleppa commented Aug 6, 2018

@55 Please have a look at this PR 3533. If your change requests are met, please approve them so I can merge the PR.
I have created another issue about monitoring endpoint changes (input & display), so they are outside of scope of this PR.

@55 55 merged commit 21329cc into develop Aug 7, 2018
@ghost ghost removed the Ready for review label Aug 7, 2018
@55 55 deleted the apinf/monitoring-history-3521 branch August 7, 2018 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants