Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.81 KB | None | 0 0
  1. <template>
  2. <div>
  3. <div id="mainuserbox">
  4. <div>
  5. <b> <h5 id="userheader"> User Management </h5> </b>
  6. </div>
  7. <div id="searchbar">
  8. <div class="row">
  9. <div class="column">
  10. <div class="row">
  11. <q-input class="inputspace" placeholder="First Name" color="secondary" v-model="fname" @input="finduser()"/>
  12. <q-input class="inputspace" placeholder="Last Name" color="secondary" v-model="lname" @input="finduser()"/>
  13. </div>
  14. <div class="row">
  15. <q-input class="inputspace" placeholder="Phone Number" color="secondary" v-model="phonenumber" @input="finduser()"/>
  16. <q-input class="inputspace" placeholder="Address" color="secondary" v-model="address" @input="finduser()"/>
  17. </div>
  18. </div>
  19. <div>
  20. <div class="row">
  21. <q-btn icon="clear" color="secondary" @click="clear()" class="inputspace" @keyup.native.esc="clear()">
  22. <q-tooltip anchor="bottom middle" self="top middle" :offset="[10, 10]" color="secondary" @click="showing = false">
  23. Clear (Ctrl + Q)
  24. </q-tooltip>
  25. </q-btn>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <center v-if="users.length===0">
  31. <h6 class="secondarycolor"> No Results </h6>
  32. <q-btn v-if="!arefieldsempty()" label="Add New User" class="inputspace" color="secondary" @click="adduser()"/>
  33. </center> <br>
  34. <div id="userlist">
  35. <div class="row justify-center">
  36. <q-card color="secondary" dark class="q-ma-sm" v-for="user in users" :key="user.UserID" >
  37. <q-card-title>
  38. <div class="row">
  39. <div class="row">
  40. <div id="leftrow">
  41. <p class="margintop"><b>First Name:</b></p>
  42. <p class="margintop"><b>Last Name:</b> </p>
  43. <p class="margintop"><b>Phone Number:</b> </p>
  44. <p class="margintop"><b>Address:</b> </p>
  45. <p class="margintop"><b>Username:</b> </p>
  46. <p class="margintop marginbottom"> <b>Password:</b> </p>
  47. </div>
  48. <div id="rightrow">
  49. <p class="margintop">{{ user.FirstName }}</p>
  50. <p class="margintop">{{ user.LastName }}</p>
  51. <p class="margintop">{{ user.PhoneNumber }}</p>
  52. <p class="margintop">{{ user.Address }}</p>
  53. <p class="margintop">{{ user.Username }}</p>
  54. <p class="margintop marginbottom">
  55. <q-input type="password" :value="user.Password" class="margintop passcode" color="secondary" inverted readonly :style="{'min-width': width}"/>
  56. </p>
  57. </div>
  58. </div>
  59. <div class="column" slot="right">
  60. <div>
  61. <q-icon name="person" size="50px"/>
  62. </div>
  63. </div>
  64. </div>
  65. </q-card-title>
  66.  
  67. <q-card-separator />
  68. <q-card-actions>
  69. <q-btn icon="edit" @click="edituser(user)" class="inputspace">
  70. <q-tooltip anchor="bottom middle" self="top middle" :offset="[10, 10]" color="secondary" @click="showing = false">
  71. Edit
  72. </q-tooltip>
  73. </q-btn>
  74. <q-btn icon="delete" color="secondary" @click="deactivate(user)" class="inputspace">
  75. <q-tooltip anchor="bottom middle" self="top middle" :offset="[10, 10]" color="secondary" @click="showing = false">
  76. Deactivate
  77. </q-tooltip>
  78. </q-btn>
  79. </q-card-actions>
  80. </q-card>
  81. </div>
  82. </div>
  83. <q-dialog
  84. v-model="dialog1"
  85. prevent-close
  86. >
  87. <span slot="title" class="secondarycolor"> Edit User </span>
  88. <template slot="message">
  89. <div class="secondarycolor marginbottom"> First Name: </div>
  90. <q-input v-model="newfname" color="secondary" @input="popupinput()"/>
  91. <div class="secondarycolor topspace marginbottom"> Last Name: </div>
  92. <q-input v-model="newlname" color="secondary" @input="popupinput()"/>
  93. <div class="secondarycolor topspace marginbottom"> Address: </div>
  94. <q-input v-model="newaddress" color="secondary" @input="popupinput()"/>
  95. <div class="secondarycolor topspace marginbottom"> Phone Number: </div>
  96. <q-input v-model="newphonenumber" color="secondary" @input="popupinput()"/>
  97. <div class="secondarycolor topspace marginbottom"> Username: </div>
  98. <q-input v-model="newusername" type="textarea" color="secondary" @input="popupinput()"/>
  99. <div class="secondarycolor topspace marginbottom"> Password: </div>
  100. <q-input v-model="newpassword" color="secondary" @input="popupinput()" type="password"/>
  101. </template>
  102. <span slot="buttons" slot-scope="props">
  103. <q-btn label="Submit" color="secondary" @click="yesclicked()" :disable="edituserdisable"/>
  104. <q-btn label="Cancel" color="red" @click="noclicked()"/>
  105. </span>
  106. </q-dialog>
  107. <q-dialog
  108. v-model="dialog3"
  109. color="secondary"
  110. >
  111. <span slot="title" class="secondarycolor"> Update Request </span>
  112. <span slot="message"> User Edited Successfully </span>
  113. </q-dialog>
  114. <q-dialog
  115. v-model="dialog4"
  116. color="secondary"
  117. >
  118. <span slot="title" class="secondarycolor"> Addition Request </span>
  119. <span slot="message"> User Added Successfully </span>
  120. </q-dialog>
  121. <q-dialog
  122. v-model="dialog2"
  123. prevent-close
  124. >
  125. <span slot="title" class="secondarycolor"> Add User </span>
  126. <template slot="message">
  127. <div class="secondarycolor marginbottom"> First Name: </div>
  128. <q-input v-model="newfname" color="secondary" @input="popupinput()"/>
  129. <div class="secondarycolor topspace marginbottom"> Last Name: </div>
  130. <q-input v-model="newlname" color="secondary" @input="popupinput()"/>
  131. <div class="secondarycolor topspace marginbottom"> Address: </div>
  132. <q-input v-model="newaddress" color="secondary" @input="popupinput()"/>
  133. <div class="secondarycolor topspace marginbottom"> Phone Number: </div>
  134. <q-input v-model="newphonenumber" color="secondary" @input="popupinput()"/>
  135. <div class="secondarycolor topspace marginbottom"> Username: </div>
  136. <q-input v-model="newusername" type="textarea" color="secondary" @input="popupinput()"/>
  137. <div class="secondarycolor topspace marginbottom"> Password: </div>
  138. <q-input v-model="newpassword" color="secondary" @input="popupinput()" type="password"/>
  139. <div class="secondarycolor topspace marginbottom"> Admin Privilege: </div> <br>
  140. <q-checkbox v-model="admin" label="Admin" color="secondary"/> <br>
  141. </template>
  142. <span slot="buttons" slot-scope="props">
  143. <q-btn label="Submit" color="secondary" @click="yesclicked1()" :disable="edituserdisable"/>
  144. <q-btn label="Cancel" color="red" @click="noclicked1()"/>
  145. </span>
  146. </q-dialog>
  147. <q-dialog
  148. v-model="dialog5"
  149. color="secondary"
  150. >
  151. <span slot="title" class="secondarycolor"> Deactivate </span>
  152. <span slot="message"> Are you sure you want to deactivate this user? </span>
  153. <span slot="buttons" slot-scope="props">
  154. <q-btn label="Yes" color="secondary" @click="yesclicked2()"/>
  155. <q-btn label="No" color="red" @click="noclicked2()"/>
  156. </span>
  157. </q-dialog>
  158. <q-dialog
  159. v-model="dialog6"
  160. color="secondary"
  161. >
  162. <span slot="title" class="secondarycolor"> Deactivation Request </span>
  163. <span slot="message"> User has been deactivated successfully </span>
  164. </q-dialog>
  165. </div>
  166. </div>
  167. </template>
  168.  
  169. <script>
  170. export default {
  171. // name: 'ComponentName',
  172. data () {
  173. return {
  174. fname: "",
  175. lname: "",
  176. users: [],
  177. newfname: "",
  178. newlname: "",
  179. newusername: "",
  180. newpassword: "",
  181. dialog1: false,
  182. dialog2: false,
  183. edituserdisable: true,
  184. dialog3: false,
  185. userid: null,
  186. dialog4: false,
  187. dialog5: false,
  188. dialog6: false,
  189. visibility: false,
  190. visicon: "visibility_off",
  191. admin: false,
  192. phonenumber: "",
  193. address: "",
  194. newphonenumber: "",
  195. newaddress: "",
  196. width: ""
  197. }
  198. },
  199. mounted() {
  200. this.$nextTick (() => {
  201. //this.width=document.getElementById("rightrow").offsetWidth + "px"
  202. })
  203. },
  204. methods: {
  205. clear: function () {
  206. this.fname=""
  207. this.lname=""
  208. this.users=[]
  209. this.address=""
  210. this.phonenumber=""
  211. },
  212. arefieldsempty: function () {
  213. if(this.fname=="" && this.lname=="")
  214. {
  215. return true
  216. }
  217. else
  218. {
  219. return false
  220. }
  221. },
  222. adduser: function () {
  223.  
  224. },
  225. input: function () {
  226. this.visibility=false
  227. this.visicon="visibility_off"
  228. if(this.fname=="" && this.lname=="" && this.address && this.phonenumber)
  229. {
  230. this.users=[]
  231. }
  232. else{
  233. this.finduser()
  234. }
  235. },
  236. finduser: function () {
  237. if(this.fname!=''||this.lname!=''||this.address!=''||this.phonenumber!='')
  238. {
  239. this.$Socket.emit('finduser', {
  240. FirstName: this.fname,
  241. LastName: this.lname,
  242. Address: this.address,
  243. PhoneNumber: this.phonenumber
  244. }, (userlist) => {
  245. this.users=userlist
  246. }
  247. )
  248. }
  249. else
  250. {
  251. this.users=[]
  252. }
  253. },
  254. popupinput: function () {
  255. if( this.newfname=="" || this.newlname =="" || this.newusername=="" || this.newpassword=="" || this.newaddress=="" || this.newphonenumber=="")
  256. {
  257. this.edituserdisable=true
  258. }
  259. else {
  260. this.edituserdisable=false
  261. }
  262. },
  263. yesclicked: function () {
  264. this.$Socket.emit('edituser', {
  265. UserID: this.userid,
  266. FirstName: this.newfname,
  267. LastName: this.newlname,
  268. Address: this.newaddress,
  269. PhoneNumber: this.newphonenumber,
  270. Username: this.newusername,
  271. Password: this.newpassword
  272. }, ({authenticated}) => {
  273. if(authenticated==true)
  274. {
  275. this.dialog1=false
  276. this.dialog3=true
  277. this.clearpopup()
  278. this.finduser()
  279. }
  280. })
  281. },
  282. clearpopup: function () {
  283. this.newfname=""
  284. this.newlname=""
  285. this.newusername=""
  286. this.newpassword=""
  287. this.newaddress=""
  288. this.newphonenumber=""
  289. this.admin=false
  290. },
  291. noclicked: function () {
  292. this.clearpopup()
  293. this.dialog1=false
  294. },
  295. edituser: function (user) {
  296. this.newfname=user.FirstName
  297. this.newlname=user.LastName
  298. this.newaddress=user.Address
  299. this.newphonenumber=user.PhoneNumber
  300. this.newusername=user.Username
  301. this.newpassword=user.Password
  302. this.dialog1=true
  303. this.edituserdisable=true
  304. this.userid=user.UserID
  305. },
  306. adduser: function () {
  307. this.newfname=this.fname
  308. this.newlname=this.lname
  309. this.newaddress=this.address
  310. this.newphonenumber=this.phonenumber
  311. this.dialog2=true
  312. this.edituserdisable=true
  313. },
  314. noclicked1: function () {
  315. this.clearpopup()
  316. this.dialog2=false
  317. },
  318. yesclicked1: function () {
  319. this.$Socket.emit('adduser', {
  320. FirstName: this.newfname,
  321. LastName: this.newlname,
  322. Address: this.address,
  323. PhoneNumber: this.phonenumber,
  324. Username: this.newusername,
  325. Password: this.newpassword,
  326. PermissionLvl: this.convertbool(this.admin)
  327. }, ({authenticated}) => {
  328. if(authenticated==true)
  329. {
  330. this.dialog2=false
  331. this.dialog4=true
  332. this.finduser()
  333. }
  334. })
  335. },
  336. convertbool: function (data) {
  337. if(data==true)
  338. {
  339. return 1
  340. }
  341. else {
  342. return 0
  343. }
  344. },
  345. deactivate: function (user) {
  346. this.dialog5=true
  347. this.userid=user.UserID
  348. },
  349. yesclicked2: function () {
  350. this.$Socket.emit('deactivateuser', {
  351. UserID: this.userid
  352. }, ({authenticated}) => {
  353. if(authenticated==true)
  354. {
  355. this.dialog5=false
  356. this.dialog6=true
  357. this.finduser()
  358. }
  359. })
  360. },
  361. noclicked2: function () {
  362. this.dialog5=false
  363. },
  364. passformat: function (pass) {
  365. var password=""
  366. for (var x=0; x<pass.length; x++)
  367. {
  368. password= password + "u2022"
  369. }
  370. return password
  371. },
  372. visibilityfn: function () {
  373. if(this.visibility==false)
  374. {
  375. this.visibility=true
  376. this.visicon="visibility"
  377. }
  378. else
  379. {
  380. this.visibility=false
  381. this.visicon="visibility_off"
  382. }
  383. }
  384. }
  385. }
  386. </script>
  387.  
  388. <style>
  389. #mainuserbox {
  390. text-align: center;
  391. }
  392. .passcode {
  393. max-width: 120px;
  394. }
  395. #userheader {
  396. display: inline-block;
  397. margin: 10px;
  398. color: #26a69a;
  399. }
  400. #searchbar {
  401. display: inline-block;
  402. border-bottom: 2px solid #26A69A;
  403. padding-bottom: 15px;
  404. margin-bottom: 15px;
  405. }
  406. #userlist {
  407. display: inline-block;
  408. text-align: center;
  409. }
  410. .secondarycolor {
  411. color: #26a69a;
  412. }
  413. .marginbottom {
  414. margin-bottom: -10px;
  415. }
  416. .topspace {
  417. margin-top: 15px;
  418. }
  419. #usericon {
  420. vertical-align: top;
  421. }
  422. .margintop {
  423. margin-top: -15px;
  424. }
  425. #visbtn {
  426. margin-top: 40px;
  427. }
  428. .inputspace {
  429. margin: 5px;
  430. }
  431. #leftrow {
  432. margin-right: 5px;
  433. text-align: right;
  434. }
  435. #rightrow {
  436. text-align: left;
  437. margin-left: 5px;
  438. }
  439. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement