AdminSettings.vue 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568
  1. <template>
  2. <div v-if="loaded">
  3. <div class="header bg-primary pb-2 mt-n4">
  4. <div class="container-fluid">
  5. <div class="header-body">
  6. <div class="row align-items-center py-4">
  7. <div class="col-lg-6 col-7">
  8. <p class="display-1 text-white d-inline-block mb-0">Settings</p>
  9. <p class="h3 text-white font-weight-light">Manage your server settings</p>
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. <div class="container">
  16. <div class="row">
  17. <div class="col-12 col-md-3">
  18. <div class="nav-wrapper">
  19. <div class="nav flex-column nav-pills" id="tabs-icons-text" role="tablist" aria-orientation="vertical">
  20. <div v-for="tab in tabs" class="nav-item">
  21. <a class="nav-link mb-sm-3" :class="{ active: tabIndex === tab.id }" href="#" @click.prevent="toggleTab(tab.id)">
  22. <i :class="tab.icon"></i>
  23. <span class="ml-2">{{ tab.title }}</span>
  24. </a>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="col-12 col-md-9">
  30. <div class="card shadow mt-3">
  31. <div class="card-body">
  32. <div class="tab-content">
  33. <div v-if="tabIndex === 1" class="tab-pane fade show active">
  34. <tab-header title="Settings" :saving="isSubmitting" :saved="isSubmittingTimeout" @save="handleSave('overview')" />
  35. <div class="row">
  36. <div class="col-12 col-md-6">
  37. <div class="card shadow-none border card-body" style="padding: 1.1rem 1.6rem">
  38. <div class="form-group mb-0">
  39. <label for="form-summary" class="font-weight-bold">Registration Status</label>
  40. <select v-model="features.registration_status" class="form-control form-control-muted">
  41. <option value="open" >Open - Anyone can register</option>
  42. <option value="filtered">Filtered - Anyone can apply (Curated Onboarding)</option>
  43. <option value="closed">Closed - Nobody can register</option>
  44. </select>
  45. </div>
  46. </div>
  47. <checkbox
  48. name="Cloud Storage"
  49. :value="features.cloud_storage"
  50. description="Store photos and videos on S3 compatible object storage providers."
  51. @change="handleChange($event, 'features', 'cloud_storage')"
  52. />
  53. <checkbox
  54. name="ActivityPub"
  55. :value="features.activitypub_enabled"
  56. description="ActivityPub federation, compatible with Pixelfed, Mastodon and other projects."
  57. @change="handleChange($event, 'features', 'activitypub_enabled')"
  58. />
  59. <checkbox
  60. name="Authorized Fetch Mode"
  61. :value="features.authorized_fetch"
  62. description="Strictly enforce domain restrictions by enabling Authorized Fetch mode."
  63. @change="handleChange($event, 'features', 'authorized_fetch')"
  64. />
  65. <checkbox
  66. name="Account Migration"
  67. :value="features.account_migration"
  68. description="Allow local accounts to migrate to other local or remote accounts."
  69. @change="handleChange($event, 'features', 'account_migration')"
  70. />
  71. </div>
  72. <div class="col-12 col-md-6">
  73. <checkbox
  74. name="Mobile APIs"
  75. :value="features.mobile_apis"
  76. description="Enable apis required for official mobile app support and 3rd party apps."
  77. @change="handleChange($event, 'features', 'mobile_apis')"
  78. />
  79. <checkbox
  80. name="Stories"
  81. :value="features.stories"
  82. description="Allow users to share federated ephemeral Stories that disappear after 24 hours."
  83. @change="handleChange($event, 'features', 'stories')"
  84. />
  85. <checkbox
  86. name="Instagram Import"
  87. :value="features.instagram_import"
  88. description="Enable users to use the <span class='font-weight-bold'>experimental</span> Instagram Import support."
  89. @change="handleChange($event, 'features', 'instagram_import')"
  90. />
  91. <!-- <checkbox
  92. name="Allowlist Mode"
  93. :value="features.activitypub_enabled"
  94. description="Permit interactions only with instances you specifically authorize, both for sending and receiving."
  95. @change="handleChange($event, 'features', 'activitypub_enabled')"
  96. /> -->
  97. <checkbox
  98. name="Spam detection"
  99. :value="features.autospam_enabled"
  100. description="Detect and remove spam from timelines using the automated Autospam detection."
  101. @change="handleChange($event, 'features', 'autospam_enabled')"
  102. />
  103. </div>
  104. </div>
  105. </div>
  106. <div v-else-if="tabIndex === 'landing'" class="tab-pane fade show active" role="tabpanel">
  107. <tab-header title="Landing" :saving="isSubmitting" :saved="isSubmittingTimeout" @save="handleSave('landing')" />
  108. <div class="row">
  109. <div class="col-12 col-md-6">
  110. <div class="card shadow-none border card-body" style="padding: 1.1rem 1.6rem">
  111. <div class="form-group mb-0">
  112. <label for="form-summary" class="font-weight-bold">Admin Account</label>
  113. <select v-model="landing.current_admin" class="form-control form-control-muted">
  114. <option disabled="" value="0">Select a designated admin</option>
  115. <option v-for="(acct, index) in landing.admins" :key="'pfc-' + acct + index" :value="acct.profile_id">{{ acct.username }}</option>
  116. </select>
  117. </div>
  118. </div>
  119. <checkbox
  120. name="Show Directory"
  121. :value="landing.show_directory"
  122. description="Show the account directory on the landing page for guest users."
  123. @change="handleChange($event, 'landing', 'show_directory')"
  124. />
  125. </div>
  126. <div class="col-12 col-md-6">
  127. <checkbox
  128. name="Show Explore Feed"
  129. :value="landing.show_explore"
  130. description="Show the explore feed of popular posts on the landing page for guest users."
  131. @change="handleChange($event, 'landing', 'show_explore')"
  132. />
  133. </div>
  134. </div>
  135. </div>
  136. <div v-else-if="tabIndex === 'branding'" class="tab-pane fade show active" role="tabpanel">
  137. <tab-header title="Branding" :saving="isSubmitting" :saved="isSubmittingTimeout" @save="handleSave('branding')" />
  138. <div class="row">
  139. <div class="col-12 col-md-8">
  140. <div class="card shadow-none border card-body" style="padding: 1.1rem 1.6rem">
  141. <div class="form-group mb-1">
  142. <label for="form-summary" class="font-weight-bold">Server Name</label>
  143. <input
  144. class="form-control form-control-muted"
  145. placeholder="Pixelfed"
  146. v-model="branding.name" />
  147. </div>
  148. <p class="help-text small text-muted mb-0">
  149. The instance name used in titles, metadata and apis.
  150. </p>
  151. </div>
  152. <div class="card shadow-none border card-body">
  153. <div class="form-group mb-1">
  154. <label for="form-summary" class="font-weight-bold">Short Description</label>
  155. <textarea
  156. class="form-control form-control-muted"
  157. placeholder="Pixelfed"
  158. rows="4"
  159. v-model="branding.short_description"></textarea>
  160. </div>
  161. <p class="help-text small text-muted mb-0">
  162. Short description of instance used on various pages and apis.
  163. </p>
  164. </div>
  165. <div class="card shadow-none border card-body">
  166. <div class="form-group mb-1">
  167. <label for="form-summary" class="font-weight-bold">Long Description</label>
  168. <textarea
  169. class="form-control form-control-muted"
  170. placeholder="Pixelfed"
  171. rows="8"
  172. v-model="branding.long_description"></textarea>
  173. </div>
  174. <p class="help-text small text-muted mb-0">
  175. Longer description of instance used on about page.
  176. </p>
  177. </div>
  178. </div>
  179. <div class="col-12 col-md-4">
  180. <p>
  181. <a class="btn btn-dark btn-block" href="/i/admin/settings/custom-css">Edit Custom CSS</a>
  182. </p>
  183. </div>
  184. </div>
  185. </div>
  186. <div v-else-if="tabIndex === 'media'" class="tab-pane fade show active" role="tabpanel">
  187. <tab-header title="Media" :saving="isSubmitting" :saved="isSubmittingTimeout" @save="handleSave('media')" />
  188. <div class="row">
  189. <div class="col-12 col-md-6">
  190. <div class="card shadow-none border card-body">
  191. <div class="form-group mb-1">
  192. <label class="font-weight-bold text-muted">Max Media Size</label>
  193. <div class="input-group mb-0">
  194. <input
  195. type="text"
  196. class="form-control"
  197. placeholder="15000"
  198. aria-label="Max media size"
  199. aria-describedby="maxMediaSize"
  200. v-model="media.max_photo_size">
  201. <div class="input-group-append">
  202. <span class="input-group-text" id="maxMediaSize">= {{ maxMediaSizeToMb }}</span>
  203. </div>
  204. </div>
  205. </div>
  206. <p class="help-text small text-muted mb-0">
  207. Maximum file upload size in KB
  208. </p>
  209. </div>
  210. <checkbox
  211. name="Optimize Images"
  212. :value="media.optimize_image"
  213. description="Enable to optimize images and generate thumbnails for local image media uploads."
  214. @change="handleChange($event, 'media', 'optimize_image')"
  215. />
  216. <checkbox
  217. name="Optimize Video"
  218. :value="media.optimize_video"
  219. description="Enable to generate video thumbnails for local video media uploads."
  220. @change="handleChange($event, 'media', 'optimize_video')"
  221. />
  222. <div class="card shadow-none border card-body">
  223. <div class="form-group mb-1">
  224. <label class="font-weight-bold text-muted">Media Types</label>
  225. <div class="list-group">
  226. <div v-for="(mediaType, key) in mediaTypes" class="list-group-item py-2">
  227. <div class="custom-control custom-checkbox">
  228. <input
  229. type="checkbox"
  230. class="custom-control-input"
  231. :name="key"
  232. :id="key"
  233. v-model="mediaTypes[key]">
  234. <label class="custom-control-label font-weight-bold" :for="key">{{ key }}</label>
  235. </div>
  236. </div>
  237. </div>
  238. </div>
  239. <p class="help-text small text-muted mb-0">
  240. Supported mime types for media uploads
  241. </p>
  242. </div>
  243. </div>
  244. <div class="col-12 col-md-6">
  245. <div class="card shadow-none border card-body">
  246. <div class="form-group mb-1">
  247. <label class="font-weight-bold text-muted">Photo Album Limit</label>
  248. <input
  249. type="number"
  250. min="1"
  251. max="20"
  252. class="form-control"
  253. name="max_album_length"
  254. v-model="media.max_album_length">
  255. </div>
  256. <p class="help-text small text-muted mb-0">
  257. The maximum number of photos or videos per album
  258. </p>
  259. </div>
  260. <transition name="fade">
  261. <div v-if="media.optimize_image" class="card shadow-none border card-body">
  262. <div class="form-group mb-1">
  263. <label class="font-weight-bold text-muted">Image Quality</label>
  264. <input
  265. type="number"
  266. min="20"
  267. max="100"
  268. class="form-control"
  269. name="image_quality"
  270. v-model="media.image_quality">
  271. </div>
  272. <p class="help-text small text-muted mb-0">
  273. Image optimization quality from 0-100%.
  274. </p>
  275. </div>
  276. </transition>
  277. </div>
  278. </div>
  279. </div>
  280. <div v-else-if="tabIndex === 'platform'" class="tab-pane fade show active" role="tabpanel">
  281. <tab-header title="Platform" :saving="isSubmitting" :saved="isSubmittingTimeout" @save="handleSave('platform')" />
  282. <div class="row">
  283. <div class="col-12 col-md-6">
  284. <checkbox
  285. name="Allow Profile Embeds"
  286. :value="platform.allow_profile_embeds"
  287. description="Allow anyone to embed public profiles on other websites."
  288. @change="handleChange($event, 'platform', 'allow_profile_embeds')"
  289. />
  290. <div class="card shadow-none border card-body">
  291. <div class="form-group mb-0">
  292. <div class="custom-control custom-checkbox">
  293. <input
  294. type="checkbox"
  295. name="allow_app_registrations"
  296. class="custom-control-input"
  297. id="platform1"
  298. :disabled="features.registration_status !== 'open'"
  299. v-model="platform.allow_app_registration">
  300. <label class="custom-control-label font-weight-bold" for="platform1">Allow App Registrations</label>
  301. </div>
  302. <p v-if="features.registration_status !== 'open'" class="mb-0 small text-muted">Requires open registration to be enabled.</p>
  303. <p v-else class="mb-0 small">Allow users to register via the official Pixelfed mobile application.</p>
  304. </div>
  305. </div>
  306. <checkbox
  307. name="Custom Emoji"
  308. :value="platform.custom_emoji_enabled"
  309. description="Enable federated custom emoji that is compatible with Mastodon, Pleroma and others."
  310. @change="handleChange($event, 'platform', 'custom_emoji_enabled')"
  311. />
  312. <template v-if="features.registration_status === 'open' && features.allow_app_registration">
  313. <div class="card shadow-none border card-body">
  314. <div class="form-group mb-1">
  315. <label class="font-weight-bold text-muted">app_registration_rate_limit_attempts</label>
  316. <input
  317. type="number"
  318. class="form-control"
  319. name="app_registration_rate_limit_attempts"
  320. v-model="platform.app_registration_rate_limit_attempts">
  321. </div>
  322. <p class="help-text small text-muted mb-0">
  323. app_registration_rate_limit_attempts.
  324. </p>
  325. </div>
  326. <div class="card shadow-none border card-body">
  327. <div class="form-group mb-1">
  328. <label class="font-weight-bold text-muted">app_registration_rate_limit_decay</label>
  329. <input
  330. type="number"
  331. class="form-control"
  332. name="app_registration_rate_limit_decay"
  333. v-model="platform.app_registration_rate_limit_decay">
  334. </div>
  335. <p class="help-text small text-muted mb-0">
  336. app_registration_rate_limit_decay
  337. </p>
  338. </div>
  339. </template>
  340. </div>
  341. <div class="col-12 col-md-6">
  342. <checkbox
  343. name="Allow Post Embeds"
  344. :value="platform.allow_post_embeds"
  345. description="Allow anyone to embed public posts on other websites."
  346. @change="handleChange($event, 'platform', 'allow_post_embeds')"
  347. />
  348. <div class="card shadow-none border card-body">
  349. <div class="form-group mb-1">
  350. <div class="custom-control custom-checkbox">
  351. <input
  352. type="checkbox"
  353. name="hcaps"
  354. class="custom-control-input"
  355. id="hcp"
  356. v-model="platform.captcha_enabled">
  357. <label class="custom-control-label font-weight-bold" for="hcp">Enable hCaptcha</label>
  358. </div>
  359. </div>
  360. <template v-if="platform.captcha_enabled">
  361. <hr class="my-2">
  362. <div class="row">
  363. <div class="col-12 col-md-6">
  364. <div class="form-group my-1">
  365. <label class="text-muted small">hCaptcha Secret</label>
  366. <input
  367. type="text"
  368. class="form-control"
  369. name="captcha_secret"
  370. v-model="platform.captcha_secret">
  371. </div>
  372. </div>
  373. <div class="col-12 col-md-6">
  374. <div class="form-group my-1">
  375. <label class="text-muted small">hCaptcha Sitekey</label>
  376. <input
  377. type="text"
  378. class="form-control"
  379. name="captcha_sitekey"
  380. v-model="platform.captcha_sitekey">
  381. </div>
  382. </div>
  383. </div>
  384. <hr class="mt-2 mb-4">
  385. <div class="row">
  386. <div class="col-12 col-lg-6">
  387. <div class="custom-control custom-checkbox">
  388. <input
  389. type="checkbox"
  390. name="captcha_on_login"
  391. class="custom-control-input"
  392. id="captcha_on_login"
  393. v-model="platform.captcha_on_login">
  394. <label class="custom-control-label font-weight-bold" for="captcha_on_login">Login Captcha</label>
  395. </div>
  396. </div>
  397. <div class="col-12 col-lg-6">
  398. <div class="custom-control custom-checkbox">
  399. <input
  400. type="checkbox"
  401. name="captcha_on_register"
  402. class="custom-control-input"
  403. id="captcha_on_register"
  404. v-model="platform.captcha_on_register">
  405. <label class="custom-control-label font-weight-bold" for="captcha_on_register">Register Captcha</label>
  406. </div>
  407. </div>
  408. </div>
  409. <hr class="mt-4 mb-2">
  410. </template>
  411. <p class="help-text small text-muted mb-0">
  412. Enable hCaptcha on login and register pages
  413. </p>
  414. </div>
  415. <template v-if="features.registration_status === 'open' && features.allow_app_registration">
  416. <div class="card shadow-none border card-body">
  417. <div class="form-group mb-1">
  418. <label class="font-weight-bold text-muted">app_registration_confirm_rate_limit_attempts</label>
  419. <input
  420. type="number"
  421. class="form-control"
  422. name="app_registration_confirm_rate_limit_attempts"
  423. v-model="platform.app_registration_confirm_rate_limit_attempts">
  424. </div>
  425. <p class="help-text small text-muted mb-0">
  426. app_registration_confirm_rate_limit_attempts.
  427. </p>
  428. </div>
  429. <div class="card shadow-none border card-body">
  430. <div class="form-group mb-1">
  431. <label class="font-weight-bold text-muted">app_registration_confirm_rate_limit_decay</label>
  432. <input
  433. type="number"
  434. class="form-control"
  435. name="app_registration_confirm_rate_limit_decay"
  436. v-model="platform.app_registration_confirm_rate_limit_decay">
  437. </div>
  438. <p class="help-text small text-muted mb-0">
  439. app_registration_confirm_rate_limit_decay.
  440. </p>
  441. </div>
  442. </template>
  443. </div>
  444. </div>
  445. </div>
  446. <div v-else-if="tabIndex === 'posts'" class="tab-pane fade show active" role="tabpanel">
  447. <tab-header title="Posts" :saving="isSubmitting" :saved="isSubmittingTimeout" @save="handleSave('posts')" />
  448. <div class="row">
  449. <div class="col-12 col-md-6">
  450. <div class="card shadow-none border card-body">
  451. <div class="form-group mb-1">
  452. <label class="font-weight-bold text-muted">Max Caption Length</label>
  453. <input
  454. type="number"
  455. min="1"
  456. max="10000"
  457. class="form-control"
  458. name="max_caption_limit"
  459. v-model="posts.max_caption_length">
  460. </div>
  461. <p class="help-text small text-muted mb-0">
  462. The maximum character count of post captions. We recommend a limit between 500-2000.
  463. </p>
  464. </div>
  465. </div>
  466. <div class="col-12 col-md-6">
  467. <div class="card shadow-none border card-body">
  468. <div class="form-group mb-1">
  469. <label class="font-weight-bold text-muted">Max Alttext Length</label>
  470. <input
  471. type="number"
  472. min="1"
  473. max="10000"
  474. class="form-control"
  475. name="max_altext_length"
  476. v-model="posts.max_altext_length">
  477. </div>
  478. <p class="help-text small text-muted mb-0">
  479. The maximum character count of post media alttext captions. We recommend a limit between 2000-10000.
  480. </p>
  481. </div>
  482. </div>
  483. </div>
  484. </div>
  485. <div v-else-if="tabIndex === 'rules'" class="tab-pane fade show active" role="tabpanel">
  486. <tab-header title="Rules" :saving="isSubmitting" :saved="isSubmittingTimeout" @save="handleSave('rules')" />
  487. <div class="row">
  488. <div class="col-12 mb-3">
  489. <div v-if="hasDuplicateRulesComputed" class="alert alert-danger">
  490. <p class="font-weight-bold mb-0">Duplicate rules detected, you should fix this!</p>
  491. </div>
  492. <div class="position-relative">
  493. <div class="card shadow-none border">
  494. <div class="card-header py-2 bg-primary text-white font-weight-bold text-center">Active Rules</div>
  495. <div class="list-group list-group-flush">
  496. <div
  497. v-for="(rule, idx) in rulesComputed"
  498. class="list-group-item">
  499. <div class="d-flex justify-content-between align-items-start">
  500. <div class="d-flex gap-1 align-items-start">
  501. <div class="rule-badge">
  502. <div class="rule-badge-inner">{{ idx + 1 }}</div>
  503. </div>
  504. <admin-read-more
  505. :key="rule"
  506. class="text-dark rule-text"
  507. :content="rule"
  508. :maxLength="140"
  509. :initialLimit="30"
  510. fontSize="13" />
  511. </div>
  512. <button
  513. class="btn btn-link btn-sm"
  514. :disabled="isDeletingRule"
  515. @click.prevent="handleDeleteRule(rule, idx, $event)">
  516. <i class="fas fa-trash-alt text-danger"></i>
  517. </button>
  518. </div>
  519. </div>
  520. <div v-if="!rules || !rules.length" class="list-group-item">
  521. <p class="text-center mb-0">No rules set!</p>
  522. </div>
  523. </div>
  524. </div>
  525. <div v-if="!showAllRules && rules.length > 2" class="d-flex justify-content-center" style="position:absolute;width: 100%;padding-top: 10rem;bottom:0;background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255, 1));">
  526. <button class="btn btn-dark font-weight-bold rounded-pill btn-block" @click.prevent="showAllRules = true">Show all rules</button>
  527. </div>
  528. </div>
  529. </div>
  530. <div class="col-12 col-md-6">
  531. <div class="card shadow-none border card-body">
  532. <div class="form-group mb-1">
  533. <label class="font-weight-bold text-muted">Add New Rule</label>
  534. <textarea
  535. type="text"
  536. class="form-control"
  537. name="new_rule"
  538. rows="5"
  539. minlength="5"
  540. maxlength="1000"
  541. placeholder="Add your new rule here..."
  542. :disabled="isSubmittingNewRule || isDeletingRule"
  543. v-model="newRule"></textarea>
  544. </div>
  545. <div class="d-flex justify-content-between align-items-center">
  546. <p class="help-text small text-muted mb-0">
  547. Add a new rule
  548. </p>
  549. <p class="help-text small text-muted mb-0">
  550. {{ newRule && newRule.length ? newRule.length : 0 }}/1000
  551. </p>
  552. </div>
  553. <hr class="my-2">
  554. <p class="mb-0">
  555. <button
  556. class="btn btn-primary btn-sm btn-block font-weight-bold rounded-pill"
  557. :disabled="!newRule || !newRule.length || isSubmittingNewRule || isDeletingRule"
  558. @click.prevent="handleAddRule">Add Rule</button>
  559. </p>
  560. </div>
  561. <button v-if="rules && rules.length" class="btn btn-outline-danger rounded-pill btn-block btn-sm" @click.prevent="handleDeleteAllRules">Delete all rules</button>
  562. </div>
  563. <div v-if="suggestedRulesComputed && suggestedRulesComputed.length" class="col-12 col-md-6">
  564. <div class="border-bottom pb-2 mb-3 d-flex justify-content-between align-items-center">
  565. <p class="font-weight-bold mb-0">Suggested Rules</p>
  566. <a v-if="!rules.length" class="font-weight-bold small" href="#" @click.prevent="importAllDefaultRules">Import All</a>
  567. </div>
  568. <div class="list-group">
  569. <a
  570. v-for="rule in suggestedRulesComputed"
  571. class="list-group-item small"
  572. href="#"
  573. @click.prevent="addSuggestedRule(rule, $event)">{{ rule }}</a>
  574. </div>
  575. </div>
  576. </div>
  577. </div>
  578. <div v-else-if="tabIndex === 'storage'" class="tab-pane fade show active" role="tabpanel">
  579. <tab-header title="Storage" :saving="isSubmitting" :saved="isSubmittingTimeout" @save="handleSave('storage')" />
  580. <div class="row">
  581. <div class="col-12 col-md-6">
  582. <div class="card shadow-none border card-body" style="padding: 1.1rem 1.6rem">
  583. <div class="form-group mb-0">
  584. <label for="form-summary" class="font-weight-bold">Primary Storage Disk</label>
  585. <select v-model="storage.primary_disk" class="form-control form-control-muted">
  586. <option value="local" >Local</option>
  587. <option value="cloud">Cloud/S3</option>
  588. </select>
  589. </div>
  590. <p class="help-text small text-muted mt-2 mb-0">
  591. The storage disk where avatars and media uploads are stored.
  592. </p>
  593. </div>
  594. </div>
  595. <div class="col-12 col-md-6">
  596. <div class="card border">
  597. <div class="card-header bg-gradient-primary">
  598. <p class="text-center mb-0 text-white font-weight-bold">Cloud Disk Config</p>
  599. </div>
  600. <div v-if="!showDiskConfig" class="card-body">
  601. <p class="text-center mb-0">
  602. <a
  603. class="btn btn-primary bg-gradient-primary shadow-lg rounded-pill"
  604. href="#"
  605. @click.prevent="showDiskConfig = true">
  606. View/Edit
  607. </a>
  608. </p>
  609. </div>
  610. <div v-else class="card-body">
  611. <div class="form-group mb-4 d-flex align-items-center gap-1">
  612. <label for="form-summary" class="font-weight-bold mb-0">Disk</label>
  613. <select v-model="storage.disk_config.driver" class="form-control form-control-muted mb-0">
  614. <option value="s3" >S3</option>
  615. <option value="spaces">DigitalOcean Spaces</option>
  616. </select>
  617. </div>
  618. <form-input
  619. name="Key"
  620. :value="storage.disk_config.key"
  621. description=""
  622. :isCard="false"
  623. :isInline="true"
  624. @change="handleSubChange($event, 'storage', 'disk_config', 'key')"
  625. />
  626. <form-input
  627. name="Secret"
  628. :value="storage.disk_config.secret"
  629. description=""
  630. :isCard="false"
  631. :isInline="true"
  632. @change="handleSubChange($event, 'storage', 'disk_config', 'secret')"
  633. />
  634. <form-input
  635. name="Region"
  636. :value="storage.disk_config.region"
  637. description=""
  638. :isCard="false"
  639. :isInline="true"
  640. @change="handleSubChange($event, 'storage', 'disk_config', 'region')"
  641. />
  642. <form-input
  643. name="Bucket"
  644. :value="storage.disk_config.bucket"
  645. description=""
  646. :isCard="false"
  647. :isInline="true"
  648. @change="handleSubChange($event, 'storage', 'disk_config', 'bucket')"
  649. />
  650. <form-input
  651. name="Endpoint"
  652. :value="storage.disk_config.endpoint"
  653. description=""
  654. :isCard="false"
  655. :isInline="true"
  656. @change="handleSubChange($event, 'storage', 'disk_config', 'endpoint')"
  657. />
  658. <form-input
  659. name="Visibility"
  660. :value="storage.disk_config.visibility"
  661. description=""
  662. :isCard="false"
  663. :isInline="true"
  664. :isDisabled="true"
  665. @change="handleSubChange($event, 'storage', 'disk_config', 'visibility')"
  666. />
  667. <form-input
  668. name="Url"
  669. :value="storage.disk_config.url"
  670. description=""
  671. :isCard="false"
  672. :isInline="true"
  673. @change="handleSubChange($event, 'storage', 'disk_config', 'url')"
  674. />
  675. </div>
  676. </div>
  677. </div>
  678. </div>
  679. </div>
  680. <div v-else-if="tabIndex === 'users'" class="tab-pane fade show active" role="tabpanel">
  681. <tab-header title="Users" :saving="isSubmitting" :saved="isSubmittingTimeout" @save="handleSave('users')" />
  682. <div class="row">
  683. <div class="col-12 col-md-6">
  684. <checkbox
  685. name="Require Email Verifications"
  686. :value="users.require_email_verification"
  687. description="Require users to verify their email address is valid before they can use the account."
  688. @change="handleChange($event, 'users', 'require_email_verification')"
  689. />
  690. <form-input
  691. name="Max User Blocks"
  692. :value="users.max_user_blocks.toString()"
  693. description="The max number of account blocks per user."
  694. @change="handleChange($event, 'users', 'max_user_blocks')"
  695. />
  696. <form-input
  697. name="Max User Mutes"
  698. :value="users.max_user_mutes.toString()"
  699. description="The max number of account mutes per user."
  700. @change="handleChange($event, 'users', 'max_user_mutes')"
  701. />
  702. <form-input
  703. name="Max User Domain Blocks"
  704. :value="users.max_domain_blocks.toString()"
  705. description="The max number of domain blocks per user."
  706. @change="handleChange($event, 'users', 'max_domain_blocks')"
  707. />
  708. </div>
  709. <div class="col-12 col-md-6">
  710. <div class="card shadow-none border card-body">
  711. <div class="form-group mb-0">
  712. <div class="custom-control custom-checkbox">
  713. <input type="checkbox" name="enforce_account_limit" class="custom-control-input" id="users2" v-model="users.enforce_account_limit">
  714. <label class="custom-control-label font-weight-bold" for="users2">Enforce Account Limit</label>
  715. </div>
  716. <p class="mb-0 small">Set a storage limit per user account for all uploaded media (photo + video).</p>
  717. </div>
  718. <transition name="fade">
  719. <div v-if="users.enforce_account_limit">
  720. <hr class="my-2">
  721. <div class="form-group mb-1">
  722. <div class="input-group mb-0">
  723. <input
  724. type="text"
  725. class="form-control"
  726. placeholder="15000"
  727. aria-label="Max account size"
  728. aria-describedby="maxMediaSize"
  729. v-model="users.max_account_size">
  730. <div class="input-group-append">
  731. <span class="input-group-text">= {{maxAccountSizeToMb }}</span>
  732. </div>
  733. </div>
  734. </div>
  735. <p class="help-text small text-muted mb-0">
  736. Maximum file storage limit per user account.
  737. </p>
  738. </div>
  739. </transition>
  740. </div>
  741. <div class="card shadow-none border">
  742. <div class="card-body">
  743. <div class="form-group mb-0">
  744. <div class="custom-control custom-checkbox">
  745. <input type="checkbox" name="admin_autofollow" class="custom-control-input" id="users4" v-model="users.admin_autofollow">
  746. <label class="custom-control-label font-weight-bold" for="users4">Autofollow Accounts</label>
  747. </div>
  748. <p class="mb-0 small">Force new accounts to follow accounts you specify below</p>
  749. </div>
  750. </div>
  751. <transition name="fade">
  752. <div v-if="users.admin_autofollow" class="list-group list-group-flush">
  753. <div v-if="users.admin_autofollow_accounts?.length">
  754. <div v-for="user in users.admin_autofollow_accounts" class="list-group-item">
  755. <div class="d-flex justify-content-between align-items-center">
  756. <p class="font-weight-bold mb-0">&commat;{{ user }}</p>
  757. <button class="btn btn-link p-0" @click.prevent="removeAutofollow(user, $event)"><i class="fas fa-trash-alt text-danger"></i></button>
  758. </div>
  759. </div>
  760. </div>
  761. <div v-else class="list-group-item">
  762. <p class="text-center mb-0">No autofollow accounts active.</p>
  763. </div>
  764. </div>
  765. </transition>
  766. <transition name="fade">
  767. <div v-if="users.admin_autofollow && (users.admin_autofollow_accounts && users.admin_autofollow_accounts.length < 5)" class="card-footer">
  768. <button
  769. class="btn btn-primary btn-block rounded-pill"
  770. @click.prevent="addAutofollow">Add Autofollow Account</button>
  771. </div>
  772. </transition>
  773. </div>
  774. </div>
  775. </div>
  776. </div>
  777. </div>
  778. </div>
  779. </div>
  780. </div>
  781. </div>
  782. </div>
  783. </div>
  784. <div v-else>
  785. <div class="container my-5 py-5 text-center">
  786. <div class="spinner-border text-primary" role="status">
  787. <span class="sr-only">Loading...</span>
  788. </div>
  789. </div>
  790. </div>
  791. </template>
  792. <script type="text/javascript">
  793. import AdminReadMore from "./partial/AdminReadMore.vue";
  794. import AdminSettingsTabHeader from "./partial/AdminSettingsTabHeader.vue";
  795. import Checkbox from "./partial/AdminSettingsCheckbox.vue";
  796. import FormInput from "./partial/AdminSettingsInput.vue";
  797. export default {
  798. components: {
  799. "admin-read-more": AdminReadMore,
  800. "tab-header": AdminSettingsTabHeader,
  801. "checkbox": Checkbox,
  802. "form-input": FormInput
  803. },
  804. data() {
  805. return {
  806. loaded: false,
  807. initialData: {},
  808. tabIndex: 1,
  809. tabbies: [
  810. 'landing',
  811. 'branding',
  812. 'media',
  813. 'posts',
  814. 'platform',
  815. 'rules',
  816. 'users',
  817. 'storage'
  818. ],
  819. tabs: [
  820. { id: 1, title: "Overview", icon: "far fa-home" },
  821. // { id: 2, title: "Status", icon: "far fa-asterisk" },
  822. { id: 'landing', title: "Landing", icon: "far fa-info-circle" },
  823. { id: 'branding', title: "Branding", icon: "far fa-user-crown" },
  824. { id: 'media', title: "Media", icon: "far fa-image" },
  825. { id: 'platform', title: "Platform", icon: "far fa-database" },
  826. { id: 'posts', title: "Posts", icon: "far fa-heart" },
  827. { id: 'rules', title: "Rules", icon: "far fa-eye-slash" },
  828. { id: 'storage', title: "Storage", icon: "far fa-hdd" },
  829. { id: 'users', title: "Users", icon: "far fa-users" },
  830. ],
  831. isSubmitting: false,
  832. isSubmittingTimeout: false,
  833. isSubmittingTimeoutHandler: undefined,
  834. features: [],
  835. landing: {
  836. current_admin: 0,
  837. },
  838. branding: [],
  839. media: [],
  840. mediaTypes: {
  841. jpeg: false,
  842. png: false,
  843. gif: false,
  844. webp: false,
  845. avif: false,
  846. heic: false,
  847. mp4: false,
  848. mov: false,
  849. },
  850. rules: [],
  851. users: [],
  852. posts: [],
  853. platform: [],
  854. storage: [],
  855. newRule: undefined,
  856. isSubmittingNewRule: false,
  857. isDeletingRule: false,
  858. suggestedRules: [],
  859. hasDuplicateRules: false,
  860. showAllRules: false,
  861. showDiskConfig: false,
  862. }
  863. },
  864. computed: {
  865. maxMediaSizeToMb: {
  866. get() {
  867. if(!this.media || !this.media.max_photo_size) {
  868. return '0.00 MB';
  869. }
  870. return (this.media.max_photo_size / 1000).toFixed(2) + ' MB';
  871. }
  872. },
  873. maxAccountSizeToMb: {
  874. get() {
  875. if(!this.users || !this.users.max_account_size) {
  876. return '0.00 MB';
  877. }
  878. const mb = (this.users.max_account_size / 1024);
  879. if(mb > 1000000) {
  880. return (mb / 1000000).toFixed(1) + 'TB';
  881. }
  882. if(mb > 1000) {
  883. return (mb / 1024).toFixed(2) + 'GB';
  884. }
  885. return (this.users.max_account_size / 1024).toFixed(2) + ' MB';
  886. }
  887. },
  888. rulesComputed: {
  889. get() {
  890. if(!this.rules || !this.rules.length) {
  891. return [];
  892. }
  893. if(this.rules.length > 2) {
  894. if(!this.showAllRules) {
  895. return this.rules.slice(0, 2);
  896. }
  897. }
  898. return this.rules;
  899. }
  900. },
  901. suggestedRulesComputed: {
  902. get() {
  903. if(!this.rules || !this.rules.length) {
  904. return this.suggestedRules;
  905. }
  906. return this.suggestedRules.filter(rule => {
  907. if(this.rules.includes(rule)) {
  908. return false;
  909. }
  910. return true;
  911. });
  912. }
  913. },
  914. hasDuplicateRulesComputed: {
  915. get() {
  916. if(!this.rules || !this.rules.length) {
  917. return false;
  918. }
  919. const array = this.rules;
  920. const duplicates = array.filter((item, index) => array.indexOf(item) !== index);
  921. return duplicates.length;
  922. }
  923. },
  924. activeMediaTypes: {
  925. get() {
  926. let res = '';
  927. if(this.mediaTypes.jpeg) {
  928. res += 'image/jpeg,'
  929. }
  930. if(this.mediaTypes.png) {
  931. res += 'image/png,'
  932. }
  933. if(this.mediaTypes.gif) {
  934. res += 'image/gif,'
  935. }
  936. if(this.mediaTypes.webp) {
  937. res += 'image/webp,'
  938. }
  939. if(this.mediaTypes.mp4) {
  940. res += 'video/mp4'
  941. }
  942. if(res.endsWith(',')) {
  943. res = res.slice(0, -1);
  944. }
  945. return res;
  946. }
  947. }
  948. },
  949. mounted() {
  950. this.fetchInitialData();
  951. const params = new URL(window.location.href);
  952. if(params.searchParams.has('t')) {
  953. const tab = params.searchParams.get('t');
  954. if(this.tabbies.includes(tab)) {
  955. this.tabIndex = tab;
  956. } else {
  957. window.history.pushState(null, null, '/i/admin/settings')
  958. }
  959. }
  960. },
  961. methods: {
  962. toggleTab(idx) {
  963. clearTimeout(this.isSubmittingTimeoutHandler)
  964. this.isSubmittingTimeout = false;
  965. this.tabIndex = idx;
  966. this.showAllRules = false;
  967. if(this.tabbies.includes(idx)) {
  968. window.history.pushState(null, null, '/i/admin/settings?t=' + idx);
  969. } else {
  970. window.history.pushState(null, null, '/i/admin/settings');
  971. }
  972. },
  973. fetchInitialData() {
  974. axios.get('/i/admin/api/settings/fetch')
  975. .then(res => {
  976. this.initialData = res.data;
  977. this.features = res.data.features;
  978. this.landing = res.data.landing;
  979. this.branding = res.data.branding;
  980. this.media = res.data.media;
  981. this.setMediaTypes();
  982. this.rules = res.data.rules;
  983. this.users = res.data.users;
  984. this.suggestedRules = res.data['suggested_rules'];
  985. this.posts = res.data.posts;
  986. this.platform = res.data.platform;
  987. this.storage = res.data.storage;
  988. })
  989. .then(() => {
  990. this.loaded = true;
  991. })
  992. },
  993. setMediaTypes() {
  994. const types = this.media.media_types.split(',');
  995. if(types && types.length) {
  996. types.forEach((type) => {
  997. let mime = type.split('/')[1];
  998. if(['jpeg', 'png', 'gif', 'webp', 'mp4'].includes(mime)) {
  999. this.mediaTypes[mime] = true;
  1000. }
  1001. })
  1002. }
  1003. },
  1004. formatCount(c) {
  1005. return window.App.util.format.count(c);
  1006. },
  1007. formatDateTime(ts) {
  1008. let date = new Date(ts);
  1009. return new Intl.DateTimeFormat('en-US', {dateStyle: 'medium', timeStyle: 'short'}).format(date);
  1010. },
  1011. formatDate(ts) {
  1012. let date = new Date(ts);
  1013. return new Intl.DateTimeFormat('en-US', {month: 'short', year: 'numeric'}).format(date);
  1014. },
  1015. formatTimestamp(ts) {
  1016. return window.App.util.format.timeAgo(ts);
  1017. },
  1018. handleSave(type) {
  1019. this.isSubmitting = true;
  1020. switch(type) {
  1021. case 'overview':
  1022. return this.saveHome();
  1023. break;
  1024. case 'landing':
  1025. return this.saveLanding();
  1026. break;
  1027. case 'branding':
  1028. return this.saveBranding();
  1029. break;
  1030. case 'posts':
  1031. return this.savePosts();
  1032. break;
  1033. case 'media':
  1034. return this.saveMedia();
  1035. break;
  1036. case 'platform':
  1037. return this.savePlatform();
  1038. break;
  1039. case 'users':
  1040. return this.saveUsers();
  1041. break;
  1042. case 'storage':
  1043. return this.saveStorage();
  1044. break;
  1045. }
  1046. },
  1047. handleAddRule($event) {
  1048. $event.currentTarget?.blur();
  1049. this.isSubmittingNewRule = true;
  1050. axios.post('/i/admin/api/settings/rules/add', {
  1051. rule: this.newRule
  1052. }).then(res => {
  1053. this.rules.push(this.newRule);
  1054. this.newRule = undefined;
  1055. this.isSubmittingNewRule = false;
  1056. this.showAllRules = true;
  1057. })
  1058. .catch(err => {
  1059. if(err.response.data && err.response.data?.message) {
  1060. swal('Error', err.response.data.message, 'error');
  1061. }
  1062. this.isSubmittingNewRule = false;
  1063. })
  1064. },
  1065. addSuggestedRule(rule, $event) {
  1066. $event.currentTarget?.blur();
  1067. this.newRule = rule;
  1068. },
  1069. importAllDefaultRules($event) {
  1070. $event.currentTarget?.blur();
  1071. this.isSubmittingNewRule = true;
  1072. this.showAllRules = true;
  1073. for (var i = this.suggestedRules.length - 1; i >= 0; i--) {
  1074. const rule = this.suggestedRules[i]
  1075. setTimeout(() => {
  1076. axios.post('/i/admin/api/settings/rules/add', {
  1077. rule: rule
  1078. }).then(res => {
  1079. this.rules.push(rule);
  1080. })
  1081. }, (i * 300))
  1082. }
  1083. this.isSubmittingNewRule = false;
  1084. },
  1085. handleDeleteRule(rule, idx, $event) {
  1086. $event.currentTarget?.blur();
  1087. this.isDeletingRule = true;
  1088. axios.post('/i/admin/api/settings/rules/delete', {
  1089. rule: rule,
  1090. }).then(res => {
  1091. this.isDeletingRule = false;
  1092. this.rules = res.data;
  1093. })
  1094. .catch(err => {
  1095. })
  1096. },
  1097. handleDeleteAllRules($event) {
  1098. $event.currentTarget?.blur();
  1099. this.isDeletingRule = true;
  1100. swal({
  1101. title: 'Confirm',
  1102. text: 'Are you sure you want to delete all rules?',
  1103. buttons: true,
  1104. dangerMode: true,
  1105. }).then(res => {
  1106. if(res === true) {
  1107. axios.post('/i/admin/api/settings/rules/delete/all')
  1108. .then(res => {
  1109. this.isDeletingRule = false;
  1110. this.rules = []
  1111. })
  1112. .catch(err => {
  1113. })
  1114. } else {
  1115. this.isDeletingRule = false;
  1116. }
  1117. })
  1118. },
  1119. removeAutofollow(username, $event) {
  1120. $event.currentTarget?.blur();
  1121. axios.post('/i/admin/api/settings/autofollow/delete', {
  1122. username: username
  1123. }).then(res => {
  1124. this.users.admin_autofollow_accounts = res.data.accounts;
  1125. }).catch(err => {
  1126. swal("Oops!", "An error occurred, please try again later!", "error");
  1127. });
  1128. },
  1129. addAutofollow($event) {
  1130. $event.currentTarget?.blur();
  1131. swal({
  1132. text: 'Enter account username',
  1133. content: "input",
  1134. button: {
  1135. text: "Add Autofollow",
  1136. closeModal: false,
  1137. },
  1138. }).then(username => {
  1139. if (!username) throw null;
  1140. axios.post('/i/admin/api/settings/autofollow/add', {
  1141. username: username
  1142. })
  1143. .then(res => {
  1144. if(!res.data.accounts.map(acc => acc.toLowerCase()).includes(username.toLowerCase())) {
  1145. swal("Oops!", "The account you attempted to add does not exist or cannot be added!", "error");
  1146. }
  1147. this.users.admin_autofollow_accounts = res.data.accounts;
  1148. swal.stopLoading();
  1149. swal.close();
  1150. })
  1151. .catch(err => {
  1152. if(err.response.data && err.response.data.message) {
  1153. swal('Error', err.response.data.message, 'error');
  1154. } else {
  1155. swal("Oops!", "The account you attempted to add does not exist or cannot be added!", "error");
  1156. }
  1157. swal.stopLoading();
  1158. swal.close();
  1159. });
  1160. })
  1161. },
  1162. saveHome() {
  1163. axios.post('/i/admin/api/settings/update/home', {
  1164. registration_status: this.features.registration_status,
  1165. cloud_storage: this.features.cloud_storage,
  1166. activitypub_enabled: this.features.activitypub_enabled,
  1167. account_migration: this.features.account_migration,
  1168. mobile_apis: this.features.mobile_apis,
  1169. stories: this.features.stories,
  1170. instagram_import: this.features.instagram_import,
  1171. autospam_enabled: this.features.autospam_enabled,
  1172. authorized_fetch: this.features.authorized_fetch,
  1173. }).then(res => {
  1174. this.isSubmitting = false;
  1175. this.isSubmittingTimeout = true;
  1176. this.isSubmittingTimeoutHandler = setTimeout(() => {
  1177. this.isSubmittingTimeout = false;
  1178. }, 4000);
  1179. })
  1180. },
  1181. saveLanding() {
  1182. axios.post('/i/admin/api/settings/update/landing', {
  1183. current_admin: this.landing.current_admin,
  1184. show_directory: this.landing.show_directory,
  1185. show_explore: this.landing.show_explore
  1186. }).then(res => {
  1187. this.isSubmitting = false;
  1188. this.isSubmittingTimeout = true;
  1189. this.isSubmittingTimeoutHandler = setTimeout(() => {
  1190. this.isSubmittingTimeout = false;
  1191. }, 4000);
  1192. })
  1193. },
  1194. saveBranding() {
  1195. axios.post('/i/admin/api/settings/update/branding', {
  1196. name: this.branding.name,
  1197. short_description: this.branding.short_description,
  1198. long_description: this.branding.long_description
  1199. }).then(res => {
  1200. this.isSubmitting = false;
  1201. this.isSubmittingTimeout = true;
  1202. this.isSubmittingTimeoutHandler = setTimeout(() => {
  1203. this.isSubmittingTimeout = false;
  1204. }, 4000);
  1205. })
  1206. },
  1207. savePosts() {
  1208. axios.post('/i/admin/api/settings/update/posts', {
  1209. max_caption_length: this.posts.max_caption_length,
  1210. max_altext_length: this.posts.max_altext_length,
  1211. }).then(res => {
  1212. this.posts = res.data;
  1213. this.isSubmitting = false;
  1214. this.isSubmittingTimeout = true;
  1215. this.isSubmittingTimeoutHandler = setTimeout(() => {
  1216. this.isSubmittingTimeout = false;
  1217. }, 4000);
  1218. })
  1219. .catch(err => {
  1220. this.isSubmitting = false;
  1221. if(err.response.data && err.response.data.message) {
  1222. swal('Error', err.response.data.message, 'error');
  1223. } else {
  1224. swal('Oops!', 'An error occured', 'error');
  1225. }
  1226. })
  1227. },
  1228. saveMedia() {
  1229. axios.post('/i/admin/api/settings/update/media', {
  1230. image_quality: this.media.image_quality,
  1231. max_album_length: this.media.max_album_length,
  1232. max_photo_size: this.media.max_photo_size,
  1233. media_types: this.activeMediaTypes,
  1234. optimize_image: this.media.optimize_image,
  1235. optimize_video: this.media.optimize_video,
  1236. }).then(res => {
  1237. this.isSubmitting = false;
  1238. this.isSubmittingTimeout = true;
  1239. this.isSubmittingTimeoutHandler = setTimeout(() => {
  1240. this.isSubmittingTimeout = false;
  1241. }, 4000);
  1242. }).catch(err => {
  1243. this.isSubmitting = false;
  1244. if(err.response.data && err.response.data.message) {
  1245. swal('Error', err.response.data.message, 'error');
  1246. } else {
  1247. swal('Oops!', 'An error occured', 'error');
  1248. }
  1249. })
  1250. },
  1251. savePlatform() {
  1252. axios.post('/i/admin/api/settings/update/platform', {
  1253. allow_app_registration: this.platform.allow_app_registration,
  1254. app_registration_rate_limit_attempts: this.platform.app_registration_rate_limit_attempts,
  1255. app_registration_rate_limit_decay: this.platform.app_registration_rate_limit_decay,
  1256. app_registration_confirm_rate_limit_attempts: this.platform.app_registration_confirm_rate_limit_attempts,
  1257. app_registration_confirm_rate_limit_decay: this.platform.app_registration_confirm_rate_limit_decay,
  1258. allow_post_embeds: this.platform.allow_post_embeds,
  1259. allow_profile_embeds: this.platform.allow_profile_embeds,
  1260. captcha_enabled: this.platform.captcha_enabled,
  1261. captcha_secret: this.platform.captcha_secret,
  1262. captcha_sitekey: this.platform.captcha_sitekey,
  1263. captcha_on_login: this.platform.captcha_on_login,
  1264. captcha_on_register: this.platform.captcha_on_register,
  1265. custom_emoji_enabled: this.platform.custom_emoji_enabled,
  1266. }).then(res => {
  1267. this.platform = res.data;
  1268. this.isSubmitting = false;
  1269. this.isSubmittingTimeout = true;
  1270. this.isSubmittingTimeoutHandler = setTimeout(() => {
  1271. this.isSubmittingTimeout = false;
  1272. }, 4000);
  1273. })
  1274. .catch(err => {
  1275. this.isSubmitting = false;
  1276. if(err.response.data && err.response.data.message) {
  1277. swal('Error', err.response.data.message, 'error');
  1278. } else {
  1279. swal('Oops!', 'An error occured', 'error');
  1280. }
  1281. })
  1282. },
  1283. saveUsers() {
  1284. axios.post('/i/admin/api/settings/update/users', {
  1285. require_email_verification: this.users.require_email_verification,
  1286. enforce_account_limit: this.users.enforce_account_limit,
  1287. max_account_size: this.users.max_account_size,
  1288. admin_autofollow: this.users.admin_autofollow,
  1289. admin_autofollow_accounts: this.users.admin_autofollow_accounts,
  1290. max_user_blocks: this.users.max_user_blocks,
  1291. max_user_mutes: this.users.max_user_mutes,
  1292. max_domain_blocks: this.users.max_domain_blocks,
  1293. }).then(res => {
  1294. this.isSubmitting = false;
  1295. this.isSubmittingTimeout = true;
  1296. this.isSubmittingTimeoutHandler = setTimeout(() => {
  1297. this.isSubmittingTimeout = false;
  1298. }, 4000);
  1299. }).catch(err => {
  1300. if(err.response.data.message) {
  1301. swal('Error', err.response.data.message, 'error');
  1302. } else {
  1303. swal('Error', 'An unexpected error occurred, please try again!', 'error');
  1304. }
  1305. this.isSubmitting = false;
  1306. })
  1307. },
  1308. saveStorage() {
  1309. let data = this.showDiskConfig ?
  1310. {
  1311. primary_disk: this.storage.primary_disk,
  1312. update_disk: true,
  1313. disk_config: this.storage.disk_config,
  1314. } : {
  1315. primary_disk: this.storage.primary_disk,
  1316. }
  1317. axios.post('/i/admin/api/settings/update/storage', data)
  1318. .then(res => {
  1319. this.features.cloud_storage = res.data.primary_disk === 'cloud';
  1320. this.isSubmitting = false;
  1321. this.isSubmittingTimeout = true;
  1322. this.isSubmittingTimeoutHandler = setTimeout(() => {
  1323. this.isSubmittingTimeout = false;
  1324. }, 4000);
  1325. }).catch(err => {
  1326. if(err.response.data.error) {
  1327. if(err.response.data.s3_vce) {
  1328. let el = document.createElement('div');
  1329. el.classList.add('text-left');
  1330. el.innerHTML = err.response.data.message;
  1331. let wrapper = document.createElement('div');
  1332. wrapper.appendChild(el);
  1333. swal({
  1334. title: 'Invalid S3 Credentials',
  1335. content: wrapper,
  1336. icon: 'error'
  1337. });
  1338. } else {
  1339. swal('Error', err.response.data.message, 'error');
  1340. }
  1341. }
  1342. this.isSubmitting = false;
  1343. })
  1344. },
  1345. handleChange($event, cat, type) {
  1346. switch(cat) {
  1347. case 'features':
  1348. this.features[type] = $event;
  1349. break;
  1350. case 'landing':
  1351. this.landing[type] = $event;
  1352. break;
  1353. case 'platform':
  1354. this.platform[type] = $event;
  1355. break;
  1356. case 'media':
  1357. this.media[type] = $event;
  1358. break;
  1359. case 'users':
  1360. this.users[type] = $event;
  1361. break;
  1362. case 'storage':
  1363. this.storage[type] = $event;
  1364. break;
  1365. }
  1366. console.log($event)
  1367. console.log(type)
  1368. },
  1369. handleSubChange($event, cat, type, sub) {
  1370. switch(cat) {
  1371. case 'features':
  1372. this.features[type][sub] = $event;
  1373. break;
  1374. case 'landing':
  1375. this.landing[type][sub] = $event;
  1376. break;
  1377. case 'platform':
  1378. this.platform[type][sub] = $event;
  1379. break;
  1380. case 'media':
  1381. this.media[type][sub] = $event;
  1382. break;
  1383. case 'users':
  1384. this.users[type][sub] = $event;
  1385. break;
  1386. case 'storage':
  1387. this.storage[type][sub] = $event;
  1388. break;
  1389. }
  1390. console.log($event)
  1391. console.log(type)
  1392. },
  1393. },
  1394. watch: {
  1395. }
  1396. }
  1397. </script>
  1398. <style lang="scss" scoped>
  1399. .rule-badge {
  1400. display: flex;
  1401. width: 34px;
  1402. height: 34px;
  1403. justify-content: center;
  1404. align-items: center;
  1405. background-color: #fff;
  1406. border-radius: 34px;
  1407. border: 2px solid var(--primary);
  1408. &-inner {
  1409. display: flex;
  1410. justify-content: center;
  1411. align-items: center;
  1412. width: 26px;
  1413. height: 26px;
  1414. border-radius: 26px;
  1415. background-color: var(--primary);
  1416. color: #fff;
  1417. font-weight: bold;
  1418. font-size: 13px;
  1419. }
  1420. }
  1421. .rule-text {
  1422. max-width: 90%;
  1423. margin-bottom: 0px;
  1424. font-size: 14px;
  1425. }
  1426. .gap-1 {
  1427. gap: 1rem;
  1428. }
  1429. </style>