Commit b4e82409 authored by tejaswi's avatar tejaswi
Browse files

User dashboard chat screen code

parent d268ae04
Showing with 1895 additions and 18 deletions
+1895 -18
......@@ -13241,6 +13241,14 @@
"resolved": "https://registry.npmjs.org/react-native-device-info/-/react-native-device-info-8.1.3.tgz",
"integrity": "sha512-73e3wiGFL8DvIXEd8x4Aq+mO8mZvHARwfYorIEu+X0trLHY92bP5Ict8DJHDjCQ0+HtAvpA4Wda2VoUVN1zh6Q=="
},
"react-native-document-picker": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/react-native-document-picker/-/react-native-document-picker-7.1.1.tgz",
"integrity": "sha512-lEgyfl+JbU/UCDu8UdagBrC5CC71WTfqCzWyGeALLZiXGHrCJo/5BMqWbAc9PSCeiqNMnFkjcybO/kws5gMkxA==",
"requires": {
"invariant": "^2.2.4"
}
},
"react-native-drawer": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/react-native-drawer/-/react-native-drawer-2.5.1.tgz",
......
This diff is collapsed.
/*
FileName:UserChat.js
Version:1.0.0
Purpose:Getting the List of task messages with GroupName and List of Group Members and also send Message
Devloper:Naveen, Mahesh
*/
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
TouchableOpacity,
Image,
Alert,
ScrollView,
TextInput,
FlatList,
Button,
Dimensions,
KeyboardAvoidingView,
TouchableWithoutFeedback,
Keyboard
} from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import AsyncStorage from '@react-native-community/async-storage';
import { Title, Container, Content, Header, Right, Left, Body, Tab, Tabs, TabHeading, Footer, Item, Input, FooterTab, Subtitle } from 'native-base';
import NetInfo from '@react-native-community/netinfo';
import { API } from "../WebServices/RestClient";
import log from '../LogFile/Log';
export default class AdminChatUser extends Component {
constructor(props) {
super(props);
this.state = {
message: '',
dataSource: [],
subtaskId: this.props.navigation.state.params.taskid,
action: this.props.navigation.state.params.action,
empId: this.props.navigation.state.params.empId,
device_id: this.props.navigation.state.params.device_id,
name: this.props.navigation.state.params.name,
// sno:this.props.navigation.state.params.sno,
userid: '',
groupName: '',
groupList: '',
};
}
componentDidMount() {
log("Debug", "Task Chat screen is loaded");
// this.groupMembersList();//Getting the List of GroupMembers
this.getMessages();//Getting the List of Messages based pn Task
this.updateMessages();//Update the chat count
}
//getting task related messages
getMessages() {
log("Info", " getMessages(role, userToken, cropcode) is used getting task related messages");
// const groupId = this.state.subtaskId;
// alert("Hello")
AsyncStorage.multiGet(["cropcode", "userToken"], (err, response) => {
const cropcode = response[0][1];
const userToken = response[1][1];
this.setState({ userid: userToken });
AsyncStorage.getItem("projectId", (err, res) => {
const projectId = res;
NetInfo.fetch().then(state => {
if (state.type == "none") {
log("Warn", "No internet connection");
Snackbar.show({
title: 'No Internet Connection',
backgroundColor: 'red',
duration: Snackbar.LENGTH_LONG,
});
}
else {
fetch(API + 'squad_chat.php',
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
action: "get_messages",
sendBy: userToken,
receivedBy: this.props.navigation.state.params.empId,
})
})
.then((response) => response.json())
.then((responseJson) => {
// alert(JSON.stringify(responseJson.data))
if (responseJson.status === 'True') {
console.warn(responseJson);
this.setState({
dataSource: responseJson.data,
});
} else {
this.setState({
dataSource: '',
});
}
})
.catch((error) => {
console.error(error);
log("Error", "getting task related messages error");
});
}
});
});
});
}
//getting task related messages
userMessages() {
log("Info", " getMessages(role, userToken, cropcode) is used getting task related messages");
// const groupId = this.state.subtaskId;
alert(this.props.navigation.state.params.empId)
const message = this.state.message;
AsyncStorage.multiGet(["cropcode", "userToken"], (err, response) => {
const cropcode = response[0][1];
const userToken = response[1][1];
this.setState({ userid: userToken });
AsyncStorage.getItem("projectId", (err, res) => {
const projectId = res;
NetInfo.fetch().then(state => {
if (state.type == "none") {
log("Warn", "No internet connection");
Snackbar.show({
title: 'No Internet Connection',
backgroundColor: 'red',
duration: Snackbar.LENGTH_LONG,
});
}
else {
fetch(API + 'squad_chat.php',
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
action: 'send',
// groupId: groupId,
// corp_code: cropcode,
message: message,
messagedBy: userToken,
message: this.state.message,
receivedBy: this.props.navigation.state.params.empId,
// projectId:projectId,
})
})
.then((response) => response.json())
.then((responseJson) => {
if (responseJson.status === 'True') {
console.warn(responseJson);
this.setState({
dataSource: responseJson.data,
});
} else {
this.setState({
dataSource: '',
});
}
})
.catch((error) => {
console.error(error);
log("Error", "getting task related messages error");
});
}
});
});
});
}
//update task related messages
updateMessages() {
log("Info", " updateMessages(role, userToken, cropcode) is used to update task related messages");
const groupId = this.state.subtaskId;
const sno = this.state.sno;
console.warn("sno" + sno)
// alert(sno)
const msgId = sno ? sno.map((msgId, index) => {
return msgId.sno
}) : null
// console.warn("Sno of the data"+this.props.navigation.state.params.sno)
AsyncStorage.multiGet(["cropcode", "userToken"], (err, response) => {
const cropcode = response[0][1];
const userToken = response[1][1];
this.setState({ userid: userToken });
NetInfo.fetch().then(state => {
if (state.type == "none") {
log("Warn", "No internet connection");
Snackbar.show({
title: 'No Internet Connection',
backgroundColor: 'red',
duration: Snackbar.LENGTH_LONG,
});
}
else {
fetch(API + 'squad_chat.php"',
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
action: 'updateChat',
// corp_code: cropcode,
messagedBy: userToken,
msgId: msgId ? msgId : " "
// groupId: groupId
})
})
.then((response) => response.json())
.then((responseJson) => {
console.warn("update chat" + JSON.stringify(responseJson))
// alert(responseJson)
})
.catch((error) => {
console.error(error);
log("Error", "getting task related messages error");
});
}
});
});
}
//Sending Message without empty data added by naveen on 11 Nov
sendMessageText() {
if (this.state.message == 0) {
alert("please type message")
log("Warn", "message should not be empty");
}
else {
this.sendMessage()
}
}
//send messages
sendMessage() {
log("Info", " sendMessage(role, userToken, cropcode) is used to send messages");
const message = this.state.message;
// const groupId = this.state.subtaskId;
// alert(this.props.navigation.state.params.device_id)
// alert(this.props.navigation.state.params.empId)
console.warn(message)
// alert(message)
AsyncStorage.multiGet(["cropcode", "userToken"], (err, response) => {
const cropcode = response[0][1];
const userToken = response[1][1];
AsyncStorage.getItem("projectId", (err, res) => {
const projectId = res;
fetch(API + 'squad_chat.php', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
action: "send",
sendBy: userToken,
message: this.state.message,
receivedBy: this.props.navigation.state.params.empId,
messagedBy: userToken,
})
}).then((response) => response.json())
.then((responseJson) => {
// console.log(JSON.stringify(responseJson.data))
// alert(JSON.stringify(responseJson.data))
this.getMessages();
this.setState({
message: ''
});
}).catch((error) => {
console.error(error);
log("Error", "send message error");
});
});
});
}
renderDate = (date) => {
return (
<Text style={styles.time}>
{date}
</Text>
);
}
render() {
return (
<KeyboardAvoidingView
behavior={Platform.OS === "ios" ? "padding" : "height"}
style={styles.container}
>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<Container>
<Header
androidStatusBarColor="#00A2C1"
style={{
backgroundColor: '#00A2C1',
height: 60,
width: Dimensions.get('window').width,
borderBottomColor: '#ffffff',
justifyContent: 'space-between',
}}>
<Icon name="arrow-left" size={20} style={{ color: '#fff', paddingTop: 15 }}
onPress={() =>
this.props.navigation.goBack()} />
<Body style={{ paddingLeft: 30, }}>
<Title style={{ color: '#fff', fontWeight: '600', paddingTop: 10 }}>{this.props.navigation.state.params.name}</Title>
<Subtitle></Subtitle>
</Body>
</Header>
{/* <KeyboardAvoidingView> */}
<View style={styles.container}>
<ScrollView ref="scrollView"
onContentSizeChange={(width, height) => this.refs.scrollView.scrollTo({ y: height })}>
<FlatList style={styles.list}
data={this.state.dataSource}
keyExtractor={(item) => {
return item.id;
}}
renderItem={(message) => {
const item = message.item;
let inMessage = item.messagedBy === this.state.userid;
let itemStyle = !inMessage ? styles.itemIn : styles.itemOut;
const left = <Text style={{ fontSize: 12, color: 'orange' }}>{item.username}</Text>
const right = <Text style={{ fontSize: 12, color: 'blue' }}>{item.username}</Text>
return (
<ScrollView>
<View style={[styles.item, itemStyle]}>
<View style={{ paddingLeft: 5, }}>
{itemStyle === styles.itemOut ? left : right}
<Text>{item.message}</Text>
{!inMessage && this.renderDate(item.date)}
{inMessage && this.renderDate(item.date)}
</View>
</View>
</ScrollView>
)
}} />
</ScrollView>
<View style={styles.footer}>
<View style={styles.inputContainer}>
<TextInput style={styles.inputs}
placeholder="Write a message..."
underlineColorAndroid='transparent'
multiline={true}
onChangeText={(value) => this.setState({ message: value })}
value={this.state.message} />
</View>
<TouchableOpacity style={styles.btnSend} onPress={() => { this.sendMessageText() }}>
{/* <Image source={{uri:"https://png.icons8.com/small/75/ffffff/filled-sent.png"}} style={styles.iconSend} /> */}
<Image source={require('../Images/sent.png')} style={styles.iconSend} />
</TouchableOpacity>
</View>
</View>
{/* </KeyboardAvoidingView> */}
</Container>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
);
}
}
//Styles fro UI
const styles = StyleSheet.create({
container: {
flex: 1
},
list: {
paddingHorizontal: 17,
},
footer: {
flexDirection: 'row',
height: 60,
backgroundColor: '#eeeeee',
paddingHorizontal: 10,
padding: 5,
},
btnSend: {
backgroundColor: "#00BFFF",
width: 40,
height: 40,
borderRadius: 360,
alignItems: 'center',
justifyContent: 'center',
},
iconSend: {
width: 30,
height: 30,
alignSelf: 'center',
},
inputContainer: {
borderBottomColor: '#F5FCFF',
backgroundColor: '#FFFFFF',
borderRadius: 30,
borderBottomWidth: 1,
height: 40,
flexDirection: 'row',
alignItems: 'center',
flex: 1,
marginRight: 10,
alignItems: 'baseline',
},
inputs: {
height: 40,
marginLeft: 16,
borderBottomColor: '#FFFFFF',
flex: 1,
// position:'absolute',
alignItems: 'baseline',
paddingTop: 10
},
balloon: {
maxWidth: 200,
padding: 10,
borderRadius: 20,
},
itemIn: {
alignSelf: 'flex-start',
maxWidth: '98%',
// flexDirection:'row'
},
itemOut: {
alignSelf: 'flex-end',
//paddingLeft:10,
maxWidth: '98%',
// flexDirection:'row'
},
time: {
alignSelf: 'flex-end',
// margin: 15,
fontSize: 12,
color: "#808080",
paddingRight: 10
},
item: {
marginVertical: 14,
flex: 1,
flexDirection: 'row',
// paddingLeft:50,
backgroundColor: "#eeeeee",
borderRadius: 10,
padding: 5,
},
});
\ No newline at end of file
/*
FileName:NavigationRouter.js
Version:1.0.0
Purpose:Navgate to all classes from Here
Purpose:Navigate to all classes from Here
Devloper:Mahesh Reddy
*/
import React, { Component } from 'react';
......@@ -84,6 +84,9 @@ import AddLicensesPayment from '../UserComponents/AddLicensesPayment';
import UserGroupChat from '../UserComponents/UserGroupChat';
import UserGroupChatModify from '../UserComponents/UserGroupChatModify';
import UserDashboard from '../UserComponents/UserDashboard';
import UserImageUpload from '../UserComponents/UserImageUpload';
import AdminChat from '../CommonComponents/AdminChat';
import AdminChatUser from '../CommonComponents/AdminChatUser';
import AddModule from '../CommonComponents/AddModule';
import AddMainTask from '../CommonComponents/AddMainTask';
......@@ -359,6 +362,7 @@ UserDashboard:{screen:TabNavigation},
UserCompletedProjects: { screen: UserCompletedProjects },
RoadBlockList: { screen: RoadBlockList },
UserGroupChat:{screen:UserGroupChat},
UserImageUpload:{screen:UserImageUpload},
//EmployeeManageTask: { screen: EmployeeManageTask },
// AddModule : {screen: AddModule},
Updates: { screen: Updates },
......@@ -911,7 +915,12 @@ const userAppStack = createStackNavigator({
header:null,
},
},
UserImageUpload:{
screen:UserImageUpload,
navigationOptions:{
header:null,
},
},
// Maintenance: {
// screen: Maintenance,
// navigationOptions: {
......@@ -949,6 +958,20 @@ const userAppStack = createStackNavigator({
header: null,
},
},
AdminChat:{
screen:AdminChat,
navigationOptions:{
header:null,
},
},
AdminChatUser:{
screen:AdminChatUser,
navigationOptions:{
header:null,
},
},
ReleaseOwner: {
screen: ReleaseOwner,
navigationOptions: {
......
......@@ -194,6 +194,13 @@ export default class drawerContentComponents extends Component {
</TouchableOpacity>
{button2}
<TouchableOpacity onPress={this.navigateToScreen('UserImageUpload')}>
<View style={styles.screenStyle}>
<Image style={{ width: wp('6%'), height: hp('3%') }} source={require('../Images/activesprint.png')} />
<Text style={{ color: '#000000', marginLeft: 20 }}>ImageUpload</Text>
</View>
</TouchableOpacity>
{/* <TouchableOpacity onPress={this.navigateToScreen('UserModules')}>
<View style={styles.screenStyle}>
<View style={{ width: wp('8%') }}>
......
......@@ -495,7 +495,7 @@ export default class UserBacklogPending extends Component {
error1: '', error2: '',
itemPressedDisabled: false,
};
this.unassignedTasksData();
// this.unassignedTasksData();
AsyncStorage.getItem("cropcode", (err, res) => {
this.setState({ squadName: res });
......@@ -519,7 +519,7 @@ export default class UserBacklogPending extends Component {
this.getRequestedIdeas();
this.GetStatus();
// this.getModules();
this.getActiveSprints();//active sprint user stories
// this.getActiveSprints();//active sprint user stories
// this.getSprints();
// this.getUnactiveSprintTasks();
this.getUnassigned();//Backlogs user stories
......@@ -683,15 +683,15 @@ export default class UserBacklogPending extends Component {
// this.getActiveSprints();
// this.getUnassigned();
this.ideas();
this.getRequestedIdeas();
// this.getRequestedIdeas();
this.GetStatus();
this.getModules();
this.getActiveSprints();
// this.getActiveSprints();
this.getSprints1();
this.getUnactiveSprintTasks();
this.getUnassigned();
this.getPending();
this.unassignedTasksData();
// this.unassignedTasksData();
}
});
......@@ -1357,7 +1357,7 @@ export default class UserBacklogPending extends Component {
} else {
//to get the user pending my task list
this.getRequestedIdeas();
this.unassignedTasksData();
// this.unassignedTasksData();
// this.onRefresh();
}
});
......@@ -1379,7 +1379,7 @@ export default class UserBacklogPending extends Component {
console.log(res);
this.setState({ cropcode: res });
});
this.unassignedTasksData();
// this.unassignedTasksData();
this.getRequestedIdeas(this.state.role, this.state.userToken, this.state.cropcode);
}
......@@ -1402,7 +1402,7 @@ export default class UserBacklogPending extends Component {
// this.getRequestedIdeas();
this.GetStatus();
// this.getModules();
this.getActiveSprints();
// this.getActiveSprints();
this.getSprints1();
this.getUnactiveSprintTasks();
this.getUnassigned();
......
......@@ -163,7 +163,7 @@ export default class UserDashboard extends Component {
.then((responseJson) => {
console.warn(responseJson)
//alert(JSON.stringify(responseJson))
// alert(JSON.stringify(responseJson))
if (responseJson.status == 'True') {
......@@ -312,6 +312,17 @@ export default class UserDashboard extends Component {
AsyncStorage.setItem('projectId', projects.id));
// { id: projects.id,squadName:projects.value });
}
//Navigates to TaskChat Screen
AdminChat() {
// console.warn("msgCount" + msgCount);
// console.warn("taskid" + taskid);
// alert(taskid)
// alert("taskid" + taskid)
// log("Info", "UserPendingMyTasks:TaskChat(item, index) used to navigate to taskchat")
this.props.navigation.navigate("AdminChat");
}
render() {
......@@ -348,6 +359,12 @@ export default class UserDashboard extends Component {
</Text>
</TouchableOpacity>
</View>
<View>
<TouchableOpacity style={{ marginTop: 20, marginLeft: 18 }} onPress={() => { this.AdminChat() }}>
<Image style={{ width: 25, height: 25,color: 'white' }} source={require('../Images/chat.png')} />
</TouchableOpacity>
</View>
<View style={{ marginTop: 20, flexDirection: 'row' }}>
<TouchableOpacity onPress={this.logOutOption.bind(this)}>
{/* <Text style={{ borderRadius: 20, height: 45,color: 'white' }}>Logout</Text> */}
......
import React, { useState } from 'react';
// Import core components
import {
StyleSheet,
Text,
View,
TouchableOpacity
} from 'react-native';
import { API } from "../WebServices/RestClient";
// Import Document Picker
import DocumentPicker from 'react-native-document-picker';
const UserImageUpload = () => {
const [singleFile, setSingleFile] = useState(null);
const uploadImage = async () => {
// Check if any file is selected or not
if (singleFile != null) {
// If file selected then create FormData
const fileToUpload = singleFile;
const data = new FormData();
data.append('name', 'Image Upload');
data.append('file_attachment', fileToUpload);
// Please change file upload URL
let res = await fetch(API + "upload.php",
{
method: 'post',
body: data,
headers: {
'Content-Type': 'multipart/form-data; ',
},
}
);
let responseJson = await res.json();
if (responseJson.status == 1) {
alert('Upload Successful');
}
} else {
// If no file selected the show alert
alert('Please Select File first');
}
};
const selectFile = async () => {
// Opening Document Picker to select one file
try {
const res = await DocumentPicker.pick({
// Provide which type of file you want user to pick
type: [DocumentPicker.types.allFiles],
// There can me more options as well
// DocumentPicker.types.allFiles
// DocumentPicker.types.images
// DocumentPicker.types.plainText
// DocumentPicker.types.audio
// DocumentPicker.types.pdf
});
// Printing the log realted to the file
console.log('res : ' + JSON.stringify(res));
// Setting the state to show single file attributes
setSingleFile(res);
} catch (err) {
setSingleFile(null);
// Handling any exception (If any)
if (DocumentPicker.isCancel(err)) {
// If user canceled the document selection
alert('Canceled');
} else {
// For Unknown Error
alert('Unknown Error: ' + JSON.stringify(err));
throw err;
}
}
};
return (
<View style={styles.mainBody}>
<View style={{ alignItems: 'center' }}>
<Text style={{ fontSize: 30, textAlign: 'center' }}>
React Native File Upload Example
</Text>
<Text
style={{
fontSize: 25,
marginTop: 20,
marginBottom: 30,
textAlign: 'center',
}}>
www.aboutreact.com
</Text>
</View>
{/*Showing the data of selected Single file*/}
{singleFile != null ? (
<Text style={styles.textStyle}>
File Name: {singleFile.name ? singleFile.name : ''}
{'\n'}
Type: {singleFile.type ? singleFile.type : ''}
{'\n'}
File Size: {singleFile.size ? singleFile.size : ''}
{'\n'}
URI: {singleFile.uri ? singleFile.uri : ''}
{'\n'}
</Text>
) : null}
<TouchableOpacity
style={styles.buttonStyle}
activeOpacity={0.5}
onPress={selectFile}>
<Text style={styles.buttonTextStyle}>Select File</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.buttonStyle}
activeOpacity={0.5}
onPress={uploadImage}>
<Text style={styles.buttonTextStyle}>Upload File</Text>
</TouchableOpacity>
</View>
);
};
const styles = StyleSheet.create({
mainBody: {
flex: 1,
justifyContent: 'center',
padding: 20,
},
buttonStyle: {
backgroundColor: '#307ecc',
borderWidth: 0,
color: '#FFFFFF',
borderColor: '#307ecc',
height: 40,
alignItems: 'center',
borderRadius: 30,
marginLeft: 35,
marginRight: 35,
marginTop: 15,
},
buttonTextStyle: {
color: '#FFFFFF',
paddingVertical: 10,
fontSize: 16,
},
textStyle: {
backgroundColor: '#fff',
fontSize: 15,
marginTop: 16,
marginLeft: 35,
marginRight: 35,
textAlign: 'center',
},
});
export default UserImageUpload;
\ No newline at end of file
/*****MySql********/
//pre production environment (development)
// export const API = "https://api-single.agile24x7.com/release/";
// export const ReportsAPI = "https://testapiv2reporting.agile24x7.com/";
// export const Client_URL = "https://sdtest.agile24x7.com/#/";
export const API = "https://api-single.agile24x7.com/release/";
export const ReportsAPI = "https://testapiv2reporting.agile24x7.com/";
export const Client_URL = "https://sdtest.agile24x7.com/#/";
//production environment
// export const API = "https://api-single.agile24x7.com/Migration/";
......@@ -15,9 +15,9 @@
//pre production environment (development)
export const API = "https://api-single.agile24x7.com/pg_migration/";
export const ReportsAPI = "https://pgtestreporting.agile24x7.com/";
export const Client_URL = "https://pgtest.agile24x7.com/#/";
// export const API = "https://api-single.agile24x7.com/pg_migration/";
// export const ReportsAPI = "https://pgtestreporting.agile24x7.com/";
// export const Client_URL = "https://pgtest.agile24x7.com/#/";
......
......@@ -123,7 +123,7 @@ export default class App extends React.Component {
<Image style={{ width: 400, height: 162 }} source={require('./Images/agile2.png')} />
<Text style={styles.text}>Powered by Novisync</Text>
<Text></Text>
<Text style={styles.text1}>1.0.1 11-30-2021</Text>
<Text style={styles.text1}>1.0.1 12-13-2021</Text>
</View>
);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment