I'm using the last version of vue-js and element-ui
This question addresses the upload component whose documentation can be found here
Situation
A hook function before-upload allows us to check some stuff before allowing the upload to be accomplished.
Problem
When using a confirmation dialog, the upload does not wait the user to be accomplished
Question
Am I doing something wrong? Is this a bug?
https://jsfiddle.net/buoy2m4o/1/
You need to return the promise.
beforeAvatarUpload(file) {
return this.$confirm('Are you sure to upload this?', 'Warning', {
confirmButtonText: 'OK',
cancelButtonText: 'Cancel',
type: 'warning'
}).then(() => {
// do stuff
})
}
Updated fiddle.
Related
I am facing a problem in findding a login data of user and user is logedin to my site using google auth platform and i want to get that login data and store data in my local storage and I am working on Angular 14
Kindly help if any one know the soluiton of this problem
Thanks
I had searched a lot but not find a convieniet solution
It's work for me in this way.
According to the new documentation of Google (https://developers.google.com/identity/gsi/web/guides/overview), you should follow next steps:
Create a google app in google cloud console platform and generate a client id.
Load the client library. Add this script "<script src="https://accounts.google.com/gsi/client" async defer>" between the <head></head> tags of your index.html file of Angular project.
Add this code on ngOnInit() function in the component that you would like to have "Sign in with Google button."
ngOnInit() {
// #ts-ignore
google.accounts.id.initialize({
client_id: "YOUR GOOGLE CLIENT ID",
callback: this.handleCredentialResponse.bind(this),
auto_select: false,
cancel_on_tap_outside: true,
});
// #ts-ignore
google.accounts.id.renderButton(
// #ts-ignore
document.getElementById("google-button"),
{ theme: "outline", size: "large", width: "100%" }
);
// #ts-ignore
google.accounts.id.prompt((notification: PromptMomentNotification) => {});
}
async handleCredentialResponse(response: any) {
// Here will be your response from Google.
console.log(response);
}
Add div or button element to the html file of this component, with the same id that you mentioned into the initialization. ( "google-button" ):
<div class="" id="google-button"></div>.
Let me know if you have any issues.
I want to show a simple message when a user is logged in I am trying to use this method:
this.$router.push('/dashboard', () => {
console.log('hiiiii')
this.$bvToast.toast('Welcome!', {
title: 'Message',
solid: true,
variant: 'success'
})
})
I can see console.log('hiiiii') is executed but I dont see the toast showing in the screen, I thought that onComplete shall execute after the url is changed or I am missing something ?
I am using nuxtjs v.2.15.7 with vue-router v.3.5.1
I'm looking for the most optimal way of solving the following problem and would really appreciate some help. I have built a react native app which uses redux-saga for state management and redux-persist to keep offline data.
Problem:
When offline, users need to be able to use the native app to create "Posts" (for the sake of example) which can have multiple images attached to them. Then once they have internet connection they need to be able to click a sync/upload button. This button changes state.offlineQueue.offlineQueueShoud from 'cache' to 'sync'
Few things to consider; server side, I have a posts table, and an images table with a many to one relationship (many images to one post), which means to upload an image to the server I need to pass the post_id; meaning I have to have uploaded the post it's 'attached' to to the server so I can pass the post_id in the request. To solve this part, I have a function that uses temporary uuid's to maintain the relationship between posts and images:
function* postProcessToOfflineQueueSaga (action) {
try {
let post = Object.assign({}, action.payload);
post.uuid = uuid();
post.uploaded = false;
const imagesArr = post.images;
imagesArr.forEach(image => {
image.uuid = uuid();
image.postUuid = post.uuid;
});
post.imageIds = imagesArr.map(image => image.uuid);
delete post.images;
yield put({ type: POST_ADD_TO_OFFLINE_QUEUE, post });
yield put({ type: IMAGE_ADD_TO_OFFLINE_QUEUE, imagesArr });
} catch (error) {
console.log(error)
}
}
Which then saves it to the app state into two arrays; posts and images. E.g.
state.offlineQueue.offlinePosts: [
...
{
id: undefined,
uuid: "4df64ee5-29ba-4347-ae30-ee3d5602eae4",
imageIds: [
"62e11ef4-01f7-4052-a3e4-6cd109392818",
"2c7065ef-fed9-457f-950a-08d4224516dd",
],
uploaded: false,
}
...
]
state.offlineQueue.offlineImages: [
...
{
id: undefined,
uuid: "62e11ef4-01f7-4052-a3e4-6cd109392818",
postId: undefined,
postUuid: "4df64ee5-29ba-4347-ae30-ee3d5602eae4",
uploaded: false,
uri: "/path/to/file/on/device",
},
{
id: undefined,
uuid: "2c7065ef-fed9-457f-950a-08d4224516dd",
postId: undefined,
postUuid: "4df64ee5-29ba-4347-ae30-ee3d5602eae4",
uploaded: false,
uri: "/path/to/file/on/device",
},
...
]
state.offlineQueue.offlineQueueShoud: 'cache' // either 'cache' or 'sync'
So how do I go about sending this data to the server? What I'm thinking is:
Check 'offlineQueueShoud' (if 'cache' don't do anything to save battery?)
If offlineQueueShoud === 'sync', first iterate through the posts array and send each post to the server and use the response so that we can set post.id and image.postId to the server generated id.
Once all posts uploaded, start uploading images one by one as we now have the right post id.
Once all posts and images uploaded, clear the list.
I've had a look at redux saga channels, is that the best way to do it? If so, how do I make it so that if offlineQueueShoud === 'cache' it doesn't eat up battery, and if the app is closed/reopened no data is lost. Apologies if I'm being a noob, I'm only young :)
P.S. am I even doing this all the right way?!
UPDATE 1
I removed return from code and now links work on IOS.
But on android I can't open any app. Any idea?
I am trying to open different apps from my app.
return Linking.openURL(“twitter://“);
return Linking.openURL(“instagram://“);
But it doesn’t work. I configured IOS by documentation. On android doesn’t work too. While...
return Linking.openURL(“tripadvisor://“);
Work just fine.
Any idea why I can’t open other apps.
This is code that I am using (open app if installed or open store with it but sometimes even store doesn't open) what I did wrong:
let appUrl = "instagram://";
Linking.canOpenURL(appUrl).then(supported => {
if (!supported) {
Alert.alert("",
"",
[
{text: "go to store", onPress: this.openStorePress},
{text: "cancel", onPress: () => { }, style: 'cancel'},
],
{ cancelable: false }
);
} else {
return Linking.openURL(appUrl);
}
}).catch(err => {
console.error(err);
});
Your issue is related to the content of the url, twitter:// means nothing for the Android Twitter app, so it will not open.
For example, the following code should work:
Linking.openURL('twitter://timeline')
or
Linking.openURL('instagram://user?username=apple')
You have to find the rights url schemes (documentations are not very clear about it) that may be different between iOS and Android.
Twitter: How can I open a Twitter tweet using the native Twitter app on iOS?
Instagram: https://www.instagram.com/developer/mobile-sharing/iphone-hooks/ (all do not work on Android)
misc: https://pureoxygenlabs.com/10-app-url-schemes-for-marketers/
You have to find the rights URL schemes. Have look at my code
Instagram
Linking.openURL('instagram://user?username=apple')
.catch(() => {
Linking.openURL('https://www.instagram.com/apple');
})
Twitter
Linking.openURL('twitter://user?screen_name=apple')
.catch(() => {
Linking.openURL('https://www.twitter.com/apple');
})
Facebook
Linking.openURL('fb://page/PAGE_ID');
Linking.openURL('http://instagram.com/_u/USER_NAME');
Linking.openURL('http://instagram.com/_p/PICTURE');
Your code looks pretty solid, here's an example of how I open twitter in my app.
const twitterUrlScheme = `twitter://user?screen_name=${twitterUsername}`;
Linking.canOpenURL(twitterUrlScheme)
.then((supported) =>
Linking.openURL(
supported
? twitterUrlScheme
: `https://www.twitter.com/${twitterUsername}`
)
)
.catch((err) => console.error('An error occurred', err));
I think perhaps your issue might be the return Linking.openUrl, I'm not sure you need the return in that statement. Does it work if you remove the return? Otherwise, it might help to move your Alert outside of the then-block from canOpenUrl.
I have used only url and it's working both iOS and android
Linking.openURL('https://www.facebook.com/');
You haven't completed the " fot twitter and instagram, I don't know whether you made the same mistake in app too, if yes, fixing that might solve it.
Try to use a package like:
https://github.com/react-native-community/react-native-share
You can try to use only some of it's functions or look into the native code from there and create some bridge functions in the native code and then export them to be used in JS code.
Note: you will have to use real devices for the tests.
iOS issue only:
I am using the following code to get the users location.
navigator.geolocation.getCurrentPosition(
(position) => {
console.log("Native GEO GOOD", position);
return resolve(position)
},
(err) => {
console.log("Native GEO BADD", err);
return reject(err)
},
{ enableHighAccuracy: false, timeout: 5000, maximumAge: 0 },
)
The above code opens a dialog box, from which the user can allow my app to geolocate.
The problem is I want to wait until the user actually responds using the dialog box before calling the error or success callback.
I tried to use: requestAuthorization(). But that just opens the dialog box and I have no way to telling when the user has accepted the request to geolocate.
What I would like to do is ask the users permission to geolocate, then after the user accepts, try to geolocate the user.
But I don't see how to do that using react-native geolocation.
If requestAuthorization() took a callback option for when the user responds to the dialog box, that would solve my issue.
In React-Native using Expo (https://expo.io) you ask for permissions using a Promise and then act on the promise (hopefully when permission is given).
Permissions.askAsync((Permissions.LOCATION)
.then(({status}) => {
//your code here after permission is granted
});
);
If you aren't using expo, there is a Component call react-native-permissions (https://github.com/yonahforst/react-native-permissions.git) that allows you to request permissions using a promise like my example but without expo. Their example shows the request setting state to let you know the permissions status which you can act on.
Permissions.request('location', { type: 'always' }).then(response => {
this.setState({ locationPermission: response })
})