diff --git a/.meteor/packages b/.meteor/packages index 32d2a4ab4a..b9b3073748 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -90,3 +90,4 @@ peppelg:bootstrap-3-modal apinf:api-umbrella standard-minifier-css standard-minifier-js +vsivsi:file-collection diff --git a/.meteor/versions b/.meteor/versions index 0c06339990..89ac6bce97 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -92,7 +92,7 @@ iron:core@1.0.11 iron:dynamic-template@1.0.12 iron:layout@1.0.12 iron:location@1.0.11 -iron:middleware-stack@1.0.11 +iron:middleware-stack@1.1.0 iron:router@1.0.12 iron:url@1.0.11 jparker:crypto-core@0.1.0 @@ -186,6 +186,7 @@ url@1.0.9 useraccounts:bootstrap@1.14.2 useraccounts:core@1.14.2 useraccounts:iron-routing@1.14.2 +vsivsi:file-collection@1.3.5 webapp@1.2.8 webapp-hashing@1.0.9 yogiben:autoform-file@0.4.2 diff --git a/both/collections/apiDocs.js b/both/collections/apiDocs.js deleted file mode 100644 index 41bae588bb..0000000000 --- a/both/collections/apiDocs.js +++ /dev/null @@ -1,28 +0,0 @@ -ApiDocs = new Mongo.Collection('apiDocs'); - -ApiDocs.allow({ - insert: function () { - return true; - }, - update: function () { - return true; - }, - remove: function () { - return true; - } -}); - -ApiDocs.helpers({ - getApiBackendName: function () { - // Get API Backend ID - var apiBackendId = this.apiBackendId; - - // Get API Backend - var apiBackend = ApiBackends.findOne(apiBackendId); - - // Get API Backend name - var apiBackendName = apiBackend.name; - - return apiBackendName; - } -}); diff --git a/both/collections/apiDocumentation.js b/both/collections/apiDocumentation.js deleted file mode 100644 index 8134904751..0000000000 --- a/both/collections/apiDocumentation.js +++ /dev/null @@ -1,36 +0,0 @@ -/*jshint -W020 */ -ApiDocumentation = new FS.Collection("apiDocumentation", { - // TODO: Determine how to upload files within the project directory - // without hardcoding FS path - stores: [ - new FS.Store.GridFS("apiDocumentation") - ], -}); - -ApiDocumentation.filters({ - allow: { - // ~ 10Mbs. - maxSize: 10048567, - extensions: ['json', 'yaml', 'txt', 'swagger'] - }, - onInvalid: function (message) { - // Show error message if it doesn't pass filter settings - FlashMessages.sendError(message); - } -}); - -if (Meteor.isServer) { - ApiDocumentation.allow({ - insert: function (/*userId, doc*/) { - // allow insert by default - // TODO: determine proper upload/insert permisison - return true; - }, - update: function (/*userId, doc*/) { - return true; - }, - download: function(/*userId, fileObj*/) { - return true; - } - }); -} diff --git a/both/collections/backend.js b/both/collections/backend.js index a0c226d933..6fa7c150e1 100644 --- a/both/collections/backend.js +++ b/both/collections/backend.js @@ -31,6 +31,10 @@ Schemas.ApiBackendsSchema = new SimpleSchema({ type: String, optional: false }, + documentationFileId: { + type: String, + optional: true + }, documentation_link: { type: String, optional: true, diff --git a/both/collections/settings.js b/both/collections/settings.js index cc30220630..887fa2da74 100644 --- a/both/collections/settings.js +++ b/both/collections/settings.js @@ -18,15 +18,7 @@ Schemas.SettingsSchema = new SimpleSchema({ type: String, regEx: SimpleSchema.RegEx.Url, label: "Host", - optional: true, // Optional must be true for custom validation - custom: function () { // Custom validator logic - // get the value of apiDocumentationEditor.enabled field - let enabledFieldValue = this.field("apiDocumentationEditor.enabled").value; - // if enabled is true, host field is required - if (enabledFieldValue === true) { - return "required"; // host field is required - } - } + optional: false }, apiUmbrella: { type: Object, diff --git a/client/layouts/master_layout/sidebar/sidebar.html b/client/layouts/master_layout/sidebar/sidebar.html index 5f8ee7be8b..092e5c30a2 100644 --- a/client/layouts/master_layout/sidebar/sidebar.html +++ b/client/layouts/master_layout/sidebar/sidebar.html @@ -34,22 +34,6 @@ {{_ "masterLayout_sidebar_Catalogue"}} {{# if currentUser }} -
{{_ "apiDocumentationSelect_noApiDocumentation"}}
- {{/if}} - {{/if}} - diff --git a/client/views/documentation/select/select.js b/client/views/documentation/select/select.js deleted file mode 100644 index a31f0009f6..0000000000 --- a/client/views/documentation/select/select.js +++ /dev/null @@ -1,19 +0,0 @@ -Template.apiDocumentationSelect.created = function () { - // Get reference to template instance - var instance = this; - - // Subscribe to All API Documentation - instance.subscribe('allApiDocs'); - - // Subscribe to API backends with Docs - instance.subscribe('apiBackendsWithDocs'); -}; - -Template.apiDocumentationSelect.helpers({ - "apiDocumentation": function () { - // Get API Documentation - var apiDocumentationArray = ApiDocs.find().fetch(); - - return apiDocumentationArray; - } -}); diff --git a/client/views/documentation/view/documentation.css b/client/views/documentation/view/documentation.css deleted file mode 100644 index 802694d554..0000000000 --- a/client/views/documentation/view/documentation.css +++ /dev/null @@ -1,10 +0,0 @@ -/* - Make sure iframe is full height and width - source: http://stackoverflow.com/a/27853830/1191545 -*/ -iframe { - display: block; /* iframes are inline by default */ - border: none; /* Reset default border */ - width: 100%; - height: 100vh; -} diff --git a/client/views/documentation/view/documentation.html b/client/views/documentation/view/documentation.html deleted file mode 100644 index 760f1dac5c..0000000000 --- a/client/views/documentation/view/documentation.html +++ /dev/null @@ -1,4 +0,0 @@ - - {{> apiDocumentationSelect }} - - diff --git a/client/views/documentation/view/documentation.js b/client/views/documentation/view/documentation.js deleted file mode 100644 index da799755e3..0000000000 --- a/client/views/documentation/view/documentation.js +++ /dev/null @@ -1,59 +0,0 @@ -Template.documentation.created = function () { - // Get reference to template instance - var instance = this; - - // Create Reactive Variable for selected documentation - instance.swaggerDocumentUrl = new ReactiveVar(); -}; - -Template.documentation.rendered = function () { - $(function() { - // Pass window url parameters into documentation IFRAME - // http://stackoverflow.com/a/12944835/1191545 - - // Get search parameter(s) from window location - var search = window.location.search; - - // Create new iframe src by appending search parameter(s) - var newSrc = $("#documentation").attr("src") + search; - - // Update iframe src attribute with new source - $("#documentation").attr("src", newSrc); - }); -}; - -Template.documentation.events({ - "change [name='selected-documentation']": function (event) { - // Get reference to template instance - var instance = Template.instance(); - - // Set Swagger document URL to selected value - instance.swaggerDocumentUrl.set(event.target.value); - }, - "load #documentation": function () { - - // gets current users object - var user = Meteor.user(); - - // gets current user's apiKey - var apiKey = user.profile.apiKey; - - // passes api key to iFrame once it is loaded - $("#documentation").contents().find("#input_apiKey").val(apiKey); - - // Click Explore to attach API key to "Try out" request - $("#documentation").contents().find("#explore").click(); - } -}); - -Template.documentation.helpers({ - "swaggerDocumentUrl": function () { - // Get reference to template instance - var instance = Template.instance(); - - // Get the Swagger document URL - var swaggerDocumentUrl = instance.swaggerDocumentUrl.get(); - - return swaggerDocumentUrl; - } -}); diff --git a/documentation/collection/collection.js b/documentation/collection/collection.js new file mode 100644 index 0000000000..02711ca36e --- /dev/null +++ b/documentation/collection/collection.js @@ -0,0 +1,17 @@ +const DocumentationFiles = FileCollection({ + resumable: true, + resumableIndexName: 'test', + http: [ + { + method: 'get', + path: '/md5/:md5', + lookup: function(params, query) { + return { + md5: params.md5 + }; + } + } + ] +}); + +export { DocumentationFiles }; diff --git a/documentation/collection/server/permissions.js b/documentation/collection/server/permissions.js new file mode 100644 index 0000000000..962767ec91 --- /dev/null +++ b/documentation/collection/server/permissions.js @@ -0,0 +1,16 @@ +import { DocumentationFiles } from '/documentation/collection/collection'; + +DocumentationFiles.allow({ + insert: function(userId, file) { + return Roles.userIsInRole(userId, ['manager']); + }, + remove: function(userId, file) { + return Roles.userIsInRole(userId, ['manager']); + }, + read: function(userId, file) { + return true; + }, + write: function(userId, file, fields) { + return true; + } +}); diff --git a/client/views/documentation/documentation-editor/documentation-editor.html b/documentation/design/client/documentation-editor.html similarity index 100% rename from client/views/documentation/documentation-editor/documentation-editor.html rename to documentation/design/client/documentation-editor.html diff --git a/client/views/documentation/documentation-editor/documentation-editor.js b/documentation/design/client/documentation-editor.js similarity index 100% rename from client/views/documentation/documentation-editor/documentation-editor.js rename to documentation/design/client/documentation-editor.js diff --git a/documentation/manage/client/autoform.js b/documentation/manage/client/autoform.js new file mode 100644 index 0000000000..d82f996578 --- /dev/null +++ b/documentation/manage/client/autoform.js @@ -0,0 +1,5 @@ +AutoForm.addHooks(['apiBackendDocumentationLinkForm'], { + onSuccess: function () { + sAlert.success(TAPi18n.__('manageApiDocumentationModal_LinkField_Updated_Message')); + } +}); diff --git a/documentation/manage/client/manage.css b/documentation/manage/client/manage.css new file mode 100644 index 0000000000..6cf980800f --- /dev/null +++ b/documentation/manage/client/manage.css @@ -0,0 +1,3 @@ +.documentation-file { + margin-bottom: 2em; +} diff --git a/documentation/manage/client/manage.html b/documentation/manage/client/manage.html new file mode 100644 index 0000000000..0997332444 --- /dev/null +++ b/documentation/manage/client/manage.html @@ -0,0 +1,51 @@ + +