Merge pull request 'Memperbaiki fungsi invoke' (#14) from pengembangan into main
Reviewed-on: #14
This commit was merged in pull request #14.
This commit is contained in:
commit
eab4ea5567
15 files changed
+63
-101
No files matched your search
@@ -1,5 +1,7 @@
|
|||||||
<?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" android:maxSdkVersion="30" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
|
<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_CONNECT" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
const COMMANDS: &[&str] = &["cek_izin", "minta_izin", "daftar_perangkat", "kirim"];
|
const COMMANDS: &[&str] = &[
|
||||||
|
"check_permissions",
|
||||||
|
"request_permissions",
|
||||||
|
"daftar_perangkat",
|
||||||
|
"kirim",
|
||||||
|
];
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri_plugin::Builder::new(COMMANDS)
|
tauri_plugin::Builder::new(COMMANDS)
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { SBlueclasMuatanKirim, SBlueclasResponDaftarPerangkat } from "./models";
|
import { SBlueclasMuatanKirim, SBlueclasResponDaftarPerangkat } from "./models";
|
||||||
|
|
||||||
export async function cekIzin(): Promise<string> {
|
|
||||||
return await invoke<string>("plugin:bluclas|cek_izin").then((res: string) => res);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function mintaIzin(): Promise<null> {
|
|
||||||
return await invoke<null>("plugin:bluclas|minta_izin");
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function daftarPerangkat(): Promise<
|
export async function daftarPerangkat(): Promise<
|
||||||
SBlueclasResponDaftarPerangkat[]
|
SBlueclasResponDaftarPerangkat[]
|
||||||
> {
|
> {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@segubi/tauri-plugin-bluclas-api",
|
"name": "@segubi/tauri-plugin-bluclas-api",
|
||||||
"version": "0.1.1",
|
"version": "0.1.5",
|
||||||
"author": "Rizky Denianto",
|
"author": "Rizky Denianto",
|
||||||
"description": "",
|
"description": "",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
# 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-check-permissions"
|
||||||
|
description = "Enables the check_permissions command without any pre-configured scope."
|
||||||
|
commands.allow = ["check_permissions"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "deny-check-permissions"
|
||||||
|
description = "Denies the check_permissions command without any pre-configured scope."
|
||||||
|
commands.deny = ["check_permissions"]
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# 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"]
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated - DO NOT EDIT!
|
||||||
|
|
||||||
|
"$schema" = "../../schemas/schema.json"
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "allow-request-permissions"
|
||||||
|
description = "Enables the request_permissions command without any pre-configured scope."
|
||||||
|
commands.allow = ["request_permissions"]
|
||||||
|
|
||||||
|
[[permission]]
|
||||||
|
identifier = "deny-request-permissions"
|
||||||
|
description = "Denies the request_permissions command without any pre-configured scope."
|
||||||
|
commands.deny = ["request_permissions"]
|
||||||
@@ -4,8 +4,8 @@ Default permissions for the plugin
|
|||||||
|
|
||||||
#### This default permission set includes the following:
|
#### This default permission set includes the following:
|
||||||
|
|
||||||
- `allow-cek-izin`
|
- `allow-check-permissions`
|
||||||
- `allow-minta-izin`
|
- `allow-request-permissions`
|
||||||
- `allow-daftar-perangkat`
|
- `allow-daftar-perangkat`
|
||||||
- `allow-kirim`
|
- `allow-kirim`
|
||||||
|
|
||||||
@@ -21,12 +21,12 @@ Default permissions for the plugin
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`bluclas:allow-cek-izin`
|
`bluclas:allow-check-permissions`
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Enables the cek_izin command without any pre-configured scope.
|
Enables the check_permissions command without any pre-configured scope.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -34,12 +34,12 @@ Enables the cek_izin command without any pre-configured scope.
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`bluclas:deny-cek-izin`
|
`bluclas:deny-check-permissions`
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Denies the cek_izin command without any pre-configured scope.
|
Denies the check_permissions command without any pre-configured scope.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -99,12 +99,12 @@ Denies the kirim command without any pre-configured scope.
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`bluclas:allow-minta-izin`
|
`bluclas:allow-request-permissions`
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Enables the minta_izin command without any pre-configured scope.
|
Enables the request_permissions command without any pre-configured scope.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -112,12 +112,12 @@ Enables the minta_izin command without any pre-configured scope.
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`bluclas:deny-minta-izin`
|
`bluclas:deny-request-permissions`
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Denies the minta_izin command without any pre-configured scope.
|
Denies the request_permissions command without any pre-configured scope.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
[default]
|
[default]
|
||||||
description = "Default permissions for the plugin"
|
description = "Default permissions for the plugin"
|
||||||
permissions = [
|
permissions = [
|
||||||
"allow-cek-izin",
|
"allow-check-permissions",
|
||||||
"allow-minta-izin",
|
"allow-request-permissions",
|
||||||
"allow-daftar-perangkat",
|
"allow-daftar-perangkat",
|
||||||
"allow-kirim"
|
"allow-kirim"
|
||||||
]
|
]
|
||||||
@@ -295,16 +295,16 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"description": "Enables the cek_izin command without any pre-configured scope.",
|
"description": "Enables the check_permissions command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "allow-cek-izin",
|
"const": "allow-check-permissions",
|
||||||
"markdownDescription": "Enables the cek_izin command without any pre-configured scope."
|
"markdownDescription": "Enables the check_permissions command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Denies the cek_izin command without any pre-configured scope.",
|
"description": "Denies the check_permissions command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "deny-cek-izin",
|
"const": "deny-check-permissions",
|
||||||
"markdownDescription": "Denies the cek_izin command without any pre-configured scope."
|
"markdownDescription": "Denies the check_permissions command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Enables the daftar_perangkat command without any pre-configured scope.",
|
"description": "Enables the daftar_perangkat command without any pre-configured scope.",
|
||||||
@@ -331,22 +331,22 @@
|
|||||||
"markdownDescription": "Denies the kirim command without any pre-configured scope."
|
"markdownDescription": "Denies the kirim command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Enables the minta_izin command without any pre-configured scope.",
|
"description": "Enables the request_permissions command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "allow-minta-izin",
|
"const": "allow-request-permissions",
|
||||||
"markdownDescription": "Enables the minta_izin command without any pre-configured scope."
|
"markdownDescription": "Enables the request_permissions command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Denies the minta_izin command without any pre-configured scope.",
|
"description": "Denies the request_permissions command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "deny-minta-izin",
|
"const": "deny-request-permissions",
|
||||||
"markdownDescription": "Denies the minta_izin command without any pre-configured scope."
|
"markdownDescription": "Denies the request_permissions command without any pre-configured scope."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-cek-izin`\n- `allow-minta-izin`\n- `allow-daftar-perangkat`\n- `allow-kirim`",
|
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-check-permissions`\n- `allow-request-permissions`\n- `allow-daftar-perangkat`\n- `allow-kirim`",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "default",
|
"const": "default",
|
||||||
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-cek-izin`\n- `allow-minta-izin`\n- `allow-daftar-perangkat`\n- `allow-kirim`"
|
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-check-permissions`\n- `allow-request-permissions`\n- `allow-daftar-perangkat`\n- `allow-kirim`"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,6 @@ 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<String> {
|
|
||||||
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,14 +14,6 @@ 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<String> {
|
|
||||||
return Ok(String::new());
|
|
||||||
}
|
|
||||||
|
|
||||||
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![] });
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-7
@@ -1,4 +1,4 @@
|
|||||||
use crate::commands::{cek_izin, daftar_perangkat, kirim, minta_izin};
|
use crate::commands::{daftar_perangkat, kirim};
|
||||||
use tauri::{
|
use tauri::{
|
||||||
Manager, Runtime,
|
Manager, Runtime,
|
||||||
plugin::{Builder, TauriPlugin},
|
plugin::{Builder, TauriPlugin},
|
||||||
@@ -36,12 +36,7 @@ impl<R: Runtime, T: Manager<R>> crate::BluclasExt<R> for T {
|
|||||||
/// Initializes the plugin.
|
/// Initializes the plugin.
|
||||||
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![daftar_perangkat, kirim])
|
||||||
cek_izin,
|
|
||||||
minta_izin,
|
|
||||||
daftar_perangkat,
|
|
||||||
kirim
|
|
||||||
])
|
|
||||||
.setup(|app, api| {
|
.setup(|app, api| {
|
||||||
#[cfg(mobile)]
|
#[cfg(mobile)]
|
||||||
let bluclas = mobile::init(app, api)?;
|
let bluclas = mobile::init(app, api)?;
|
||||||
|
|||||||
@@ -25,20 +25,6 @@ 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<String> {
|
|
||||||
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