afterInstall: function() { return RSVP.all([ this.addBowerPackageToProject( 'froala-wysiwyg-editor', '~2.3.2' ), this.addAddonToProject( 'ember-cli-font-awesome', '^1.5.0' ) ]); } // :afterInstall
RSVP.all(promises).then(function (resources) { return RSVP.all(resources.map(function (resource) { return afterReadHook(resource, req, res); })); }).then(function (resources) {
.then(function(resources) { return RSVP.all(resources.map(function(resource) { return afterReadHook(resource, req, res); })); }, function(error) {
.then(function(resources) { return RSVP.all(resources.map(function(resource) { project(resource, fields); return afterTransform(relatedModel, resource, req, res); })); }, function(error) {
}).then(function(wipeFns){ console.log("Wiping collections:"); return RSVP.all(wipeFns); }).then(function(){
_uploadFileList: function uploadFileList(files) { this.log('Beginning upload.', {verbose: true}); return RSVP.all(files.map(throat(5, this._uploadFile.bind(this)))) .then(this._getReleaseFiles.bind(this)); },
.then(function(resources) { return RSVP.all(resources.map(function(resource) { return adapter.create(model, resource); })); }, function(errors) {
return scraper.getItems(Item.modelName).then(function (items) { return RSVP.all(items.map(function (item) { // -> item is serialized here. return Item.upsert(new Item(item)); })); }).then(function (items) {
}).then(function (grades) { log.info('Aggregated %d grades.', numberAffected(grades)); stream.write('\n'); log.info('Downloading schedules...'); // store a schedule queue = async.queue(function (task, callback) { var item = task.item; RSVP.all(task.lessons.map(function (lesson) { return models.Lesson.upsert(lesson); })).catch(function (err) { if (err.name === 'VersionError') log.error('Concurrency issues!'); log.error('Failed to insert lessons for %d -', item._id, err); }).then(function (lessons) { log.debug('Updated %d of %d lessons for %s [%s]', numberAffected(lessons), lessons.length, item._id, item.type); return models.Schedule.upsert(new models.Schedule({ lessons: _.pluck(lessons, 'product') })); }).then(function (schedule) { schedules.push(schedule); // set generated schedule id item.schedule = schedule.product._id; return item.promisedSave(); }).then(function () { callback(); }, function (err) { log.error('Failed to insert schedule for %d -', item._id, err); }); }, 1); return RSVP.all(models.items.map(function (Item) { var ItemLesson = models[Item.modelName + 'Lesson']; return Item.find().exec() .then(function (items) { // items = [Student|...] // execute http requests with a max concurrency of 5 return flow.asyncMap(items, function (item) { return scraper.getLessons(Item.modelName, item.toObject()) // for some reason, when using `.then(Lesson.x)` it doesn't work. .then(function (lessons) { return ItemLesson.serialize(lessons); }).then(function (lessons) { var task = { item: item, lessons: lessons.map(function (lesson) { // create new lesson and cast to general lesson return new models.Lesson(new ItemLesson(lesson)); }) }; queue.push(task); return task.lessons.length; }); }, 5); // first parse lessons - then store the schedule. }).then(function (schedules) { var updated = schedules.length; log.debug('Downloaded %d schedules [%s]', updated, Item.modelName); return updated; }); })).catch(function (err) { log.error('Failed to download schedules -', err); }); }).then(function (schedules) {
return function(arr) { return rsvp.all(arr.map(fn)) }
import Helper from '@ember/component/helper'; import RSVP from 'rsvp'; export default Helper.extend({ compute(...promises) { return RSVP.all(promises); }, });
return function(arr) { return rsvp.all(arr.map(fn)).then(function(objs) { return objs.map(function(obj, i) { return [ arr[i], obj ] }) }) }
SJH.all = function (promises) { /* From Axios - https://github.com/mzabriskie/axios/ */ return RSVP.all(promises); };
return true; } }, becameReady() { // This absorbs became ready in case it's not handled elsewhere }, showAbout() { this.controllerFor('application').set('showAbout', true); }, switchProject(projectId, transitionTo = 'authenticated', transitionArgs) { // console.log('Switch to Project:' + projectId); PromiseAll([ get(this, 'scope.subscribeProject').disconnect(), ]).then(() => { // console.log('Switch is disconnected'); this.send('finishSwitch', `project:${ projectId }`, transitionTo, transitionArgs); }); }, finishSwitch(id, transitionTo, transitionArgs) { // console.log('Switch finishing'); const cookies = get(this, 'cookies'); var [whichCookie, idOut] = id.split(':'); get(this, 'storeReset').reset(); if ( transitionTo ) {
import { all } from 'rsvp'; import Route from '@ember/routing/route'; import activeState from "last-strawberry/constants/active-states"; const MODEL_INCLUDES = [ "locations", "locations.company" ]; export default Route.extend({ setupController(controller, model) { controller.set("locations", this.store.peekAll("location")); controller.set("item", this.store.peekAll("item")); this._super(controller, model); }, model() { return all([ this.store.query("company", { "filter[active_state]":activeState.ACTIVE, "filter[is_customer]":true, include:MODEL_INCLUDES.join(",")}), this.store.query("item", {"filter[is_sold]":true}) ]); }, actions: { locationSelected(id) { this.transitionTo('standing-orders.location', id); } } });
this.events.on('save', function(instance, data, options) { return RSVP.all(_.map(instance.model._joinHandlers, function(handler) { return handler.func(instance, data, options); })); });
store: service(), queryParams: { region: { refreshModel: true, }, }, resetController(controller, isExiting) { if (isExiting) { controller.set('error', null); } }, beforeModel(transition) { return RSVP.all([this.get('system.regions'), this.get('system.defaultRegion')]).then( promises => { if (!this.get('system.shouldShowRegions')) return promises; const queryParam = transition.queryParams.region; const defaultRegion = this.get('system.defaultRegion.region'); const currentRegion = this.get('system.activeRegion') || defaultRegion; // Only reset the store if the region actually changed if ( (queryParam && queryParam !== currentRegion) || (!queryParam && currentRegion !== defaultRegion) ) { this.get('system').reset(); this.get('store').unloadAll(); }
.then(() => this.addPreprocessorImport()); }, addDependencies() { let dependencies = this.project.dependencies(); let promises = [ ]; if ('ember-cli-sass' in dependencies) { promises.push(this.addPackageToProject('bootstrap-sass', bs3Version)); } else { promises.push(this.addBowerPackageToProject('bootstrap', bs3Version)); } return rsvp.all(promises); }, addPreprocessorImport() { let dependencies = this.project.dependencies(); let type; let importStatement = '\n@import "ember-bootstrap/bootstrap";\n'; if ('ember-cli-sass' in dependencies) { type = 'scss'; } else if ('ember-cli-less' in dependencies) { type = 'less'; } if (type) { let stylePath = path.join('app', 'styles');
} if (!get(clusterSubscribe, 'wasConnected')) { clusterReset = true; } if ( project !== projectOld ) { if ( project ) { set(projectStore, 'baseUrl', `${get(this, 'app.apiEndpoint')}/projects/${projectId}`); } cleanupPromises.push(projectSubscribe.disconnect()); projectReset = true; } return all(cleanupPromises).then(() => { if ( clusterReset ) { clusterStore.reset(); if ( cluster && connect ) { clusterSubscribe.connect(true, clusterId, projectId); } } if ( projectReset ) { projectStore.reset(); if ( project && connect ) { projectSubscribe.connect(true, clusterId, projectId); } } }); },
doProjectActions() { const { primaryResource } = this; const { projectsToAddOnUpgrade, projectsToRemoveOnUpgrade } = this; const promises = []; if (projectsToAddOnUpgrade && projectsToAddOnUpgrade.length > 0) { promises.push(primaryResource.doAction('addProjects', { projects: projectsToAddOnUpgrade.map((p) => get(p, 'projectId')) })); } if (projectsToRemoveOnUpgrade && projectsToRemoveOnUpgrade.length > 0) { promises.push(primaryResource.doAction('removeProjects', { projects: projectsToRemoveOnUpgrade.map((p) => get(p, 'projectId')) })); } if (promises.length > 0) { return all(promises) .then(() => { return true; }) .catch((/* handled by growl error */) => { return false; }); } else { return true; } }, doneSaving() { return this.router.transitionTo('global-admin.multi-cluster-apps'); },
.then(function(resources) { return RSVP.all(resources.map(function(resource) { var t = afterTransform(resource, req, res); return t; })); }, function(error) {
})).then(function (schemasWithDescArray) { return RSVP.all(schemasWithDescArray.map(function (schemaWithDesc) { return writeSchemaToFile(schemaWithDesc.name, schemaWithDesc.schema); })); }).then(resolve);
throw err; } }), }); }, afterModel(model) { const { tab } = this.paramsFor(this.routeName); const backend = this.enginePathParam(); if (!tab || tab !== 'certs') { return; } return all( // these ids are treated specially by vault's api, but it's also // possible that there is no certificate for them in order to know, // we fetch them specifically on the list page, and then unload the // records if there is no `certificate` attribute on the resultant model ['ca', 'crl', 'ca_chain'].map(id => this.store.queryRecord('pki-certificate', { id, backend })) ).then( results => { results.rejectBy('certificate').forEach(record => record.unloadRecord()); return model; }, () => { return model; } ); }, setupController(controller, resolvedModel) { let secretParams = this.paramsFor(this.routeName);
reader.onload = (res) => { var out = res.target.result; resolve(out); }; reader.onerror = (err) => { get(this, 'growl').fromError(get(err, 'srcElement.error.message')); reject(err); }; reader.readAsText(file); })); } all(promises).then((res) => { if ( this.isDestroyed || this.isDestroying ) { return; } let value = res.join('\n'); set(this, 'value', value); if ( value ) { if (this.fileChosen) { this.fileChosen(); } } }).finally(() => { input.value = ''; });
import { get } from '@ember/object'; import RSVP from 'rsvp'; import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller'; import { translationMacro as t } from 'ember-i18n'; export default AbstractDeleteController.extend({ title: t('incident.titles.deleteIncident'), _deleteChildObject(incident, childObject, destroyPromises) { incident.get(childObject).then(function(childObject) { childObject.forEach(function(child) { destroyPromises.push(child.destroyRecord()); // Add the destroy promise to the list }); }); }, actions: { delete() { let destroyPromises = []; let incident = get(this, 'model'); this._deleteChildObject(incident, 'notes', destroyPromises); RSVP.all(destroyPromises).then(function() { // fires when all the destroys have been completed. get(this, 'model').destroyRecord().then(function() { // delete incident this.send('closeModal'); }.bind(this)); }.bind(this)); } } });
*/ findAll(resource) { return this.find(`${this.baseUrl}/${resource}`); }, /** * Fetch multiple records by making concurrent requests. * * @public * @function findMany * @param {string[]} urls * * @returns {Promise} */ findMany(urls = []) { return all(urls.map(url => this.find(url))); }, /** * Fetch record by resource name and id. * * @public * @function findRecord * @param {string} resource * @param {string} id * * @returns {Promise} */ findRecord(resource, id) { return this.find(`${this.baseUrl}/${resource}/${id}`); },
.then(function(resources) { if (!resources) return; return RSVP.all(resources.map(function(resource) { return afterWriteHook(modelName, resource, req, res); })); }, function(error) {
this.list().then(fileNames => { var promises = fileNames.map(this.find, this); RSVP.all(promises).then(resolve); }).catch(reject);
findPromise.then(function(resources) { return RSVP.all(resources.map(function(resource) { return afterReadHook(relatedModel, resource, req, res); })); }, function(error) {
if (!isEmpty(lookupListsToUpdate)) { lookupListsToUpdate.forEach((list) => { let propertyValue = get(this, get(list, 'property')); let lookupListToUpdate = get(this, get(list, 'name')); if (!isEmpty(propertyValue)) { if (!isEmpty(lookupListToUpdate) && lookupListToUpdate.then) { lookupPromises.push(lookupListToUpdate.then((lookupList) => { return this._checkListForUpdate(list, lookupList, listsToUpdate, propertyValue); })); } else { this._checkListForUpdate(list, lookupListToUpdate, listsToUpdate, propertyValue); } } }); if (!isEmpty(lookupPromises)) { return RSVP.all(lookupPromises).then(() => { let lookupLists = get(this, 'lookupLists'); let updatePromises = []; listsToUpdate.forEach((list) =>{ updatePromises.push(list.save().then(() => { set(this, 'lookupListsLastUpdate', new Date().getTime()); lookupLists.resetLookupList(get(list, 'id')); })); }); return RSVP.all(updatePromises); }); } } return RSVP.resolve(); },