Skip to content
Snippets Groups Projects
Commit 91abe89b authored by Bhabesh Bhabani Mukhopadhyay's avatar Bhabesh Bhabani Mukhopadhyay
Browse files

Basic connectivity option with android emulator developed

At this stage a flag named 'isEmulator' in CommonUtil component maintained to note whether the host is emulator or not
parent e9791135
Branches
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' https://code.jquery.com 'unsafe-inline' 'unsafe-eval'; media-src *; img-src 'self' http://opencache.statkart.no https://*.openstreetmap.org/ data: content:; connect-src 'self' https://logic.vips.nibio.no http://vipslogic-local.no https://opencache.statkart.no ws:;">
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' * https://code.jquery.com 'unsafe-inline' 'unsafe-eval'; media-src *; img-src 'self' http://opencache.statkart.no https://*.openstreetmap.org/ data: content:; connect-src 'self' * http://10.0.2.2 http://logic.vips.nibio.no https://logic.vips.nibio.no http://vipslogic-local.no https://opencache.statkart.no ws:;">
<meta name="description" content="">
<meta name="author" content="Tor-Einar Skog">
<title>VIPS Feltobservasjoner</title>
......
<template></template>
<script>
//const CONST_STR_TEST ="test 123"
export default {
......@@ -21,8 +22,6 @@ export default {
CONST_OBSERVATION_COUNT_START_ID : -1,
CONST_URL_DOMAIN : 'http://vipslogic-local.no',
CONST_URL_AUTH_UUID : '/rest/auth/uuid',
CONST_URL_AUTH_LOGIN : '/rest/auth/login',
CONST_URL_LAST_TIMESTAMP : '/rest/observation/organismsystemupdated',
......@@ -42,8 +41,43 @@ export default {
CONST_GPS_DEFAULT_ZOOM : 4.2,
CONST_GPS_OBSERVATION_ZOOM : 10,
data(){
return {
isEmulator : false,
CONST_URL_DOMAIN : 'http://vipslogic-local.no',
CONST_URL_DOMAIN_EMULATOR_ANDROID : 'http://10.0.2.2:8080/VIPSLogic', /** Android emulator host loop back */
domain : 'test',
domains : [
'http://vipslogic-local.no',
'http://10.0.2.2:8080/VIPSLogic'
],
}
},
methods :
{
getDomain()
{
return (this.isEmulator) ? this.CONST_URL_DOMAIN_EMULATOR_ANDROID : this.CONST_URL_DOMAIN;
},
//TODO - Below code need to be developed basis of HOST domain search for platform independency
domainCheck()
{
let domain = this.domain;
let domains = this.domains;
let site = 'http://vipslogic-local.no';
const requestAnimeAwait = async (site) => {
const response = await fetch('http://vipslogic-local.no', {mode:'no-cors'});
const json = await response.text();
console.log("async/await based");
console.log(response);
}
requestAnimeAwait();
}
},
}
......
......@@ -39,6 +39,7 @@
<!-- <Sync :isSyncNeeded="isSyncNeeded"/> -->
<Sync ref="Sync"/>
<common-util ref="CommonUtil"/>
</div>
</template>
......@@ -47,15 +48,17 @@
import CommonUtil from "@/components/CommonUtil";
import Sync from '@/components/Sync';
export default {
name: "LoginSystem",
components : {Sync},
components : {Sync,CommonUtil},
props:{
isWelcome : Boolean,
},
data() {
return {
CONST_URL_DOMAIN : '',
jsonServerResponse : '',
userLoggedInName: this.$root.sharedState.user.firstName + " " + this.$root.sharedState.user.lastName,
username: "",
......@@ -87,7 +90,7 @@ export default {
/** Fetch to get details */
let jsonHeader = { Authorization: userUUID };
fetch(CommonUtil.CONST_URL_DOMAIN + CommonUtil.CONST_URL_AUTH_UUID, {
fetch(this.CONST_URL_DOMAIN + CommonUtil.CONST_URL_AUTH_UUID, {
method: "GET",
headers: jsonHeader,
}).then((response) => {
......@@ -109,7 +112,7 @@ export default {
let jsonBody = JSON.stringify({"username": this.username, "password":this.password});
/** Fetch to get UUID */
fetch(
CommonUtil.CONST_URL_DOMAIN + CommonUtil.CONST_URL_AUTH_LOGIN,
this.CONST_URL_DOMAIN + CommonUtil.CONST_URL_AUTH_LOGIN,
{
method: "POST",
headers: {
......@@ -134,7 +137,7 @@ export default {
let jsonHeader = {Authorization:this.jsonServerResponse.UUID};
fetch(
CommonUtil.CONST_URL_DOMAIN +CommonUtil.CONST_URL_AUTH_UUID,
this.CONST_URL_DOMAIN + CommonUtil.CONST_URL_AUTH_UUID,
{
method:"GET",
headers : jsonHeader
......@@ -164,6 +167,7 @@ export default {
},
mounted() {
this.CONST_URL_DOMAIN = this.$refs.CommonUtil.getDomain();
this.checkValidUUID();
},
};
......
......@@ -29,7 +29,7 @@
</select>
</div>
</div>
<common-util ref="CommonUtil"/>
</div>
</template>
......@@ -69,8 +69,10 @@ let parser = new WMTSCapabilities();
export default {
name : 'MapObservation',
props : ['observationId','geoinfo','isMapPanelVisible','locationPointOfInterestId'],
components : {CommonUtil},
data(){
return {
CONST_URL_DOMAIN : '',
isMyMapPanelVisible : '',
myGeoInfo : '',
latitude : 0,
......@@ -288,7 +290,7 @@ export default {
lstPOI.push({pointOfInterestId:'undefined',name:'No POI Selected'});
fetch(CommonUtil.CONST_URL_DOMAIN +CommonUtil.CONST_URL_USER_POI,
fetch(this.CONST_URL_DOMAIN +CommonUtil.CONST_URL_USER_POI,
{
method: "GET",
headers: jsonHeader,
......@@ -368,6 +370,7 @@ export default {
},
mounted() {
this.CONST_URL_DOMAIN = this.$refs.CommonUtil.getDomain();
this.latitude = CommonUtil.CONST_GPS_DEFAULT_LATITUDE_NORWAY;
this.longitude = CommonUtil.CONST_GPS_DEFAULT_LONGITUDE_NORWAY;
......
......@@ -20,7 +20,7 @@ import { DateTime } from "luxon";
<div v-else class="alert alert-warning" role="alert">
<p class="text-danger">You don't have any observations.</p>
</div>
<common-util ref="CommonUtil"/>
</div>
</template>
......@@ -33,9 +33,11 @@ export default {
data() {
return {
/*msg: 'Startsiden'*/
observations : undefined,
CONST_URL_DOMAIN : '',
observations : undefined,
};
},
components : {CommonUtil},
methods : {
/** TODO
* This function need to be shifted for two way sync process
......@@ -45,7 +47,7 @@ export default {
let strUUID = localStorage.getItem(CommonUtil.CONST_STORAGE_UUID);
let jsonHeader = { Authorization: strUUID };
fetch(CommonUtil.CONST_URL_DOMAIN + CommonUtil.CONST_URL_USER_OBSERVATION_LIST, {
fetch(this.CONST_URL_DOMAIN + CommonUtil.CONST_URL_USER_OBSERVATION_LIST, {
method: "GET",
headers: jsonHeader,
}).then((response) => response.json())
......@@ -70,10 +72,11 @@ export default {
}
},
mounted() {
this.CONST_URL_DOMAIN = this.$refs.CommonUtil.getDomain();
let strUUID = localStorage.getItem(CommonUtil.CONST_STORAGE_UUID);
if(strUUID)
{
//this.fetchFromServer(); // TODO - Tobe shifted to two way Sync process
this.fetchFromServer(); // TODO - Tobe shifted to two way Sync process
this.getObservationsFromStore(); // TODO -- to be in effect after two sync in process
}
}
......
<template>
<div v-if="loading">
<div class="spinner-border text-success" role="status">
</div> <span class="text-danger"> Data Loading...</span>
<!-- -- Sync : <div v-html="isSyncNeeded"></div> -->
<div>
<div v-if="loading">
<div class="spinner-border text-success" role="status">
</div> <span class="text-danger"> Data Loading...</span>
<!-- -- Sync : <div v-html="isSyncNeeded"></div> -->
</div>
<common-util ref="CommonUtil"/>
</div>
</template>
......@@ -12,11 +15,13 @@ import CommonUtil from "@/components/CommonUtil";
export default {
name: "Sync",
components : {CommonUtil},
props: {
isSyncNeeded: Boolean
},
data() {
return {
CONST_URL_DOMAIN : '',
booIsSyncOneWayReady : false,
arrSyncOneWay : [
{"name":CommonUtil.CONST_STORAGE_CROP_CATEGORY,"complete":false} ,
......@@ -91,20 +96,21 @@ export default {
// TODO if appUser is not available
}
else
{ let strUrl = '';
{ let strUrl = '';
let This = this;
$.each(this.arrSyncOneWay, function(index, value){
switch(value.name) {
case CommonUtil.CONST_STORAGE_CROP_CATEGORY :
strUrl = CommonUtil.CONST_URL_DOMAIN +CommonUtil.CONST_URL_CROP_CATEGORY+appUser.organization_id;
strUrl = This.CONST_URL_DOMAIN +CommonUtil.CONST_URL_CROP_CATEGORY+appUser.organization_id;
break;
case CommonUtil.CONST_STORAGE_CROP_LIST :
strUrl = CommonUtil.CONST_URL_DOMAIN +CommonUtil.CONST_URL_CROP_LIST;
strUrl = This.CONST_URL_DOMAIN +CommonUtil.CONST_URL_CROP_LIST;
break;
case CommonUtil.CONST_STORAGE_PEST_LIST :
strUrl = CommonUtil.CONST_URL_DOMAIN +CommonUtil.CONST_URL_PEST_LIST;
strUrl = This.CONST_URL_DOMAIN +CommonUtil.CONST_URL_PEST_LIST;
break;
case CommonUtil.CONST_STORAGE_CROP_PEST_LIST :
strUrl = CommonUtil.CONST_URL_DOMAIN +CommonUtil.CONST_URL_CROP_PEST_LIST;
strUrl = This.CONST_URL_DOMAIN +CommonUtil.CONST_URL_CROP_PEST_LIST;
break;
default :
}
......@@ -218,7 +224,7 @@ export default {
let jsonHeader = {Authorization:appUser.userUuid};
fetch(
CommonUtil.CONST_URL_DOMAIN +CommonUtil.CONST_URL_LAST_TIMESTAMP,
this.CONST_URL_DOMAIN +CommonUtil.CONST_URL_LAST_TIMESTAMP,
{
method:"GET",
headers: jsonHeader,
......@@ -260,6 +266,11 @@ export default {
},
mounted () {
console.log('mounted in Sync ');
this.CONST_URL_DOMAIN = this.$refs.CommonUtil.getDomain();
}
};
</script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment