Updated parse lib in mini secchi submission

This commit is contained in:
Norbert Schmidt
2023-01-13 08:59:13 +01:00
parent 3b3353fff1
commit ef5d8e15d4

View File

@@ -3,7 +3,7 @@ import { Storage } from '@ionic/storage-angular';
import { Guid } from "guid-typescript";
import * as Parse from 'parse';
import { ENV } from '../../../../app.constant';
import { Geolocation} from '@capacitor/geolocation';
import { Geolocation } from '@capacitor/geolocation';
@Component({
selector: 'app-qccheck',
@@ -11,39 +11,39 @@ import { Geolocation} from '@capacitor/geolocation';
styleUrls: ['./qccheck.page.scss'],
})
export class QccheckPage implements OnInit {
// now get all the values
private parseAppId: string = ENV.parseAppId;
private parseServerUrl: string = ENV.parseServerUrl;
private parseJSKey: string=ENV.parseJSKey;
// now get all the values
private parseAppId: string = ENV.parseAppId;
private parseServerUrl: string = ENV.parseServerUrl;
private parseJSKey: string = ENV.parseJSKey;
public swversion_number:string;
public swversion_code:number;
public latitude: number;
public longitude: number;
public distancetowater: number;
public reappear: number;
public colourathalfdepth: number;
public colourathalfdepthimage: string;
public colouratsurface: number;
public colouratsurfaceimage: string;
public phvalue: number;
public bottom_visible: string;
public end_of_tape: string;
public angle_estimated: number;
public datetime: Date;
public datetime_ux: string;
public secchi_depth: string;
public swversion_number: string;
public swversion_code: number;
public latitude: number;
public longitude: number;
public distancetowater: number;
public reappear: number;
public colourathalfdepth: number;
public colourathalfdepthimage: string;
public colouratsurface: number;
public colouratsurfaceimage: string;
public phvalue: number;
public bottom_visible: string;
public end_of_tape: string;
public angle_estimated: number;
public datetime: Date;
public datetime_ux: string;
public secchi_depth: string;
public rec_uid: string;
public rec_uid: string;
newSecchi = { uid: null, swversion_number:null, swversion_code:null, latitude: null, longitude: null, distancetowater: null, reappear: null, colourathalfdepth: null, colourathalfdepthimage: null, colouratsurface: null, colouratsurfaceimage: null, datetimerecorded: null, datetime_ux:null, bottom_visible:null, end_of_tape:null, phvalue:null, angle_estimated:null, secchi_depth:null };
newSecchi = { uid: null, swversion_number: null, swversion_code: null, latitude: null, longitude: null, distancetowater: null, reappear: null, colourathalfdepth: null, colourathalfdepthimage: null, colouratsurface: null, colouratsurfaceimage: null, datetimerecorded: null, datetime_ux: null, bottom_visible: null, end_of_tape: null, phvalue: null, angle_estimated: null, secchi_depth: null };
constructor(private storage: Storage) {
this.rec_uid = Guid.raw(); // make it a string
}
}
@@ -58,13 +58,13 @@ public rec_uid: string;
this.storage.get('swversion_number').then((val) => {
this.swversion_number= val;
this.swversion_number = val;
});
this.storage.get('swversion_code').then((val) => {
this.swversion_code= val;
this.swversion_code = val;
});
@@ -72,82 +72,82 @@ this.swversion_code= val;
this.storage.get('latitude').then((val) => {
this.latitude= val;
this.latitude = val;
});
this.storage.get('longitude').then((val) => {
this.longitude= val;
this.longitude = val;
});
this.storage.get('distancetowater').then((val) => {
this.distancetowater= val;
this.distancetowater = val;
});
this.storage.get('reappear').then((val) => {
this.reappear= val;
this.reappear = val;
});
this.storage.get('colourathalfdepth').then((val) => {
this.colourathalfdepth= val;
this.colourathalfdepth = val;
});
this.storage.get('colouratsurface').then((val) => {
this.colouratsurface= val;
this.colouratsurface = val;
});
this.storage.get('colourathalfdepthimage').then((val) => {
// check if it is null
if (val==null) {
// check if it is null
if (val == null) {
console.log("colourathalfdepthimage is null");
return;
}
}
// convert to Parse file
val = new Parse.File("colourathalfdepthimage.png", { base64: val},"image/png");
// convert to Parse file
val = new Parse.File("colourathalfdepthimage.png", { base64: val }, "image/png");
this.colourathalfdepthimage= val;
this.colourathalfdepthimage = val;
});
this.storage.get('colouratsurfaceimage').then((val) => {
// check if it is null
if (val==null) {
// check if it is null
if (val == null) {
console.log("colouratsurfaceimage is null");
return;
}
}
// convert to Parse file
val = new Parse.File("colouratsurfaceimage.png", { base64: val},"image/png");
// convert to Parse file
val = new Parse.File("colouratsurfaceimage.png", { base64: val }, "image/png");
this.colouratsurfaceimage= val;
this.colouratsurfaceimage = val;
@@ -165,7 +165,7 @@ this.colouratsurfaceimage= val;
this.storage.get('phvalue').then((val) => {
this.phvalue= val;
this.phvalue = val;
});
@@ -173,13 +173,13 @@ this.phvalue= val;
this.storage.get('bottom_visible').then((val) => {
this.bottom_visible= val;
this.bottom_visible = val;
});
this.storage.get('end_of_tape').then((val) => {
this.end_of_tape= val;
this.end_of_tape = val;
});
@@ -188,80 +188,82 @@ this.end_of_tape= val;
this.storage.get('angle_estimated').then((val) => {
this.angle_estimated= val;
this.angle_estimated = val;
});
this.storage.get('secchi_depth').then((val) => {
this.storage.get('secchi_depth').then((val) => {
this.secchi_depth= val;
this.secchi_depth = val;
});
let d = new Date();
let d = new Date();
this.datetime=d;
this.datetime = d;
var unixTimeStamp = Math.floor(d.getTime() / 1000);
this.datetime_ux=unixTimeStamp.toString();
var unixTimeStamp = Math.floor(d.getTime() / 1000);
this.datetime_ux = unixTimeStamp.toString();
}
async validate() {
// now save to Parse
// now save to Parse
var secchi_data = Parse.Object.extend('mini_secchi_data');
var secchi_store = new secchi_data();
// set initial data record
console.log("saving to Parse");
var secchi_data = Parse.Object.extend('mini_secchi_data');
var secchi_store = new secchi_data();
// set initial data record
console.log("saving to Parse");
secchi_store.uid= this.rec_uid;
secchi_store.latitude=this.latitude;
secchi_store.longitude=this.longitude;
secchi_store.distancetowater=this.distancetowater;
secchi_store.reappear=this.reappear;
secchi_store.colourathalfdepth=this.colourathalfdepth;
secchi_store.colourathalfdepthimage=this.colourathalfdepthimage;
secchi_store.colouratsurface=this.colouratsurface;
secchi_store.colouratsurfaceimage=this.colouratsurfaceimage;
secchi_store.phvalue=this.phvalue;
secchi_store.bottom_visible=this.bottom_visible;
secchi_store.end_of_tape=this.end_of_tape;
secchi_store.angle_estimated=this.angle_estimated;
secchi_store.secchi_depth=this.secchi_depth;
secchi_store.datetime_ux=this.datetime_ux.toString();
secchi_store.datetimerecorded=this.datetime.toISOString();
console.log ('saving to Parse', secchi_store);
secchi_store.set('uid', this.rec_uid);
secchi_store.set('latitude', this.latitude);
secchi_store.set('longitude', this.longitude);
secchi_store.set('distancetowater', this.distancetowater);
secchi_store.set('reappear', this.reappear);
secchi_store.set('colourathalfdepth', this.colourathalfdepth);
secchi_store.set('colourathalfdepthimage', this.colourathalfdepthimage);
secchi_store.set('colouratsurface', this.colouratsurface);
secchi_store.set('colouratsurfaceimage', this.colouratsurfaceimage);
secchi_store.set('phvalue', this.phvalue);
secchi_store.set('bottom_visible', this.bottom_visible);
secchi_store.set('end_of_tape', this.end_of_tape);
secchi_store.set('angle_estimated', this.angle_estimated);
secchi_store.set('secchi_depth', this.secchi_depth);
secchi_store.set('datetime_ux', this.datetime_ux.toString());
secchi_store.set('datetimerecorded', this.datetime.toISOString());
try {
try {
const result = await secchi_store.save();
console.log('Data saved successfully:', result);
} catch (error) {
} catch (error) {
console.error('Error saving data:', error);
// You could add additional handling for the error here, such as displaying a message to the user or retrying the save operation.
}
}
}
}
async getLocation() {
const position = await Geolocation.getCurrentPosition({enableHighAccuracy: true});
async getLocation() {
const position = await Geolocation.getCurrentPosition({ enableHighAccuracy: true });
this.latitude = position.coords.latitude;
// console.log (position.coords.latitude);
this.longitude = position.coords.longitude;
return position.coords;
}
}
private parseInitialize() {
private parseInitialize() {
Parse.initialize(this.parseAppId, this.parseJSKey);