c8osdkvuejs
Advanced tools
Comparing version
{ | ||
"name": "c8osdkvuejs", | ||
"version": "0.0.0-beta4", | ||
"version": "0.0.0-beta5", | ||
"description": "convertigo's MBaaS client API service", | ||
@@ -5,0 +5,0 @@ "main": "bundle/index.umd.js", |
@@ -35,81 +35,83 @@ "use strict"; | ||
var _this = this; | ||
var nullableEndpoint = true; | ||
if (c8oSettings !== undefined) { | ||
if (c8oSettings.endpoint != null) { | ||
nullableEndpoint = false; | ||
if (process["browser"]) { | ||
var nullableEndpoint = true; | ||
if (c8oSettings !== undefined) { | ||
if (c8oSettings.endpoint != null) { | ||
nullableEndpoint = false; | ||
} | ||
} | ||
} | ||
if (nullableEndpoint) { | ||
this.promiseConstructor = new Promise(function (resolve) { | ||
if (window.location.href.startsWith("http") && window.location.href.indexOf("/DisplayObjects") != -1) { | ||
var n = window.location.href.indexOf("/DisplayObjects"); | ||
_this.endpoint = window.location.href.substring(0, n); | ||
resolve(); | ||
} | ||
else { | ||
var uri = ""; | ||
if (window.location.href.startsWith("file://")) { | ||
uri = (window.location.href.substring(0, window.location.href.indexOf("/index.html"))) + "/env.json"; | ||
if (nullableEndpoint) { | ||
this.promiseConstructor = new Promise(function (resolve) { | ||
if (window.location.href.startsWith("http") && window.location.href.indexOf("/DisplayObjects") != -1) { | ||
var n = window.location.href.indexOf("/DisplayObjects"); | ||
_this.endpoint = window.location.href.substring(0, n); | ||
resolve(); | ||
} | ||
else { | ||
uri = window.location.origin + "/env.json"; | ||
} | ||
_this.httpPublic.get(uri) | ||
.then(function (data) { | ||
_this.data = data; | ||
var remoteBase = data["remoteBase"].toString(); | ||
var n = remoteBase.indexOf("/_private"); | ||
_this.endpoint = remoteBase.substring(0, n); | ||
_this._automaticRemoveSplashsCreen = data["splashScreenRemoveMode"] !== "manual"; | ||
resolve(); | ||
}).catch(function (error) { | ||
alert("Missing env.json file"); | ||
var errMsg; | ||
if (error instanceof Error) { | ||
errMsg = error.message; | ||
var uri = ""; | ||
if (window.location.href.startsWith("file://")) { | ||
uri = (window.location.href.substring(0, window.location.href.indexOf("/index.html"))) + "/env.json"; | ||
} | ||
else { | ||
errMsg = error.status + " - " + (error.statusText || "") + " " + error; | ||
uri = window.location.origin + "/env.json"; | ||
} | ||
return Observable_1.Observable.throw(errMsg); | ||
}); | ||
} | ||
}).then(function () { | ||
_this.extractendpoint(); | ||
_this.httpPublic.get(uri) | ||
.then(function (data) { | ||
_this.data = data; | ||
var remoteBase = data["remoteBase"].toString(); | ||
var n = remoteBase.indexOf("/_private"); | ||
_this.endpoint = remoteBase.substring(0, n); | ||
_this._automaticRemoveSplashsCreen = data["splashScreenRemoveMode"] !== "manual"; | ||
resolve(); | ||
}).catch(function (error) { | ||
alert("Missing env.json file"); | ||
var errMsg; | ||
if (error instanceof Error) { | ||
errMsg = error.message; | ||
} | ||
else { | ||
errMsg = error.status + " - " + (error.statusText || "") + " " + error; | ||
} | ||
return Observable_1.Observable.throw(errMsg); | ||
}); | ||
} | ||
}).then(function () { | ||
_this.extractendpoint(); | ||
}); | ||
} | ||
else { | ||
this.promiseConstructor = new Promise(function (resolve) { | ||
_this.endpoint = c8oSettings.endpoint; | ||
_this.extractendpoint(); | ||
resolve(); | ||
}); | ||
} | ||
this.promiseInit = Promise.all([this.promiseConstructor]).then(function () { | ||
return new Promise(function (resolve) { | ||
_this.copy(c8oSettings); | ||
_this.httpInterface = new c8oHttpInterface_service_1.C8oHttpInterface(_this); | ||
_this.c8oLogger.affect_val(_this, false); | ||
_this.c8oLogger.logRemoteInit(); | ||
document.addEventListener("offline", function () { | ||
_this.c8oLogger.info("Network offline"); | ||
_this.c8oLogger.info("Setting remote logs to false"); | ||
_this.logRemote = false; | ||
if (_this.logOnFail != null) { | ||
_this.logOnFail(new c8osdkjscore_1.C8oException(c8osdkjscore_1.C8oExceptionMessage.RemoteLogFail()), null); | ||
} | ||
}, false); | ||
document.addEventListener("online", function () { | ||
_this.log.info("Network online"); | ||
if (_this._initialLogRemote && !_this.logRemote) { | ||
_this.logRemote = true; | ||
_this.log.info("Setting remote logs to true"); | ||
} | ||
}, false); | ||
_this.c8oLogger.logMethodCall("C8o Constructor"); | ||
_this.c8oFullSync = new c8osdkjscore_1.C8oFullSyncCbl(_this); | ||
resolve(); | ||
}); | ||
}); | ||
return this.promiseInit; | ||
} | ||
else { | ||
this.promiseConstructor = new Promise(function (resolve) { | ||
_this.endpoint = c8oSettings.endpoint; | ||
_this.extractendpoint(); | ||
resolve(); | ||
}); | ||
} | ||
this.promiseInit = Promise.all([this.promiseConstructor]).then(function () { | ||
return new Promise(function (resolve) { | ||
_this.copy(c8oSettings); | ||
_this.httpInterface = new c8oHttpInterface_service_1.C8oHttpInterface(_this); | ||
_this.c8oLogger.affect_val(_this, false); | ||
_this.c8oLogger.logRemoteInit(); | ||
document.addEventListener("offline", function () { | ||
_this.c8oLogger.info("Network offline"); | ||
_this.c8oLogger.info("Setting remote logs to false"); | ||
_this.logRemote = false; | ||
if (_this.logOnFail != null) { | ||
_this.logOnFail(new c8osdkjscore_1.C8oException(c8osdkjscore_1.C8oExceptionMessage.RemoteLogFail()), null); | ||
} | ||
}, false); | ||
document.addEventListener("online", function () { | ||
_this.log.info("Network online"); | ||
if (_this._initialLogRemote && !_this.logRemote) { | ||
_this.logRemote = true; | ||
_this.log.info("Setting remote logs to true"); | ||
} | ||
}, false); | ||
_this.c8oLogger.logMethodCall("C8o Constructor"); | ||
_this.c8oFullSync = new c8osdkjscore_1.C8oFullSyncCbl(_this); | ||
resolve(); | ||
}); | ||
}); | ||
return this.promiseInit; | ||
}; | ||
@@ -116,0 +118,0 @@ C8o.prototype.finalizeInit = function () { |
@@ -29,29 +29,30 @@ import {C8oCore, C8oLogger, C8oSettings, C8oException, C8oExceptionMessage, C8oFullSyncCbl, C8oFullSync} from "c8osdkjscore"; | ||
public init(c8oSettings?: C8oSettings): Promise<any> { | ||
let nullableEndpoint = true; | ||
if (c8oSettings !== undefined) { | ||
if (c8oSettings.endpoint != null) { | ||
nullableEndpoint = false; | ||
if (process["browser"]) { | ||
let nullableEndpoint = true; | ||
if (c8oSettings !== undefined) { | ||
if (c8oSettings.endpoint != null) { | ||
nullableEndpoint = false; | ||
} | ||
} | ||
} | ||
if (nullableEndpoint) { | ||
this.promiseConstructor = new Promise((resolve) => { | ||
// if project is running into web browser served by convertigo | ||
// get the url from window.location | ||
if (window.location.href.startsWith("http") && window.location.href.indexOf("/DisplayObjects") != -1) { | ||
let n = window.location.href.indexOf("/DisplayObjects"); | ||
this.endpoint = window.location.href.substring(0, n); | ||
resolve(); | ||
} | ||
// else if project is running on device or serve by ionic serve | ||
// get the uri from env.json | ||
else { | ||
let uri =""; | ||
if(window.location.href.startsWith("file://")){ | ||
uri = (window.location.href.substring(0, window.location.href.indexOf("/index.html"))) + "/env.json" | ||
if (nullableEndpoint) { | ||
this.promiseConstructor = new Promise((resolve) => { | ||
// if project is running into web browser served by convertigo | ||
// get the url from window.location | ||
if (window.location.href.startsWith("http") && window.location.href.indexOf("/DisplayObjects") != -1) { | ||
let n = window.location.href.indexOf("/DisplayObjects"); | ||
this.endpoint = window.location.href.substring(0, n); | ||
resolve(); | ||
} | ||
else{ | ||
uri = window.location.origin + "/env.json"; | ||
} | ||
this.httpPublic.get(uri) | ||
.then(data => { | ||
// else if project is running on device or serve by ionic serve | ||
// get the uri from env.json | ||
else { | ||
let uri = ""; | ||
if (window.location.href.startsWith("file://")) { | ||
uri = (window.location.href.substring(0, window.location.href.indexOf("/index.html"))) + "/env.json" | ||
} | ||
else { | ||
uri = window.location.origin + "/env.json"; | ||
} | ||
this.httpPublic.get(uri) | ||
.then(data => { | ||
this.data = data; | ||
@@ -64,55 +65,56 @@ //noinspection TypeScriptUnresolvedVariable | ||
resolve(); | ||
}).catch(error=>{ | ||
alert("Missing env.json file"); | ||
let errMsg: string; | ||
if (error instanceof Error) { | ||
errMsg = error.message; | ||
} else { | ||
errMsg = `${error.status} - ${error.statusText || ""} ${error}`; | ||
} | ||
return Observable.throw(errMsg); | ||
}); | ||
} | ||
}).then(() => { | ||
this.extractendpoint(); | ||
}); | ||
} | ||
else { | ||
this.promiseConstructor = new Promise((resolve) => { | ||
this.endpoint = c8oSettings.endpoint; | ||
this.extractendpoint(); | ||
resolve(); | ||
}); | ||
} | ||
}).catch(error => { | ||
alert("Missing env.json file"); | ||
let errMsg: string; | ||
if (error instanceof Error) { | ||
errMsg = error.message; | ||
} else { | ||
errMsg = `${error.status} - ${error.statusText || ""} ${error}`; | ||
} | ||
return Observable.throw(errMsg); | ||
}); | ||
} | ||
}).then(() => { | ||
this.extractendpoint(); | ||
}); | ||
} | ||
else { | ||
this.promiseConstructor = new Promise((resolve) => { | ||
this.endpoint = c8oSettings.endpoint; | ||
this.extractendpoint(); | ||
resolve(); | ||
}); | ||
} | ||
this.promiseInit = Promise.all([this.promiseConstructor]).then(() => { | ||
return new Promise((resolve) => { | ||
this.copy(c8oSettings); | ||
this.promiseInit = Promise.all([this.promiseConstructor]).then(() => { | ||
return new Promise((resolve) => { | ||
this.copy(c8oSettings); | ||
this.httpInterface = new C8oHttpInterface(this); | ||
this.c8oLogger.affect_val(this, false); | ||
this.c8oLogger.logRemoteInit(); | ||
this.httpInterface = new C8oHttpInterface(this); | ||
this.c8oLogger.affect_val(this, false); | ||
this.c8oLogger.logRemoteInit(); | ||
document.addEventListener("offline", () => { | ||
this.c8oLogger.info("Network offline"); | ||
this.c8oLogger.info("Setting remote logs to false"); | ||
this.logRemote = false; | ||
if (this.logOnFail != null) { | ||
this.logOnFail(new C8oException(C8oExceptionMessage.RemoteLogFail()), null); | ||
} | ||
}, false); | ||
document.addEventListener("online", () => { | ||
this.log.info("Network online"); | ||
if (this._initialLogRemote && !this.logRemote) { | ||
this.logRemote = true; | ||
this.log.info("Setting remote logs to true"); | ||
} | ||
}, false); | ||
document.addEventListener("offline", () => { | ||
this.c8oLogger.info("Network offline"); | ||
this.c8oLogger.info("Setting remote logs to false"); | ||
this.logRemote = false; | ||
if (this.logOnFail != null) { | ||
this.logOnFail(new C8oException(C8oExceptionMessage.RemoteLogFail()), null); | ||
} | ||
}, false); | ||
document.addEventListener("online", () => { | ||
this.log.info("Network online"); | ||
if (this._initialLogRemote && !this.logRemote) { | ||
this.logRemote = true; | ||
this.log.info("Setting remote logs to true"); | ||
} | ||
}, false); | ||
this.c8oLogger.logMethodCall("C8o Constructor"); | ||
this.c8oFullSync = new C8oFullSyncCbl(this); | ||
resolve(); | ||
this.c8oLogger.logMethodCall("C8o Constructor"); | ||
this.c8oFullSync = new C8oFullSyncCbl(this); | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
return this.promiseInit; | ||
return this.promiseInit; | ||
} | ||
} | ||
@@ -119,0 +121,0 @@ |
Sorry, the diff of this file is not supported yet
78392
0.92%1068
0.38%