Skip to content

Commit

Permalink
Merge pull request #3608 from apinf/develop
Browse files Browse the repository at this point in the history
release 0.57.0
  • Loading branch information
ilarimikkonen committed Oct 31, 2018
2 parents f9ad3c7 + c177d89 commit a98dfb0
Show file tree
Hide file tree
Showing 95 changed files with 5,365 additions and 82 deletions.
2 changes: 1 addition & 1 deletion apinf_packages/about/client/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h3>
Apinf
</dt>
<dd>
0.56.3
0.57.0
</dd>
<dt>
API Umbrella
Expand Down
2 changes: 1 addition & 1 deletion apinf_packages/analytics/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ Meteor.startup(() => {

if (proxies.length > 0 && proxyBackendsCount > 0) {
// Restart all cron tasks are related to fetching Analytics Data
Meteor.call('restartAnalyticsDataCron');
// Meteor.call('restartAnalyticsDataCron');
}
});
2 changes: 1 addition & 1 deletion apinf_packages/api_catalog/client/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ FlowRouter.route('/apis', {
}],
name: 'apiCatalog',
action: () => {
BlazeLayout.render('masterLayout', { main: 'apiCatalog' });
BlazeLayout.render('masterLayout', { bar: 'navbar', main: 'apiCatalog' });
},
});

Expand Down
2 changes: 1 addition & 1 deletion apinf_packages/api_docs/client/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import { FlowRouter } from 'meteor/kadira:flow-router';
FlowRouter.route('/documentation/editor', {
name: 'apiDocumentationEditor',
action () {
BlazeLayout.render('masterLayout', { main: 'apiDocumentationEditor' });
BlazeLayout.render('masterLayout', { bar: 'navbar', main: 'apiDocumentationEditor' });
},
});
4 changes: 2 additions & 2 deletions apinf_packages/apis/client/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FlowRouter.route('/apis/new', {
// Check if API exists
Meteor.call('currentUserCanAddApi', (error, canAdd) => {
if (canAdd) {
BlazeLayout.render('masterLayout', { main: 'addApi' });
BlazeLayout.render('masterLayout', { bar: 'navbar', main: 'addApi' });
} else {
FlowRouter.go('forbidden');
}
Expand Down Expand Up @@ -60,7 +60,7 @@ FlowRouter.route('/apis/:slug/', {
// Ensure current user has permissions to view backend
Meteor.call('currentUserCanViewApi', slug, (canViewError, userCanViewApi) => {
if (userCanViewApi) {
BlazeLayout.render('masterLayout', { main: 'viewApi' });
BlazeLayout.render('masterLayout', { bar: 'navbar', main: 'viewApi' });
} else {
// User is not allowed to view API
FlowRouter.go('forbidden');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Copyright 2017 Apinf Oy
This file is covered by the EUPL license.
You may obtain a copy of the licence at
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 -->

<template name="apiSettingsAnalytics">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
<i class="fa fa-bar-chart" aria-hidden="true"></i>
API Analytics
</h2>
</div>
<div class="panel-body">
{{# autoForm id="updateApiAnalytics" type="normal" schema=updateAnalyitcsSchema }}
<fieldset>
{{> afQuickField type="hidden" name='proxyBackendId' value=proxyBackend._id }}
{{> afQuickField type="hidden" name='lastDay' value='today' }}
{{> afQuickField name='daysCount' }}
</fieldset>
<button type="submit" class="btn btn-success">
Update
</button>
{{/ autoForm }}
</div>
</div>
</template>
31 changes: 31 additions & 0 deletions apinf_packages/apis/client/profile/settings/analytics/analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* Copyright 2017 Apinf Oy
This file is covered by the EUPL license.
You may obtain a copy of the licence at
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 */

import { Template } from 'meteor/templating';

// Meteor contributed packages imports
import { SimpleSchema } from 'meteor/aldeed:simple-schema';

Template.apiSettingsAnalytics.helpers({
// Schema for SDK Code Generator form
updateAnalyitcsSchema () {
// Create simple schema for sdk modal
return new SimpleSchema({
proxyBackendId: {
type: String,
optional: false,
},
lastDay: {
type: String,
optional: false,
},
daysCount: {
label: 'Days Count',
type: Number,
optional: false,
},
});
},
});
53 changes: 53 additions & 0 deletions apinf_packages/apis/client/profile/settings/analytics/autoform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* Copyright 2017 Apinf Oy
This file is covered by the EUPL license.
You may obtain a copy of the licence at
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 */

import { Meteor } from 'meteor/meteor';
// Meteor packages imports
import { AutoForm } from 'meteor/aldeed:autoform';
import { TAPi18n } from 'meteor/tap:i18n';
import { sAlert } from 'meteor/juliancwirko:s-alert';

AutoForm.addHooks('updateApiAnalytics', {
onSubmit (formValues) {
// Get reference to form
const form = this;

// Prevent form from submitting
form.event.preventDefault();

if (formValues.daysCount < 1) {
// The value has to be more than 0. Display error
// Get error message translation
const message = TAPi18n.__('sdkCodeGeneratorModal_errorTextInvalidHost');

// Alert user of error
sAlert.error(message, { timeout: 'none' });

form.done(new Error(message));
} else {
Meteor.call('proxyBackendAnalyticsData',
formValues.proxyBackendId, formValues.daysCount, formValues.lastDay, (error) => {
if (error) {
// The value has to be more than 0. Display error
// Get error message translation
const message = TAPi18n.__('sdkCodeGeneratorModal_errorTextInvalidHost');

// Alert user of error
sAlert.error(message, { timeout: 'none' });

form.done(new Error(message));
}
// The value has to be more than 0. Display error
// Get error message translation
const message = TAPi18n.__('sdkCodeGeneratorModal_errorTextInvalidHost');

// Alert user of error
sAlert.success(message);

form.done();
});
}
},
});
9 changes: 8 additions & 1 deletion apinf_packages/apis/client/profile/settings/settings.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Copyright 2017 Apinf Oy
<!-- Copyright 2018 Apinf Oy
This file is covered by the EUPL license.
You may obtain a copy of the licence at
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 -->
Expand All @@ -10,5 +10,12 @@

{{> apiSettingsVisibility api=api }}

<!--- from feature/mqtt-dashboard -->
{{> apiMonitoring api=api }}

{{# if displayAnalyticsSettings }}
{{> apiSettingsAnalytics proxyBackend=proxyBackend }}
{{/ if }}

{{> apiSettingsDelete api=api }}
</template>
21 changes: 21 additions & 0 deletions apinf_packages/apis/client/profile/settings/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* Copyright 2017 Apinf Oy
This file is covered by the EUPL license.
You may obtain a copy of the licence at
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 */

// Meteor packages imports
import { Template } from 'meteor/templating';

// Collections import
import Settings from '/apinf_packages/settings/collection';


Template.apiSettings.helpers({
displayAnalyticsSettings () {
const proxyBackend = Template.currentData().proxyBackend;
const settings = Settings.findOne();

// Display block if "Development Features" is enablemd and API is connected to Proxy
return settings && settings.developmentFeatures && proxyBackend;
},
});
2 changes: 1 addition & 1 deletion apinf_packages/apis/client/profile/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
{{/ if }}

<div id="api-settings" class="tab-pane fade">
{{> apiSettings api=api }}
{{> apiSettings api=api proxyBackend=proxyBackend }}
</div>
{{/ if }}
{{/ if }}
Expand Down
8 changes: 6 additions & 2 deletions apinf_packages/apis/client/profile/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ Template.viewApi.onCreated(function () {

// Subscribe to public proxy details
templateInstance.subscribe('proxyCount');
// Subscribe to public proxy details for proxy form
templateInstance.subscribe('publicProxyDetails');
// Subscribe to public proxy details (particular type)
templateInstance.subscribe('publicProxyDetails', 'apiUmbrella');
// Subscribe to Settings "supportsGraphql"
templateInstance.subscribe('singleSetting', 'supportsGraphql');
// Subscribe to development Features settings
templateInstance.subscribe('singleSetting', 'developmentFeatures');

// Using to get updated subscription
templateInstance.autorun(() => {
Expand Down
6 changes: 3 additions & 3 deletions apinf_packages/branding/client/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ import signedIn from '/apinf_packages/core/client/lib/router';
signedIn.route('/settings/branding', {
name: 'branding',
action () {
BlazeLayout.render('masterLayout', { main: 'branding' });
BlazeLayout.render('masterLayout', { bar: 'navbar', main: 'branding' });
},
});

FlowRouter.route('/privacy-policy', {
name: 'privacyPolicy',
action () {
BlazeLayout.render('masterLayout', { main: 'privacyPolicy' });
BlazeLayout.render('masterLayout', { bar: 'navbar', main: 'privacyPolicy' });
},
});

FlowRouter.route('/terms-of-use', {
name: 'termsOfUse',
action () {
BlazeLayout.render('masterLayout', { main: 'termsOfUse' });
BlazeLayout.render('masterLayout', { bar: 'navbar', main: 'termsOfUse' });
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
}

.dropdown-toggle {
background-color: {{ mostReadableBackground }} !important;
color: {{ primaryColorText }} !important;
background-color: {{ mostReadableBackground }};
color: {{ primaryColorText }};
}

.project-name-link {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{> customStylesheet }}
{{# if Template.subscriptionsReady }}
<div class="master-layout">
{{> navbar branding=branding }}
{{> Template.dynamic template=bar data=branding }}
<div class="content-wrapper">
{{> Template.dynamic template=main }}
{{> sAlert }}
Expand Down
6 changes: 3 additions & 3 deletions apinf_packages/core/client/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ const signedIn = FlowRouter.group({
FlowRouter.route('/not-authorized', {
name: 'notAuthorized',
action () {
BlazeLayout.render('masterLayout', { main: 'notAuthorized' });
BlazeLayout.render('masterLayout', { bar: 'navbar', main: 'notAuthorized' });
},
});

// Define 403 route
FlowRouter.route('/forbidden', {
name: 'forbidden',
action () {
BlazeLayout.render('masterLayout', { main: 'forbidden' });
BlazeLayout.render('masterLayout', { bar: 'navbar', main: 'forbidden' });
},
});

// Define 404 route
FlowRouter.notFound = {
action () {
BlazeLayout.render('masterLayout', { main: 'notFound' });
BlazeLayout.render('masterLayout', { bar: 'navbar', main: 'notFound' });
},
};

Expand Down
8 changes: 8 additions & 0 deletions apinf_packages/core/client/navbar/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
{{/ if }}
{{/ if }}
{{/ if }}
{{# if userCanViewMqttDashboard }}
<li>
<a href="{{ pathFor 'mqtt' }}">
<i class="fa fa-area-chart" aria-hidden="true"></i>
{{_ "navbar_mqttDashboard" }}
</a>
</li>
{{/ if }}
<li class="{{ isActiveRoute 'apiCatalog' }}">
<a href="{{ pathFor 'apiCatalog' }}" id="apis-button">
<i class="fa fa-book" aria-hidden="true"></i>
Expand Down
13 changes: 13 additions & 0 deletions apinf_packages/core/client/navbar/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Template.navbar.onCreated(function () {
// Subscribe to project logo
templateInstance.subscribe('projectLogo');
templateInstance.subscribe('proxyCount');
templateInstance.subscribe('emqProxyCount');

templateInstance.autorun(() => {
// Check if user is logged in
Expand Down Expand Up @@ -158,6 +159,18 @@ Template.navbar.helpers({
// By default allowing all user to add an API
return true;
},
userCanViewMqttDashboard () {
// Get current user Id
const userId = Meteor.userId();
// User is admin
const userIsAdmin = Roles.userIsInRole(userId, ['admin']);

// Get count of EMQ Proxies
const proxyCount = Counts.get('emqProxyCount');

// Can view if he is Admin and Emq Proxy is defined
return userIsAdmin && proxyCount > 0;
},
});

Template.navbar.events({
Expand Down

0 comments on commit a98dfb0

Please sign in to comment.