Switch to unified view

a b/web-app/client/src/components/LoginnPatient.vue
1
<template>
2
      <div>
3
4
        
5
           
6
       
7
         
8
          <div v-show="vs" class="regpatient" >
9
10
                <h1 id="pl" >PATIENT LOGIN</h1>
11
                <form @submit="fs" enctype=multipart/form-data>
12
                    <ul>
13
                        <li>
14
                            <label for="fname" class="label" >Username:</label>
15
                            <input type="text"   v-model="username"   id="fname" name="username" class="inputfield" required><br><br>
16
                        </li>
17
                        <li>
18
                            <label for="fname" class="label">Password:</label>
19
                            <input type="text"    v-model="password"   id="fname" name="password" class="inputfield"><br><br>
20
                        </li>
21
                      
22
                      
23
                       
24
                        <li>
25
                            
26
                        </li>
27
                    </ul>
28
                    <input type="submit" value="Submit" name="patient" class="signup">
29
                </form>
30
31
                
32
            <div>
33
                       <h1>{{objj.error}}</h1>
34
                    
35
            </div>
36
        
37
            </div>
38
            <h1>{{filter}}</h1>
39
40
            <h4>{{gmsg.Success}}</h4>
41
              <h4>{{rmsg.Success}}</h4>
42
43
                <!-- <div>
44
                    <p>  {{patientdatas}}</p>
45
                    <p>{{reports}}</p>
46
                </div>
47
               -->
48
             <div v-show="pasked">
49
                 <h1>show content</h1>
50
                  <form @submit="fs2" enctype=multipart/form-data>
51
                  
52
                    
53
                    <input type="submit" value="Grant" name="patient" class="signup">
54
                </form>
55
56
                <form @submit="fs3" enctype=multipart/form-data>
57
                  
58
                    
59
                    <input type="submit" value="Reject" name="patient" class="signup">
60
                </form>
61
62
                 
63
             </div>
64
            <vue-instant-loading-spinner ref="Spinner"></vue-instant-loading-spinner>
65
         </div>
66
            
67
         <!-- <pp/> -->
68
    
69
    
70
71
72
73
74
</template>
75
76
<script>
77
// import uuid from 'uuid';
78
import VueInstantLoadingSpinner from "vue-instant-loading-spinner/src/components/VueInstantLoadingSpinner.vue";
79
import axios from "axios";
80
export default {
81
    name: "LoginnPatient",
82
    async mounted() {
83
    // console.log("created");
84
    // this.x = 99;
85
86
    let res = await axios.get('http://localhost:8080/getPatients');
87
88
    let data = res.data;
89
    this.patientdatas = data;
90
    console.log("this is patient data")
91
   console.log(data)
92
 
93
94
    
95
//     let res1 = await axios.get('http://localhost:8080/getDoctors');
96
97
//     let data1 = res1.data;
98
//     this.doctordatas = data1;
99
//     console.log("this is doctor data")
100
//    console.log(data1)
101
102
    let res2 = await axios.get('http://localhost:8080/getReports');
103
    this.reports=res2.data;
104
    console.log("these are reports")
105
    console.log()
106
    //  console.log(this.reports[0].Record.patientId)
107
    //  this.pid=this.reports[0].Record.patientId;
108
    //  console.log("insie")
109
    //  console.log(this.pid)
110
 
111
  },
112
    data (){
113
        return{
114
             x:" ",
115
            objj: {
116
                
117
             
118
               
119
120
            },
121
            patientdatas : [],
122
            reports : [],
123
            
124
125
            gmsg:{},
126
            rmsg:{},
127
128
            username: '',
129
            password: '',
130
            vs:true,
131
            pasked:false,
132
            index:"",
133
            filter:{}
134
           
135
          
136
        
137
    
138
        }
139
    },
140
    
141
142
    components: {
143
    VueInstantLoadingSpinner,
144
    // pp
145
  },
146
  methods:{
147
         async fs(e)
148
        { 
149
            //  let list = {};
150
            // let x;        
151
            e.preventDefault();
152
            console.log("submit pressed")
153
            this.objj.username=this.username
154
            this.objj.password=this.password
155
          
156
            const newTodo = {
157
                username: this.username,
158
                password : this.password ,
159
             
160
               
161
            
162
            }
163
            console.log(newTodo)
164
            //1593418037214
165
          
166
          let params = {
167
                patientId: this.username,
168
                 pswd : this.password 
169
          }
170
171
          let res = await axios.post('http://localhost:8080/validatePatient',params);
172
          this.objj=res.data;
173
          let x = this.objj.Success;
174
        //   console.log()
175
176
        //   axios.post('http://localhost:8080/validatePatient', {
177
        //         patientId: this.username,
178
        //         pswd : this.password ,
179
            
180
        //          })
181
        //     // .then(res => this.objj=res.data)
182
        //      .then(res => x.json() =res.data.Success )
183
            
184
        //      .then(console.log(x))
185
             
186
        //     // .then(data => {})
187
        //     .catch(e => {
188
        //     this.errors.push(e)
189
        //     })
190
        //     // console.log(`this is api response ${res.data.Success}`)
191
        //     // console.log(``)
192
        //     console.log(x)
193
        
194
        if (x)
195
        {
196
            // this.$router.push('PatientDashboard') 
197
            this.vs=false;
198
            console.log("if executed")
199
        }
200
           for(var i=0;i<this.reports.length;i++)
201
       {
202
           console.log("for executed")
203
           console.log(this.username)
204
          if(this.username==this.reports[i].Record.patientId)
205
          {
206
            console.log("matched")
207
            let index = i;
208
            this.index = index;
209
            let c=1;
210
            console.log(index)
211
212
            if(c==1)
213
            {
214
               this.filter = this.patientdatas[index].Record;
215
               if(this.reports[index].Record.isAsked=="1")
216
               {
217
                   
218
               
219
                    console.log("permission is asked")
220
                   this.pasked=true; 
221
                }
222
           
223
          }
224
       }
225
      
226
        }
227
  },
228
  async fs2(e)
229
  {
230
       e.preventDefault();
231
232
    let l = this.index;
233
         let params = {
234
                patientId: this.username,
235
                 reportId : this.reports[l].Record.reportId
236
          }
237
238
          let res = await axios.post('http://localhost:8080/grantAccess',params);
239
         console.log(res.data)
240
         this.gmsg=res.data
241
242
       console.log(("granted"))
243
        this.pasked=false; 
244
245
  },
246
  async fs3(e)
247
  {
248
         e.preventDefault();
249
250
         let l = this.index;
251
         let params = {
252
                patientId: this.username,
253
                 reportId : this.reports[l].Record.reportId
254
          }
255
256
          let res = await axios.post('http://localhost:8080/rejectAccess',params);
257
         console.log(res.data)
258
          this.rmsg=res.data;
259
           console.log(("Rejected"))
260
            this.pasked=false; 
261
262
  }
263
   
264
}
265
}
266
 
267
268
</script>
269
270
<style  scoped>
271
272
.regpatient
273
{
274
    background-color: white;
275
    height: 280px;
276
    width: 300px;
277
     border-radius: 25px;
278
  padding: 2em;
279
    margin: 5em auto;
280
  
281
  -webkit-box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
282
          box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
283
}
284
285
286
.signup{
287
    background-color: #126597; /* Green */
288
  border: none;
289
  color: white;
290
  padding: 12px;
291
  text-align: center;
292
  text-decoration: none;
293
  display: inline-block;
294
  font-size: 16px;
295
  /* margin: 4px 2px; */
296
  margin-left: 6em;
297
  cursor: pointer;
298
  border-radius: 12px;
299
  width: 100px;
300
  font-weight: bold;
301
}
302
#pl{
303
    text-align: center;
304
}
305
.inputfield {
306
       width: 15em;
307
    padding: 0.8em;
308
    /* border-radius: 0.5em; */
309
    border: none;
310
    border-bottom: 1px solid black;
311
}
312
ul{
313
    list-style-type: none;
314
}
315
</style>