Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ngAfterViewInit() {
this.loader.hideLoader();
// load high resolution image in background
//console.log("Image Loading: " + this.item.url + "/500/500");
if(!this.item.loaded) {
Http.request({
url: this.item.url + "/500/500",
method: "GET",
headers: this.headers
}).then((response:any)=> {
response.content.toImage()
.then((image)=> {
let base64 = image.toBase64String("jpg");
let highsrc = base64;
this.item.src = highsrc;
this.item.loaded = true;
})
.catch((error)=> {
//util.log("error", error);
});
this.current.push(item);
}
this.updateFooter(this.cache.images[this.cache.currentAlbum.nodeid].totAlbums, 0);
let data = this.cache.images[this.cache.currentAlbum.nodeid].data;
// otherwise too fast :)
timer.setTimeout(()=> {
this.loader.hideLoader();
this.scanImages(data.files, nodeid);
}, 800);
} else {
this.util.log("Cache Not Found :( Retrieving from cloud…", null);
Http.request({
url: url,
method: "GET",
headers: this.headers
}).then((response:any)=> {
let data = null;
try {
data = response.content.toJSON();
} catch(e) {
Toast.makeText(this.translate.instant("Error loading. Please retry")).show();
this.util.log("Error", e);
this.loader.hideLoader();
return;
}
if(data==null) {
export var test_request_requestShouldTimeout = function (done) {
var result;
http.request({ url: "https://10.255.255.1", method: "GET", timeout: 500 }).catch(function (e) {
result = e;
try {
TKUnit.assert(result instanceof Error, "Result from request().catch() should be Error! Current type is " + typeof result);
done(null);
}
catch (err) {
done(err);
}
});
};
private loadImages(albumid, item) {
if(albumid==this.cache.currentAlbum.nodeid) {
let filepath = "";
let filepath_chunk = item.path.split("/");
for(let c=0; c {
if(albumid==this.cache.currentAlbum.nodeid) {
let imgObj = new GalleryItem();
response.content.toImage()
.then((image)=> {
let base64 = image.toBase64String();
imgObj.src = base64;
imgObj.title = filepath_chunk[filepath_chunk.length-1];
imgObj.url = imgurlroot;
imgObj.mtime = item.mtime;
this.current.push(imgObj);
resetPassword(email) {
return http.request({
url: this.baseUrl + "rpc/" + this.appKey + "/" + email + "/user-password-reset-initiate",
method: "POST",
headers:this.getCommonHeaders()
})
.then(this.validateCode)
.then(this.getJson)
.then(data => {
console.info('Reset password for email: ' + data.Result.Result)
})
}
if (value[1] === '/' && (value[0] === '.' || value[0] === '~')) {
value = value.substr(2);
}
if (value[0] !== '/') {
value = currentPath + '/' + value;
}
this._drawable = new pl.droidsonroids.gif.GifDrawable(value);
this.nativeView.setImageDrawable(this._drawable);
} else {
const requestOptions: any = { url: value, method: 'GET' };
if (this._headers !== null) {
requestOptions.headers = this._headers;
}
HttpRequest(requestOptions).then(
r => {
if (r.statusCode === 200) {
this._drawable = new pl.droidsonroids.gif.GifDrawable(
r.content.raw.toByteArray()
);
this.nativeView.setImageDrawable(this._drawable);
} else {
console.log('error getting image: ' + r.statusCode);
}
},
err => {
console.log(err);
}
);
}
} else {
private _postRequest(endpoint: string, content: string = ''): Promise {
let url = this._backendURL(endpoint);
return httpModule.request({
url: url,
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=utf-8" },
content
}).then(response => {
if (response.statusCode < 200 || response.statusCode >= 300) {
throw new Error(response.content.toString());
}
return response;
});
}