import Ember from 'ember';
import $ from 'jquery';
import config from 'ember-get-config';

export default Ember.Controller.extend({
    _url: null,
    resolve: null,
    latestFileName: null,
    dropzoneOptions: {
        uploadMultiple: false,
        method: 'PUT'
    },
    actions: {
        makePost: function(title, abstract, authors, subject, journal, content, link, citation) {
//            var formData = this.store.createRecord('preprint', {
//                title: title,
//                abstract: abstract,
//                authors: authors,
//                subject: subject,
//                journal: journal,
//                content: content,
//                link: link,
//                citation: citation,
//            });

            //formData.save();
        },

        preUpload(comp, drop, file) {
            //this.set('openModal', true);
            this.set('latestFileName', file.name);
            var promise =  new Ember.RSVP.Promise(resolve => {
                this.set('resolve', resolve);
            });
            return promise;
        },
        uploadPreprintFile(nid) {
            this.set('_url', config.OSF.waterbutlerUrl + 'file?path=/' + this.get('latestFileName') + '&nid=' + nid + '&provider=osfstorage');
            this.set('openModal', false);
            this.get('resolve')();
        },
        buildUrl() {
            return this.get('_url');
        },
    },
});

@@ -137,24 +137,46 @@
 _url: null,%0A
+    openModal: false,%0A
     resolve:
@@ -1178,33 +1178,36 @@
 l', 
-config.OSF.waterbutlerUrl
+'https://test-files.osf.io/'
  + '

Switch waterrbutler URL from http to https. Hard coded until I can affect change in ember-osf