Skip to content

Commit 2ca5750

Browse files
authored
Merge pull request #171 from Digipalvelutehdas/develop
Merging to master for release
2 parents ecc3d97 + 504f5f6 commit 2ca5750

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1698
-621
lines changed

.meteor/packages

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@ kadira:flow-router
7676
kadira:blaze-layout
7777
arillo:flow-router-helpers
7878
useraccounts:flow-routing
79+
nimble:restivus
80+
apinf:restivus-swagger
81+
kurounin:pagination-blaze
82+
kurounin:pagination

.meteor/versions

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ apinf:[email protected]
1919
2020
2121
22+
2223
2324
2425
@@ -97,6 +98,7 @@ momentjs:[email protected]
9798
9899
99100
101+
100102
101103
102104
@@ -128,6 +130,7 @@ [email protected]
128130
129131
130132
133+
131134
132135
softwarerero:[email protected]
133136

about/client/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h3>
2828
Apinf
2929
</dt>
3030
<dd>
31-
0.36.0
31+
0.37.0
3232
</dd>
3333
<dt>
3434
API Umbrella

apis/client/add/add.html

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
<template name="addApi">
2-
<div class="container">
3-
<h1 class="page-header">
4-
{{_ "addApi_header" }}
5-
</h1>
6-
{{# autoForm collection=ApisCollection id="addApiForm" type="insert" }}
7-
<!--invisible auto-value field-->
8-
{{> afQuickField name='latestMonitoringStatusCode' value="-1" type="hidden"}}
9-
<fieldset>
10-
{{> afQuickField name='name' }}
11-
{{> afQuickField name='description' rows=2 }}
12-
{{> afQuickField name='url' }}
13-
</fieldset>
14-
<button type="submit" class="btn btn-primary">
15-
{{_ 'addApi_button_text' }}
16-
</button>
17-
{{/ autoForm }}
18-
</div>
2+
{{# if Template.subscriptionsReady }}
3+
<div class="container">
4+
<h1 class="page-header">
5+
{{_ "addApi_header" }}
6+
</h1>
7+
{{# autoForm collection=ApisCollection id="addApiForm" type="insert" }}
8+
<!--invisible auto-value field-->
9+
{{> afQuickField name='latestMonitoringStatusCode' value="-1" type="hidden"}}
10+
<fieldset>
11+
{{> afQuickField name='name' }}
12+
{{> afQuickField name='description' rows=2 }}
13+
{{> afQuickField name='url' }}
14+
{{> afQuickField name='lifecycleStatus' }}
15+
{{# if organizationsExist }}
16+
{{> afQuickField name='organizationId' }}
17+
{{/ if }}
18+
</fieldset>
19+
<button type="submit" class="btn btn-primary">
20+
{{_ 'addApi_button_text' }}
21+
</button>
22+
{{/ autoForm }}
23+
</div>
24+
{{ else }}
25+
{{> spinner }}
26+
{{/ if }}
1927
</template>

apis/client/add/add.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1-
import { Apis } from "../../collection";
1+
// Meteor package import
2+
import { Template } from 'meteor/templating';
3+
// Import collections
4+
import { Organizations } from '/organizations/collection';
5+
import { Apis } from '../../collection';
6+
7+
Template.addApi.onCreated( function () {
8+
const instance = this;
9+
10+
// Subscribe to all organizations, returns only id and name
11+
instance.subscribe('allOrganizationBasicDetails');
12+
});
213

314
Template.addApi.helpers({
415
ApisCollection () {
516
// Make APIs collection available to template (i.e. autoform)
617
return Apis;
7-
}
18+
},
19+
organizationsExist () {
20+
const organizationsCount = Organizations.find().count();
21+
22+
return organizationsCount > 0;
23+
},
824
});

apis/client/add/autoform.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { Roles } from 'meteor/alanning:roles';
33
import { AutoForm } from 'meteor/aldeed:autoform';
44
import { FlowRouter } from 'meteor/kadira:flow-router';
55

6+
import { Organizations } from '/organizations/collection';
7+
import { ApiMetadata } from '/metadata/collection';
8+
69
AutoForm.hooks({
710
addApiForm: {
811
before: {
@@ -17,6 +20,36 @@ AutoForm.hooks({
1720
return api;
1821
},
1922
},
23+
after: {
24+
insert () {
25+
// Get API id
26+
const apiId = this.docId;
27+
// Get organization id
28+
const organizationId = this.insertDoc.organizationId;
29+
30+
// Find the organization document
31+
const organization = Organizations.findOne(organizationId);
32+
33+
// If organization was selected
34+
if (organization) {
35+
// Fill a object with organization information for metadata
36+
const metadataInformation = {
37+
apiBackendId: apiId,
38+
organization: {
39+
name: organization.name,
40+
description: organization.description,
41+
},
42+
contact: {
43+
name: organization.contact.person,
44+
phone: organization.contact.phone,
45+
email: organization.contact.email,
46+
},
47+
};
48+
// Create a new metadata document
49+
ApiMetadata.insert(metadataInformation);
50+
}
51+
},
52+
},
2053
onSuccess (formType, apiId) {
2154
// Redirect to newly added API
2255
FlowRouter.go('viewApi', { _id: apiId });

apis/client/view/header/header.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@
77
<h1 id="api-header">
88
{{ api.name }}
99
{{> viewApiStatus api=api width="0.4" }}
10+
1011
</h1>
12+
1113
{{# unless api.isPublic }}
12-
<span class="label label-default label-align">private</span>
14+
<span class="label label-default">
15+
{{_ "viewApiPageHeader_privateLabel_text" }}
16+
</span>
1317
{{/ unless }}
18+
&nbsp; <!--TODO: determine why these labels don't have margin -->
19+
{{> apiLifecycleStatus api=api }}
20+
1421
<ul class="list-inline view-api-meta-details">
1522
<li>
1623
<i class="fa fa-user"></i>

apis/client/view/header/header.less

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
margin-top: 0.1em;
2222
}
2323

24-
.label-align {
25-
vertical-align: text-top;
26-
}
27-
2824
.view-api-meta-details {
2925
padding-left: 0.5em;
3026
margin-left: 3.4em;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<template name="apiLifecycleStatus">
2+
<!-- show lifecycle status label -->
3+
<span class="label label-{{ labelType }}">
4+
{{ lifecycleStatus }}
5+
</span>
6+
</template>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { Template } from 'meteor/templating';
2+
import { TAPi18n } from 'meteor/tap:i18n';
3+
4+
Template.apiLifecycleStatus.helpers({
5+
labelType () {
6+
// Get reference to template instance
7+
const templateInstance = Template.instance();
8+
9+
// Placeholder for label type
10+
let labelType;
11+
12+
// Get API lifecycle status from template instance
13+
const lifecycleStatus = templateInstance.data.api.lifecycleStatus;
14+
15+
// Get label type based on lifecycle status
16+
switch (lifecycleStatus) {
17+
case 'development':
18+
labelType = 'primary';
19+
break;
20+
case 'production':
21+
labelType = 'success';
22+
break;
23+
case 'design':
24+
labelType = 'info';
25+
break;
26+
case 'testing':
27+
labelType = 'warning';
28+
break;
29+
case 'deprecated':
30+
labelType = 'danger';
31+
break;
32+
default:
33+
labelType = 'default';
34+
}
35+
return labelType;
36+
},
37+
lifecycleStatus () {
38+
// Get reference to template instahce
39+
const templateInstance = Template.instance();
40+
41+
let statusText;
42+
43+
if (templateInstance.data.api && templateInstance.data.api.lifecycleStatus) {
44+
// Get lifecycle status from API document
45+
const status = templateInstance.data.api.lifecycleStatus;
46+
47+
// Get status text translation
48+
statusText = TAPi18n.__(`apiLifecycleStatus_labelText_${status}`);
49+
} else {
50+
// Get translation text for Unknown lifecycle status
51+
statusText = TAPi18n.__('apiLifecycleStatus_labelText_unknown');
52+
}
53+
54+
return statusText;
55+
},
56+
});

0 commit comments

Comments
 (0)