CreateGroup.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <div class="create-group-component col-12 col-md-9" style="height: 100vh - 51px !important;overflow:hidden">
  3. <div v-if="!hide" class="row h-100 bg-lighter">
  4. <div class="col-12 col-md-8 border-left">
  5. <div class="bg-dark p-5 mx-n3">
  6. <p class="h1 font-weight-bold text-light mb-2">Create Group</p>
  7. <p class="text-lighter mb-0">Create a new federated Group that is compatible with other Pixelfed and Lemmy servers</p>
  8. </div>
  9. <div class="px-2 mb-5">
  10. <div class="mt-4">
  11. <text-input
  12. label="Group Name"
  13. :value="name"
  14. :hasLimit="true"
  15. :maxLimit="limit.name.max"
  16. placeholder="Add your group name"
  17. helpText="Alphanumeric characters only, you can change this later."
  18. :largeInput="true"
  19. @update="handleUpdate('name', $event)"
  20. />
  21. <hr>
  22. <select-input
  23. label="Group Type"
  24. :value="membership"
  25. :categories="membershipCategories"
  26. placeholder="Select a type"
  27. helpText="Select the membership type, you can change this later."
  28. @update="handleUpdate('membership', $event)"
  29. />
  30. <hr>
  31. <select-input
  32. label="Group Category"
  33. :value="category"
  34. :categories="categories"
  35. placeholder="Select a category"
  36. helpText="Choose the most relevant category to improve discovery and visibility"
  37. @update="handleUpdate('category', $event)"
  38. />
  39. <hr>
  40. <text-area-input
  41. label="Group Description"
  42. :value="description"
  43. :hasLimit="true"
  44. :maxLimit="limit.description.max"
  45. placeholder="Describe your groups purpose in a few words"
  46. helpText="Describe your groups purpose in a few words, you can change this later."
  47. @update="handleUpdate('description', $event)"
  48. />
  49. <hr>
  50. <checkbox-input
  51. label="Adult Content"
  52. inputText="Allow Adult Content"
  53. :value="configuration.adult"
  54. helpText="Groups that allow adult content should enable this or risk suspension or deletion by instance admins. Illegal content is prohibited. You can change this later."
  55. />
  56. <hr>
  57. <checkbox-input
  58. label=""
  59. inputText="I agree to the the Community Guidelines and Terms of Use and will administrate this group according to the rules set by this server. I understand that failure to abide by these terms may lead to the suspension of this group, and my account."
  60. :value="hasConfirmed"
  61. :strongText="false"
  62. @update="handleUpdate('hasConfirmed', $event)"
  63. />
  64. <!-- <div class="form-group row">
  65. <div class="col-sm-10 offset-sm-2">
  66. <div class="form-check">
  67. <input class="form-check-input" type="checkbox" id="gridCheck1" v-model="hasConfirmed">
  68. <label class="form-check-label" for="gridCheck1">
  69. I agree to the <a href="#">Community Guidelines</a> and <a href="#">Terms of Use</a>
  70. </label>
  71. </div>
  72. </div>
  73. </div> -->
  74. <button
  75. class="btn btn-primary btn-block font-weight-bold rounded-pill mt-4"
  76. @click="createGroup"
  77. :disabled="!hasConfirmed">
  78. Create Group
  79. </button>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="col-12 col-md-4 bg-white">
  84. <!-- <div>
  85. <button
  86. v-if="page <= 4"
  87. class="btn btn-primary btn-block font-weight-bold rounded-pill mt-4"
  88. @click="nextPage"
  89. :disabled="!membership">
  90. Next
  91. </button>
  92. <button
  93. v-if="page == 5"
  94. class="btn btn-primary btn-block font-weight-bold rounded-pill mt-4"
  95. @click="createGroup"
  96. :disabled="!hasConfirmed">
  97. Create Group
  98. </button>
  99. <button
  100. v-if="page >= 2"
  101. class="btn btn-light btn-block font-weight-bold rounded-pill border mt-4"
  102. @click="prevPage">
  103. Back
  104. </button>
  105. <div v-if="maxPage > 2" class="mt-4">
  106. <p v-if="name && name.length">
  107. <span class="text-lighter">Name:</span>
  108. <span class="font-weight-bold">{{ name }}</span>
  109. </p>
  110. <p v-if="description && description.length">
  111. <span class="text-lighter">Description:</span>
  112. <span>{{ description }}</span>
  113. </p>
  114. <p v-if="membership && membership.length">
  115. <span class="text-lighter">Membership:</span>
  116. <span class="text-capitalize">{{ membership }}</span>
  117. </p>
  118. <p v-if="category && category.length">
  119. <span class="text-lighter">Category:</span>
  120. <span class="text-capitalize">{{ category }}</span>
  121. </p>
  122. </div>
  123. </div> -->
  124. </div>
  125. </div>
  126. </div>
  127. </template>
  128. <script type="text/javascript">
  129. import TextInput from '@/groups/partials/CreateForm/TextInput.vue';
  130. import SelectInput from '@/groups/partials/CreateForm/SelectInput.vue';
  131. import TextAreaInput from '@/groups/partials/CreateForm/TextAreaInput.vue';
  132. import CheckboxInput from '@/groups/partials/CreateForm/CheckboxInput.vue';
  133. export default {
  134. components: {
  135. "text-input": TextInput,
  136. "select-input": SelectInput,
  137. "text-area-input": TextAreaInput,
  138. "checkbox-input": CheckboxInput,
  139. },
  140. data() {
  141. return {
  142. hide: true,
  143. name: null,
  144. page: 1,
  145. maxPage: 1,
  146. description: null,
  147. membership: "placeholder",
  148. submitting: false,
  149. categories: [],
  150. category: "",
  151. limit: {
  152. name: {
  153. max: 60
  154. },
  155. description: {
  156. max: 500
  157. }
  158. },
  159. configuration: {
  160. types: {
  161. text: true,
  162. photos: true,
  163. videos: true,
  164. // events: false,
  165. polls: true
  166. },
  167. federation: true,
  168. adult: false,
  169. discoverable: false,
  170. autospam: false,
  171. dms: false,
  172. slowjoin: {
  173. enabled: false,
  174. age: 90,
  175. limit: {
  176. post: 1,
  177. comment: 20,
  178. threads: 2,
  179. likes: 5,
  180. hashtags: 5,
  181. mentions: 1,
  182. autolinks: 1
  183. }
  184. }
  185. },
  186. hasConfirmed: false,
  187. permissionChecked: false,
  188. membershipCategories: [
  189. { key: 'Public', value: 'public' },
  190. // { key: 'Private', value: 'private' },
  191. // { key: 'Local', value: 'local' },
  192. ],
  193. }
  194. },
  195. mounted() {
  196. this.permissionCheck();
  197. this.fetchCategories();
  198. },
  199. methods: {
  200. permissionCheck() {
  201. axios.post('/api/v0/groups/permission/create')
  202. .then(res => {
  203. if(res.data.permission == false) {
  204. swal('Limit reached', 'You cannot create any more groups', 'error');
  205. this.hide = true;
  206. } else {
  207. this.hide = false;
  208. }
  209. this.permissionChecked = true;
  210. });
  211. },
  212. submit($event) {
  213. $event.preventDefault();
  214. this.submitting = true;
  215. axios.post('/api/v0/groups/create', {
  216. name: this.name,
  217. description: this.description,
  218. membership: this.membership
  219. }).then(res => {
  220. console.log(res.data);
  221. window.location.href = res.data.url;
  222. }).catch(err => {
  223. console.log(err.response);
  224. })
  225. },
  226. fetchCategories() {
  227. axios.get('/api/v0/groups/categories/list')
  228. .then(res => {
  229. this.categories = res.data.map(c => {
  230. return {
  231. key: c,
  232. value: c
  233. }
  234. });
  235. })
  236. },
  237. createGroup() {
  238. axios.post('/api/v0/groups/create', {
  239. name: this.name,
  240. description: this.description,
  241. membership: this.membership,
  242. configuration: this.configuration
  243. })
  244. .then(res => {
  245. console.log(res.data);
  246. location.href = res.data.url;
  247. })
  248. },
  249. handleUpdate(key, val) {
  250. this[key] = val;
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="scss">
  256. .create-group-component {
  257. .submit-button {
  258. width: 130px;
  259. }
  260. .multistep {
  261. margin-top: 30px;
  262. margin-bottom: 30px;
  263. overflow: hidden;
  264. counter-reset: step;
  265. text-align: center;
  266. padding-left: 0;
  267. }
  268. .multistep li {
  269. list-style-type: none;
  270. text-transform: uppercase;
  271. font-size: 9px;
  272. font-weight: 700;
  273. width: 20%;
  274. float: left;
  275. position: relative;
  276. color: #B8C2CC;
  277. }
  278. .multistep li.active {
  279. color: #000;
  280. }
  281. .multistep li:before {
  282. content: counter(step);
  283. counter-increment: step;
  284. width: 24px;
  285. height: 24px;
  286. line-height: 26px;
  287. display: block;
  288. font-size: 12px;
  289. color: #B8C2CC;
  290. background: #F3F4F6;
  291. border-radius: 25px;
  292. margin: 0 auto 10px auto;
  293. transition: background 400ms;
  294. }
  295. .multistep li:after {
  296. content: '';
  297. width: 100%;
  298. height: 2px;
  299. background: #dee2e6;
  300. position: absolute;
  301. left: -50%;
  302. top: 11px;
  303. z-index: -1;
  304. transition: background 400ms;
  305. }
  306. .multistep li:first-child:after {
  307. content: none;
  308. }
  309. .multistep li.active:before,
  310. .multistep li.active:after {
  311. background: #2c78bf;
  312. color: white;
  313. transition: background 400ms;
  314. }
  315. .col-form-label {
  316. font-weight: 600;
  317. text-align: right;
  318. }
  319. }
  320. </style>