My backend looks like this:
table1
id | lotsofothercolumns | problemID
-----------------------------------
1 | blah blah | 1
table2 (which is basically a mapping table)
id | problemID | resolutionSteps
-----------------------------------
1 | 1 | "do this do that"
In App.tsx, I have added both resource:
<Resource name="table1" list={Table1List} edit={Table1Edit} />
<Resource name="table2" />
In Table1Edit, I tried to display the resolutionSteps from table2
<Edit>
<SimpleForm>
<ReferenceInput source="problemID" reference="table2">
<TextInput source="resolutionSteps" />
</ReferenceInput>
...
//display lots of stuff from table1, all no issue
...
</SimpleForm>
</Edit>
Unfortunately, it doesn't display 'do this do that', instead it simply displays '1' and gives an error 'Associated reference no longer appears to be available'. Everything other column from table1 is displayed correctly so the plumbing from frontend to backend should be working. I read the react-admin documentation and it seems that ReferenceInput can only be used with Inputs that supports choices, so how do I display resolutionSteps in this case?
All choices inputs accepts an optionText prop which allows you to specify which field should be used for the option text:
<Edit>
<SimpleForm>
<ReferenceInput source="problemID" reference="table2">
<SelectInput optionText="resolutionSteps" />
</ReferenceInput>
...
//display lots of stuff from table1, all no issue
...
</SimpleForm>
</Edit>
Related
I have the next data:
Different users has different ids in the one common table. Object in a table is an action between System and user. It could be like : show_popup/close_popup/show_price/unsubsribe/pay etc. Also I have a time of all this actions, user static info (geo for example) and other.
All table looks like:
id user_id....some_static_info....popup_id action....time <br />
1..aaaaaaa..xxxxxxxxxxxxxxxx....28........show........23 <br />
2..aaaaaaa..xxxxxxxxxxxxxxxx....28........close........25 <br />
4..abbabab..yyyyyyyyyyyyyyyy....27........close........27 <br />
3..abbabab..yyyyyyyyyyyyyyyy....27........show ........22 <br />
4..abbabab..yyyyyyyyyyyyyyyy....27........show ........ 10 <br />
5..abbabab..yyyyyyyyyyyyyyyy....51........show ........ 5 <br />
6..bbccabb..zzzzzzzzzzzzzzzz....27........price........ 45 <br />
7..bbccabb..zzzzzzzzzzzzzzzz....51........show ........ 44 <br />
.....................................................................
I want to teach LSTM to predict the reaction of user (actions like show_price) is positive and (usnubsribe, close_popup) is negative. So I added new column:
id user_id some_static_info popup_id action time target
1 aaaaaaa xxxxxxxxxxxxxxxx 28 show 23 0 <- this is a single action <br />
2 aaaaaaa xxxxxxxxxxxxxxxx 28 close 25 -1<br />
4 abbabab yyyyyyyyyyyyyyyy 27 close 27 -1<br />
3 abbabab yyyyyyyyyyyyyyyy 27 show 22 0<br />
4 abbabab yyyyyyyyyyyyyyyy 27 show 10 0<br />
5 abbabab yyyyyyyyyyyyyyyy 51 show 5 0<br />
6 bbccabb zzzzzzzzzzzzzzzz 27 price 45 1 <- other action with user reaction<br />
7 bbccabb zzzzzzzzzzzzzzzz 51 show 44 0<br />
.................................................
So target 0 is neutral actions and it could make influence to user for a positive or negative reaction. I want to teach LSTM on a series of previous actions to predict the reaction.
So Id like to get something like:
[ <br />
[[action1] [action2] [action3] [action4] [action_target]], <br />
[[action12] [action11] [action8] [action_target]],<br />
[[action14] [action16] [..] [..] [..] [..] [..]],<br />
[[..] [..] [..] [..] [.]],<br />
]<br />
So timesteps will be various and and I dont know how to make it.
If there is no solution Id like to make func to create data that collect only n-samples in each series.
Like this:
[ <br />
[[action1] [action2] [action3] [action4] [action_target1]], <- n_samples = 4<br />
[[action12] [action23] [action53] [action54] [action_target2]],<br />
[[action13] [action24] [action36] [action44] [action_target3]],<br />
[[..] [..] [..] [..] [.]],<br />
]<br />
I made this function in the next way:
Sort all table by user_id, time
Find all unique user_id
For each user_id get all actions , that belong to it. (using iterrows)
Find all rows where target != 0
Find n previous rows whith target = 0
Collect that rows to the table
So I expect the table will be looks like
id user_id....some_static_info....popup_id action....time....target <br />
1..aaaaaaa..xxxxxxxxxxxxxxxx....28........show........23 .... 0 <br />
2..aaaaaaa..xxxxxxxxxxxxxxxx....28........show ........24....0 <br />
4..aaaaaaa..xxxxxxxxxxxxxxxx....27........show ........25....0 <br />
3..aaaaaaa..xxxxxxxxxxxxxxxx....27........show ........26... 0 <br />
4..aaaaaaa..xxxxxxxxxxxxxxxx....27........price........ 27....1 <br />
5..abbabab..yyyyyyyyyyyyyyyy....51........show ........ 1 ....0 <br />
6..abbabab..yyyyyyyyyyyyyyyy....27........show ........ 3....0 <br />
7..abbabab..yyyyyyyyyyyyyyyy....51........show ........ 5....0 <br />
7..abbabab..yyyyyyyyyyyyyyyy....51........show ........ 6....0 <br />
7..abbabab..yyyyyyyyyyyyyyyy....51........unsub........ 8....-1 <br />
.....................................................................
After that Im going to use standart .reshape() for it with a static n.
The problem is that I dont know how to make this without pd.iterrows().
If I do it whith iterrows() the execution will take a lot of time (about a week).
Any ideas to make it faster?
for printing receipts I am using Template strings so it looks like this
<TouchableHighlight onPress={() => {
var textToPrint =
`
--------------------------------
how to put image logo here
--------------------------------
${GLOBAL.USERNAME}
${new Date().getDate()}
Bestell ID: ${props.currentorder.order.OrderID}
--------------------------------
Kunde:
${props.currentorder.order.firstname} ${props.currentorder.order.lastname}
${props.currentorder.order.phone}
Adresse:
${props.currentorder.order.address}
${props.currentorder.order.zip} ${props.currentorder.order.city}
********************************
${(props.currentorder.order.payment==='cash'?"BARGELD":'Online – Bestellung schon bezahlt')}
********************************
--------------------------------`
BtPrint(textToPrint)
}}
>
<Text>Print</Text>
</TouchableHighlight>
Is there any way that on the begining of the recipe in this text I can put image logo?
Thank you so much
I can't find the problem in my code when trying to query with variables from react-native. A simple Hello World! is working.
The render:
render() {
return (
<AppContext.Consumer>
{context => {
const{ userID,employeeID,salonID,currentDay,serviceTime}=context.state
return (
<Query
query={query}
variables={{userID:userID,employeeID:employeeID,salonID:salonID,day:currentDay,serviceTime:serviceTime}}
>
{(response, error) => {
console.log(`response: ${response.data.listOfAppointments}`);
console.log(`EMPL: ${response.data.employeeInfo}`);
console.log(`\helo: ${response.data.hello}`);
return (
<Grid>
<Col>
<MyHeader
navigation={this.props.navigation}
title={context.state.currentDay
.format("DD.MM.YYYY")
.toString()}
/>
{!response.data.listOfAppointments? (
<CircularProgress />
) : (
<ScheduleList data={response.data.listOfAppointments} />
)}
</Col>
</Grid>
);
}}
</Query>
);
}}
</AppContext.Consumer>
);
}
The Query:
const query =gql`
query Query($userID:String!,$employeeID:String!,$salonID:String!,$day:Int!,$serviceTime:Int){
hello
listOfAppointments(
userID: $userID
employeeID: $employeeID
salonID: $salonID
day: $day
serviceTime: $serviceTime
) {
start
end
status
disabled
}
employeeInfo(employeeID: $employeeID
salonID: $salonID){
token
name
ID
notifyWhenCreated
notifyWhenDeleted
salonName
}
}
`;
The schemas and types:
If I delete listOfAppointments,employeeInfo and the part where I declare the variables the hello is working.
Otherwise it's giving me status code: 400
react-native log-android is not throwing anything.
If I try to console.log() the result it's undefined.
Thanks!
A status code of 400 usually means the query itself is invalid. It could be that the query has a syntax error, or is somehow not passing validation. To get the detailed response from the server, you can either 1) observe the actual response from the server in the network tab of your browser or 2) capture the error from the component itself.
<Query /* props */>
({ data, error }) => {
console.log(error)
return null
}
</Query>
Note that we're only dealing with the first parameter in the render props function and just using destructuring to get its data and error properties.
As far as I can tell, your query does not have any syntax errors, so I suspect the issue is that some or all of the variables you are passing in are in fact undefined, which will cause your query to blow up if any of them are marked as non-null inside the query.
I need to show different choices based on record's field value.
The code for my needs looks like this:
const myChoicesGenerator = (record) => {
if (record.field === false) {
return ['a', 'b'];
} else {
return ['b', 'c'];
}
<SelectInput ... choices = {myChoicesGenerator}/>
But unfortunately i can't pass functions in "choices" property, so this code doesn't work.
Is there a way to do it?
You may use a <FormDataConsumer /> to get the current record and pass it to your function.
<FormDataConsumer>
{
({formData, ...rest}) =>
<SelectInput
choices={myChoiceGenerator(formData)}
{...rest}
/>
}
</FormDataConsumer>
Doc: https://marmelab.com/react-admin/Inputs.html#linking-two-inputs
I dont' know if the values ['a', 'b'] are valid for <SelectInput />. Consider using a list of tuples (id, name) as described in the documentation.
I have a xml where the values are given:
<User version="5.1.0.1" ... (omitted for brevity) >
<Login usewinLogin="true" passwordNeverExpires="false" />
<Misc />
<AdditionalInfo />
<OutOfOfficeSettings isOutOfOffice="false" startDateTime="0001-01-01T00:00:00.0000000Z" />
<RegionalSettings language="de" culture="de" />
</User>`
I would need the value from OutofOfficeSettings isOutofOffice= (Options are false or true).
I never did this before, is someone here to help me?
One option
Declare #DWUser table (Active int, settings xml )
Insert Into #DWUser values
(1,'<User version="5.1.0.1" uid="1" oid="2" w3uid="ADMIN" guid="05b6f2a2-cdf8-4b73-8d1b-86eab657654" oguid="43a0d394-e515-45ea-aa25-7822673c52a3" name="admin" active="true" eMail="admin#admin.com" distribution="NetworkStartup" securityLevel="Normal" defaultWebBasket="cc1c589a-549a-4957-959b-3b5acc4decc9"><Login usewinLogin="true" passwordNeverExpires="false" /><Misc /><AdditionalInfo /><OutOfOfficeSettings isOutOfOffice="false" startDateTime="0001-01-01T00:00:00.0000000Z" /><RegionalSettings language="de" culture="de" /></User>')
,(1,'<root><OtherXML>Hi</OtherXML></root>')
Select A.active
,Type = X.attr.value('#isOutOfOffice','varchar(100)')
From #DWUser A
Outer Apply A.settings.nodes('User/OutOfOfficeSettings') as X(attr)
Where A.Active=1
Returns
active Type
1 false
1 NULL