upd: view file
Deskripsi: - unduh diilangin - kegiatan umum - task divisi - dokumen divisi No Issues
This commit is contained in:
4
android/.kotlin/errors/errors-1749523770398.log
Normal file
4
android/.kotlin/errors/errors-1749523770398.log
Normal file
@@ -0,0 +1,4 @@
|
||||
kotlin version: 2.0.21
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
@@ -25,9 +25,14 @@ import {
|
||||
MaterialCommunityIcons,
|
||||
MaterialIcons,
|
||||
} from "@expo/vector-icons";
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import { startActivityAsync } from 'expo-intent-launcher';
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import * as Sharing from 'expo-sharing';
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
Alert,
|
||||
Platform,
|
||||
Pressable,
|
||||
SafeAreaView,
|
||||
ScrollView,
|
||||
@@ -35,6 +40,7 @@ import {
|
||||
ToastAndroid,
|
||||
View,
|
||||
} from "react-native";
|
||||
import * as mime from 'react-native-mime-types';
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
@@ -258,6 +264,39 @@ export default function DocumentDivision() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const openFile = (item: Props) => {
|
||||
let remoteUrl = 'https://wibu-storage.wibudev.com/api/files/' + item.idStorage;
|
||||
const fileName = item.name + '.' + item.extension;
|
||||
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
|
||||
const mimeType = mime.lookup(fileName)
|
||||
|
||||
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
|
||||
const contentURL = await FileSystem.getContentUriAsync(uri);
|
||||
try {
|
||||
|
||||
if (Platform.OS == 'android') {
|
||||
// open with android intent
|
||||
await startActivityAsync(
|
||||
'android.intent.action.VIEW',
|
||||
{
|
||||
data: contentURL,
|
||||
flags: 1,
|
||||
type: mimeType as string,
|
||||
}
|
||||
);
|
||||
// or
|
||||
// Sharing.shareAsync(localPath);
|
||||
|
||||
} else if (Platform.OS == 'ios') {
|
||||
Sharing.shareAsync(localPath);
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
@@ -331,9 +370,7 @@ export default function DocumentDivision() {
|
||||
:
|
||||
data.length > 0 ? (
|
||||
data.map((item, index) => {
|
||||
const isSelected = selectedFiles.some(
|
||||
(i: any) => i?.id == item.id
|
||||
);
|
||||
const isSelected = selectedFiles.some((i: any) => i?.id == item.id);
|
||||
return (
|
||||
<ItemFile
|
||||
key={index}
|
||||
@@ -357,7 +394,11 @@ export default function DocumentDivision() {
|
||||
}}
|
||||
checked={isSelected}
|
||||
onPress={() => {
|
||||
setPath(item.id);
|
||||
if (item.category == "FOLDER" && selectedFiles.length == 0 && !dariSelectAll) {
|
||||
setPath(item.id);
|
||||
} else if (item.category == "FILE" && selectedFiles.length == 0 && !dariSelectAll) {
|
||||
openFile(item)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -380,7 +421,7 @@ export default function DocumentDivision() {
|
||||
{(selectedFiles.length > 0 || dariSelectAll) && (
|
||||
<View style={[ColorsStatus.primary, Styles.bottomMenuSelectDocument]}>
|
||||
<View style={[Styles.rowItemsCenter, { justifyContent: "center" }]}>
|
||||
<MenuItemRow
|
||||
{/* <MenuItemRow
|
||||
icon={
|
||||
<MaterialCommunityIcons
|
||||
name="download-outline"
|
||||
@@ -393,7 +434,7 @@ export default function DocumentDivision() {
|
||||
column="many"
|
||||
color="white"
|
||||
disabled={selectedFiles.length == 0 || !copyAllowed}
|
||||
/>
|
||||
/> */}
|
||||
<MenuItemRow
|
||||
icon={
|
||||
<MaterialCommunityIcons
|
||||
|
||||
@@ -3,11 +3,13 @@ import { apiDeleteFileProject, apiGetProjectOne } from "@/lib/api";
|
||||
import { setUpdateProject } from "@/lib/projectUpdate";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
// import * as FileSystem from 'expo-file-system';
|
||||
import { Directory, File, Paths } from 'expo-file-system/next';
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import { startActivityAsync } from 'expo-intent-launcher';
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import * as Sharing from 'expo-sharing';
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, ToastAndroid, View } from "react-native";
|
||||
import { Alert, Platform, Text, ToastAndroid, View } from "react-native";
|
||||
import * as mime from 'react-native-mime-types';
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import AlertKonfirmasi from "../alertKonfirmasi";
|
||||
import BorderBottomItem from "../borderBottomItem";
|
||||
@@ -30,10 +32,10 @@ export default function SectionFile({ status, member }: { status: number | undef
|
||||
const { id } = useLocalSearchParams<{ id: string }>();
|
||||
const [data, setData] = useState<Props[]>([]);
|
||||
const update = useSelector((state: any) => state.projectUpdate)
|
||||
const [idSelect, setIdSelect] = useState('')
|
||||
const dispatch = useDispatch()
|
||||
const [loading, setLoading] = useState(true)
|
||||
const arrSkeleton = Array.from({ length: 3 })
|
||||
const [selectFile, setSelectFile] = useState<Props | null>(null)
|
||||
|
||||
async function handleLoad(loading: boolean) {
|
||||
try {
|
||||
@@ -64,7 +66,7 @@ export default function SectionFile({ status, member }: { status: number | undef
|
||||
async function handleDelete() {
|
||||
try {
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiDeleteFileProject({ user: hasil }, idSelect);
|
||||
const response = await apiDeleteFileProject({ user: hasil }, String(selectFile?.id));
|
||||
if (response.success) {
|
||||
ToastAndroid.show('Berhasil menghapus file', ToastAndroid.SHORT)
|
||||
dispatch(setUpdateProject({ ...update, file: !update.file }))
|
||||
@@ -79,14 +81,45 @@ export default function SectionFile({ status, member }: { status: number | undef
|
||||
}
|
||||
}
|
||||
|
||||
async function download() {
|
||||
const destination = new Directory(Paths.document, 'pdfs');
|
||||
const filename = "dummy.pdf";
|
||||
const result = await File.downloadFileAsync('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', destination);
|
||||
console.log(result)
|
||||
}
|
||||
// async function download() {
|
||||
// const destination = new Directory(Paths.document, 'pdfs');
|
||||
// const filename = "dummy.pdf";
|
||||
// const result = await File.downloadFileAsync('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', destination);
|
||||
// }
|
||||
|
||||
|
||||
const openFile = () => {
|
||||
let remoteUrl = 'https://wibu-storage.wibudev.com/api/files/' + selectFile?.idStorage;
|
||||
const fileName = selectFile?.name + '.' + selectFile?.extension;
|
||||
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
|
||||
const mimeType = mime.lookup(fileName)
|
||||
|
||||
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
|
||||
const contentURL = await FileSystem.getContentUriAsync(uri);
|
||||
try {
|
||||
|
||||
if (Platform.OS == 'android') {
|
||||
// open with android intent
|
||||
await startActivityAsync(
|
||||
'android.intent.action.VIEW',
|
||||
{
|
||||
data: contentURL,
|
||||
flags: 1,
|
||||
type: mimeType as string,
|
||||
}
|
||||
);
|
||||
// or
|
||||
// Sharing.shareAsync(localPath);
|
||||
|
||||
} else if (Platform.OS == 'ios') {
|
||||
Sharing.shareAsync(localPath);
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
return (
|
||||
@@ -111,7 +144,7 @@ export default function SectionFile({ status, member }: { status: number | undef
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name + '.' + item.extension}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIdSelect(item.id); setModal(true) }}
|
||||
onPress={() => { setSelectFile(item); setModal(true) }}
|
||||
width={65}
|
||||
/>
|
||||
)
|
||||
@@ -128,17 +161,17 @@ export default function SectionFile({ status, member }: { status: number | undef
|
||||
icon={<MaterialCommunityIcons name="file-eye" color="black" size={25} />}
|
||||
title="Lihat File"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
openFile()
|
||||
}}
|
||||
/>
|
||||
<MenuItemRow
|
||||
{/* <MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="download" color="black" size={25} />}
|
||||
title="Download"
|
||||
onPress={() => {
|
||||
download()
|
||||
// download()
|
||||
// setModal(false)
|
||||
}}
|
||||
/>
|
||||
/> */}
|
||||
{
|
||||
!member && (entityUser.role == "user" || entityUser.role == "coadmin") ? <></>
|
||||
:
|
||||
|
||||
@@ -3,9 +3,13 @@ import { apiDeleteFileTask, apiGetTaskOne } from "@/lib/api";
|
||||
import { setUpdateTask } from "@/lib/taskUpdate";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import { startActivityAsync } from 'expo-intent-launcher';
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import * as Sharing from 'expo-sharing';
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, ToastAndroid, View } from "react-native";
|
||||
import { Alert, Platform, Text, ToastAndroid, View } from "react-native";
|
||||
import * as mime from 'react-native-mime-types';
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import AlertKonfirmasi from "../alertKonfirmasi";
|
||||
import BorderBottomItem from "../borderBottomItem";
|
||||
@@ -25,11 +29,11 @@ export default function SectionFileTask() {
|
||||
const { token, decryptToken } = useAuthSession()
|
||||
const { detail } = useLocalSearchParams<{ detail: string }>();
|
||||
const [data, setData] = useState<Props[]>([])
|
||||
const [idSelect, setIdSelect] = useState('')
|
||||
const update = useSelector((state: any) => state.taskUpdate)
|
||||
const dispatch = useDispatch()
|
||||
const [loading, setLoading] = useState(true)
|
||||
const arrSkeleton = Array.from({ length: 5 })
|
||||
const [selectFile, setSelectFile] = useState<Props | null>(null)
|
||||
|
||||
async function handleLoad(loading: boolean) {
|
||||
try {
|
||||
@@ -52,10 +56,43 @@ export default function SectionFileTask() {
|
||||
handleLoad(true)
|
||||
}, [])
|
||||
|
||||
const openFile = () => {
|
||||
let remoteUrl = 'https://wibu-storage.wibudev.com/api/files/' + selectFile?.idStorage;
|
||||
const fileName = selectFile?.name + '.' + selectFile?.extension;
|
||||
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
|
||||
const mimeType = mime.lookup(fileName)
|
||||
|
||||
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
|
||||
const contentURL = await FileSystem.getContentUriAsync(uri);
|
||||
try {
|
||||
|
||||
if (Platform.OS == 'android') {
|
||||
// open with android intent
|
||||
await startActivityAsync(
|
||||
'android.intent.action.VIEW',
|
||||
{
|
||||
data: contentURL,
|
||||
flags: 1,
|
||||
type: mimeType as string,
|
||||
}
|
||||
);
|
||||
// or
|
||||
// Sharing.shareAsync(localPath);
|
||||
|
||||
} else if (Platform.OS == 'ios') {
|
||||
Sharing.shareAsync(localPath);
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
async function handleDelete() {
|
||||
try {
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiDeleteFileTask({ user: hasil }, idSelect);
|
||||
const response = await apiDeleteFileTask({ user: hasil }, String(selectFile?.id));
|
||||
if (response.success) {
|
||||
ToastAndroid.show('Berhasil menghapus file', ToastAndroid.SHORT)
|
||||
dispatch(setUpdateTask({ ...update, file: !update.file }))
|
||||
@@ -92,7 +129,7 @@ export default function SectionFileTask() {
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name + '.' + item.extension}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIdSelect(item.id); setModal(true) }}
|
||||
onPress={() => { setSelectFile(item); setModal(true) }}
|
||||
width={65}
|
||||
/>
|
||||
)
|
||||
@@ -109,16 +146,17 @@ export default function SectionFileTask() {
|
||||
icon={<MaterialCommunityIcons name="file-eye" color="black" size={25} />}
|
||||
title="Lihat File"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
openFile()
|
||||
// setModal(false)
|
||||
}}
|
||||
/>
|
||||
<MenuItemRow
|
||||
{/* <MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="download" color="black" size={25} />}
|
||||
title="Download"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
}}
|
||||
/>
|
||||
/> */}
|
||||
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash" color="black" size={25} />}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: 'http://10.0.2.2:3000/api',
|
||||
// baseURL: 'http://10.0.2.2:3000/api',
|
||||
baseURL: 'http://192.168.1.243:3000/api',
|
||||
});
|
||||
|
||||
export const apiCheckPhoneLogin = async (body: { phone: string }) => {
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"expo-font": "~13.3.1",
|
||||
"expo-haptics": "~14.1.4",
|
||||
"expo-image-picker": "~16.1.4",
|
||||
"expo-intent-launcher": "~12.1.5",
|
||||
"expo-linear-gradient": "~14.1.4",
|
||||
"expo-linking": "~7.1.5",
|
||||
"expo-media-library": "~17.1.6",
|
||||
@@ -59,6 +60,7 @@
|
||||
"react-native-gesture-handler": "~2.24.0",
|
||||
"react-native-gifted-charts": "^1.4.57",
|
||||
"react-native-image-picker": "^8.2.1",
|
||||
"react-native-mime-types": "^2.5.0",
|
||||
"react-native-modal": "^14.0.0-rc.1",
|
||||
"react-native-modal-datetime-picker": "^18.0.0",
|
||||
"react-native-otp-entry": "^1.8.4",
|
||||
@@ -70,7 +72,7 @@
|
||||
"react-native-svg": "15.11.2",
|
||||
"react-native-ui-datepicker": "^3.0.5",
|
||||
"react-native-web": "^0.20.0",
|
||||
"react-native-webview": "13.12.5",
|
||||
"react-native-webview": "^13.15.0",
|
||||
"react-redux": "^9.2.0",
|
||||
"redux": "^5.0.1"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user