From 80a33bbda0ed7e2c5250d71444a02d0b2507fc13 Mon Sep 17 00:00:00 2001 From: tejaswi <tejaswi.uddanti@gmail.com> Date: Fri, 17 Dec 2021 20:01:08 +0530 Subject: [PATCH] User dashboard screen --- src/CommonComponents/AdminChat.js | 4 +- src/UserComponents/UserDashboard.js | 204 +++++++++++++++++- src/UserComponents/UserPendingMyTask.js | 4 +- src/UserComponents/UserRoadblocksAssigned.js | 168 +++++++-------- .../UserRoadblocksTobeAssigned.js | 39 +--- src/WebServices/RestClient.js | 12 +- 6 files changed, 294 insertions(+), 137 deletions(-) diff --git a/src/CommonComponents/AdminChat.js b/src/CommonComponents/AdminChat.js index 43594aa..f9b0ef8 100644 --- a/src/CommonComponents/AdminChat.js +++ b/src/CommonComponents/AdminChat.js @@ -690,7 +690,7 @@ export default class AdminChat extends Component { } ); - // this.arrayholder = responseJson.data; + this.arrayholder = responseJson.data; }) .catch((error) => { check.Maintenance(); @@ -742,7 +742,7 @@ export default class AdminChat extends Component { const empStatus = item.empStatus.toUpperCase() const empStatus1 = text.toUpperCase() //const designation = item.designation.toUpperCase() - const designation1 = text.toUpperCase() + // const designation1 = text.toUpperCase() const email = item.email.toUpperCase() const email1 = text.toUpperCase() const mobileNumber = item.mobileNumber.toUpperCase() diff --git a/src/UserComponents/UserDashboard.js b/src/UserComponents/UserDashboard.js index d4a5524..07cf570 100644 --- a/src/UserComponents/UserDashboard.js +++ b/src/UserComponents/UserDashboard.js @@ -57,6 +57,8 @@ export default class UserDashboard extends Component { abc: [], squadName: '', dataSource2: [], + allMessagesUser: [], + allMessages: [], } @@ -65,6 +67,10 @@ export default class UserDashboard extends Component { // console.warn("squadname" + this.state.squadName); // }); + AsyncStorage.getItem("userToken", (err, res) => { + this.setState({ empId: res }); + }) + } moveUp = () => this.setState({ offset: -110 }); @@ -86,6 +92,7 @@ export default class UserDashboard extends Component { }); + } @@ -128,6 +135,8 @@ export default class UserDashboard extends Component { this.GetStatus(); this.getMessages(); + this.getAllUserMessages(); + this.getAllTaskMessages(); } @@ -376,6 +385,148 @@ export default class UserDashboard extends Component { }); }); } + getAllUserMessages() { + log("Info", " getMessages(role, userToken, cropcode) is used getting task related messages"); + // const groupId = this.state.subtaskId; + // console.warn("getmessages"); + AsyncStorage.multiGet(["cropcode", "userToken"], (err, response) => { + const cropcode = response[0][1]; + const userToken = response[1][1]; + this.setState({ userid: userToken }); + // console.warn("userToken"+userToken) + // console.warn("cropcode"+cropcode) + + 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 + "user_chat.php", + { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + + action: "get_all_messages_dash", + // corp_code: cropcode, + sendBy: userToken, + + + }) + }) + .then((response) => response.json()) + .then((responseJson) => { + // console.warn("Messages For chat application" + JSON.stringify(responseJson.data)); + + // console.warn("Messages from users" + JSON.stringify(responseJson)) + // console.warn("Send By Name" + JSON.stringify(responseJson.data)) + // alert(JSON.stringify(responseJson.data)) + if (responseJson.status === 'True') { + + // console.warn("Setted Data") + + + + this.setState({ + allMessagesUser: responseJson.data, + }); + // console.warn("Method data" + responseJson.data.sendBy) + } + else { + // console.warn("Empty Data") + this.setState({ + allMessagesUser: [], + }); + } + }) + .catch((error) => { + console.error(error); + log("Error", "getting task related messages error"); + }); + + } + }); + }); + } + + getAllTaskMessages() { + log("Info", " getMessages(role, userToken, cropcode) is used getting task related messages"); + + 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 + "user_story_chat.php", + { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + + action: "getAllTaskMessagesDash", + // corp_code: cropcode, + sendBy: userToken, + + + }) + }) + .then((response) => response.json()) + .then((responseJson) => { + // console.warn("Messages For chat application" + JSON.stringify(responseJson.data)); + + // console.warn("Messages from users" + JSON.stringify(responseJson)) + // console.warn("Send By Name" + JSON.stringify(responseJson.data)) + // alert(JSON.stringify(responseJson.data)) + if (responseJson.status === 'True') { + + // console.warn("Setted Data") + + + + this.setState({ + allMessages: responseJson.data, + }); + // console.warn("Method data" + responseJson.data.sendBy) + } + else { + // console.warn("Empty Data") + this.setState({ + allMessages: [], + }); + } + }) + .catch((error) => { + console.error(error); + log("Error", "getting task related messages error"); + }); + + } + }); + }); + } + @@ -404,9 +555,37 @@ export default class UserDashboard extends Component { // this.props.navigation.navigate("AdminChat"); this.props.navigation.push("AdminChat"); } + + render() { + const getMessagesCount = (p_id, msg, empId, userMsg) => { + + const msgCount = msg.filter(message => message.readBy.split(",").indexOf(empId) === -1 + && (message.messagedBy !== empId && message.project_id === p_id)).map((messages, i) => { + return i, messages + }) + const msgCountUser = userMsg.filter(message => message.project_id === p_id).map((messagess, index) => { + return index, messagess + }) + + // console.warn("iiiiiiii" + id) + // console.warn("msgcount" + msgCount) + // console.warn("msgCountUser" + msgCountUser) + + return ( + + <View style={{ flexDirection: 'row', backgroundColor: 'whitesmoke', flex: 1 }}> + {msgCount.length + msgCountUser.length > 0 ? ( + <View style={{ flexDirection: 'row', textAlign: 'right' }}> + <Text style={{ color: 'black', fontWeight: 'bold' }}>Messages</Text> + <Text style={{ color: 'red', }}> {msgCount.length + msgCountUser.length > 0 ? msgCount.length + msgCountUser.length : null} </Text> + </View>) : <Text></Text>} + </View> + ) + + } if (this.state.isLoading) { return ( @@ -431,20 +610,27 @@ export default class UserDashboard extends Component { borderBottomColor: '#ffffff', justifyContent: 'space-between', }}> - <View style={{ marginTop: 20, flexDirection: 'row' }}> - <Image style={{ width: 25, height: 25 }} source={require('../Images/add.png')} /> + <TouchableOpacity onPress={this.openModal}> + <View style={{ marginTop: 20, flexDirection: 'row' }}> + + <Image style={{ width: 25, height: 25 }} source={require('../Images/add.png')} /> + - <TouchableOpacity onPress={this.openModal}> <Text style={{ width: 150, borderRadius: 20, height: 45, flexDirection: 'row', color: 'white', padding: 5 }}> Add New Project </Text> - </TouchableOpacity> - </View> - <View style={{ flexDirection: 'row' }}> - <TouchableOpacity style={{ marginTop: 20, marginLeft: 18 }} onPress={() => { this.AdminChat() }}> + </View> + </TouchableOpacity> + + <View style={{ flexDirection: 'row', marginTop: 20, }}> + <View style={{ marginRight: 2, }} > <Text style={{ color: 'white' }}>{this.state.dataSource2.length}</Text> - <Image style={{ width: 25, height: 25, color: 'white' }} source={require('../Images/chat.png')} /> + </View> + <TouchableOpacity onPress={() => { this.AdminChat() }}> + <View> + <Image style={{ width: 25, height: 25, color: 'white' }} source={require('../Images/chat.png')} /> + </View> </TouchableOpacity> </View> <View style={{ marginTop: 20, flexDirection: 'row' }}> @@ -497,7 +683,7 @@ export default class UserDashboard extends Component { // onPress={() => this.props.navigation.navigate('UserMyTask', { id: projects.id,squadName: projects.value, })} > <DataTable.Cell style={{ backgroundColor: projects.color, width: '92%', height: 150, marginTop: 5, marginBottom: 15, justifyContent: 'center' }}><Text style={{ color: 'black', }}>{projects.value} </Text></DataTable.Cell> - + {getMessagesCount(projects.id, this.state.allMessages, this.state.empId, this.state.allMessagesUser)} </TouchableOpacity> </DataTable.Row> diff --git a/src/UserComponents/UserPendingMyTask.js b/src/UserComponents/UserPendingMyTask.js index 3e977be..4b2241b 100644 --- a/src/UserComponents/UserPendingMyTask.js +++ b/src/UserComponents/UserPendingMyTask.js @@ -1283,10 +1283,10 @@ updateActiveTaskStatus1 = (todoStoryId,assignedTo,inProgressStoryId) => { .then((responseJson) => { console.warn(responseJson) if (responseJson.status === 'true') { - alert(responseJson.message) + // alert(responseJson.message) this.addCommentUserStory(message, todoStoryId, "1") - // alert("Success"); + alert("Updated Successfully"); } else { new Pending().onRefresh(); diff --git a/src/UserComponents/UserRoadblocksAssigned.js b/src/UserComponents/UserRoadblocksAssigned.js index b88aa9f..e4484a6 100644 --- a/src/UserComponents/UserRoadblocksAssigned.js +++ b/src/UserComponents/UserRoadblocksAssigned.js @@ -25,7 +25,7 @@ import { SkypeIndicator, UIActivityIndicator } from 'react-native-indicators'; -import { SUBTASK, DESCRIPTION,ASSIGNED_TO,ASSIGNED_BY, ROADBLOCK_DATE,MODIFY, PRIORITY,SEVERITY, TARGET_DATE,ASSIGNED_DATE } from '../CommonComponents/Header'; +import { SUBTASK, DESCRIPTION, ASSIGNED_TO, ASSIGNED_BY, ROADBLOCK_DATE, MODIFY, PRIORITY, SEVERITY, TARGET_DATE, ASSIGNED_DATE } from '../CommonComponents/Header'; import { Collapse, CollapseHeader, CollapseBody } from "accordion-collapse-react-native"; @@ -134,14 +134,14 @@ class ListItem extends React.Component { return ( <View> - + {/* <Collapse style={styles.container}> <CollapseHeader style={styles.boxheader}> */} <View style={styles.container}> <View style={styles.boxheader}> <TouchableOpacity activeOpacity={0.8} onPress={this.changeLayout} > <View style={{ flexDirection: 'row' }}> - <View style={{ flexDirection: 'row', width: wp('70%') }}> + <View style={{ flexDirection: 'row', width: wp('70%') }}> <Text style={styles.signUpText0} >User Story Id:</Text> <Text style={styles.signUpText1} >{(this.props.cropcode).substring(0, 3).toUpperCase()}:{item.story_id.substring(0, 5).toUpperCase()}- {item.subtaskname}</Text> </View> @@ -174,7 +174,7 @@ class ListItem extends React.Component { </View> {/* </CollapseHeader> */} <View style={{ height: this.state.expanded ? null : 0, overflow: 'hidden' }}> - <CollapseBody style={{backgroundColor:'white',}}> + <CollapseBody style={{ backgroundColor: 'white', }}> <View style={{ flexDirection: 'row', paddingRight: 25, width: wp('90%') }}> @@ -242,10 +242,10 @@ class ListItem extends React.Component { <Text style={styles.signUpText000} >{TARGET_DATE}:</Text> <Text style={styles.signUpText111} >{item.target_date}</Text> {/* <Text style={styles.signUpText1} >{item.date}</Text> */} - {/* </View> */} - {/* <Text style={styles.signUpText002} >Updated On:0000-00-00 00:00:00 </Text> */} + {/* </View> */} + {/* <Text style={styles.signUpText002} >Updated On:0000-00-00 00:00:00 </Text> */} - {/* </View> */} + {/* </View> */} {/* <View style={{ flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'center' }}> @@ -368,7 +368,7 @@ export default class Assigned extends Component { //navigate to ModifySubtask this.props.navigation.navigate('ModifyRoadblock', { callHome: this.userCompletedMyTasks.bind(this), - subtaskid: item.subTaskId, roadblockId: item.sno, subTaskName: item.subTaskName,priorityLevel:item.priorityLevel,severityLevel:item.severityLevel, description: item.roadBlockDescription, requested: item.requestedBy, person: item.assignedTo, + subtaskid: item.subTaskId, roadblockId: item.sno, subTaskName: item.subTaskName, priorityLevel: item.priorityLevel, severityLevel: item.severityLevel, description: item.roadBlockDescription, requested: item.requestedBy, person: item.assignedTo, name: item.assignedBy, subTaskId: item.subTaskId, days: days, hours: hours }); @@ -384,69 +384,69 @@ export default class Assigned extends Component { AsyncStorage.getItem("projectId", (err, res) => { const projectId = res; - AsyncStorage.getItem("emp_role", (err, res) => { - const emp_role = res; - //Checking the Internet Connection - NetInfo.fetch().then(state => { - if (state.type == "none" || state.type == 'unknown') { - console.log(state.type); - Snackbar.show({ - title: 'No Internet Connection', - backgroundColor: 'red', - duration: Snackbar.LENGTH_LONG, - }); - } else { - - fetch(API + 'manage_roadblocks.php', - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - crop: cropcode, - action: "assignedroadblocks", - projectId: projectId - // userType: emp_role, - // empId: empId - }) - }) - .then((response) => response.json()) - .then((responseJson) => { - console.log(responseJson); - console.warn(responseJson); - // alert(JSON.stringify(responseJson.data)) - if (responseJson.status === 'True') { - this.setState({ - isLoading: false, - dataSource: responseJson.data, - isFetching: false - }, function () { - }); - this.arrayholder = responseJson.data; - } else { - log("Info", "no completed my tasks at user side"); - this.arrayholder = []; - this.setState({ - isLoading: false, - }) - Snackbar.show({ - title: 'No Completed Subtasks', - backgroundColor: '#3BB9FF', - duration: Snackbar.LENGTH_LONG, - }); - } - - }) - .catch((error) => { - console.error(error); - log("Error", "Error in getting of completed my tasks at user side"); + AsyncStorage.getItem("emp_role", (err, res) => { + const emp_role = res; + //Checking the Internet Connection + NetInfo.fetch().then(state => { + if (state.type == "none" || state.type == 'unknown') { + console.log(state.type); + Snackbar.show({ + title: 'No Internet Connection', + backgroundColor: 'red', + duration: Snackbar.LENGTH_LONG, }); + } else { + + fetch(API + 'manage_roadblocks.php', + { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + crop: cropcode, + action: "assignedroadblocks", + projectId: projectId + // userType: emp_role, + // empId: empId + }) + }) + .then((response) => response.json()) + .then((responseJson) => { + console.log(responseJson); + console.warn(responseJson); + // alert(JSON.stringify(responseJson.data)) + if (responseJson.status === 'True') { + this.setState({ + isLoading: false, + dataSource: responseJson.data, + isFetching: false + }, function () { + }); + this.arrayholder = responseJson.data; + } else { + log("Info", "no completed my tasks at user side"); + this.arrayholder = []; + this.setState({ + isLoading: false, + }) + Snackbar.show({ + title: 'No Completed Subtasks', + backgroundColor: '#3BB9FF', + duration: Snackbar.LENGTH_LONG, + }); + } + + }) + .catch((error) => { + console.error(error); + log("Error", "Error in getting of completed my tasks at user side"); + }); - } + } + }); }); - }); }); @@ -473,34 +473,24 @@ export default class Assigned extends Component { // const subTaskId1 = text.toUpperCase() const r_id = item.r_id.toUpperCase() const r_id1 = text.toUpperCase() - - const subTaskName = item.subTaskName.toUpperCase() - const subTaskName1 = text.toUpperCase() const roadblock_description = item.roadblock_description.toUpperCase() const roadblock_description1 = text.toUpperCase() const status = item.status.toUpperCase() const status1 = text.toUpperCase() - const assignedTo = item.assignedTo.toUpperCase() - const assignedTo1 = text.toUpperCase() - const roadblock_date = item.roadblock_date.toUpperCase() - const roadblock_date1 = text.toUpperCase() - const assignedBy = item.assignedBy.toUpperCase() - const assignedBy1 = text.toUpperCase() const assigned_date = item.assigned_date.toUpperCase() const assigned_date1 = text.toUpperCase() - const target_date = item.target_date.toUpperCase() - const target_date1 = text.toUpperCase() - return r_id.indexOf(r_id1) > -1 || + const assignedto = item.assignedto.toUpperCase() + const assignedto1 = text.toUpperCase() + const assignedby = item.assignedby.toUpperCase() + const assignedby1 = text.toUpperCase() - subTaskName.indexOf(subTaskName1) > -1 || + return r_id.indexOf(r_id1) > -1 || roadblock_description.indexOf(roadblock_description1) > -1 || - target_date.indexOf(target_date1) > -1 || status.indexOf(status1) > -1 || - assigned_date.indexOf(assigned_date1) > -1 || - assignedBy.indexOf(assignedBy1) > -1 - assignedTo.indexOf(assignedTo1) > -1 || - targetDate.indexOf(targetDate1) > -1 - // dependencyTitle.indexOf(dependencyTitle1) > -1 + assignedto.indexOf(assignedto1) > -1 || + assignedby.indexOf(assignedby1) > -1 || + assigned_date.indexOf(assigned_date1) > -1 + }) this.setState({ @@ -521,7 +511,7 @@ export default class Assigned extends Component { return ( <Container style={{ height: Dimensions.get('window').height }}> <Item> - + <Input placeholder="Search" onChangeText={(text) => this.SearchFilterFunction(text)} /> <Icon name="search" size={20} /> @@ -808,7 +798,7 @@ const styles = StyleSheet.create({ alignSelf: 'center', }, boxheader: { - backgroundColor:'white', + backgroundColor: 'white', justifyContent: 'space-between', flexDirection: 'column', position: 'relative', diff --git a/src/UserComponents/UserRoadblocksTobeAssigned.js b/src/UserComponents/UserRoadblocksTobeAssigned.js index 0833331..92aa053 100644 --- a/src/UserComponents/UserRoadblocksTobeAssigned.js +++ b/src/UserComponents/UserRoadblocksTobeAssigned.js @@ -1,5 +1,5 @@ /* -FileName:TobeAssigned.js +FileName:UserRoadblockTobeAssigned.js Version:1.0.0 Purpose:Getting the List of user pending my task list Devloper:Rishitha,Naveen,Harsha,Mahesh @@ -211,7 +211,7 @@ class ListItem extends React.Component { <Text style={styles.signUpText0} >User Story Id:</Text> <Text style={styles.signUpText1} >{(this.props.cropcode).substring(0, 3).toUpperCase()}:{item.story_id.substring(0, 5).toUpperCase()}- {item.subtaskname}</Text> </View> - + </View> {/* <Text style={styles.signUpText02} >{item.status} </Text> */} @@ -264,7 +264,7 @@ class ListItem extends React.Component { <View style={{ flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'center' }}> <TouchableOpacity onPress={this.props.RoadBlock} style={{ width: 80, backgroundColor: 'black', borderRadius: 30, marginRight: 5 }}><Text style={{ color: '#fff', textAlign: 'center' }}>{ASSIGN}</Text></TouchableOpacity> - + </View> <View style={{ @@ -450,7 +450,7 @@ export default class TobeAssigned extends Component { }) .then((response) => response.json()) .then((responseJson) => { - //alert(JSON.stringify(responseJson)) + // alert(JSON.stringify(responseJson)) console.warn(responseJson); if (responseJson.status === 'True') { this.setState({ @@ -629,40 +629,21 @@ export default class TobeAssigned extends Component { log("Info", "UserCompletedMyTasks:SearchFilterFunction(text) for search functionality"); console.log(text); const newData = this.arrayholder.filter(function (item) { - //const subTaskId = item.subTaskId.toUpperCase() - //const subTaskId1 = text.toUpperCase() const r_id = item.r_id.toUpperCase() const r_id1 = text.toUpperCase() - const subTaskName = item.subTaskName.toUpperCase() - const subTaskName1 = text.toUpperCase() const roadblock_description = item.roadblock_description.toUpperCase() const roadblock_description1 = text.toUpperCase() const status = item.status.toUpperCase() const status1 = text.toUpperCase() - const assignedTo = item.assignedTo.toUpperCase() - const assignedTo1 = text.toUpperCase() - const roadblock_date = item.roadblock_date.toUpperCase() - const roadblock_date1 = text.toUpperCase() - const assignedBy = item.assignedBy.toUpperCase() - const assignedBy1 = text.toUpperCase() - const assigned_date = item.assigned_date.toUpperCase() - const assigned_date1 = text.toUpperCase() - const target_date = item.target_date.toUpperCase() - const target_date1 = text.toUpperCase() - // - // subTaskId.indexOf(subTaskId1) > -1 || - // r_id.indexOf(r_id1) > -1 || + const requestedby = item.requestedby.toUpperCase() + const requestedby1 = text.toUpperCase() + return r_id.indexOf(r_id1) > -1 || - subTaskName.indexOf(subTaskName1) > -1 || roadblock_description.indexOf(roadblock_description1) > -1 || - target_date.indexOf(target_date1) > -1 || status.indexOf(status1) > -1 || - assigned_date.indexOf(assigned_date1) > -1 || - assignedBy.indexOf(assignedBy1) > -1 - assignedTo.indexOf(assignedTo1) > -1 || - targetDate.indexOf(targetDate1) > -1 - // dependencyTitle.indexOf(dependencyTitle1) > -1 + requestedby.indexOf(requestedby1) > -1 + }) this.setState({ @@ -978,7 +959,7 @@ const styles = StyleSheet.create({ fontSize: 13, paddingRight: 5, color: 'red', - textAlign:'right' + textAlign: 'right' // paddingBottom: 10, diff --git a/src/WebServices/RestClient.js b/src/WebServices/RestClient.js index d3f8b90..dadd30d 100644 --- a/src/WebServices/RestClient.js +++ b/src/WebServices/RestClient.js @@ -1,9 +1,9 @@ /*****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 @@ export const Client_URL = "https://sdtest.agile24x7.com/#/"; //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/#/"; -- GitLab