Merge pull request 'Menambah izin per perintah atau per fungsi' (#8) from pengembangan into main
Reviewed-on: #8
This commit was merged in pull request #8.
This commit is contained in:
commit
424c0f7049
14 files changed
+234
-35
No files matched your search
@@ -1,3 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
const COMMANDS: &[&str] = &["ping"];
|
const COMMANDS: &[&str] = &["cek_izin", "minta_izin", "daftar_perangkat", "kirim"];
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri_plugin::Builder::new(COMMANDS)
|
tauri_plugin::Builder::new(COMMANDS)
|
||||||
.android_path("android")
|
.android_path("android")
|
||||||
.ios_path("ios")
|
.ios_path("ios")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated - DO NOT EDIT!
|
||||||
|
|
||||||
|
"$schema" = "../../schemas/schema.json"
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-cek-izin"
|
||||||
|
description = "Enables the cek_izin command without any pre-configured scope."
|
||||||
|
commands.allow = ["cek_izin"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "deny-cek-izin"
|
||||||
|
description = "Denies the cek_izin command without any pre-configured scope."
|
||||||
|
commands.deny = ["cek_izin"]
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated - DO NOT EDIT!
|
||||||
|
|
||||||
|
"$schema" = "../../schemas/schema.json"
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-daftar-perangkat"
|
||||||
|
description = "Enables the daftar_perangkat command without any pre-configured scope."
|
||||||
|
commands.allow = ["daftar_perangkat"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "deny-daftar-perangkat"
|
||||||
|
description = "Denies the daftar_perangkat command without any pre-configured scope."
|
||||||
|
commands.deny = ["daftar_perangkat"]
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated - DO NOT EDIT!
|
||||||
|
|
||||||
|
"$schema" = "../../schemas/schema.json"
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-kirim"
|
||||||
|
description = "Enables the kirim command without any pre-configured scope."
|
||||||
|
commands.allow = ["kirim"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "deny-kirim"
|
||||||
|
description = "Denies the kirim command without any pre-configured scope."
|
||||||
|
commands.deny = ["kirim"]
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated - DO NOT EDIT!
|
||||||
|
|
||||||
|
"$schema" = "../../schemas/schema.json"
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-minta-izin"
|
||||||
|
description = "Enables the minta_izin command without any pre-configured scope."
|
||||||
|
commands.allow = ["minta_izin"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "deny-minta-izin"
|
||||||
|
description = "Denies the minta_izin command without any pre-configured scope."
|
||||||
|
commands.deny = ["minta_izin"]
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
"$schema" = "../../schemas/schema.json"
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-ping"
|
|
||||||
description = "Enables the ping command without any pre-configured scope."
|
|
||||||
commands.allow = ["ping"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-ping"
|
|
||||||
description = "Denies the ping command without any pre-configured scope."
|
|
||||||
commands.deny = ["ping"]
|
|
||||||
@@ -4,7 +4,10 @@ Default permissions for the plugin
|
|||||||
|
|
||||||
#### This default permission set includes the following:
|
#### This default permission set includes the following:
|
||||||
|
|
||||||
- `allow-ping`
|
- `cek_izin`
|
||||||
|
- `minta_izin`
|
||||||
|
- `daftar_perangkat`
|
||||||
|
- `kirim`
|
||||||
|
|
||||||
## Permission Table
|
## Permission Table
|
||||||
|
|
||||||
@@ -18,12 +21,12 @@ Default permissions for the plugin
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`bluclas:allow-ping`
|
`bluclas:allow-cek-izin`
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Enables the ping command without any pre-configured scope.
|
Enables the cek_izin command without any pre-configured scope.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -31,12 +34,90 @@ Enables the ping command without any pre-configured scope.
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`bluclas:deny-ping`
|
`bluclas:deny-cek-izin`
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Denies the ping command without any pre-configured scope.
|
Denies the cek_izin command without any pre-configured scope.
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
`bluclas:allow-daftar-perangkat`
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
Enables the daftar_perangkat command without any pre-configured scope.
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
`bluclas:deny-daftar-perangkat`
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
Denies the daftar_perangkat command without any pre-configured scope.
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
`bluclas:allow-kirim`
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
Enables the kirim command without any pre-configured scope.
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
`bluclas:deny-kirim`
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
Denies the kirim command without any pre-configured scope.
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
`bluclas:allow-minta-izin`
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
Enables the minta_izin command without any pre-configured scope.
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
`bluclas:deny-minta-izin`
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
Denies the minta_izin command without any pre-configured scope.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
[default]
|
[default]
|
||||||
description = "Default permissions for the plugin"
|
description = "Default permissions for the plugin"
|
||||||
permissions = ["allow-ping"]
|
permissions = [
|
||||||
|
"cek_izin",
|
||||||
|
"minta_izin",
|
||||||
|
"daftar_perangkat",
|
||||||
|
"kirim"
|
||||||
|
]
|
||||||
@@ -295,22 +295,58 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"description": "Enables the ping command without any pre-configured scope.",
|
"description": "Enables the cek_izin command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "allow-ping",
|
"const": "allow-cek-izin",
|
||||||
"markdownDescription": "Enables the ping command without any pre-configured scope."
|
"markdownDescription": "Enables the cek_izin command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Denies the ping command without any pre-configured scope.",
|
"description": "Denies the cek_izin command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "deny-ping",
|
"const": "deny-cek-izin",
|
||||||
"markdownDescription": "Denies the ping command without any pre-configured scope."
|
"markdownDescription": "Denies the cek_izin command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-ping`",
|
"description": "Enables the daftar_perangkat command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "allow-daftar-perangkat",
|
||||||
|
"markdownDescription": "Enables the daftar_perangkat command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the daftar_perangkat command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deny-daftar-perangkat",
|
||||||
|
"markdownDescription": "Denies the daftar_perangkat command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the kirim command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "allow-kirim",
|
||||||
|
"markdownDescription": "Enables the kirim command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the kirim command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deny-kirim",
|
||||||
|
"markdownDescription": "Denies the kirim command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Enables the minta_izin command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "allow-minta-izin",
|
||||||
|
"markdownDescription": "Enables the minta_izin command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Denies the minta_izin command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"const": "deny-minta-izin",
|
||||||
|
"markdownDescription": "Denies the minta_izin command without any pre-configured scope."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `cek_izin`\n- `minta_izin`\n- `daftar_perangkat`\n- `kirim`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "default",
|
"const": "default",
|
||||||
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-ping`"
|
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `cek_izin`\n- `minta_izin`\n- `daftar_perangkat`\n- `kirim`"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,16 @@ use crate::BluclasExt;
|
|||||||
use crate::Result;
|
use crate::Result;
|
||||||
use crate::models::*;
|
use crate::models::*;
|
||||||
|
|
||||||
|
#[command]
|
||||||
|
pub(crate) async fn cek_izin<R: Runtime>(app: AppHandle<R>) -> Result<bool> {
|
||||||
|
return app.bluclas().cek_izin();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[command]
|
||||||
|
pub(crate) async fn minta_izin<R: Runtime>(app: AppHandle<R>) -> Result<()> {
|
||||||
|
return app.bluclas().minta_izin();
|
||||||
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
pub(crate) async fn daftar_perangkat<R: Runtime>(
|
pub(crate) async fn daftar_perangkat<R: Runtime>(
|
||||||
app: AppHandle<R>,
|
app: AppHandle<R>,
|
||||||
|
|||||||
@@ -14,6 +14,14 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
|
|||||||
pub struct Bluclas<R: Runtime>(AppHandle<R>);
|
pub struct Bluclas<R: Runtime>(AppHandle<R>);
|
||||||
|
|
||||||
impl<R: Runtime> Bluclas<R> {
|
impl<R: Runtime> Bluclas<R> {
|
||||||
|
pub fn cek_izin(&self) -> crate::Result<bool> {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn minta_izin(&self) -> crate::Result<()> {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
||||||
return Ok(SBlueclasResponDaftarPerangkat { data: vec![] });
|
return Ok(SBlueclasResponDaftarPerangkat { data: vec![] });
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-3
@@ -1,6 +1,7 @@
|
|||||||
|
use crate::commands::{cek_izin, daftar_perangkat, kirim, minta_izin};
|
||||||
use tauri::{
|
use tauri::{
|
||||||
plugin::{Builder, TauriPlugin},
|
|
||||||
Manager, Runtime,
|
Manager, Runtime,
|
||||||
|
plugin::{Builder, TauriPlugin},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use models::*;
|
pub use models::*;
|
||||||
@@ -36,8 +37,10 @@ impl<R: Runtime, T: Manager<R>> crate::BluclasExt<R> for T {
|
|||||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||||
Builder::new("bluclas")
|
Builder::new("bluclas")
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
commands::daftar_perangkat,
|
cek_izin,
|
||||||
commands::kirim
|
minta_izin,
|
||||||
|
daftar_perangkat,
|
||||||
|
kirim
|
||||||
])
|
])
|
||||||
.setup(|app, api| {
|
.setup(|app, api| {
|
||||||
#[cfg(mobile)]
|
#[cfg(mobile)]
|
||||||
|
|||||||
@@ -25,6 +25,20 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
|
|||||||
pub struct Bluclas<R: Runtime>(PluginHandle<R>);
|
pub struct Bluclas<R: Runtime>(PluginHandle<R>);
|
||||||
|
|
||||||
impl<R: Runtime> Bluclas<R> {
|
impl<R: Runtime> Bluclas<R> {
|
||||||
|
pub fn cek_izin(&self) -> crate::Result<bool> {
|
||||||
|
return self
|
||||||
|
.0
|
||||||
|
.run_mobile_plugin("checkPermissions", ())
|
||||||
|
.map_err(Into::into);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn minta_izin(&self) -> crate::Result<()> {
|
||||||
|
return self
|
||||||
|
.0
|
||||||
|
.run_mobile_plugin("requestPermissions", ())
|
||||||
|
.map_err(Into::into);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
||||||
return self
|
return self
|
||||||
.0
|
.0
|
||||||
|
|||||||
Reference in new issue
Block a user