|
|
|
@ -7,14 +7,24 @@ const tableType = { |
|
|
|
|
'user': {'primaryKey': 'User Id', 'apiAdress': '_matrix/client/r0/watchauserlist', |
|
|
|
|
//'JoinTables':
|
|
|
|
|
//{'matchingKey': {}},
|
|
|
|
|
'header': {'User Id': 'name', 'date of creation': 'creation_ts', |
|
|
|
|
'Admin': 'admin', 'Partner': 'is_partner', 'Email': 'email', 'Devices': 'display_name'} }, |
|
|
|
|
'room': {'primaryKey': 'Room Id', 'apiAdress': '_matrix/client/r0/watcharoomlist', |
|
|
|
|
'header': |
|
|
|
|
{'User Id': {'name': 'name', 'type': 'string'}, |
|
|
|
|
'date of creation': {'name': 'creation_ts', 'type': 'date'}, |
|
|
|
|
'Admin': {'name': 'admin', 'type': 'boolean'}, |
|
|
|
|
'Partner': {'name': 'is_partner', 'type': 'boolean'}, |
|
|
|
|
'Email': {'name': 'email', 'type': 'string'}, |
|
|
|
|
'Devices': {'name': 'display_name', 'type': 'string'}} }, |
|
|
|
|
'room': { |
|
|
|
|
'primaryKey': 'Room Id', 'apiAdress': '_matrix/client/r0/watcharoomlist', |
|
|
|
|
'JoinTables': |
|
|
|
|
{'watcharoomname': {'matchingKey': |
|
|
|
|
{ 'mainTable': 'Room Id', 'secondaryTable': 'room_id'}, |
|
|
|
|
'apiAdress': '_matrix/client/r0/watcharoomname', 'column': 'name'} }, |
|
|
|
|
'header': {'Room Id': 'room_id', 'Creator': 'creator', 'Name': 'watcharoomname'} }, |
|
|
|
|
'header': {'Room Id': {'name': 'room_id', 'type': 'string'}, |
|
|
|
|
'Name': {'name': 'watcharoomname', 'type': 'list'}, |
|
|
|
|
'Creator': {'name': 'creator', 'type': 'string'}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
'stats': {}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -75,6 +85,7 @@ export default class DataToTable extends Component { |
|
|
|
|
const homeServer = this.props.server; |
|
|
|
|
const accessToken = this.props.token; |
|
|
|
|
const JoinTables = this.state.type['JoinTables']; |
|
|
|
|
console.log(accessToken); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
const userRequest = await fetch(homeServer+ this.state.type['apiAdress'], { |
|
|
|
@ -97,8 +108,12 @@ export default class DataToTable extends Component { |
|
|
|
|
if ({}.hasOwnProperty.call(this.state.type['header'], columnHeader)) { |
|
|
|
|
for (const property in userData[user]) { |
|
|
|
|
if ({}.hasOwnProperty.call(userData[user], property)) { |
|
|
|
|
if (property === this.state.type['header'][columnHeader]) { |
|
|
|
|
dataObject[columnHeader] = userData[user][property]; |
|
|
|
|
if (property === this.state.type['header'][columnHeader]['name']) { |
|
|
|
|
dataObject[columnHeader] = |
|
|
|
|
this.convertRawData(userData[user][property], this.state.type['header'][columnHeader]['type']); |
|
|
|
|
} |
|
|
|
|
if (this.state.type['header'][columnHeader]['type']==='list') { |
|
|
|
|
dataObject[columnHeader] = []; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -118,7 +133,7 @@ export default class DataToTable extends Component { |
|
|
|
|
const userRequest = await fetch(homeServer+ apiAdress, { |
|
|
|
|
method: 'GET', |
|
|
|
|
headers: { |
|
|
|
|
'Authorization': 'bearer '+accessToken, |
|
|
|
|
'Authorization': 'Bearer '+accessToken, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -134,7 +149,7 @@ export default class DataToTable extends Component { |
|
|
|
|
if (this.state.arrayOfdata[dataObject][mainKey] === JoinTablesData[data][secondaryKey]) { |
|
|
|
|
for (const columnHeader in this.state.type['header']) { |
|
|
|
|
if ({}.hasOwnProperty.call(this.state.type['header'], columnHeader)) { |
|
|
|
|
if (table === this.state.type['header'][columnHeader]) { |
|
|
|
|
if (table === this.state.type['header'][columnHeader]['name']) { |
|
|
|
|
this.state.arrayOfdata[dataObject][columnHeader]=JoinTablesData[data][column]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -150,6 +165,30 @@ export default class DataToTable extends Component { |
|
|
|
|
|
|
|
|
|
this.setState({finish: true}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
convertRawData = (rawData, type) => { |
|
|
|
|
let data; |
|
|
|
|
switch (type) { |
|
|
|
|
case 'string': |
|
|
|
|
data = rawData; |
|
|
|
|
break; |
|
|
|
|
case 'boolean': |
|
|
|
|
if (rawData === 0) { |
|
|
|
|
data = false; |
|
|
|
|
} else { |
|
|
|
|
data = true; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'date': |
|
|
|
|
data=rawData; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
data = ''; |
|
|
|
|
} |
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getData = () => { |
|
|
|
|
let data; |
|
|
|
|
switch (this.props.tableName) { |
|
|
|
|