How to use the ember-get-config.OSF function in ember-get-config

To help you get started, we’ve selected a few ember-get-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CenterForOpenScience / ember-osf-web / app / components / new-navbar-auth-dropdown / component.js View on Github external
/**
     * The URL to use for signup. May be overridden, eg for special campaign pages
     *
     * @property signupUrl
     * @type {String}
     */
    signupUrl: `${config.OSF.url}register`,

    serviceLinks,
    gravatarUrl: Ember.computed('user', function() {
        const imgLink = this.get('user.links.profile_image');

        return imgLink ? `${imgLink}&s=25` : '';
    }),
    host: config.OSF.url,
    user: null,
    _loadCurrentUser() {
        this.get('currentUser')
            .load()
            .then(user => this.set('user', user));
    },
    init() {
        this._super(...arguments);
        // TODO: React to changes in service/ event?
        if (this.get('session.isAuthenticated')) {
            this._loadCurrentUser();
        }
    },
    // TODO: These parameters are defined in osf settings.py; make sure ember config matches.
    allowLogin: true,
    enableInstitutions: true,
github CenterForOpenScience / ember-osf / addon / adapters / osf-adapter.js View on Github external
/*
  Base adapter class for all OSF APIv2 endpoints
 */
import Ember from 'ember';
import DS from 'ember-data';

import HasManyQuery from 'ember-data-has-many-query';
import config from 'ember-get-config';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';

export default DS.JSONAPIAdapter.extend(HasManyQuery.RESTAdapterMixin, DataAdapterMixin, {
    authorizer: 'authorizer:osf-token',
    host: config.OSF.apiUrl,
    namespace: config.OSF.apiNamespace,
    buildURL(modelName, id, snapshot, requestType) {
        // Fix issue where CORS request failed on 301s: Ember does not seem to append trailing
        // slash to URLs for single documents, but DRF redirects to force a trailing slash
        var url = this._super(...arguments);
        if (requestType === 'deleteRecord' || requestType === 'updateRecord' || requestType === 'findRecord') {
            if (snapshot.record.get('links.self')) {
                url = snapshot.record.get('links.self');
            }
        }
        if (url.lastIndexOf('/') !== url.length - 1) {
            url += '/';
        }
        return url;
    },
    /**
github CenterForOpenScience / ember-osf-web / app / components / new-osf-navbar / component.js View on Github external
*
 * Sample usage:
 * ```handlebars
 * {{osf-navbar
 *   loginAction=loginAction
 * }}
 * ```
 *
 * @class osf-navbar
 */
export default Ember.Component.extend(hostAppName, AnalyticsMixin, {
    layout,
    osfServices,
    session: Ember.inject.service(),
    serviceLinks,
    host: config.OSF.url,
    currentService: Ember.computed('hostAppName', function() { // Pulls current service name from consuming service's config file
        let appName = this.get('hostAppName') || 'Home';
        if (appName === 'Dummy App') {
            appName = 'Home';
        }
        return appName.toUpperCase();
    }),
    currentServiceLink: Ember.computed('serviceLinks', 'currentService', function() {
        const serviceMapping = {
            HOME: 'osfHome',
            PREPRINTS: 'preprintsHome',
            REGISTRIES: 'registriesHome',
            MEETINGS: 'meetingsHome',
        };
        const service = this.get('currentService');
        return this.get('serviceLinks')[serviceMapping[service]];
github CenterForOpenScience / ember-osf-web / app / services / meta-tags.ts View on Github external
getMetaTags(this: MetaTags, metaTagsOverrides: MetaTagsData): MetaTagsDefs {
        // Default values.
        const metaTagsData: MetaTagsData = {
            type: 'article',
            description: this.get('i18n').t('general.hosted_on_the_osf'),
            url: pathJoin(config.OSF.url, this.get('router').get('currentURL')),
            language: this.get('i18n').get('locale'),
            image: pathJoin(config.OSF.url, 'static/img/preprints_assets/osf/sharing.png'),
            imageType: 'image/png',
            imageWidth: 1200,
            imageHeight: 630,
            imageAlt: this.get('i18n').t('home.brand'),
            siteName: this.get('i18n').t('home.brand'),
            institution: this.get('i18n').t('general.cos'),
            fbAppId: config.FB_APP_ID,
            twitterSite: config.social.twitter.viaHandle,
            twitterCreator: config.social.twitter.viaHandle,
            ...metaTagsOverrides,
        };

        // Include URL, DOI, and any additional identifiers.
        const identifiers = toArray(metaTagsData.url)
github CenterForOpenScience / ember-osf / addon / mixins / osf-token-login-route.js View on Github external
beforeModel() {
        // TODO: Should this check for resolution of a promise?
        this._super(...arguments);

        var accessToken;
        if (config.OSF.isLocal) {
            accessToken = config.OSF.accessToken;
        } else {
            accessToken = getTokenFromHash(window.location.hash);
            if (!accessToken) {
                return null;
            }
            window.location.hash = '';
        }

        return this.get('session').authenticate('authenticator:osf-token', accessToken)
            .catch(err => Ember.Logger.log('Authentication failed: ', err));
    }
});
github CenterForOpenScience / ember-osf-preprints / tests / helpers / module-for-acceptance.js View on Github external
beforeEach() {
        this.application = startApp();
        FakeServer.start();
        manualSetup(this.application.__container__);
        const url = config.OSF.apiUrl;
        const provider = FactoryGuy.build('preprint-provider');

        stubRequest('get', url + '/v2/users/me', (request) => {
            request.unauthorized({});
        });
        stubRequest('get', url + '/v2/preprint_providers', (request) => {
            request.ok({data: [{
                attributes: provider.data.attributes,
                type: "preprint_providers",
                id: "osf"
            }]});
        });
        stubRequest('get', url + '/v2/preprint_providers/osf', (request) => {
            request.ok({data: {
                attributes: provider.data.attributes,
                type: "preprint_providers",
github CenterForOpenScience / ember-osf / addon / components / scheduled-banner / component.js View on Github external
init() {
        this._super(...arguments);

        Ember.$.ajax({
                url: `${config.OSF.apiUrl}/_/banners/current`,
                crossDomain: true
            })
            .then(({data: { attributes: attrs, links}}) => {
                this.setProperties({
                    color: attrs.color,
                    defaultAltText: attrs.default_alt_text,
                    mobileAltText: attrs.mobile_alt_text,
                    defaultPhoto: links.default_photo,
                    mobilePhoto: links.mobile_photo,
                    startDate: attrs.start_date,
                    link: attrs.link,
                    name: attrs.name,
                });
                this.get('startDate') && this.set('hidden', false);
            })
            .fail(() => {
github CenterForOpenScience / ember-osf-web / app / authenticators / osf-token.js View on Github external
_test(accessToken) {
        return $.ajax({
            method: 'GET',
            url: `${config.OSF.apiUrl}/${config.OSF.apiNamespace}/users/me/`,
            dataType: 'json',
            contentType: 'application/json',
            xhrFields: {
                withCredentials: false,
            },
            headers: {
                Authorization: `Bearer ${accessToken}`,
            },
        }).then(function(res) {
            res.data.attributes.accessToken = accessToken;
            return res.data;
        });
    },
    restore(data) {
github CenterForOpenScience / ember-osf / addon / components / file-renderer / component.js View on Github external
mfrUrl: Ember.computed('links.download', 'links.version', 'links.render', function() {
        if (this.get('links.render') != null) {
            return this.get('links.render')
        } else {
            let download = this.get('links.download');
            if (download.includes('?')) {
                download = download + '&mode=render';
            } else {
                download = download + '?direct&mode=render';
            }
            if (this.get('version')) {
                download += '&version=' + this.get('version');
            }
            const fallbackMfrRenderUrl = config.OSF.renderUrl + '?url=' + encodeURIComponent(download);
            return fallbackMfrRenderUrl;
        }
    }),
    mfrOrigin: Ember.computed('mfrUrl', function() {
github CenterForOpenScience / ember-osf-web / app / components / file-renderer / component.js View on Github external
mfrUrl: computed('download', 'version', function() {
        let download = `${this.get('download')}?direct&mode=render&initialWidth=766`;
        if (this.get('version')) {
            download += `&version=${this.get('version')}`;
        }
        return `${config.OSF.renderUrl}?url=${encodeURIComponent(download)}`;
    }),
});