Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return o;
}
// BEGIN-SNIPPET modal-fun-controller
import { task, timeout, taskGroup } from 'ember-concurrency';
let PAUSE_FOREVER = Ember.RSVP.defer().promise;
export default Ember.Controller.extend({
openWizard: task({
perform: function * () {
this.get('stepOne').perform();
yield PAUSE_FOREVER;
},
states: taskGroup().restartable(),
currentState: alias('states.last'),
next: taskByName('next'),
prev: taskByName('prev'),
stepOne: state({
title: "Step 1",
next: 'stepTwo',
index: 0,
}),
stepTwo: state({
perform: function * () {
while (true) {
yield timeout(500);
this.set('title', reverse(this.title));
import { computed } from '@ember/object';
import Controller from '@ember/controller';
import { taskGroup } from 'ember-concurrency';
// BEGIN-SNIPPET task-groups
export default Controller.extend({
everything: taskGroup(),
everythingDropped: taskGroup().drop(),
everythingEnqueue: taskGroup().enqueue(),
everythingRestart: taskGroup().restartable(),
everythingDropped3: taskGroup().maxConcurrency(3).drop(),
everythingEnqueue3: taskGroup().maxConcurrency(3).enqueue(),
everythingRestart3: taskGroup().maxConcurrency(3).restartable(),
taskGroups: computed(function () {
return [
this.get('everything'),
this.get('everythingDropped'),
this.get('everythingEnqueue'),
this.get('everythingRestart'),
this.get('everythingDropped3'),
this.get('everythingEnqueue3'),
this.get('everythingRestart3'),
];
import { computed } from '@ember/object';
import Controller from '@ember/controller';
import { taskGroup } from 'ember-concurrency';
// BEGIN-SNIPPET task-groups
export default Controller.extend({
everything: taskGroup(),
everythingDropped: taskGroup().drop(),
everythingEnqueue: taskGroup().enqueue(),
everythingRestart: taskGroup().restartable(),
everythingDropped3: taskGroup().maxConcurrency(3).drop(),
everythingEnqueue3: taskGroup().maxConcurrency(3).enqueue(),
everythingRestart3: taskGroup().maxConcurrency(3).restartable(),
taskGroups: computed(function () {
return [
this.get('everything'),
this.get('everythingDropped'),
this.get('everythingEnqueue'),
this.get('everythingRestart'),
this.get('everythingDropped3'),
this.get('everythingEnqueue3'),
this.get('everythingRestart3'),
];
}),
});
// END-SNIPPET
import { isEmpty } from '@ember/utils';
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
import PatientVisitsMixin from 'hospitalrun/mixins/patient-visits';
import PatientAppointmentsMixin from 'hospitalrun/mixins/patient-appointments';
import PatientInvoicesMixin from 'hospitalrun/mixins/patient-invoices';
import PouchDbMixin from 'hospitalrun/mixins/pouchdb';
import ProgressDialog from 'hospitalrun/mixins/progress-dialog';
import { translationMacro as t } from 'ember-i18n';
import { task, taskGroup, all } from 'ember-concurrency';
export default AbstractDeleteController.extend(PatientVisitsMixin, PatientInvoicesMixin, PouchDbMixin, ProgressDialog, PatientAppointmentsMixin, {
title: t('patients.titles.delete'),
progressTitle: t('patients.titles.deletePatientRecord'),
progressMessage: t('patients.messages.deletingPatient'),
deleting: taskGroup(),
deleteMany(manyArray) {
return this.get('deleteManyTask').perform(manyArray);
},
deleteManyTask: task(function* (manyArray) {
if (!manyArray) {
return;
}
let resolvedArray = yield manyArray;
if (isEmpty(resolvedArray)) {
// empty array: no records to delete
return;
}
let deleteRecordTask = this.get('deleteRecordTask');
let archivePromises = [];
// separate task for autosave so that it doesn't override a manual save
autosave: task(function* () {
if (!this.get('save.isRunning')) {
return yield this._savePromise({
silent: true,
backgroundSave: true
});
}
}).drop(),
// updateSlug and save should always be enqueued so that we don't run into
// problems with concurrency, for example when Cmd-S is pressed whilst the
// cursor is in the slug field - that would previously trigger a simultaneous
// slug update and save resulting in ember data errors and inconsistent save
// results
saveTasks: taskGroup().enqueue(),
// save tasks cancels autosave before running, although this cancels the
// _xSave tasks that will also cancel the autosave task
save: task(function* (options) {
this.send('cancelAutosave');
return yield this._savePromise(options);
}).group('saveTasks'),
// TODO: convert this into a more ember-concurrency flavour
_savePromise(options) {
let prevStatus = this.get('model.status');
let isNew = this.get('model.isNew');
let promise, status;
options = options || {};
import Component from '@ember/component';
import { get, getProperties } from '@ember/object';
import { inject as service } from '@ember/service';
import { task, taskGroup } from 'ember-concurrency';
import errorMessages from 'client/utils/error-messages';
import { invokeAction } from 'ember-invoke-action';
export default Component.extend({
identification: undefined,
password: undefined,
facebook: service(),
notify: service(),
aozoraConflicts: service(),
router: service(),
authentication: taskGroup().drop(),
login: task(function* () {
const { identification, password } = getProperties(this, 'identification', 'password');
try {
yield get(this, 'session').authenticateWithOAuth2(identification, password);
yield get(this, 'gotoNext').perform();
} catch (err) {
get(this, 'notify').error(errorMessages(err));
}
}).group('authentication'),
loginWithFacebook: task(function* () {
try {
yield get(this, 'session').authenticateWithFacebook();
yield get(this, 'gotoNext').perform();
} catch (error) {
import Controller from '@ember/controller';
import { task, taskGroup } from 'ember-concurrency';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import dashboardRepositoriesSort from 'travis/utils/dashboard-repositories-sort';
export default Controller.extend({
flashes: service(),
api: service(),
starring: taskGroup().drop(),
star: task(function* (repo) {
repo.set('starred', true);
try {
yield this.api.post(`/repo/${repo.get('id')}/star`);
} catch (e) {
repo.set('starred', false);
this.flashes
.error(`Something went wrong while trying to star ${repo.get('slug')}.
Please try again.`);
}
}).group('starring'),
unstar: task(function* (repo) {
repo.set('starred', false);
try {
tooltips: or('labelless', 'mobilelabels'),
cancel: task(function* () {
let type = this.type;
yield eventually(this.item, (record) => {
record.cancel().then(() => {
this.flashes.success(`${type.capitalize()} has been successfully cancelled.`);
}, (xhr) => {
this.displayFlashError(xhr.status, 'cancel');
});
});
}).drop(),
restarters: taskGroup().drop(),
restart: task(function* () {
let type = this.type;
yield eventually(this.item, (record) => {
record.restart().then(() => {
this.flashes.success(`The ${type} was successfully restarted.`);
}, () => {
this.flashes.error(`An error occurred. The ${type} could not be restarted.`);
});
});
}).group('restarters'),
debug: task(function* () {
let type = this.type;
import Component from '@ember/component';
import { get } from '@ember/object';
import { inject as service } from '@ember/service';
import { task, taskGroup } from 'ember-concurrency';
export default Component.extend({
intl: service(),
notify: service(),
actionsTaskGroup: taskGroup(),
removeMemberTask: task(function* () {
yield get(this, 'member').destroyRecord().catch(() => {
get(this, 'notify').error(get(this, 'intl').t('errors.request'));
});
}).group('actionsTaskGroup')
});
ghostPaths: service(),
notifications: service(),
session: service(),
slugGenerator: service(),
leaveSettingsTransition: null,
dirtyAttributes: false,
showDeleteUserModal: false,
showSuspendUserModal: false,
showTransferOwnerModal: false,
showUploadCoverModal: false,
showUplaodImageModal: false,
_scratchFacebook: null,
_scratchTwitter: null,
saveHandlers: taskGroup().enqueue(),
user: alias('model'),
currentUser: alias('session.user'),
email: readOnly('user.email'),
slugValue: boundOneWay('user.slug'),
canChangeEmail: not('isAdminUserOnOwnerProfile'),
canChangePassword: not('isAdminUserOnOwnerProfile'),
canMakeOwner: and('currentUser.isOwner', 'isNotOwnProfile', 'user.isAdmin', 'isNotSuspended'),
isAdminUserOnOwnerProfile: and('currentUser.isAdmin', 'user.isOwner'),
isNotOwnersProfile: not('user.isOwner'),
isNotSuspended: not('user.isSuspended'),
rolesDropdownIsVisible: and('currentUser.isOwnerOrAdmin', 'isNotOwnProfile', 'isNotOwnersProfile'),
userActionsAreVisible: or('deleteUserActionIsVisible', 'canMakeOwner'),