loadByURL: function(url) { // first check templateCache var req; if (this.templateCache[url]) { req = Ember.RSVP.Promise.resolve(this.templateCache[url]); } else { req = raw(url, { dataType: 'text' }); } return req .then(function(response) { // if its an actual ajax request, just get the response text if (response.jqXHR) { response = response.jqXHR.responseText; } var els = Ember.$(response); for (var i = 0; i < els.length; ++i) { if (els[i].nodeName === 'svg') { return els[i]; } } }); },
deviseSendReset: function(email, password, password_confirmation, params) { console.log("params", this); console.log("queryParams", this.queryParams); var reset_password_token = this.controller.reset_password_token; var req = raw({ type: 'PUT', url: '/users/password', data: { "user": { "email": email, "password": password, "password_confirmation": password_confirmation, "reset_password_token": reset_password_token } } //, //dataType: 'json' }); var self=this; req.then(function(result){ console.log('Response from Rails', result.response); self.notifications.addNotification({ message: 'Your password was updated!', type: 'success' }); self.controller.transitionToRoute('login'); }, function(response) { console.error('There was a problem: ', response); self.notifications.addNotification({ message: 'Oops, something bad happened: ' + JSON.parse(response.jqXHR.responseText).errors[0], type: 'error' }); } ); }
signup: function() { var _this = this; var data = this.getProperties('name', 'email', 'password'); var auth = this.get('auth'); icAjaxRaw(config.host + '/' + config.namespace + '/users/create', { type: 'post', data: { user: { name: data.name, email: data.email, password: data.password } } }).then(function(result) { _this.setProperties({ name: null, email: null, password: null }) auth.login(data); }, function(err) { console.log(err); _this.set('password', null); }); }
uploadChunk: function(contURL, chunk, progress=Ember.K) { var options, xhr; xhr = Ember.$.ajaxSettings.xhr(); xhr.upload.onprogress = function(e) { var uploaded = e.loaded; progress({ 'chunk': chunk.position, 'xhr': xhr, 'total': chunk.size, 'uploaded': uploaded, }); }; options = this.mergeAjaxOptions({ url: contURL + "?format=json&update", headers: { 'Content-Type': "application/octet-stream" }, method: 'POST', processData: false, data: chunk.buffer, xhr: function() { return xhr; } }); return ajax(options); },
getRefsetExport : function(user,id) { var _this = this; var result = icAjaxRaw(RefsetENV.APP.refsetApiBaseUrl + '/' + id + '/export', {headers:this.getHeaders(user)}).then(function(response) { return response; }, function (response) { return _this.returnErrorResponse(response); }); return result; },
login: function(data) { var _this = this; this.set('state', 'logging-in'); return icAjaxRaw(this.get('serverTokenEndpoint') + '/users/authenticate', { type: 'post', data: { email: data.email, password: data.password } }).then(function(result) { _this.loginSucceeded(result); }, function(error) { _this.loginFailed(error); }); },
authenticate : function (username,password) { Ember.Logger.log("adapters.refsets:authenticate",username,password); var _this = this; var user = {name:username,token:password}; var result = icAjaxRaw(RefsetENV.APP.refsetApiBaseUrl + '/getUserDetails', {headers:this.getPreAuthHeaders(user) , type:"post", processData: false, contentType: 'application/json'}).then(function(response) { return response; }, function (response) { return _this.returnErrorResponse(response); }); return result; },
resolveHashes: function(url, hashes, size, type, params) { var hashmap, options; hashmap = { 'hashes': hashes.getEach("hash"), 'bytes': size, 'block_hash': params.hash, 'block_size': params.bs } options = this.mergeAjaxOptions({ url: url + "?format=json&update=1&hashmap=", method: 'PUT', data: JSON.stringify(hashmap), headers: {'Content-Type': type} }); return ajax(options).then(function(resp) { return { 'missing': Ember.A(), 'existing': hashes }; }).catch(function(err) { var resp, missingResp, missing = Ember.A(), existing = Ember.A(); if (err.errorThrown !== "CONFLICT") { throw err; } // parse missing hashes missingResp = Ember.A(JSON.parse(err.jqXHR.responseText)); hashes.forEach(function(h) { if (missingResp.contains(h.hash)) { missing.pushObject(h); } else { existing.pushObject(h); } }); return { 'missing': missing, 'existing': existing }; }); },
} else { dataForStudent.push( Ember.Object.create({ column_id: columnID, content: columnDatum.content }) ) } return (studentData[columnDatum.user_id] = dataForStudent) }, fetchColumnData(col, url) { if (!url) { url = ENV.GRADEBOOK_OPTIONS.custom_column_data_url.replace(/:id/, col.id) } return ajax.raw(url, {dataType: 'json'}).then(result => { for (const datum of Array.from(result.response)) { this.updateColumnData(datum, col.id) } const meta = parseLinkHeader(result.jqXHR) if (meta.next) { return this.fetchColumnData(col, meta.next) } else { return setProperties(col, { isLoading: false, isLoaded: true }) } }) },