Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2018
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.18 KB | None | 0 0
  1.  
  2. ===========
  3. index.ts:
  4.  
  5. import Vue from 'vue'
  6. import Router from 'vue-router'
  7. import mainView from '@/components/mainView.vue'
  8.  
  9.  
  10. Vue.use(Router)
  11.  
  12. const router = new Router({
  13. routes: [
  14. {
  15. path: '/',
  16. name: 'mainView',
  17. component: mainView
  18. },
  19.  
  20. ]
  21. })
  22.  
  23.  
  24. export default router;
  25.  
  26.  
  27. ===========================
  28.  
  29. main.ts:
  30.  
  31.  
  32. import Vue from 'vue'
  33. import ElementUI from 'element-ui'
  34. import 'element-ui/lib/theme-chalk/index.css'
  35. import App from './App.vue'
  36. import router from './router/index'
  37. import locale from 'element-ui/lib/locale/lang/en'
  38.  
  39. Vue.config.productionTip = false;
  40. Vue.use(ElementUI, { locale });
  41.  
  42. / eslint-disable no-new /
  43. new Vue({
  44. el: '#app',
  45. router,
  46. template: '<App/>',
  47. components: { App }
  48. });
  49.  
  50.  
  51. =====
  52.  
  53. LoginComponent.vue:
  54.  
  55. <template lang="pug">
  56. .el-form-wrap
  57. el-form.demo-ruleForm(status-icon='' label-width='120px' )
  58. el-form-item(label='User')
  59. el-input(type='text' v-model="loginForm.user")
  60. el-form-item(label='Password', prop='pass')
  61. el-input(type='password', auto-complete='off' v-model="loginForm.pass")
  62. el-form-item(label='App')
  63. el-input(type='text' v-model="loginForm.app")
  64. el-form-item(label='Vox-user')
  65. el-input(type='text' v-model="loginForm.voxUser")
  66. el-form-item
  67. .el-form-item__btn-wrap
  68. el-button(type='primary', @click="auth") OK
  69. </template>
  70.  
  71. <script lang="ts">
  72. import Vue from "vue";
  73. import Component from 'vue-class-component'
  74. import * as VoxImplant from 'voximplant-websdk';
  75.  
  76. interface LoginForm {
  77. user: string,
  78. pass: string,
  79. app: string,
  80. voxUser: string
  81. }
  82.  
  83. @Component({
  84. props: {},
  85. components: {}
  86. })
  87. export default class LoginComponent extends Vue {
  88. vox: VoxImplant.Client = VoxImplant.getInstance();
  89. loginForm: LoginForm = {
  90. user: '',
  91. pass: '',
  92. app: '',
  93. voxUser: '',
  94. };
  95. mounted(){
  96. this.vox = VoxImplant.getInstance();
  97. this.vox.init({micRequired: true, serverIp: "lab-gw.voximplant.com"});
  98. this.vox.addEventListener(VoxImplant.Events.SDKReady, this.handleSDKReady);
  99. this.vox.addEventListener(VoxImplant.Events.AuthResult, this.auth2);
  100. }
  101. private handleSDKReady():void{
  102. this.vox.connect();
  103. }
  104. private auth2(e:VoxImplant.EventHandlers.AuthResult):void{
  105. if(e.result) {
  106. this.$emit('loggined', e.displayName);
  107. }else {
  108. e.
  109. }
  110. }
  111. private auth():void {
  112. const loginStr = "" + this.loginForm.user + "@" + this.loginForm.app + "."+ this.loginForm.voxUser + ".voximplant.com";
  113. this.vox.login(loginStr, this.loginForm.pass)
  114. }
  115. }
  116. </script>
  117.  
  118. <!-- Add "scoped" attribute to limit CSS to this component only -->
  119. <style scoped>
  120. .el-form-wrap {
  121. max-width: 600px;
  122. margin: 0 auto;
  123. }
  124. .el-form-item__btn-wrap {
  125. display: flex;
  126. justify-content: flex-end;
  127. }
  128. </style>
  129. <template lang="pug">
  130. .el-form-wrap
  131. el-form.demo-ruleForm(status-icon='' label-width='120px' )
  132. el-form-item(label='User')
  133. el-input(type='text' v-model="loginForm.user")
  134. el-form-item(label='Password', prop='pass')
  135. el-input(type='password', auto-complete='off' v-model="loginForm.pass")
  136. el-form-item(label='App')
  137. el-input(type='text' v-model="loginForm.app")
  138. el-form-item(label='Vox-user')
  139. el-input(type='text' v-model="loginForm.voxUser")
  140. el-form-item
  141. .el-form-item__btn-wrap
  142. el-button(type='primary', @click="auth") OK
  143. </template>
  144.  
  145. <script lang="ts">
  146. import Vue from "vue";
  147. import Component from 'vue-class-component'
  148. import * as VoxImplant from 'voximplant-websdk';
  149.  
  150. interface LoginForm {
  151. user: string,
  152. pass: string,
  153. app: string,
  154. voxUser: string
  155. }
  156.  
  157. @Component({
  158. props: {},
  159. components: {}
  160. })
  161. export default class LoginComponent extends Vue {
  162. vox: VoxImplant.Client = VoxImplant.getInstance();
  163. loginForm: LoginForm = {
  164. user: '',
  165. pass: '',
  166. app: '',
  167. voxUser: '',
  168. };
  169. mounted(){
  170. this.vox = VoxImplant.getInstance();
  171. this.vox.init({micRequired: true, serverIp: "lab-gw.voximplant.com"});
  172. this.vox.addEventListener(VoxImplant.Events.SDKReady, this.handleSDKReady);
  173. this.vox.addEventListener(VoxImplant.Events.AuthResult, this.auth2);
  174. }
  175. private handleSDKReady():void{
  176. this.vox.connect();
  177. }
  178. private auth2(e:VoxImplant.EventHandlers.AuthResult):void{
  179. if(e.result) {
  180. this.$emit('loggined', e.displayName);
  181. }else {
  182. e.
  183. }
  184. }
  185. private auth():void {
  186. const loginStr = "" + this.loginForm.user + "@" + this.loginForm.app + "."+ this.loginForm.voxUser + ".voximplant.com";
  187. this.vox.login(loginStr, this.loginForm.pass)
  188. }
  189. }
  190. </script>
  191.  
  192. <!-- Add "scoped" attribute to limit CSS to this component only -->
  193. <style scoped>
  194. .el-form-wrap {
  195. max-width: 600px;
  196. margin: 0 auto;
  197. }
  198. .el-form-item__btn-wrap {
  199. display: flex;
  200. justify-content: flex-end;
  201. }
  202. </style>
  203.  
  204. ==========================================
  205.  
  206. ARMComponent.vue:
  207.  
  208. <template lang="pug">
  209. .username-card
  210. el-card.box-card
  211. .clearfix(slot='header')
  212. el-row
  213. el-col(:span='12')
  214. span.grid-content
  215. el-col(:span='12')
  216. .grid-content
  217. el-radio-group(v-model='radio3' size="mini")
  218. el-radio-button(label='On')
  219. el-radio-button(label='Off')
  220. el-radio-button(label='DND')
  221. el-radio-button(label='InS')
  222. el-radio-button(label='AfS')
  223. el-radio-button(label='Rdy')
  224. el-radio-button(label='TiO')
  225. p.username-card__text {{userName}}
  226. el-row
  227. el-col(:span='12')
  228. .grid-content.grid-content__left
  229. .user-card(v-if="phoneActive")
  230. h3.user-card__title ФИО:
  231. p.user-card__text Adamson Mayer
  232. h3.user-card__title Компания:
  233. p.user-card__text Pepsi
  234. h3.user-card__title Почта:
  235. p.user-card__text Pepsi@mail.com
  236. h3.user-card__title Описание:
  237. p.user-card__text Pay Every Pence to Save Israel
  238.  
  239. el-col(:span='12')
  240. .grid-content
  241. .username-card__phone-no(v-if="!phoneActive")
  242. el-input(placeholder='Please input', v-model='input')
  243. .call-wrap
  244. el-button(type='primary' v-on:click="makeCall") Call
  245. .username-card__phone-yes(v-else)
  246. el-button(type='primary', v-on:click="hangupCall") Завершить
  247. el-button(type='primary') Номер
  248. el-button(type='primary') Перевод
  249.  
  250. </template>
  251.  
  252. <script lang="ts">
  253. import Vue from "vue";
  254. import Component from 'vue-class-component'
  255.  
  256. @Component({
  257. props: {
  258. userName: String
  259. },
  260. components: {}
  261. })
  262. export default class ARMComponent extends Vue {
  263. radio3:string = 'On';
  264. input: string = "";
  265. phoneActive: boolean = false;
  266.  
  267. makeCall() {
  268. var phoneNumber = this.input;
  269. if(phoneNumber) {
  270. this.phoneActive = true;
  271. }
  272. }
  273. hangupCall() {
  274. this.phoneActive = false;
  275. }
  276. set getStatus(n){
  277. // this.radio3 = n;
  278. // console.log('woo');
  279. }
  280. get getStatus(){
  281. const vocabulary = {
  282. On: "Online",
  283. Off: "Offline",
  284. DND: "DND",
  285. InS: "InService",
  286. AfS: "AfterService",
  287. Rdy: "Ready",
  288. TiO: "Timeout"
  289. };
  290. if(typeof vocabulary[this.radio3] !== 'undefined') return vocabulary[this.radio3];
  291. return this.radio3;
  292. }
  293.  
  294.  
  295. }
  296.  
  297. </script>
  298.  
  299. <!-- Add "scoped" attribute to limit CSS to this component only -->
  300. <style scoped>
  301. .username-card {
  302. text-align: left;
  303. }
  304.  
  305. .call-wrap {
  306. display: flex;
  307. justify-content: flex-end;
  308. margin-top: 10px;
  309.  
  310. }
  311. .grid-content__left {
  312. margin-right: 10px;
  313. }
  314. .user-card {
  315. background: #f3eff0;
  316. border-radius: 5px;
  317. max-width: 300px;
  318. margin: auto;
  319. padding: 10px;
  320. border: 5px solid #e9e6e7;
  321. }
  322. .user-card__title {
  323. margin: 2px 0;
  324. padding: 0;
  325. }
  326. .user-card__text {
  327. margin: 2px 0;
  328. padding: 0;
  329. }
  330. .grid-content {
  331. min-height: 1px;
  332. }
  333.  
  334. </style>
  335.  
  336.  
  337. ====================
  338. mainView.vue:
  339.  
  340.  
  341. <template lang="pug">
  342. .wrap
  343. LoginComponent(v-if="!isAutorized",@loggined="onLoggined")
  344. ARMComponent(v-if="isAutorized", :userName = "userName")
  345. </template>
  346.  
  347. <script lang="ts">
  348. import Vue from "vue";
  349. import Component from 'vue-class-component'
  350. import LoginComponent from '@/components/LoginComponent.vue'
  351. import ARMComponent from '@/components/ARMComponent.vue'
  352.  
  353. @Component({
  354. props: {
  355.  
  356. },
  357. components: {
  358. LoginComponent,
  359. ARMComponent
  360. }
  361. })
  362. export default class mainView extends Vue {
  363. isAutorized: boolean = false;
  364. userName: string;
  365. onLoggined(userName:string):void{
  366. if(userName){
  367. this.userName = userName;
  368. this.isAutorized = true;
  369. }
  370. }
  371. }
  372.  
  373. </script>
  374.  
  375. <!-- Add "scoped" attribute to limit CSS to this component only -->
  376. <style scoped>
  377.  
  378. </style>
  379.  
  380. ===
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement