Commit 3b8b0663 authored by Alessandro Abluton's avatar Alessandro Abluton 🤖

Completed administration's queries update, according to latest tables names

parent 79da1cdf
......@@ -13,31 +13,31 @@ window.env = {
// URL
// Online Simcaa.it
// "GraphQLServer": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/query",
// "GraphQLServerNoAuth": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/query/noauth",
// "GraphQLLogin": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/login",
// "GraphQLCurrentUser": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/me",
// "GraphQLRefreshToken": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/jwtrefresh",
// "RestApiCard": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/card",
/*"GraphQLServer": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/query",
"GraphQLServerNoAuth": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/query/noauth",
"GraphQLLogin": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/login",
"GraphQLCurrentUser": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/me",
"GraphQLRefreshToken": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/jwtrefresh",
"RestApiCard": "http://www.simcaa.it/demo/apisimcaa-graphql/public/graphql/card",*/
// TEMP: DEMO2 (DELETE LATER)
// Online Simcaa.it
"GraphQLServer": "http://www.simcaa.it/demo2/apisimcaa-graphql/public/graphql/query",
/*"GraphQLServer": "http://www.simcaa.it/demo2/apisimcaa-graphql/public/graphql/query",
"GraphQLServerNoAuth": "http://www.simcaa.it/demo2/apisimcaa-graphql/public/graphql/query/noauth",
"GraphQLLogin": "http://www.simcaa.it/demo2/apisimcaa-graphql/public/graphql/login",
"GraphQLCurrentUser": "http://www.simcaa.it/demo2/apisimcaa-graphql/public/graphql/me",
"GraphQLRefreshToken": "http://www.simcaa.it/demo2/apisimcaa-graphql/public/graphql/jwtrefresh",
"RestApiCard": "http://www.simcaa.it/demo2/apisimcaa-graphql/public/graphql/card",
"RestApiCard": "http://www.simcaa.it/demo2/apisimcaa-graphql/public/graphql/card",*/
// Local
// "GraphQLServer": "http://10.0.0.132:8085/graphql/query",
// "GraphQLServerNoAuth": "http://10.0.0.132:8085/graphql/query/noauth",
// "GraphQLLogin": "http://10.0.0.132:8085/graphql/login",
// "GraphQLCurrentUser": "http://10.0.0.132:8085/graphql/me",
// "GraphQLRefreshToken": "http://10.0.0.132:8085/graphql/jwtrefresh",
// "RestApiCard": "http://10.0.0.132:8085/graphql/card",
"GraphQLServer": "http://10.0.0.132:8085/graphql/query",
"GraphQLServerNoAuth": "http://10.0.0.132:8085/graphql/query/noauth",
"GraphQLLogin": "http://10.0.0.132:8085/graphql/login",
"GraphQLCurrentUser": "http://10.0.0.132:8085/graphql/me",
"GraphQLRefreshToken": "http://10.0.0.132:8085/graphql/jwtrefresh",
"RestApiCard": "http://10.0.0.132:8085/graphql/card",
// CSS - remote
// "SemanticCSS": "http://10.0.0.132/includes/css/semantic.min.css",
......
......@@ -67,8 +67,13 @@ class AddUserModal extends Component{
email
organization
link_web
group_id
team_id
role_id
}
}
roles{
data {
id
role_desc
}
}
}
......@@ -81,7 +86,8 @@ class AddUserModal extends Component{
this.setState({
loading: false,
result: true,
usrsFound: data.data.caa_users.data
usrsFound: data.data.caa_users.data,
roles: data.data.roles.data
});
}
})
......@@ -138,7 +144,7 @@ class AddUserModal extends Component{
<p>{t("ADDUSR_MISSING_DATA")}</p>
</Message>
<Transition visible={this.state.result} animation='scale' duration={700}>
<UsrTable action='add' users={this.state.usrsFound} team={this.props.team} groups={this.state.groups} update={this.props.update} showError={this.props.showError}/>
<UsrTable action='add' users={this.state.usrsFound} team={this.props.team} userTeam={this.props.userTeam} roles={this.state.roles} update={this.props.update} showError={this.props.showError} closeModal={()=>this.close()}/>
</Transition>
</Modal.Content>
<Modal.Actions>
......
......@@ -37,14 +37,20 @@ class AllGroups extends Component{
email
organization
link_web
group_id
team_id
role_id
}
}
groups{
roles{
data {
id
desc_group
role_desc
}
}
user_teams{
data{
userteam_id
user_id
team_id
}
}
team{
......@@ -60,8 +66,9 @@ class AllGroups extends Component{
this.setState({
lock:1,
users: data.data.caa_users.data,
groups: data.data.groups.data,
teams: data.data.team.data
roles: data.data.roles.data,
teams: data.data.team.data,
user_teams: data.data.user_teams.data
})
})
.catch((error)=>{
......@@ -73,6 +80,9 @@ class AllGroups extends Component{
interror: false
})
}
findUser(user_id){
return this.state.users[this.state.users.findIndex((usr)=>usr.id===user_id)]
}
render(){
const { t, i18n } = this.props
if(this.state.lock===0){
......@@ -85,9 +95,9 @@ class AllGroups extends Component{
let teamTables = this.state.teams.map((team, idx)=>{
let usrs = []
//creo lista di utenti appartenenti a quel gruppo
for(let i=0; i<this.state.users.length; i++){
if(this.state.users[i].team_id === team.id){
usrs.push(this.state.users[i])
for(let i=0; i<this.state.user_teams.length; i++){
if(this.state.user_teams[i].team_id === team.id){
usrs.push(this.findUser(this.state.user_teams[i].user_id))
}
}
let margin = ((idx===0) ? '10px' : '65px')
......@@ -96,8 +106,8 @@ class AllGroups extends Component{
return(
<Segment style={{marginTop: margin}} key={idx}>
<Header as="h4">{team.name}</Header>
<UsrTable update={this.update} action='delete' users={usrs} team={team.id} groups={this.state.groups} showError={this.showError}/>
<AddUserModal team={team.id} update={this.update.bind(this)} showError={this.showError.bind(this)}/>
<UsrTable update={this.update} action='delete' users={usrs} userTeam={this.state.user_teams} team={team.id} roles={this.state.roles} showError={this.showError}/>
<AddUserModal team={team.id} update={this.update.bind(this)} userTeam={this.state.user_teams} showError={this.showError.bind(this)}/>
</Segment>
)
});
......
......@@ -20,11 +20,17 @@ class UsrTable extends Component{
}
handleDelete(){
//QUERY DELETE DA GRUPPO
//QUERY DELETE DA TEAM
let id_record = 0
for(let i=0; i<this.props.userTeam.length; i++){
if(this.props.userTeam[i].user_id === this.state.idToDelete && this.props.userTeam[i].team_id === this.props.team){
id_record = this.props.userTeam[i].userteam_id
}
}
let query = `
mutation removeFromTeam{
updateCaaUser(id: ${this.state.idToDelete}, team_id: 1){
deleteCaaUserTeam(id: ${id_record}){
id
}
}`
......@@ -45,26 +51,29 @@ class UsrTable extends Component{
addUser(id){
let query = `
mutation addToTeam{
updateCaaUser(id: ${id}, team_id: ${this.props.team}){
createCaaUserTeam(iduser: ${id},
idteam: ${this.props.team}){
id
team_id
}
}`
this.setState({loading: true})
this.props.apolloFetch({ query })
.then((data) => {
if(data.hasOwnProperty('errors')){
this.props.showError();
}else{
this.setState({loading: false});
this.props.update();
}
})
.catch((error) => {
console.log(error);
})
this.setState({loading: true})
this.props.apolloFetch({ query })
.then((data) => {
if(data.hasOwnProperty('errors')){
this.props.showError();
}else{
this.setState({loading: false});
this.props.update();
this.props.closeModal();
}
})
.catch((error) => {
console.log(error);
})
}
render(){
console.log(this.props);
const { t, i18n } = this.props
let tableLayout = this.props.users.map((item)=>{
let actionLayout= <div/>
......@@ -79,10 +88,10 @@ class UsrTable extends Component{
content= {t("POPUP_DEL")}
/>
}
let group=<div/>
for(let i=0; i<this.props.groups.length; i++){
if(this.props.groups[i].id === item.group_id){
group=this.props.groups[i].desc_group
let role=<div/>
for(let i=0; i<this.props.roles.length; i++){
if(this.props.roles[i].id === item.role_id){
role=this.props.roles[i].role_desc
break;
}
}
......@@ -107,7 +116,7 @@ class UsrTable extends Component{
{item.link_web}
</Table.Cell>
<Table.Cell>
{group}
{role}
</Table.Cell>
<Table.Cell>
{actionLayout}
......
......@@ -29,14 +29,13 @@ class AllUsers extends Component{
email
organization
link_web
group_id
team_id
role_id
}
}
groups{
roles{
data {
id
desc_group
role_desc
}
}
team{
......@@ -52,7 +51,7 @@ class AllUsers extends Component{
this.setState({
lock:1,
users: data.data.caa_users.data,
groups: data.data.groups.data,
roles: data.data.roles.data,
teams: data.data.team.data
})
})
......@@ -106,7 +105,7 @@ class AllUsers extends Component{
}
}
for(let i=0; i<this.state.groups.length; i++){
if(this.state.groups[i].id === item.group_id){
if(this.state.roles[i].id === item.role_id){
group=this.state.groups[i].desc_group
}
}
......
......@@ -7,7 +7,7 @@ export function selectedProjectID(id = -1) {
return (dispatch) => {
dispatch({
type: CARDUI_SELECTED_PROJECT,
projectId: parseInt(id)
projectId: parseInt(id,10)
})
}
}
......@@ -54,7 +54,7 @@ export function unlinkCard() {
let lockStatus = currentCard.codClass === 'Verbo' ? 'lock' : 'unlock'
let complexLemmaSplit = currentCard.lemma.split(' ')
let index = getState().projectData.findIndex(x => x.proj_id === parseInt(getState().selectedProjectID))
let index = getState().projectData.findIndex(x => x.proj_id === parseInt(getState().selectedProjectID,10))
let data = JSON.parse(getState().projectData[index].proj_profile)
if (complexLemmaSplit.length === 1) {
......@@ -127,7 +127,7 @@ export function mergeCard(direction, id = null, lemma = null) {
dispatch(chapterContentDataFetchDataSuccess(cardArray))
if (id && lemma) {
let index = getState().projectData.findIndex(x => x.proj_id === parseInt(getState().selectedProjectID))
let index = getState().projectData.findIndex(x => x.proj_id === parseInt(getState().selectedProjectID,10))
let data = JSON.parse(getState().projectData[index].proj_profile)
dispatch(setImg(cardArray, id, lemma, currentCard.row, true, data.imgType, data.imgStyle, data.priorityOrder))
}
......@@ -431,7 +431,7 @@ export function searchLemma() {
let currentCard = Object.assign({}, getState().cardUINavbarCard)
let localCards = getState().chapterContentData.slice()
let index = getState().projectData.findIndex(x => x.proj_id === parseInt(getState().selectedProjectID))
let index = getState().projectData.findIndex(x => x.proj_id === parseInt(getState().selectedProjectID,10))
let data = JSON.parse(getState().projectData[index].proj_profile)
dispatch(setImg(localCards, currentCard.id, currentCard.lemma, currentCard.row, true, data.imgType, data.imgStyle, data.priorityOrder))
......
......@@ -133,7 +133,7 @@ export function prioritySort(newDataSorting, lemma, imgType, imgStyle, priorityO
}
arrayInnerLemma
.sort((a, b) => {
return parseInt(b.finalOrder) - parseInt(a.finalOrder)
return parseInt(b.finalOrder,10) - parseInt(a.finalOrder,10)
})
for (let i = 0; i < arrayInnerLemma.length; i++) {
delete arrayInnerLemma[i].tmpOrder
......
This diff is collapsed.
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