Aliases.vue 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. <template>
  2. <div>
  3. <div class="flex flex-wrap flex-row items-center justify-between mb-8 md:px-2 lg:px-6">
  4. <div
  5. class="w-full md:w-1/2 lg:w-1/3 xl:w-1/6 md:-mx-2 lg:-mx-6 rounded overflow-hidden shadow-md bg-white mb-4 lg:mb-4 xl:mb-0"
  6. >
  7. <div class="p-4 flex items-center justify-between relative">
  8. <icon
  9. name="check-circle"
  10. class="inline-block w-16 h-16 text-indigo-50 stroke-current absolute top-0 right-0"
  11. />
  12. <div class="font-bold text-xl md:text-3xl text-indigo-800">
  13. {{ totalActive }}
  14. <p class="text-grey-300 text-sm tracking-wide uppercase">Active</p>
  15. </div>
  16. </div>
  17. </div>
  18. <div
  19. class="w-full md:w-1/2 lg:w-1/3 xl:w-1/6 md:-mx-2 lg:-mx-6 rounded overflow-hidden shadow-md bg-white mb-4 lg:mb-4 xl:mb-0"
  20. >
  21. <div class="p-4 flex items-center justify-between relative">
  22. <icon
  23. name="cross-circle"
  24. class="inline-block w-16 h-16 text-indigo-50 stroke-current absolute top-0 right-0"
  25. />
  26. <div class="font-bold text-xl md:text-3xl text-indigo-800">
  27. {{ totalInactive }}
  28. <p class="text-grey-300 text-sm tracking-wide uppercase">Inactive</p>
  29. </div>
  30. </div>
  31. </div>
  32. <div
  33. class="w-full md:w-1/2 lg:w-1/3 xl:w-1/6 md:-mx-2 lg:-mx-6 rounded overflow-hidden shadow-md bg-white mb-4 lg:mb-4 xl:mb-0"
  34. >
  35. <div class="p-4 flex items-center justify-between relative">
  36. <icon
  37. name="send"
  38. class="inline-block w-16 h-16 text-indigo-50 stroke-current absolute top-0 right-0"
  39. />
  40. <div class="font-bold text-xl md:text-3xl text-indigo-800">
  41. {{ totalForwarded }}
  42. <p class="text-grey-300 text-sm tracking-wide uppercase">Emails Forwarded</p>
  43. </div>
  44. </div>
  45. </div>
  46. <div
  47. class="w-full md:w-1/2 lg:w-1/3 xl:w-1/6 md:-mx-2 lg:-mx-6 rounded overflow-hidden shadow-md bg-white mb-4 lg:mb-0"
  48. >
  49. <div class="p-4 flex items-center justify-between relative">
  50. <icon
  51. name="blocked"
  52. class="inline-block w-16 h-16 text-indigo-50 stroke-current absolute top-0 right-0"
  53. />
  54. <div class="font-bold text-xl md:text-3xl text-indigo-800">
  55. {{ totalBlocked }}
  56. <p class="text-grey-300 text-sm tracking-wide uppercase">Emails Blocked</p>
  57. </div>
  58. </div>
  59. </div>
  60. <div
  61. class="w-full md:w-1/2 lg:w-1/3 xl:w-1/6 md:-mx-2 lg:-mx-6 rounded overflow-hidden shadow-md bg-white mb-4 md:mb-0"
  62. >
  63. <div class="p-4 flex items-center justify-between relative">
  64. <icon
  65. name="corner-up-left"
  66. class="inline-block w-16 h-16 text-indigo-50 stroke-current absolute top-0 right-0"
  67. />
  68. <div class="font-bold text-xl md:text-3xl text-indigo-800">
  69. {{ totalReplies }}
  70. <p class="text-grey-300 text-sm tracking-wide uppercase">Email Replies</p>
  71. </div>
  72. </div>
  73. </div>
  74. <div
  75. class="w-full md:w-1/2 lg:w-1/3 xl:w-1/6 md:-mx-2 lg:-mx-6 rounded overflow-hidden shadow-md bg-white"
  76. >
  77. <div class="p-4 flex items-center justify-between relative">
  78. <icon
  79. name="inbox"
  80. class="inline-block w-16 h-16 text-indigo-50 stroke-current absolute top-0 right-0"
  81. />
  82. <div class="font-bold text-xl md:text-3xl text-indigo-800">
  83. {{ bandwidthMb }}<span class="text-sm tracking-wide uppercase">MB</span>
  84. <p class="text-grey-300 text-sm tracking-wide uppercase">Bandwidth ({{ month }})</p>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="mb-6 flex flex-col md:flex-row justify-between md:items-center">
  90. <div class="relative">
  91. <input
  92. v-model="search"
  93. @keyup.esc="search = ''"
  94. tabindex="0"
  95. type="text"
  96. class="w-full md:w-64 appearance-none shadow bg-white text-grey-700 focus:outline-none rounded py-3 pl-3 pr-8"
  97. placeholder="Search Aliases"
  98. />
  99. <icon
  100. v-if="search"
  101. @click.native="search = ''"
  102. name="close-circle"
  103. class="absolute right-0 inset-y-0 w-5 h-full text-grey-300 fill-current mr-2 flex items-center cursor-pointer"
  104. />
  105. <icon
  106. v-else
  107. name="search"
  108. class="absolute right-0 inset-y-0 w-5 h-full text-grey-300 fill-current pointer-events-none mr-2 flex items-center"
  109. />
  110. </div>
  111. <div class="flex flex-wrap mt-4 md:mt-0">
  112. <div class="block relative mr-4">
  113. <select
  114. v-model="showAliases"
  115. class="block appearance-none w-full text-grey-700 bg-white p-3 pr-8 rounded shadow focus:ring"
  116. required
  117. >
  118. <option value="without">Hide Deleted</option>
  119. <option value="with">Show Deleted</option>
  120. <option value="only">Deleted Only</option>
  121. </select>
  122. <div
  123. class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700"
  124. >
  125. <svg
  126. class="fill-current h-4 w-4"
  127. xmlns="http://www.w3.org/2000/svg"
  128. viewBox="0 0 20 20"
  129. >
  130. <path
  131. d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"
  132. />
  133. </svg>
  134. </div>
  135. </div>
  136. <div>
  137. <button
  138. @click="generateAliasModalOpen = true"
  139. class="bg-cyan-400 hover:bg-cyan-300 text-cyan-900 font-bold py-3 px-4 rounded focus:outline-none ml-auto"
  140. >
  141. Create New Alias
  142. </button>
  143. </div>
  144. </div>
  145. </div>
  146. <vue-good-table
  147. v-if="initialAliases.length"
  148. @on-search="debounceToolips"
  149. @on-page-change="debounceToolips"
  150. :columns="columns"
  151. :rows="rows"
  152. :search-options="{
  153. enabled: true,
  154. skipDiacritics: true,
  155. externalQuery: search,
  156. }"
  157. :sort-options="{
  158. enabled: true,
  159. initialSortBy: { field: 'created_at', type: 'desc' },
  160. }"
  161. :pagination-options="{
  162. enabled: true,
  163. mode: 'pages',
  164. perPage: 25,
  165. perPageDropdown: [25, 50, 100],
  166. rowsPerPageLabel: 'Aliases per page',
  167. }"
  168. styleClass="vgt-table"
  169. >
  170. <div slot="emptystate" class="flex items-center justify-center h-24 text-lg text-grey-700">
  171. No aliases found for that search!
  172. </div>
  173. <template slot="table-row" slot-scope="props">
  174. <span v-if="props.column.field == 'created_at'" class="flex items-center">
  175. <span
  176. :class="`bg-${getAliasStatus(props.row).colour}-100`"
  177. class="tooltip outline-none h-4 w-4 rounded-full flex items-center justify-center mr-2"
  178. :data-tippy-content="getAliasStatus(props.row).status"
  179. tabindex="-1"
  180. >
  181. <span
  182. :class="`bg-${getAliasStatus(props.row).colour}-400`"
  183. class="h-2 w-2 rounded-full"
  184. ></span>
  185. </span>
  186. <span
  187. class="tooltip outline-none text-sm whitespace-nowrap"
  188. :data-tippy-content="rows[props.row.originalIndex].created_at | formatDate"
  189. >{{ props.row.created_at | timeAgo }}
  190. </span>
  191. </span>
  192. <span v-else-if="props.column.field == 'email'" class="block">
  193. <span
  194. class="text-grey-400 tooltip cursor-pointer outline-none"
  195. data-tippy-content="Click to copy"
  196. v-clipboard="() => getAliasEmail(rows[props.row.originalIndex])"
  197. v-clipboard:success="clipboardSuccess"
  198. v-clipboard:error="clipboardError"
  199. ><span class="font-semibold text-indigo-800">{{
  200. getAliasLocalPart(props.row) | truncate(60)
  201. }}</span
  202. ><span v-if="getAliasLocalPart(props.row).length <= 60">{{
  203. ('@' + props.row.domain) | truncate(60 - getAliasLocalPart(props.row).length)
  204. }}</span>
  205. </span>
  206. <div v-if="aliasIdToEdit === props.row.id" class="flex items-center">
  207. <input
  208. @keyup.enter="editAlias(rows[props.row.originalIndex])"
  209. @keyup.esc="aliasIdToEdit = aliasDescriptionToEdit = ''"
  210. v-model="aliasDescriptionToEdit"
  211. type="text"
  212. class="flex-grow text-sm appearance-none bg-grey-100 border text-grey-700 focus:outline-none rounded px-2 py-1"
  213. :class="aliasDescriptionToEdit.length > 100 ? 'border-red-500' : 'border-transparent'"
  214. placeholder="Add description"
  215. tabindex="0"
  216. autofocus
  217. />
  218. <icon
  219. name="close"
  220. class="inline-block w-6 h-6 text-red-300 fill-current cursor-pointer"
  221. @click.native="aliasIdToEdit = aliasDescriptionToEdit = ''"
  222. />
  223. <icon
  224. name="save"
  225. class="inline-block w-6 h-6 text-cyan-500 fill-current cursor-pointer"
  226. @click.native="editAlias(rows[props.row.originalIndex])"
  227. />
  228. </div>
  229. <div v-else-if="props.row.description" class="flex items-center">
  230. <span class="inline-block text-grey-400 text-sm py-1 border border-transparent">
  231. {{ props.row.description | truncate(60) }}
  232. </span>
  233. <icon
  234. name="edit"
  235. class="inline-block w-6 h-6 ml-2 text-grey-300 fill-current cursor-pointer"
  236. @click.native="
  237. ;(aliasIdToEdit = props.row.id), (aliasDescriptionToEdit = props.row.description)
  238. "
  239. />
  240. </div>
  241. <div v-else>
  242. <span
  243. class="inline-block text-grey-300 text-sm cursor-pointer py-1 border border-transparent"
  244. @click=";(aliasIdToEdit = props.row.id), (aliasDescriptionToEdit = '')"
  245. >Add description</span
  246. >
  247. </div>
  248. </span>
  249. <span
  250. v-else-if="props.column.field == 'recipients'"
  251. class="flex items-center justify-center"
  252. >
  253. <span
  254. v-if="props.row.recipients.length && props.row.id !== recipientsAliasToEdit.id"
  255. class="inline-block tooltip outline-none font-semibold text-indigo-800"
  256. :data-tippy-content="recipientsTooltip(props.row.recipients)"
  257. >
  258. {{ props.row.recipients.length }}
  259. </span>
  260. <span v-else-if="props.row.id === recipientsAliasToEdit.id">{{
  261. aliasRecipientsToEdit.length ? aliasRecipientsToEdit.length : '1'
  262. }}</span>
  263. <span
  264. v-else-if="has(props.row.aliasable, 'default_recipient.email')"
  265. class="py-1 px-2 text-xs bg-yellow-200 text-yellow-900 rounded-full tooltip outline-none"
  266. :data-tippy-content="props.row.aliasable.default_recipient.email"
  267. >{{
  268. props.row.aliasable_type === 'App\\Models\\Domain' ? 'domain' : 'username'
  269. }}'s</span
  270. >
  271. <span
  272. v-else
  273. class="py-1 px-2 text-xs bg-yellow-200 text-yellow-900 rounded-full tooltip outline-none"
  274. :data-tippy-content="defaultRecipientEmail"
  275. >default</span
  276. >
  277. <icon
  278. name="edit"
  279. class="ml-2 inline-block w-6 h-6 text-grey-300 fill-current cursor-pointer"
  280. @click.native="openAliasRecipientsModal(props.row)"
  281. />
  282. </span>
  283. <span
  284. v-else-if="props.column.field == 'emails_forwarded'"
  285. class="font-semibold text-indigo-800"
  286. >
  287. {{ props.row.emails_forwarded }}
  288. </span>
  289. <span
  290. v-else-if="props.column.field == 'emails_blocked'"
  291. class="font-semibold text-indigo-800"
  292. >
  293. {{ props.row.emails_blocked }}
  294. </span>
  295. <span
  296. v-else-if="props.column.field == 'emails_replied'"
  297. class="font-semibold text-indigo-800"
  298. >
  299. {{ props.row.emails_replied }} <span class="text-grey-300">/</span>
  300. {{ props.row.emails_sent }}
  301. </span>
  302. <span v-else-if="props.column.field === 'active'" class="flex items-center">
  303. <Toggle
  304. v-model="rows[props.row.originalIndex].active"
  305. @on="activateAlias(props.row.id)"
  306. @off="deactivateAlias(props.row.id)"
  307. />
  308. </span>
  309. <span v-else class="flex items-center justify-center outline-none" tabindex="-1">
  310. <more-options>
  311. <div role="none">
  312. <span
  313. @click="openSendFromModal(props.row)"
  314. class="group cursor-pointer flex items-center px-4 py-3 text-sm text-grey-700 hover:bg-grey-100 hover:text-grey-900"
  315. role="menuitem"
  316. >
  317. <icon name="send" class="block mr-3 w-5 h-5 text-grey-300 outline-none" />
  318. Send From
  319. </span>
  320. </div>
  321. <div v-if="props.row.deleted_at" role="none">
  322. <span
  323. @click="openRestoreModal(props.row.id)"
  324. class="group cursor-pointer flex items-center px-4 py-3 text-sm text-grey-700 hover:bg-grey-100 hover:text-grey-900"
  325. role="menuitem"
  326. >
  327. <icon
  328. name="undo"
  329. class="block mr-3 w-5 h-5 text-grey-300 fill-current outline-none"
  330. />
  331. Restore
  332. </span>
  333. </div>
  334. <div v-else role="none">
  335. <span
  336. @click="openDeleteModal(props.row.id)"
  337. class="group cursor-pointer flex items-center px-4 py-3 text-sm text-grey-700 hover:bg-grey-100 hover:text-grey-900"
  338. role="menuitem"
  339. >
  340. <icon
  341. name="trash"
  342. class="block mr-3 w-5 h-5 text-grey-300 fill-current outline-none"
  343. />
  344. Delete
  345. </span>
  346. </div>
  347. </more-options>
  348. </span>
  349. </template>
  350. </vue-good-table>
  351. <div v-else class="bg-white rounded shadow overflow-x-auto">
  352. <div class="p-8 text-center text-lg text-grey-700">
  353. <h1 class="mb-6 text-2xl text-indigo-800 font-semibold">
  354. It doesn't look like you have any aliases yet!
  355. </h1>
  356. <div class="mx-auto mb-6 w-24 border-b-2 border-grey-200"></div>
  357. <p class="mb-4">There are two ways to create new aliases.</p>
  358. <h3 class="mb-4 text-xl text-indigo-800 font-semibold">
  359. Option 1: Create aliases on the fly
  360. </h3>
  361. <p class="mb-4">
  362. To create aliases on the fly all you have to do is make up any new alias and give that out
  363. instead of your real email address.
  364. </p>
  365. <p class="mb-4">
  366. Let's say you're signing up to <b>example.com</b> you could enter
  367. <b>example@{{ subdomain }}</b> as your email address.
  368. </p>
  369. <p class="mb-4">
  370. The alias will show up here automatically as soon as it has forwarded its first email.
  371. </p>
  372. <p class="mb-4">
  373. If you start receiving spam to the alias you can simply deactivate it or delete it all
  374. together!
  375. </p>
  376. <p class="mb-4">
  377. Try it out now by sending an email to <b>first@{{ subdomain }}</b> and then refresh this
  378. page.
  379. </p>
  380. <h3 class="mb-4 text-xl text-indigo-800 font-semibold">
  381. Option 2: Generate a unique random alias
  382. </h3>
  383. <p class="mb-4">
  384. You can click the button above to generate a random alias that will look something like
  385. this:
  386. </p>
  387. <p class="mb-4">
  388. <b>86064c92-da41-443e-a2bf-5a7b0247842f@{{ domain }}</b>
  389. </p>
  390. <p>
  391. Useful if you do not wish to include your username in the email as a potential link
  392. between aliases.
  393. </p>
  394. </div>
  395. </div>
  396. <Modal :open="generateAliasModalOpen" @close="generateAliasModalOpen = false">
  397. <div class="max-w-lg w-full bg-white rounded-lg shadow-2xl p-6">
  398. <h2
  399. class="font-semibold text-grey-900 text-2xl leading-tight border-b-2 border-grey-100 pb-4"
  400. >
  401. Create new alias
  402. </h2>
  403. <p class="mt-4 text-grey-700">
  404. Other aliases e.g. alias@{{ subdomain }} can also be created automatically when they
  405. receive their first email.
  406. </p>
  407. <label for="alias_domain" class="block text-grey-700 text-sm my-2"> Alias Domain: </label>
  408. <div class="block relative w-full mb-4">
  409. <select
  410. v-model="generateAliasDomain"
  411. id="alias_domain"
  412. class="block appearance-none w-full text-grey-700 bg-grey-100 p-3 pr-8 rounded shadow focus:ring"
  413. required
  414. >
  415. <option v-for="domainOption in domainOptions" :key="domainOption" :value="domainOption">
  416. {{ domainOption }}
  417. </option>
  418. </select>
  419. <div
  420. class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700"
  421. >
  422. <svg
  423. class="fill-current h-4 w-4"
  424. xmlns="http://www.w3.org/2000/svg"
  425. viewBox="0 0 20 20"
  426. >
  427. <path
  428. d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"
  429. />
  430. </svg>
  431. </div>
  432. </div>
  433. <label for="alias_format" class="block text-grey-700 text-sm mt-4 mb-2">
  434. Alias Format:
  435. </label>
  436. <div class="block relative w-full mb-4">
  437. <select
  438. v-model="generateAliasFormat"
  439. id="alias_format"
  440. class="block appearance-none w-full text-grey-700 bg-grey-100 p-3 pr-8 rounded shadow focus:ring"
  441. required
  442. >
  443. <option
  444. v-for="formatOption in aliasFormatOptions"
  445. :key="formatOption.value"
  446. :value="formatOption.value"
  447. >
  448. {{ formatOption.label }}
  449. </option>
  450. </select>
  451. <div
  452. class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700"
  453. >
  454. <svg
  455. class="fill-current h-4 w-4"
  456. xmlns="http://www.w3.org/2000/svg"
  457. viewBox="0 0 20 20"
  458. >
  459. <path
  460. d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"
  461. />
  462. </svg>
  463. </div>
  464. </div>
  465. <div v-if="generateAliasFormat === 'custom'">
  466. <label for="alias_local_part" class="block text-grey-700 text-sm my-2">
  467. Alias Local Part:
  468. </label>
  469. <p v-show="errors.generateAliasLocalPart" class="mb-3 text-red-500 text-sm">
  470. {{ errors.generateAliasLocalPart }}
  471. </p>
  472. <input
  473. v-model="generateAliasLocalPart"
  474. id="alias_local_part"
  475. type="text"
  476. class="w-full appearance-none bg-grey-100 border border-transparent text-grey-700 focus:outline-none rounded p-3"
  477. :class="errors.generateAliasLocalPart ? 'border-red-500' : ''"
  478. placeholder="Enter local part..."
  479. autofocus
  480. />
  481. </div>
  482. <label for="alias_description" class="block text-grey-700 text-sm my-2">
  483. Description:
  484. </label>
  485. <p v-show="errors.generateAliasDescription" class="mb-3 text-red-500 text-sm">
  486. {{ errors.generateAliasDescription }}
  487. </p>
  488. <input
  489. v-model="generateAliasDescription"
  490. id="alias_description"
  491. type="text"
  492. class="w-full appearance-none bg-grey-100 border border-transparent text-grey-700 focus:outline-none rounded p-3"
  493. :class="errors.generateAliasDescription ? 'border-red-500' : ''"
  494. placeholder="Enter description (optional)..."
  495. autofocus
  496. />
  497. <label for="alias_recipient_ids" class="block text-grey-700 text-sm my-2">
  498. Recipients:
  499. </label>
  500. <p v-show="errors.generateAliasRecipientIds" class="mb-3 text-red-500 text-sm">
  501. {{ errors.generateAliasRecipientIds }}
  502. </p>
  503. <multiselect
  504. id="alias_recipient_ids"
  505. v-model="generateAliasRecipientIds"
  506. :options="recipientOptions"
  507. :multiple="true"
  508. :close-on-select="true"
  509. :clear-on-select="false"
  510. :searchable="true"
  511. :max="10"
  512. placeholder="Select recipients (optional)..."
  513. label="email"
  514. track-by="email"
  515. :preselect-first="false"
  516. :show-labels="false"
  517. >
  518. </multiselect>
  519. <div class="mt-6">
  520. <button
  521. @click="generateNewAlias"
  522. class="bg-cyan-400 hover:bg-cyan-300 text-cyan-900 font-bold py-3 px-4 rounded focus:outline-none"
  523. :class="generateAliasLoading ? 'cursor-not-allowed' : ''"
  524. :disabled="generateAliasLoading"
  525. >
  526. Create Alias
  527. <loader v-if="generateAliasLoading" />
  528. </button>
  529. <button
  530. @click="generateAliasModalOpen = false"
  531. class="ml-4 px-4 py-3 text-grey-800 font-semibold bg-white hover:bg-grey-50 border border-grey-100 rounded focus:outline-none"
  532. >
  533. Cancel
  534. </button>
  535. </div>
  536. </div>
  537. </Modal>
  538. <Modal :open="editAliasRecipientsModalOpen" @close="closeAliasRecipientsModal">
  539. <div class="max-w-lg w-full bg-white rounded-lg shadow-2xl px-6 py-6">
  540. <h2
  541. class="font-semibold text-grey-900 text-2xl leading-tight border-b-2 border-grey-100 pb-4"
  542. >
  543. Update Alias Recipients
  544. </h2>
  545. <p class="my-4 text-grey-700">
  546. Select the recipients for this alias. You can choose multiple recipients. Leave it empty
  547. if you would like to use the default recipient.
  548. </p>
  549. <multiselect
  550. v-model="aliasRecipientsToEdit"
  551. :options="recipientOptions"
  552. :multiple="true"
  553. :close-on-select="true"
  554. :clear-on-select="false"
  555. :searchable="true"
  556. :max="10"
  557. placeholder="Select recipients"
  558. label="email"
  559. track-by="email"
  560. :preselect-first="false"
  561. :show-labels="false"
  562. >
  563. </multiselect>
  564. <div class="mt-6">
  565. <button
  566. type="button"
  567. @click="editAliasRecipients()"
  568. class="px-4 py-3 text-cyan-900 font-semibold bg-cyan-400 hover:bg-cyan-300 border border-transparent rounded focus:outline-none"
  569. :class="editAliasRecipientsLoading ? 'cursor-not-allowed' : ''"
  570. :disabled="editAliasRecipientsLoading"
  571. >
  572. Update Recipients
  573. <loader v-if="editAliasRecipientsLoading" />
  574. </button>
  575. <button
  576. @click="closeAliasRecipientsModal()"
  577. class="ml-4 px-4 py-3 text-grey-800 font-semibold bg-white hover:bg-grey-50 border border-grey-100 rounded focus:outline-none"
  578. >
  579. Cancel
  580. </button>
  581. </div>
  582. </div>
  583. </Modal>
  584. <Modal :open="restoreAliasModalOpen" @close="closeRestoreModal">
  585. <div class="max-w-lg w-full bg-white rounded-lg shadow-2xl px-6 py-6">
  586. <h2
  587. class="font-semibold text-grey-900 text-2xl leading-tight border-b-2 border-grey-100 pb-4"
  588. >
  589. Restore alias
  590. </h2>
  591. <p class="mt-4 text-grey-700">
  592. Are you sure you want to restore this alias? Once restored, this alias will
  593. <b>be able to receive emails again</b>.
  594. </p>
  595. <div class="mt-6">
  596. <button
  597. type="button"
  598. @click="restoreAlias(aliasIdToRestore)"
  599. class="px-4 py-3 text-cyan-900 font-semibold bg-cyan-400 hover:bg-cyan-300 border border-transparent rounded focus:outline-none"
  600. :class="restoreAliasLoading ? 'cursor-not-allowed' : ''"
  601. :disabled="restoreAliasLoading"
  602. >
  603. Restore alias
  604. <loader v-if="restoreAliasLoading" />
  605. </button>
  606. <button
  607. @click="closeRestoreModal"
  608. class="ml-4 px-4 py-3 text-grey-800 font-semibold bg-white hover:bg-grey-50 border border-grey-100 rounded focus:outline-none"
  609. >
  610. Cancel
  611. </button>
  612. </div>
  613. </div>
  614. </Modal>
  615. <Modal :open="deleteAliasModalOpen" @close="closeDeleteModal">
  616. <div class="max-w-lg w-full bg-white rounded-lg shadow-2xl px-6 py-6">
  617. <h2
  618. class="font-semibold text-grey-900 text-2xl leading-tight border-b-2 border-grey-100 pb-4"
  619. >
  620. Delete alias
  621. </h2>
  622. <p class="mt-4 text-grey-700">
  623. Are you sure you want to delete this alias? <b>You can restore this alias</b> if you later
  624. change your mind. Once deleted, this alias will <b>reject any emails sent to it</b>.
  625. </p>
  626. <div class="mt-6">
  627. <button
  628. type="button"
  629. @click="deleteAlias(aliasIdToDelete)"
  630. class="px-4 py-3 text-white font-semibold bg-red-500 hover:bg-red-600 border border-transparent rounded focus:outline-none"
  631. :class="deleteAliasLoading ? 'cursor-not-allowed' : ''"
  632. :disabled="deleteAliasLoading"
  633. >
  634. Delete alias
  635. <loader v-if="deleteAliasLoading" />
  636. </button>
  637. <button
  638. @click="closeDeleteModal"
  639. class="ml-4 px-4 py-3 text-grey-800 font-semibold bg-white hover:bg-grey-50 border border-grey-100 rounded focus:outline-none"
  640. >
  641. Cancel
  642. </button>
  643. </div>
  644. </div>
  645. </Modal>
  646. <Modal :open="sendFromAliasModalOpen" @close="closeSendFromModal">
  647. <div class="max-w-lg w-full bg-white rounded-lg shadow-2xl px-6 py-6">
  648. <h2
  649. class="font-semibold text-grey-900 text-2xl leading-tight border-b-2 border-grey-100 pb-4"
  650. >
  651. Send from alias
  652. </h2>
  653. <p class="mt-4 text-grey-700">
  654. Use this to automatically create the correct address to send an email to in order to send
  655. an <b>email from this alias</b>.
  656. </p>
  657. <label for="send_from_alias" class="block text-grey-700 text-sm my-2"> Alias: </label>
  658. <input
  659. v-model="aliasToSendFrom.email"
  660. id="send_from_alias"
  661. type="text"
  662. class="w-full appearance-none bg-grey-100 border border-transparent text-grey-700 focus:outline-none rounded p-3"
  663. disabled
  664. />
  665. <label for="send_from_alias_destination" class="block text-grey-700 text-sm my-2">
  666. Email destination:
  667. </label>
  668. <p v-show="errors.sendFromAliasDestination" class="mb-3 text-red-500 text-sm">
  669. {{ errors.sendFromAliasDestination }}
  670. </p>
  671. <input
  672. v-model="sendFromAliasDestination"
  673. id="send_from_alias_destination"
  674. type="text"
  675. class="w-full appearance-none bg-grey-100 border border-transparent text-grey-700 focus:outline-none rounded p-3"
  676. :class="errors.sendFromAliasDestination ? 'border-red-500' : ''"
  677. placeholder="Enter email..."
  678. autofocus
  679. />
  680. <div v-if="sendFromAliasEmailToSendTo">
  681. <p for="alias_domain" class="block text-grey-700 text-sm my-2">
  682. Send your message to this email:
  683. </p>
  684. <div
  685. v-clipboard="() => sendFromAliasEmailToSendTo"
  686. v-clipboard:success="setSendFromAliasCopied"
  687. class="flex items-center justify-between cursor-pointer text-xs border-t-4 rounded-sm text-green-800 border-green-600 bg-green-100 p-2 mb-3"
  688. role="alert"
  689. >
  690. <span>
  691. {{ sendFromAliasEmailToSendTo }}
  692. </span>
  693. <svg
  694. v-if="sendFromAliasCopied"
  695. viewBox="0 0 24 24"
  696. width="20"
  697. height="20"
  698. stroke="currentColor"
  699. stroke-width="2"
  700. fill="none"
  701. stroke-linecap="round"
  702. stroke-linejoin="round"
  703. >
  704. <polyline points="9 11 12 14 22 4"></polyline>
  705. <path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"></path>
  706. </svg>
  707. <svg
  708. v-else
  709. viewBox="0 0 24 24"
  710. width="20"
  711. height="20"
  712. stroke="currentColor"
  713. stroke-width="2"
  714. fill="none"
  715. stroke-linecap="round"
  716. stroke-linejoin="round"
  717. >
  718. <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
  719. <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
  720. </svg>
  721. </div>
  722. </div>
  723. <div class="mt-6">
  724. <button
  725. type="button"
  726. @click="displaySendFromAddress(aliasToSendFrom)"
  727. class="px-4 py-3 text-cyan-900 font-semibold bg-cyan-400 hover:bg-cyan-300 border border-transparent rounded focus:outline-none"
  728. :class="sendFromAliasLoading ? 'cursor-not-allowed' : ''"
  729. :disabled="sendFromAliasLoading"
  730. >
  731. Show address
  732. <loader v-if="sendFromAliasLoading" />
  733. </button>
  734. <button
  735. @click="closeSendFromModal"
  736. class="ml-4 px-4 py-3 text-grey-800 font-semibold bg-white hover:bg-grey-50 border border-grey-100 rounded focus:outline-none"
  737. >
  738. Cancel
  739. </button>
  740. </div>
  741. </div>
  742. </Modal>
  743. </div>
  744. </template>
  745. <script>
  746. import Modal from './../components/Modal.vue'
  747. import Toggle from './../components/Toggle.vue'
  748. import MoreOptions from './../components/MoreOptions.vue'
  749. import { roundArrow } from 'tippy.js'
  750. import 'tippy.js/dist/svg-arrow.css'
  751. import 'tippy.js/dist/tippy.css'
  752. import tippy from 'tippy.js'
  753. import Multiselect from 'vue-multiselect'
  754. export default {
  755. props: {
  756. defaultRecipientEmail: {
  757. type: Object,
  758. required: true,
  759. },
  760. initialAliases: {
  761. type: Array,
  762. required: true,
  763. },
  764. recipientOptions: {
  765. type: Array,
  766. required: true,
  767. },
  768. totalForwarded: {
  769. type: Number,
  770. required: true,
  771. },
  772. totalBlocked: {
  773. type: Number,
  774. required: true,
  775. },
  776. totalReplies: {
  777. type: Number,
  778. required: true,
  779. },
  780. domain: {
  781. type: String,
  782. required: true,
  783. },
  784. subdomain: {
  785. type: String,
  786. required: true,
  787. },
  788. bandwidthMb: {
  789. type: Number,
  790. required: true,
  791. },
  792. month: {
  793. type: String,
  794. required: true,
  795. },
  796. domainOptions: {
  797. type: Array,
  798. required: true,
  799. },
  800. defaultAliasDomain: {
  801. type: String,
  802. required: true,
  803. },
  804. defaultAliasFormat: {
  805. type: String,
  806. required: true,
  807. },
  808. },
  809. components: {
  810. Modal,
  811. Toggle,
  812. Multiselect,
  813. MoreOptions,
  814. },
  815. data() {
  816. return {
  817. search: '',
  818. showAliases: 'without',
  819. aliasIdToEdit: '',
  820. aliasDescriptionToEdit: '',
  821. aliasIdToDelete: '',
  822. aliasToSendFrom: {},
  823. sendFromAliasDestination: '',
  824. sendFromAliasEmailToSendTo: '',
  825. sendFromAliasCopied: false,
  826. aliasIdToRestore: '',
  827. deleteAliasLoading: false,
  828. deleteAliasModalOpen: false,
  829. sendFromAliasLoading: false,
  830. sendFromAliasModalOpen: false,
  831. restoreAliasLoading: false,
  832. restoreAliasModalOpen: false,
  833. editAliasRecipientsLoading: false,
  834. editAliasRecipientsModalOpen: false,
  835. generateAliasModalOpen: false,
  836. generateAliasLoading: false,
  837. generateAliasDomain: this.defaultAliasDomain ? this.defaultAliasDomain : this.domain,
  838. generateAliasLocalPart: '',
  839. generateAliasDescription: '',
  840. generateAliasRecipientIds: [],
  841. generateAliasFormat: this.defaultAliasFormat ? this.defaultAliasFormat : 'random_characters',
  842. aliasFormatOptions: [
  843. {
  844. value: 'random_characters',
  845. label: 'Random Characters',
  846. },
  847. {
  848. value: 'uuid',
  849. label: 'UUID',
  850. },
  851. {
  852. value: 'random_words',
  853. label: 'Random Words',
  854. },
  855. {
  856. value: 'custom',
  857. label: 'Custom',
  858. },
  859. ],
  860. recipientsAliasToEdit: {},
  861. aliasRecipientsToEdit: [],
  862. columns: [
  863. {
  864. label: 'Created',
  865. field: 'created_at',
  866. globalSearchDisabled: true,
  867. },
  868. {
  869. label: 'Alias',
  870. field: 'email',
  871. },
  872. {
  873. label: 'Recipients',
  874. field: 'recipients',
  875. tdClass: 'text-center',
  876. sortable: true,
  877. sortFn: this.sortRecipients,
  878. globalSearchDisabled: true,
  879. },
  880. {
  881. label: 'Description',
  882. field: 'description',
  883. sortable: false,
  884. hidden: true,
  885. },
  886. {
  887. label: 'Forwarded',
  888. field: 'emails_forwarded',
  889. type: 'number',
  890. tdClass: 'text-center',
  891. globalSearchDisabled: true,
  892. },
  893. {
  894. label: 'Blocked',
  895. field: 'emails_blocked',
  896. type: 'number',
  897. tdClass: 'text-center',
  898. globalSearchDisabled: true,
  899. },
  900. {
  901. label: 'Replies/Sent',
  902. field: 'emails_replied',
  903. type: 'number',
  904. tdClass: 'text-center',
  905. globalSearchDisabled: true,
  906. },
  907. {
  908. label: 'Active',
  909. field: 'active',
  910. type: 'boolean',
  911. globalSearchDisabled: true,
  912. },
  913. {
  914. label: '',
  915. field: 'actions',
  916. sortable: false,
  917. globalSearchDisabled: true,
  918. },
  919. ],
  920. rows: this.initialAliases,
  921. tippyInstance: null,
  922. errors: {},
  923. }
  924. },
  925. watch: {
  926. showAliases() {
  927. this.updateAliases()
  928. },
  929. },
  930. computed: {
  931. activeUuidAliases() {
  932. return _.filter(this.rows, alias => alias.id === alias.local_part && alias.active)
  933. },
  934. totalActive() {
  935. return _.filter(this.rows, 'active').length
  936. },
  937. totalInactive() {
  938. return _.reject(this.rows, 'active').length
  939. },
  940. },
  941. methods: {
  942. addTooltips() {
  943. if (this.tippyInstance) {
  944. _.each(this.tippyInstance, instance => instance.destroy())
  945. }
  946. this.tippyInstance = tippy('.tooltip', {
  947. arrow: roundArrow,
  948. allowHTML: true,
  949. })
  950. },
  951. debounceToolips: _.debounce(function () {
  952. this.addTooltips()
  953. }, 50),
  954. recipientsTooltip(recipients) {
  955. return _.reduce(recipients, (list, recipient) => list + `${recipient.email}<br>`, '')
  956. },
  957. openDeleteModal(id) {
  958. this.deleteAliasModalOpen = true
  959. this.aliasIdToDelete = id
  960. },
  961. closeDeleteModal() {
  962. this.deleteAliasModalOpen = false
  963. this.aliasIdToDelete = ''
  964. },
  965. openSendFromModal(alias) {
  966. this.sendFromAliasDestination = ''
  967. this.sendFromAliasEmailToSendTo = ''
  968. this.sendFromAliasCopied = false
  969. this.sendFromAliasModalOpen = true
  970. this.aliasToSendFrom = alias
  971. },
  972. closeSendFromModal() {
  973. this.sendFromAliasModalOpen = false
  974. this.aliasToSendFrom = {}
  975. },
  976. openRestoreModal(id) {
  977. this.restoreAliasModalOpen = true
  978. this.aliasIdToRestore = id
  979. },
  980. closeRestoreModal() {
  981. this.restoreAliasModalOpen = false
  982. this.aliasIdToRestore = ''
  983. },
  984. updateAliases() {
  985. axios
  986. .get(`/api/v1/aliases?deleted=${this.showAliases}`, {
  987. headers: { 'Content-Type': 'application/json' },
  988. })
  989. .then(response => {
  990. this.rows = response.data.data
  991. })
  992. .catch(error => {
  993. this.error()
  994. })
  995. },
  996. deleteAlias(id) {
  997. this.deleteAliasLoading = true
  998. axios
  999. .delete(`/api/v1/aliases/${id}`)
  1000. .then(response => {
  1001. this.rows = _.reject(this.rows, alias => alias.id === id)
  1002. this.deleteAliasModalOpen = false
  1003. this.deleteAliasLoading = false
  1004. })
  1005. .catch(error => {
  1006. this.error()
  1007. this.deleteAliasModalOpen = false
  1008. this.deleteAliasLoading = false
  1009. })
  1010. },
  1011. restoreAlias(id) {
  1012. this.restoreAliasLoading = true
  1013. axios
  1014. .patch(`/api/v1/aliases/${id}/restore`, {
  1015. headers: { 'Content-Type': 'application/json' },
  1016. })
  1017. .then(response => {
  1018. this.updateAliases()
  1019. this.restoreAliasModalOpen = false
  1020. this.restoreAliasLoading = false
  1021. this.success('Alias restored successfully')
  1022. })
  1023. .catch(error => {
  1024. this.error()
  1025. this.restoreAliasModalOpen = false
  1026. this.restoreAliasLoading = false
  1027. })
  1028. },
  1029. openAliasRecipientsModal(alias) {
  1030. this.editAliasRecipientsModalOpen = true
  1031. this.recipientsAliasToEdit = alias
  1032. this.aliasRecipientsToEdit = alias.recipients
  1033. },
  1034. closeAliasRecipientsModal() {
  1035. this.editAliasRecipientsModalOpen = false
  1036. this.recipientsAliasToEdit = {}
  1037. this.aliasRecipientsToEdit = []
  1038. },
  1039. editAliasRecipients() {
  1040. this.editAliasRecipientsLoading = true
  1041. axios
  1042. .post(
  1043. '/api/v1/alias-recipients',
  1044. JSON.stringify({
  1045. alias_id: this.recipientsAliasToEdit.id,
  1046. recipient_ids: _.map(this.aliasRecipientsToEdit, recipient => recipient.id),
  1047. }),
  1048. {
  1049. headers: { 'Content-Type': 'application/json' },
  1050. }
  1051. )
  1052. .then(response => {
  1053. let alias = _.find(this.rows, ['id', this.recipientsAliasToEdit.id])
  1054. alias.recipients = this.aliasRecipientsToEdit
  1055. this.editAliasRecipientsModalOpen = false
  1056. this.editAliasRecipientsLoading = false
  1057. this.recipientsAliasToEdit = {}
  1058. this.aliasRecipientsToEdit = []
  1059. this.success('Alias recipients updated')
  1060. })
  1061. .catch(error => {
  1062. this.editAliasRecipientsModalOpen = false
  1063. this.editAliasRecipientsLoading = false
  1064. this.recipientsAliasToEdit = {}
  1065. this.aliasRecipientsToEdit = []
  1066. this.error()
  1067. })
  1068. },
  1069. generateNewAlias() {
  1070. this.errors = {}
  1071. // Validate alias local part
  1072. if (
  1073. this.generateAliasFormat === 'custom' &&
  1074. !this.validLocalPart(this.generateAliasLocalPart)
  1075. ) {
  1076. return (this.errors.generateAliasLocalPart = 'Valid local part required')
  1077. }
  1078. if (this.generateAliasDescription.length > 100) {
  1079. return (this.errors.generateAliasDescription = 'Description cannot exceed 100 characters')
  1080. }
  1081. this.generateAliasLoading = true
  1082. axios
  1083. .post(
  1084. '/api/v1/aliases',
  1085. JSON.stringify({
  1086. domain: this.generateAliasDomain,
  1087. local_part: this.generateAliasLocalPart,
  1088. description: this.generateAliasDescription,
  1089. format: this.generateAliasFormat,
  1090. recipient_ids: _.map(this.generateAliasRecipientIds, recipient => recipient.id),
  1091. }),
  1092. {
  1093. headers: { 'Content-Type': 'application/json' },
  1094. }
  1095. )
  1096. .then(({ data }) => {
  1097. this.generateAliasLoading = false
  1098. this.generateAliasLocalPart = ''
  1099. this.generateAliasDescription = ''
  1100. this.generateAliasRecipientIds = []
  1101. this.rows.push(data.data)
  1102. this.generateAliasModalOpen = false
  1103. this.success('New alias generated successfully')
  1104. })
  1105. .catch(error => {
  1106. this.generateAliasLoading = false
  1107. if (error.response.status === 429) {
  1108. this.error('You have reached your hourly limit for creating new aliases')
  1109. } else {
  1110. this.error()
  1111. }
  1112. })
  1113. },
  1114. editAlias(alias) {
  1115. if (this.aliasDescriptionToEdit.length > 100) {
  1116. return this.error('Description cannot be more than 100 characters')
  1117. }
  1118. axios
  1119. .patch(
  1120. `/api/v1/aliases/${alias.id}`,
  1121. JSON.stringify({
  1122. description: this.aliasDescriptionToEdit,
  1123. }),
  1124. {
  1125. headers: { 'Content-Type': 'application/json' },
  1126. }
  1127. )
  1128. .then(response => {
  1129. alias.description = this.aliasDescriptionToEdit
  1130. this.aliasIdToEdit = ''
  1131. this.aliasDescriptionToEdit = ''
  1132. this.success('Alias description updated')
  1133. })
  1134. .catch(error => {
  1135. this.aliasIdToEdit = ''
  1136. this.aliasDescriptionToEdit = ''
  1137. this.error()
  1138. })
  1139. },
  1140. activateAlias(id) {
  1141. axios
  1142. .post(
  1143. `/api/v1/active-aliases`,
  1144. JSON.stringify({
  1145. id: id,
  1146. }),
  1147. {
  1148. headers: { 'Content-Type': 'application/json' },
  1149. }
  1150. )
  1151. .then(response => {
  1152. //
  1153. })
  1154. .catch(error => {
  1155. this.error()
  1156. })
  1157. },
  1158. deactivateAlias(id) {
  1159. axios
  1160. .delete(`/api/v1/active-aliases/${id}`)
  1161. .then(response => {
  1162. //
  1163. })
  1164. .catch(error => {
  1165. this.error()
  1166. })
  1167. },
  1168. displaySendFromAddress(alias) {
  1169. this.errors = {}
  1170. if (!this.validEmail(this.sendFromAliasDestination)) {
  1171. this.errors.sendFromAliasDestination = 'Valid Email required'
  1172. return
  1173. }
  1174. this.sendFromAliasEmailToSendTo = `${
  1175. alias.local_part
  1176. }+${this.sendFromAliasDestination.replace('@', '=')}@${alias.domain}`
  1177. },
  1178. setSendFromAliasCopied() {
  1179. this.sendFromAliasCopied = true
  1180. },
  1181. getAliasEmail(alias) {
  1182. return alias.extension
  1183. ? `${alias.local_part}+${alias.extension}@${alias.domain}`
  1184. : alias.email
  1185. },
  1186. getAliasLocalPart(alias) {
  1187. return alias.extension ? `${alias.local_part}+${alias.extension}` : alias.local_part
  1188. },
  1189. getAliasStatus(alias) {
  1190. if (alias.deleted_at) {
  1191. return {
  1192. colour: 'red',
  1193. status: 'Deleted',
  1194. }
  1195. } else {
  1196. return {
  1197. colour: alias.active ? 'green' : 'grey',
  1198. status: alias.active ? 'Active' : 'Inactive',
  1199. }
  1200. }
  1201. },
  1202. sortRecipients(x, y) {
  1203. return x.length < y.length ? -1 : x.length > y.length ? 1 : 0
  1204. },
  1205. has(object, path) {
  1206. return _.has(object, path)
  1207. },
  1208. validLocalPart(part) {
  1209. let re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))$/
  1210. return re.test(part)
  1211. },
  1212. validEmail(email) {
  1213. let re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
  1214. return re.test(email)
  1215. },
  1216. clipboardSuccess() {
  1217. this.success('Copied to clipboard')
  1218. },
  1219. clipboardError() {
  1220. this.error('Could not copy to clipboard')
  1221. },
  1222. success(text = '') {
  1223. this.$notify({
  1224. title: 'Success',
  1225. text: text,
  1226. type: 'success',
  1227. })
  1228. },
  1229. error(text = 'An error has occurred, please try again later') {
  1230. this.$notify({
  1231. title: 'Error',
  1232. text: text,
  1233. type: 'error',
  1234. })
  1235. },
  1236. },
  1237. }
  1238. </script>
  1239. <style src="vue-multiselect/dist/vue-multiselect.min.css"></style>