Skip to content

Commit e129b0b

Browse files
committed
Merge pull request #400 from apinf/feature/export-functionality
Feature/export functionality
2 parents ab8e6e4 + 13e6404 commit e129b0b

File tree

6 files changed

+47
-4
lines changed

6 files changed

+47
-4
lines changed

.meteor/packages

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ frenchbread:dynatable
6464
brylie:api-umbrella
6565
bevanhunt:leaflet
6666
brylie:leaflet-heat
67+
pfafman:filesaver
6768
mizzao:sharejs-ace
6869
raix:ui-dropped-event
6970
brylie:accounts-admin-ui
71+
brylie:first-user-admin

.meteor/versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ [email protected]
113113
114114
115115
116+
116117
117118
118119

client/layouts/master_layout/sidebar.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
<li class="{{isActiveRoute 'documentation'}}">
3636
<a href="/documentation"><i class="fa fa-book"></i><span>Documentation</span></a>
3737
</li>
38-
{{/if}}
3938
{{# if isInRole 'admin' }}
4039
+ <li class="{{isActiveRoute 'accountsAdmin'}}">
4140
+ <a href="{{pathFor route='accountsAdmin'}}"><i class="fa fa-users"></i><span>Users</span></a>

client/views/api_backends/view_api_backend/view_api_backend.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ <h2>URL Matchers</h2>
4444
</ul>
4545
{{/each}}
4646
</div>
47+
<div class="row">
48+
<h2>Export API configurations</h2>
49+
<a class="btn btn-lg btn-success" id="exportJSONConfig">Export .json</a>
50+
<a class="btn btn-lg btn-success" id="exportYAMLConfig">Export .yaml</a>
51+
</div>
4752
</div>
4853
</div>
4954
</template>

client/views/api_backends/view_api_backend/view_api_backend.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Template.viewApiBackend.created = function() {
88

99
// Subscribe to a single API Backend, by ID
1010
instance.subscribe("apiBackend", backendId);
11-
1211
};
1312

1413
Template.viewApiBackend.rendered = function () {
@@ -50,3 +49,42 @@ Template.viewApiBackend.rendered = function () {
5049
});
5150

5251
};
52+
53+
Template.viewApiBackend.events({
54+
'click #exportJSONConfig' : function () {
55+
56+
// Get API Backend ID from URL
57+
var apiBackendId = Router.current().params._id;
58+
59+
// Get API Backend from database collection
60+
var apiBackend = ApiBackends.findOne(apiBackendId);
61+
62+
// converts JSON object to JSON string and adds indentation
63+
var json = JSON.stringify(apiBackend, null, '\t');
64+
65+
// creates file object with content type of JSON
66+
var file = new Blob([json], {type: "application/json;charset=utf-8"});
67+
68+
// forces "save As" function allow user download file
69+
saveAs(file, "apiConfig.json");
70+
},
71+
'click #exportYAMLConfig' : function () {
72+
73+
// Get API Backend ID from URL
74+
var apiBackendId = Router.current().params._id;
75+
76+
// Get API Backend from database collection
77+
var apiBackend = ApiBackends.findOne(apiBackendId);
78+
79+
// converts from json to yaml
80+
var yaml = jsyaml.safeDump(apiBackend);
81+
82+
// creates file object with content type of YAML
83+
var file = new Blob([yaml], {type: "application/x-yaml;charset=utf-8"});
84+
85+
// forces "save As" function allow user download file
86+
saveAs(file, "apiConfig.yaml");
87+
}
88+
});
89+
90+

server/startup.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ Meteor.startup(function () {
1515
Meteor.call("syncApiUmbrellaUsers");
1616
Meteor.call("syncApiBackends");
1717

18-
Meteor.call("createAdminRoleIfNotDefined");
19-
2018
});
2119

2220
SyncedCron.start();

0 commit comments

Comments
 (0)