Wednesday, 8 May 2019

code test react js




user.Service.js


function getHospitalAll() {


return.apiservice.getAPIService("http://100.00.0.0").this(handlerespnse)

.this(admin=>){

return admin;

});

}

----------------------------

api.service.js

Function getAPIService(url) {


 constrequestoption = {

method:'GET',

headers:authHeader()

};

return fetch('$ { env.config.url.API.url})

${url.request option};

}

 ---------------------------------------------------------------------------------------------------

table.js

(user.Service.getHospitalAll())




import React, { Component } from 'react';

class App extends Component {

constructor(props){

super(props);

this.state ={
item:[],
isLoaded:False,
}
}

ComponentDidMount() {


feach('http://100.00.0.0') // userService.getHospitalAll()
.then(res => res.json())
.then(json => {
 this.setState({
isLoaded:true,
item.json
})
});
}

render() {
var(isLoades, item ) .this.state;
if(!isLoaded){
retuen <div>loading.....</div>
}
else return {

<ul>
{item.map(item =>(
<li>{item.id}</li>
<li>{item.name}</li>
<li>{item.mode}</li>
))};
}


 }



-----------------------------------------------------------------------



import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';



@Component({
  selector:'app-root',
  template:`
  <!-- router-outlet></router-outlet -->
 
  <!--   <input [(ngModel)]="name" /> <input [(ngModel)]="val" /> <button (click)="send()">Click</button>
     <button (click)="find();">Find</button>
     <button (click)="delete()">Delete</button>
     <img src="assets/images/sample.gif" />
     -->

<h1>Template driven form</h1>
<form #loginForm="ngForm"  class="myForm" (ngSubmit)="formSubmit(loginForm)" >
 <div>
   <input  [(ngModel)]="email" name="uemail" #lemail="ngModel" required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"/>
   <span *ngIf="lemail.touched && lemail.invalid" class="error">
    Email error !
   </span>
 </div>
 <div>
  <input   type="password" [(ngModel)]="password" name="upassword" #lpassword="ngModel" required/>
  <div *ngIf="lpassword.touched && lpassword.invalid" class="error">
     Password !
  </div>
 </div>


 <button>Submit</button>
 <!-- <div *ngIf="loginForm.touched && loginForm.invalid" class="error">
    Something went Wrong !
 </div> -->
</form>



<h2>Register</h2>

<form #regiForm="ngForm"  class="myForm" (ngSubmit)="formRegi(regiForm)" >
 <div>
   <input  [(ngModel)]="remail" name="uemail" #lemail="ngModel" required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"/>
   <span *ngIf="lemail.touched && lemail.invalid" class="error">
    Email error !
   </span>
 </div>

 <div>
  <input   type="password" [(ngModel)]="rpassword" name="upassword" #lpassword="ngModel" required/>
  <div *ngIf="lpassword.touched && lpassword.invalid" class="error">
     Password !
  </div>
 </div>

 <div>
   <input  [(ngModel)]="rname" name="uname" #lname="ngModel" required />
   <span *ngIf="lname.touched && lname.invalid" class="error">
    name error !
   </span>
 </div>

 <div>
   <input  [(ngModel)]="mnumber" name="umnumber" #lmnumber="ngModel" required />
   <span *ngIf="lmnumber.touched && lmnumber.invalid" class="error">
    number error !
   </span>
 </div>

 <button>Submit</button>
 <!-- <div *ngIf="regiForm.touched && regiForm.invalid" class="error">
    Something went Wrong !
 </div> -->
</form>

  `,
  styles:[`
        input,button{
          padding: 3px; margin:3px; border: 1px solid silver;
        }
        .error{ color: red; }
        .myForm .ng-touched.ng-invalid{
          border-left: 3px solid red;
        }
        .myForm .ng-touched.ng-valid{
          border-left: 3px solid green;
        }
    `]
})
export class AppComponent{

  public name:string=''; public val:string='';

  constructor( ){
  //  console.log(this.regModel);
  }

  formSubmit(loginForm:any){
    if(loginForm.valid){
    //  alert('Submitted....');
    console.log('Submitted',loginForm.value);
       this.api.login(loginForm.value).then( (res:any)=>{
        //  console.log('resss',res);
        if(res.status=="success"){
        //alert('Login Success');
        window.location.href="/accounts";
      }else{
        alert('Login Failed');
      }
     } )
    }

  }



  formRegi(regiForm:any){
    if(regiForm.valid){
    //  alert('Submitted....');
    console.log('Submitted',regiForm.value);
       this.api.register(regiForm.value).then( (res:any)=>{
        //  console.log('resss',res);
        if(res.status=="success"){
        alert('Register Success');
      }else{
        alert('Register Failed');
      }
     } )
    }

  }

send(){
  let obj = [];
  obj[this.name]=this.val;
  this.storage.set(obj);
}

find(){
  console.log( this.storage.get('') )
}

delete(){
  this.storage.remove( this.name );
}


}

Tuesday, 7 May 2019

delet url


https://drive.google.com/file/d/1hC5xhF7ma0DTf1mYc1WDHF9RZK3cCggV/view?usp=sharing



https://stackoverflow.com/questions/40234757/in-react-how-to-show-data-from-api-in-a-html-table

https://www.digitalocean.com/community/tutorials/how-to-display-data-from-the-digitalocean-api-with-react

https://www.codingame.com/playgrounds/8508/reactjs-constructor-tutorial

https://github.com/benawad/basic-react-form/tree/2_material_ui


https://react.rocks/tag/DataTable

https://react.rocks/example/reactabular

https://appdividend.com/2018/05/04/react-bootstrap-table2-example/

https://reactjsexample.com/tag/table/

https://medium.com/@everdimension/how-to-handle-forms-with-just-react-ac066c48bd4f (POst data - date -react and send data to the server?


https://github.com/catalin-luntraru/redux-minimal