Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions apis/client/export/export.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
<template name="viewApiBackendExport">
<template name="apiExport">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
{{_ "view_ApiBackend_Export_Title"}}
{{_ "apiExport_title"}}
</h2>
</div>
<div class="panel-body">
<a class="btn btn-lg btn-success" id="exportJSONConfig">{{_ "view_ApiBackend_ExportJson"}}</a>
<a class="btn btn-lg btn-success" id="exportYAMLConfig">{{_ "view_ApiBackend_ExportYaml"}}</a>
<h3>
{{_ "apiExport_api_title"}}
</h3>
<p>
{{_ "apiExport_api_description"}}
</p>
<a class="btn btn-success" id="exportJSONConfig">
{{_ "apiExport_json_button"}}
</a>
<a class="btn btn-success" id="exportYAMLConfig">
{{_ "apiExport_yaml_button"}}
</a>
<hr class="panel-hr" />
<h3>
{{_ "apiExport_proxy_title"}}
</h3>
<p>
{{_ "apiExport_proxy_description"}}
</p>
<a class="btn btn-success" id="exportJSONProxyConfig">
{{_ "apiExport_json_button"}}
</a>
<a class="btn btn-success" id="exportYAMLProxyConfig">
{{_ "apiExport_yaml_button"}}
</a>
</div>
</div>
</template>
48 changes: 47 additions & 1 deletion apis/client/export/export.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import { Template } from 'meteor/templating';
import { ProxyBackends } from '/proxy_backends/collection';

import jsyaml from 'js-yaml';

Template.viewApiBackendExport.events({
Template.apiExport.onCreated(function () {
// Get reference to template instance
const instance = this;

// Get the API Backend ID from data context
const apiId = instance.data.api._id;

// Subscribe to proxy settings for this API
instance.subscribe('apiProxySettings', apiId);
});

Template.apiExport.events({
'click #exportJSONConfig': function (event, instance) {
// Get API Backend from database collection
const api = instance.data.api;
Expand All @@ -24,6 +38,38 @@ Template.viewApiBackendExport.events({
// creates file object with content type of YAML
const file = new Blob([yaml], { type: 'application/x-yaml;charset=utf-8' });

// forces "save As" function allow user download file
saveAs(file, 'apiConfig.yaml');
},
'click #exportJSONProxyConfig': function (event, instance) {
// Get the API Backend ID from data context
const apiId = instance.data.api._id;

// Find proxy backends by API id
const proxy = ProxyBackends.findOne({ apiId });

// converts JSON object to JSON string and adds indentation
const json = JSON.stringify(proxy, null, '\t');

// creates file object with content type of JSON
const file = new Blob([json], { type: 'application/json;charset=utf-8' });

// forces "save As" function allow user download file
saveAs(file, 'apiProxyConfig.json');
},
'click #exportYAMLProxyConfig': function (event, instance) {
// Get the API Backend ID from data context
const apiId = instance.data.api._id;

// Find proxy backends by API id
const proxy = ProxyBackends.findOne({ apiId });

// converts from json to yaml
const yaml = jsyaml.safeDump(proxy);

// creates file object with content type of YAML
const file = new Blob([yaml], { type: 'application/x-yaml;charset=utf-8' });

// forces "save As" function allow user download file
saveAs(file, 'apiConfig.yaml');
},
Expand Down
2 changes: 1 addition & 1 deletion apis/client/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Router.route('/api/:_id/', function () {
// Ensure current user is authorized to view backend
Meteor.call('currentUserCanViewApi', apiBackendId, function (error, userIsAuthorized) {
if (userIsAuthorized) {
route.render('viewApiBackend');
route.render('viewApi');
route.layout('masterLayout');
} else {
Router.go('notAuthorized');
Expand Down
8 changes: 4 additions & 4 deletions apis/client/view/details/details.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template name="viewApiBackendDetails">
<template name="apiDetails">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title clearfix">
{{_ "view_ApiBackend_Details_Title"}}
{{_ "viewApi_Details_Title"}}
</h2>
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-12 api-details-block">
{{ # if api.description }}
<h3>
{{_ "viewApiBackendDetails_description_headingText" }}
{{_ "apiDetails_description_headingText" }}
</h3>
<p>
{{ api.description }}
Expand All @@ -20,7 +20,7 @@ <h3>

{{# if url }}
<h3>
{{_ "viewApiBackendDetails_baseUrl_headingText" }}
{{_ "apiDetails_baseUrl_headingText" }}
</h3>
<div class="input-group">
<input
Expand Down
4 changes: 2 additions & 2 deletions apis/client/view/details/details.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Clipboard from 'clipboard';

Template.viewApiBackendDetails.onRendered(function () {
Template.apiDetails.onRendered(function () {
// Initialize Clipboard copy button
const copyButton = new Clipboard('#copyApiUrl');

Expand All @@ -18,7 +18,7 @@ Template.viewApiBackendDetails.onRendered(function () {
});
});

Template.viewApiBackendDetails.helpers({
Template.apiDetails.helpers({
url () {
// Get reference to template instance
const instance = Template.instance();
Expand Down
28 changes: 14 additions & 14 deletions apis/client/view/header/header.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<template name="viewApiBackendPageHeader">
<template name="viewApiPageHeader">
<div class="page-head-topblock">
<div class="container">
<!-- Header -->
Expand All @@ -7,7 +7,7 @@
{{> viewApiLogo }}
<h1 class="api-name">
{{ api.name }}
{{> viewApiBackendStatus api=api width="0.4" }}
{{> viewApiStatus api=api width="0.4" }}
</h1>
<ul class="list-inline view-api-meta-details">
<li>
Expand Down Expand Up @@ -45,59 +45,59 @@ <h1 class="api-name">
<li class="active">
<a href="#api-details" data-toggle="tab">
<i class="fa fa-info-circle"></i>
{{_ "viewApiBackendNavigationMenu_details" }}
{{_ "viewApiNavigationMenu_details" }}
</a>
</li>
<li>
<a href="#api-documentation" data-toggle="tab">
<i class="fa fa-file-text"></i>
{{_ "viewApiBackendNavigationMenu_documentation" }}
{{_ "viewApiNavigationMenu_documentation" }}
</a>
</li>
<li>
<a href="#api-metadata" data-toggle="tab">
<i class="fa fa-book"></i>
{{_ "viewApiBackendNavigationMenu_metadata" }}
{{_ "viewApiNavigationMenu_metadata" }}
</a>
</li>
<li>
<a href="#api-feedback" data-toggle="tab">
<i class="fa fa-comments-o"></i>
{{_ "viewApiBackendNavigationMenu_feedback" }}
{{_ "viewApiNavigationMenu_feedback" }}
</a>
</li>
<li>
<a href="#api-backlog" data-toggle="tab">
<i class="fa fa-check-square-o"></i>
{{_ "viewApiBackendNavigationMenu_backlog" }}
{{_ "viewApiNavigationMenu_backlog" }}
</a>
</li>
{{ # if currentUser }}
{{ # if api.currentUserCanEdit }}
<li>
<a href="#api-export" data-toggle="tab">
<a href="#api-backend-export" data-toggle="tab">
Copy link
Copy Markdown
Contributor

@brylie brylie Sep 15, 2016

Choose a reason for hiding this comment

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

Small detail, but the word 'backend' was removed on purpose, please revert -- and if possible, remove Backend from the template name too.

Basically, the word 'backend' is appearing in our code quite a lot, and is not really helping improve readability. We have been removing 'backend' and 'frontend' from our user interface and code, to the extent possible.

I can remove the 'backend' from viewApiBackend and all related i18n strings, if you will just clean up this part of the code.

<i class="fa fa-cloud-download"></i>
{{_ "viewApiBackendNavigationMenu_export" }}
{{_ "viewApiNavigationMenu_export" }}
</a>
</li>

{{# if api.currentUserCanEdit }}
<li>
<a href="#api-settings" data-toggle="tab">
<i class="fa fa-cog"></i>
{{_ "viewApiBackendNavigationMenu_settings" }}
{{_ "viewApiNavigationMenu_settings" }}
</a>
</li>

{{# if proxyIsConfigured }}
<li>
<a href="#api-proxy" data-toggle="tab">
<i class="fa fa-sitemap"></i>
{{_ "viewApiBackendNavigationMenu_proxy" }}
{{_ "viewApiNavigationMenu_proxy" }}
</a>
</li>
{{/ if }}

{{ / if }}

{{ / if }}
</ul>
</div>
</div>
Expand Down
18 changes: 9 additions & 9 deletions apis/client/view/settings/settings.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template name="viewApiBackendSettings">
<template name="apiSettings">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
{{_ "viewApiBackendSettings_panelTitleAbout" }}
{{_ "apiSettings_panelTitleAbout" }}
</h2>
</div>
<div class="panel-body">
<h3>
{{_ "viewApiBackendSettings_uploadLogo_heading" }}
{{_ "apiSettings_uploadLogo_heading" }}
</h3>
<p>
{{_ "viewApiBackendSettings_uploadLogoText" }}
{{_ "apiSettings_uploadLogoText" }}
</p>
{{> uploadApiLogo api=api }}
<hr class="panel-hr" />
Expand All @@ -20,7 +20,7 @@ <h3>
{{> afQuickField name='url'}}
<div id="form-buttons">
<button type="submit" class="btn btn-success" id="save-settings">
{{_ "viewApiBackendSettigs_saveButton_text" }}
{{_ "viewApiSettigs_saveButton_text" }}
</button>
</div>
{{/autoForm}}
Expand All @@ -29,19 +29,19 @@ <h3>
<div class="panel panel-danger">
<div class="panel-heading">
<h2 class="panel-title">
{{_ "viewApiBackendSettings_panelTitleManage" }}
{{_ "apiSettings_panelTitleManage" }}
</h2>
</div>
<div class="panel-body">
<h3>{{_ "viewApiBackendSettings_deleteApiTitle" }}</h3>
<h3>{{_ "apiSettings_deleteApiTitle" }}</h3>
<p>
{{_ "viewApiBackendSettings_deleteApiText" }}
{{_ "apiSettings_deleteApiText" }}
</p>
<a
href="#"
class="btn btn-danger"
id="deleteModal">
{{_ "viewApiBackendDetails_deleteButton"}}
{{_ "apiDetails_deleteButton"}}
</a>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions apis/client/view/settings/settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Apis } from '/apis/collection';

Template.viewApiBackendSettings.events({
Template.apiSettings.events({
// event handler to execute when delete API button is clicked
'click #deleteModal': function () {
const apiId = this.api._id;
Expand All @@ -13,7 +13,7 @@ Template.viewApiBackendSettings.events({
},
});

Template.viewApiBackendSettings.helpers({
Template.apiSettings.helpers({
formCollection () {
return Apis;
},
Expand Down
2 changes: 1 addition & 1 deletion apis/client/view/status/status.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<template name="viewApiBackendStatus" >
<template name="viewApiStatus" >
<div
class="api-status-indicator-{{api._id}} api-status-color"
data-toggle="tooltip"
Expand Down
18 changes: 9 additions & 9 deletions apis/client/view/status/status.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Meteor imports
import { Template } from 'meteor/templating';

Template.viewApiBackendStatus.onCreated(function () {
Template.viewApiStatus.onCreated(function () {
// Create reference to instance
const instance = this;

Expand Down Expand Up @@ -35,28 +35,28 @@ Template.viewApiBackendStatus.onCreated(function () {
if (success.test(status.code)) {
className = 'status-success';
statusText = `
${TAPi18n.__('viewApiBackendStatus_statusMessage_Success')}
${TAPi18n.__('viewApiStatus_statusMessage_Success')}
`;
} else if (redirect.test(status.code)) {
className = 'status-success';
statusText = `
${TAPi18n.__('viewApiBackendStatus_statusMessage_ErrorCodeText')}
${TAPi18n.__('viewApiStatus_statusMessage_ErrorCodeText')}
${status.code}.
${TAPi18n.__('viewApiBackendStatus_statusMessage_RedirectError')}
${TAPi18n.__('viewApiStatus_statusMessage_RedirectError')}
`;
} else if (clientErr.test(status.code)) {
className = 'status-warning';
statusText = `
${TAPi18n.__('viewApiBackendStatus_statusMessage_ErrorCodeText')}
${TAPi18n.__('viewApiStatus_statusMessage_ErrorCodeText')}
${status.code}.
${TAPi18n.__('viewApiBackendStatus_statusMessage_ClientError')}
${TAPi18n.__('viewApiStatus_statusMessage_ClientError')}
`;
} else if (serverErr.test(status.code)) {
className = 'alert-danger';
statusText = `
${TAPi18n.__('viewApiBackendStatus_statusMessage_ErrorCodeText')}
${TAPi18n.__('viewApiStatus_statusMessage_ErrorCodeText')}
${status.code}.
${TAPi18n.__('viewApiBackendStatus_statusMessage_ServerError')}
${TAPi18n.__('viewApiStatus_statusMessage_ServerError')}
`;
}

Expand All @@ -67,7 +67,7 @@ Template.viewApiBackendStatus.onCreated(function () {
};
});

Template.viewApiBackendStatus.onRendered(function () {
Template.viewApiStatus.onRendered(function () {
// Get reference to template instance
const instance = this;

Expand Down
Loading