Guest User

Untitled

a guest
Dec 3rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.42 KB | None | 0 0
  1. <br />
  2. <b>Notice</b>: Undefined variable: error in <b>/var/www/html/app/Controllers/Hafka/HAFKAController.php</b> on line <b>27</b><br />
  3. <br />
  4. <b>Notice</b>: Undefined variable: id in <b>/var/www/html/app/Controllers/Hafka/HAFKAController.php</b> on line <b>29</b><br />
  5. <br />
  6. <b>Notice</b>: Undefined variable: error in <b>/var/www/html/app/Controllers/Hafka/HAFKAController.php</b> on line <b>29</b><br />
  7. {"code":"INVALID_JSON_INPUT","message":"Error decoding JSON input"}
  8.  
  9. import React, { Component } from 'react';
  10. import logo from './logo.svg';
  11. import './App.css';
  12.  
  13. export default class App extends Component {
  14.  
  15. render() {
  16. return (
  17. <div className="App">
  18. <div className="App-header"></div>
  19. <form
  20. id="main-login"
  21. action="http://don.healthedata.com/admin/login"
  22. method="post">
  23. <h2>
  24. Admin UI Login
  25. </h2>
  26. <label>
  27. <span class="text">user:</span>
  28. <input type="email" name="email"/><br/>
  29. </label>
  30. <br/>
  31. <label>
  32. <span class="text">password:</span>
  33. <input type="password" name="password"/><br/>
  34. </label><br/>
  35. <div class="align-right">
  36. <button type="submit">Submit</button>
  37. </div>
  38. </form>
  39.  
  40. </div>
  41.  
  42. );
  43. }
  44.  
  45. }
  46.  
  47. import React, {Component} from 'react';
  48. import logo from './logo.svg';
  49. import './App.css';
  50.  
  51. export default class App extends Component {
  52.  
  53. constructor(props, context) {
  54. super(props, context);
  55.  
  56. this.state = { description: '' };
  57. }
  58.  
  59. onChange(e) {
  60. this.setState({
  61. [e.target.name]: e.target.value
  62. });
  63. }
  64.  
  65. onSubmit(e) {
  66. e.preventDefault();
  67.  
  68. fetch(this.props.formAction, {
  69. headers: {
  70. 'Accept': 'application/json',
  71. 'Content-Type': 'application/json'
  72. },
  73. body: JSON.stringify({description: this.state.description})
  74. });
  75.  
  76. this.setState({description: ''});
  77. }
  78.  
  79. render() {
  80. return (
  81. <div className="App">
  82. <form
  83. id="main-login"
  84. action={this.props.action}
  85. method={this.props.method}
  86. onSubmit={this.onSubmit}>
  87. <h2>Admin UI Login</h2>
  88. <label>
  89. <span class="text">user:</span>
  90. <input type="email" name="email"/><br/>
  91. </label>
  92. <br/>
  93. <label>
  94. <span class="text">password:</span>
  95. <input type="password" name="password"/><br/>
  96. </label>
  97. <br/>
  98. <div class="align-right">
  99. <button>Submit</button>
  100. </div>
  101. </form>
  102. </div>
  103. );
  104. }
  105.  
  106. }
  107.  
  108. // App.propTypes = { action: React.PropTypes.string.isRequired, method: React.PropTypes.string}
  109. App.defaultProps = {
  110. action: 'http://don.healthedata.com/admin/login',
  111. method: 'post'
  112. };
  113.  
  114. module.exports = App;
  115.  
  116. import fetch from 'isomorphic-fetch';
  117.  
  118. export function createBlogPost(data) {
  119. return fetch('Your Rest url', {
  120. method: 'POST',
  121. body: JSON.stringify(data),
  122. headers: {
  123. 'Content-Type': 'application/json'
  124. }
  125. }).then(response => {
  126. if (response.status >= 200 && response.status < 300) {
  127. return response;
  128. console.log(response);
  129. window.location.reload();
  130. } else {
  131. console.log('Somthing happened wrong');
  132. }
  133. }).catch(err => err);
  134. }
  135.  
  136. import React, { Component, PropTypes } from 'react'
  137. import { connect } from 'react-redux'
  138. import { createBlogPost } from '../../actions/todoadd';
  139. import { addTodo } from '../../actions/todo'
  140. import { setTodoDialogOpen, setErrorText } from '../../actions/todoDialog';
  141. import Dialog from 'material-ui/Dialog';
  142. import FlatButton from 'material-ui/FlatButton';
  143. import RaisedButton from 'material-ui/RaisedButton';
  144. import TextField from 'material-ui/TextField';
  145.  
  146.  
  147. const initialstate = {
  148. title: '',
  149. desc: '',
  150. type: '',
  151. imageurl: ''
  152. }
  153.  
  154. class TodoDialog extends Component {
  155. constructor(props) {
  156. super(props)
  157. this.state = initialstate;
  158. this.onChange = this.onChange.bind(this);
  159. this.handleSubmit = this.handleSubmit.bind(this);
  160. };
  161.  
  162. onChange(e) {
  163. if (e.target.id === 'title') {
  164. this.setState({ title: e.target.value });
  165. } else if (e.target.id === 'desc') {
  166. this.setState({ desc: e.target.value });
  167. } else if (e.target.id === 'type') {
  168. this.setState({ type: e.target.value });
  169. } else if (e.target.id === 'image') {
  170. this.setState({ imageurl: e.target.value});
  171. console.log(e.target.value);
  172. }
  173. }
  174.  
  175. handleSubmit() {
  176. const text = {
  177. news_title: this.state.title,
  178. news_description: this.state.desc,
  179. news_type: this.state.type,
  180. news_src_url: this.state.imageurl,
  181. operation:"insert"
  182. }
  183. alert(text.news_src_url);
  184. createBlogPost(text);
  185. setErrorText(undefined);
  186. setTodoDialogOpen(false);
  187.  
  188. };
  189.  
  190.  
  191. render() {
  192. const { messages, todoDialog, setTodoDialogOpen, addTodo, setErrorText } = this.props;
  193. const styles = {
  194. button: {
  195. margin: 12,
  196. },
  197. exampleImageInput: {
  198. cursor: 'pointer',
  199. position: 'absolute',
  200. top: 0,
  201. bottom: 0,
  202. right: 0,
  203. left: 0,
  204. width: '100%',
  205. opacity: 0,
  206. },
  207. };
  208.  
  209. function handleClose() {
  210. setErrorText(undefined);
  211. setTodoDialogOpen(false);
  212. };
  213.  
  214. const actions = [< FlatButton label={
  215. messages.cancel || 'cancel'
  216. }
  217. primary={
  218. true
  219. }
  220. onTouchTap={
  221. handleClose
  222. } />, < FlatButton label={
  223. messages.submit || 'submit'
  224. }
  225. primary={
  226. true
  227. }
  228. onTouchTap={this.handleSubmit} />
  229. ];
  230.  
  231. return (
  232. <div>
  233. <Dialog title={messages.todo_add || 'todo_add'} actions={actions} modal={false} open={todoDialog.open} onRequestClose={handleClose}>
  234. <form>
  235. <TextField ref="todoText1" onChange={this.onChange} id='title' hintText={messages.todo_hint1 || 'todo_hint'} errorText={todoDialog.errorText} floatingLabelText={messages.todo_label1 || 'todo_label1'} fullWidth={true} />
  236. <TextField ref="todoText2" onChange={this.onChange} id='desc' hintText={messages.todo_hint2 || 'todo_hint'} errorText={todoDialog.errorText} floatingLabelText={messages.todo_label2 || 'todo_label2'} fullWidth={true} multiLine={true} rows={1} rowsMax={3} />
  237. <TextField ref="todoText3" onChange={this.onChange} id='type' hintText={messages.todo_hint3 || 'todo_hint'} errorText={todoDialog.errorText} floatingLabelText={messages.todo_label3 || 'todo_label3'} fullWidth={true} />
  238. <RaisedButton label='ADD Photo' style={styles.button} labelPosition="before" containerElement="label"><input type='file' onChange={this.onChange} id='image' style={styles.exampleImageInput} /></RaisedButton>
  239. </form>
  240. </Dialog>
  241. </div>
  242. )
  243. }
  244. }
Add Comment
Please, Sign In to add comment