Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
sungguh committed Mar 11, 2021
1 parent cdc19b1 commit 278388d
Show file tree
Hide file tree
Showing 10 changed files with 374 additions and 129 deletions.
4 changes: 3 additions & 1 deletion app/App_Resources/Android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android" package="__PACKAGE__" android:versionCode="5" android:versionName="1.2">
xmlns:android="http://schemas.android.com/apk/res/android" package="__PACKAGE__" android:versionCode="6" android:versionName="1.3">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down
13 changes: 13 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ const ModeLoadingIndicator = require('@nstudio/nativescript-loading-indicator').

global.gLocalstorage = [];
global.gConfig = {
"connectionOption": {
message: 'Sedang mengecek jaringan internet...',
margin: 10,
dimBackground: true,
color: '#FFFFFF',
backgroundColor: '#FFFFFF',
userInteractionEnabled: true,
hideBezel: true,
mode: ModeLoadingIndicator.Indeterminate,
android: {
cancelable: false,
}
},
"searchOption": {
message: 'Sedang mengecek data...',
margin: 10,
Expand Down
3 changes: 3 additions & 0 deletions app/informasi/informasi-page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<Label text="Rilis Pertama" textWrap="true" fontSize="20" color="#212121" marginTop="10" />
<Label text="22 November 2020 (v1.1)" textWrap="true" fontSize="13" color="#616161" />

<Label text="Versi Saat Ini" textWrap="true" fontSize="20" color="#212121" marginTop="10" />
<Label text="v1.3" textWrap="true" fontSize="13" color="#616161" />

<Label text="Pembuat" textWrap="true" fontSize="20" color="#212121" marginTop="10" />
<Label text="Kang cahya" textWrap="true" fontSize="13" color="#616161" />

Expand Down
23 changes: 22 additions & 1 deletion app/localdb_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,25 @@ exports.drop = function(xkey="ldkc"){
"message" : "Database has been dropped."
};
}
};
};

exports.getCurrentTime = function(){
var d = new Date();

var p = d.getFullYear(),
q = d.getMonth()+1,
r = d.getDate(),
s = d.getHours(),
t = d.getMinutes(),
u = d.getSeconds();

var months = ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des"],
monthName = months[d.getMonth()];

var days = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jum'at", "Sabtu"],
dayName = days[d.getDay()];

var result = dayName + ", " + r+"/"+monthName+"/"+p+" "+s+":"+t+":"+u;

return result;
}
219 changes: 167 additions & 52 deletions app/pengecekan/pengecekan-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const LoadingIndicatorModule = require("@nstudio/nativescript-loading-indicator"
const Xloading = new LoadingIndicatorModule();
const snackBarModule = require("@nstudio/nativescript-snackbar").SnackBar;
const snackbar = new snackBarModule();
const connectivityModule = require("tns-core-modules/connectivity");
const bottom = require("../bottom/bottom-page");
const riwayat = require("../riwayat/riwayat-page");

Expand All @@ -20,87 +21,201 @@ function searchMode(search=true){
}
}

exports.onLoaded = function(){
function checkConnection(){
const type = connectivityModule.getConnectionType();
let message = "";
switch (type) {
case connectivityModule.connectionType.none:
message = "Tidak terhubung ke jaringan Internet";
context.set("connectedText", message);
context.set("connected", false);
break;
case connectivityModule.connectionType.wifi:
message = "Sedang terhubung menggunakan koneksi WIFI";
context.set("connectedText", message);
context.set("connected", true);
break;
case connectivityModule.connectionType.mobile:
message = "Sedang terhubung menggunakan koneksi Mobile";
context.set("connectedText", message);
context.set("connected", true);
break;
case connectivityModule.connectionType.ethernet:
message = "Sedang terhubung menggunakan koneksi Hotspot";
context.set("connectedText", message);
context.set("connected", true);
break;
default:
message = "Tidak terhubung ke jaringan Internet";
context.set("connectedText", message);
context.set("connected", false);
break;
}

snackbar.action({
actionText: "OKE",
actionTextColor: '#FFEB3B',
snackText: message,
textColor: '#FFFFFF',
hideDelay: 5000,
backgroundColor: '#333',
maxLines: 15, // Optional, Android Only
isRTL: false
});
}

function isConn(){
const type = connectivityModule.getConnectionType();
if(type === connectivityModule.connectionType.none ){
context.set("connectedText", "Tidak terhubung ke jaringan Internet");
context.set("connected", false);
return false;
} else if(type === connectivityModule.connectionType.wifi) {
context.set("connectedText", "Sedang terhubung menggunakan koneksi WIFI");
context.set("connected", true);
return true;
} else if(type === connectivityModule.connectionType.mobile){
context.set("connectedText", "Sedang terhubung menggunakan koneksi Mobile");
context.set("connected", true);
return true;
} else if(type === connectivityModule.connectionType.ethernet){
context.set("connectedText", "Sedang terhubung menggunakan koneksi Hotspot");
context.set("connected", true);
return true;
} else {
context.set("connectedText", "Tidak terhubung ke jaringan Internet");
context.set("connected", false);
return false;
}
}

exports.onLoaded = function(){
context.set("isValid", false);
};

exports.onNavigatingTo = function(args) {
const page = args.object;
context = new Observable();

searchMode();
checkConnection();

page.bindingContext = context;
};

exports.ceknoktp = function(){
if((context.fullname == "" && context.nik == "") || (context.fullname == undefined && context.nik == undefined)){
snackbar.action({
actionText: "OKE",
actionTextColor: '#FFEB3B',
snackText: "Nama Lengkap & No. KTP tidak boleh kosong!",
textColor: '#FFFFFF',
hideDelay: 7000,
backgroundColor: '#333',
maxLines: 15, // Optional, Android Only
isRTL: false
});
} else {
Xloading.show(gConfig.searchOption);
TimerModule.setTimeout(() => {
NpModule.nikParse(context.nik, function(result){
if(result.status == "success"){
let data = result.data;
context.set("kelamin", data.kelamin);
context.set("lahir", data.tambahan.pasaran);
context.set("provinsi", data.provinsi);
context.set("kotakab", data.kotakab);
context.set("kecamatan", data.kecamatan);
context.set("kodepos", data.tambahan.kodepos);
context.set("usia", data.tambahan.usia);
context.set("ultah", data.tambahan.ultah);
context.set("zodiak", data.tambahan.zodiak);
data.fullname = context.fullname;

let a = lsHelper.insert(data);
if(a.success){
searchMode(false);
} else {
snackbar.action({
Xloading.show(gConfig.searchOption);
if(isConn()){
if((context.fullname == "" && context.nik == "") || (context.fullname == undefined && context.nik == undefined)){
snackbar.action({
actionText: "OKE",
actionTextColor: '#FFEB3B',
snackText: "Nama Lengkap & No. KTP tidak boleh kosong!",
textColor: '#FFFFFF',
hideDelay: 7000,
backgroundColor: '#333',
maxLines: 15, // Optional, Android Only
isRTL: false
});
Xloading.hide();
} else {
TimerModule.setTimeout(() => {
NpModule.nikParse(context.nik, function(result){
if(result.status == "success"){
let data = result.data;
context.set("kelamin", data.kelamin);
context.set("lahir", data.lahir);
context.set("provinsi", data.provinsi);
context.set("kotakab", data.kotakab);
context.set("kecamatan", data.kecamatan);
context.set("uniqcode", data.uniqcode);
context.set("kodepos", data.tambahan.kodepos);
context.set("pasaran", data.tambahan.pasaran);
context.set("usia", data.tambahan.usia);
context.set("ultah", data.tambahan.ultah);
context.set("zodiak", data.tambahan.zodiak);
context.set("isValid", true);
context.set("status", "VALID");
context.set("statusColor", "#4CAF50");
context.set("datechecker", lsHelper.getCurrentTime());
data.fullname = context.fullname;
data.datechecker = lsHelper.getCurrentTime();

let a = lsHelper.insert(data);
if(a.success){
searchMode(false);
} else {
snackbar.action({
actionText: "OKE",
actionTextColor: '#FFEB3B',
snackText: a.message,
textColor: '#FFFFFF',
hideDelay: 5000,
backgroundColor: '#333',
maxLines: 15, // Optional, Android Only
isRTL: false
});
}
} else {
console.log(result);
let a = lsHelper.insert({
fullname: context.fullname,
nik: context.nik,
datechecker: lsHelper.getCurrentTime()
});
if(a.success){
searchMode(false);
if(result.status == "error"){
context.set("isValid", false);
context.set("status", "TIDAK VALID");
context.set("statusColor", "#f44336");
context.set("datechecker", lsHelper.getCurrentTime());
}
}
/* snackbar.action({
actionText: "OKE",
actionTextColor: '#FFEB3B',
snackText: a.message,
snackText: "No. KTP tidak valid! Harap periksa kembali.",
textColor: '#FFFFFF',
hideDelay: 5000,
hideDelay: 7000,
backgroundColor: '#333',
maxLines: 15, // Optional, Android Only
isRTL: false
});
}); */
}
} else {
snackbar.action({
actionText: "OKE",
actionTextColor: '#FFEB3B',
snackText: "No. KTP tidak valid! Harap periksa kembali.",
textColor: '#FFFFFF',
hideDelay: 7000,
backgroundColor: '#333',
maxLines: 15, // Optional, Android Only
isRTL: false
});
}
Xloading.hide();
Xloading.hide();
});
}, 1500);
}
} else {
TimerModule.setTimeout(() => {
snackbar.action({
actionText: "OKE",
actionTextColor: '#FFEB3B',
snackText: "Mohon cek jaringan Internet kamu!",
textColor: '#FFFFFF',
hideDelay: 5000,
backgroundColor: '#333',
maxLines: 15, // Optional, Android Only
isRTL: false
});
Xloading.hide();
}, 1500);
}
};

exports.ceklagi = function(){
/* context.set("fullname", "");
context.set("nik", ""); */
searchMode();
};

exports.recheckConnection = function(){
Xloading.show(gConfig.connectionOption);
TimerModule.setTimeout(() => {
checkConnection();
Xloading.hide();
}, 3000);
};

exports.lihatriwayat = function(){
bottom.moveToNav(1);
riwayat.refreshPageTap();
Expand Down
Loading

0 comments on commit 278388d

Please sign in to comment.