From 2e5b80bc38f16ab3d6ea58202f1d03f037219187 Mon Sep 17 00:00:00 2001 From: a-ill Date: Tue, 1 Aug 2023 17:22:01 +0300 Subject: [PATCH] Added member and contact changing to groups --- .../app/resources/groups/GroupsController.jl | 29 + .../svelte/src/profile/profile-groups.svelte | 39 +- Server/public/js/components/index-1f2eaab8.js | 53 ++ Server/public/js/components/index-8c3676b2.js | 524 ++++++++++++++++++ Server/public/js/components/profile-groups.js | 2 +- Server/routes.jl | 4 + 6 files changed, 635 insertions(+), 16 deletions(-) create mode 100644 Server/public/js/components/index-1f2eaab8.js create mode 100644 Server/public/js/components/index-8c3676b2.js diff --git a/Server/app/resources/groups/GroupsController.jl b/Server/app/resources/groups/GroupsController.jl index d6cf7b5..63cc79b 100644 --- a/Server/app/resources/groups/GroupsController.jl +++ b/Server/app/resources/groups/GroupsController.jl @@ -258,4 +258,33 @@ function add_verified_groups() delete_from_table("groups_requests",["user_id" => user_id]) end +function changeMemberCount() + user_id = get_authentication() + groups_ids = select_from_table("users_groups" => ["group_id"], where_data = ["user_id" => user_id])[:,1] + group_id = isempty(groups_ids) ? nothing : groups_ids[1] + data = copy(jsonpayload()) + update_table("groups",data, where_data=["id" => group_id]) +end + +function change_group() + user_id = get_authentication() + groups_ids = select_from_table("users_groups" => ["group_id"], where_data = ["user_id" => user_id])[:,1] + group_id = isempty(groups_ids) ? nothing : groups_ids[1] + if !isnothing(group_id) + data = copy(jsonpayload()) + data_new = Dict() + ks = keys(data) + for x in ["members","contact"] + if x in ks + data_new[x] = data[x] + end + end + if !isempty(data_new) + update_table("groups",data_new, where_data=["id" => group_id]) + end + end + return nothing +end + + end diff --git a/Server/app/svelte/src/profile/profile-groups.svelte b/Server/app/svelte/src/profile/profile-groups.svelte index cdeafe2..7ac4be9 100644 --- a/Server/app/svelte/src/profile/profile-groups.svelte +++ b/Server/app/svelte/src/profile/profile-groups.svelte @@ -34,6 +34,11 @@ let locale = "en" + let oldValues = { + "contact": null, + "members": null, + } + let inputLocation let inputContact let inputMembers @@ -85,14 +90,6 @@ } } - function launchChangeLocation() { - showLocationOverlay() - } - - function launchChangeMembers() { - - } - function showSaveButton(button,input) { if (!input.readOnly) { button.style.display = "initial" @@ -101,23 +98,33 @@ function resetMembersField() { saveMembersButton.style.display = "none" + inputMembers = oldValues["members"] } function resetContactField() { saveContactButton.style.display = "none" + inputContact = oldValues["contact"] } function saveMembers() { - let email = emailInput.value - if (AuthTools.checkEmail(email,emailMsg)) { - if (email!=user.email) { - AuthTools.changeUser("email",email,user) - } - resetMembersField() + let val = parseInt(membersInput.value) + let data = { + "members": val } + sendData("/xx/group-change",data) + oldValues["members"] = val + saveMembersButton.style.display = "none" } - function saveContact() {} + function saveContact() { + let val = contactInput.value + let data = { + "contact": val + } + sendData("/xx/group-change",data) + oldValues["contact"] = val + saveContactButton.style.display = "none" + } function updateUserGroup(newInfo) { if (newInfo!=undefined) { @@ -159,7 +166,9 @@ let group = userGroups[0] inputContact = getContact(group.contact) + oldValues["contact"] = inputContact inputMembers = group.members + oldValues["members"] = inputMembers let status = group.status if (status!=undefined) { if (status==0) { diff --git a/Server/public/js/components/index-1f2eaab8.js b/Server/public/js/components/index-1f2eaab8.js new file mode 100644 index 0000000..e88d822 --- /dev/null +++ b/Server/public/js/components/index-1f2eaab8.js @@ -0,0 +1,53 @@ + +(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document); +import { n as noop, s as safe_not_equal } from './index-8c3676b2.js'; + +const subscriber_queue = []; +/** + * Create a `Writable` store that allows both updating and reading by subscription. + * @param {*=}value initial value + * @param {StartStopNotifier=}start start and stop notifications for subscriptions + */ +function writable(value, start = noop) { + let stop; + const subscribers = new Set(); + function set(new_value) { + if (safe_not_equal(value, new_value)) { + value = new_value; + if (stop) { // store is ready + const run_queue = !subscriber_queue.length; + for (const subscriber of subscribers) { + subscriber[1](); + subscriber_queue.push(subscriber, value); + } + if (run_queue) { + for (let i = 0; i < subscriber_queue.length; i += 2) { + subscriber_queue[i][0](subscriber_queue[i + 1]); + } + subscriber_queue.length = 0; + } + } + } + } + function update(fn) { + set(fn(value)); + } + function subscribe(run, invalidate = noop) { + const subscriber = [run, invalidate]; + subscribers.add(subscriber); + if (subscribers.size === 1) { + stop = start(set) || noop; + } + run(value); + return () => { + subscribers.delete(subscriber); + if (subscribers.size === 0) { + stop(); + stop = null; + } + }; + } + return { set, update, subscribe }; +} + +export { writable as w }; diff --git a/Server/public/js/components/index-8c3676b2.js b/Server/public/js/components/index-8c3676b2.js new file mode 100644 index 0000000..b259d92 --- /dev/null +++ b/Server/public/js/components/index-8c3676b2.js @@ -0,0 +1,524 @@ + +(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document); +function noop() { } +function add_location(element, file, line, column, char) { + element.__svelte_meta = { + loc: { file, line, column, char } + }; +} +function run(fn) { + return fn(); +} +function blank_object() { + return Object.create(null); +} +function run_all(fns) { + fns.forEach(run); +} +function is_function(thing) { + return typeof thing === 'function'; +} +function safe_not_equal(a, b) { + return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); +} +let src_url_equal_anchor; +function src_url_equal(element_src, url) { + if (!src_url_equal_anchor) { + src_url_equal_anchor = document.createElement('a'); + } + src_url_equal_anchor.href = url; + return element_src === src_url_equal_anchor.href; +} +function is_empty(obj) { + return Object.keys(obj).length === 0; +} +function validate_store(store, name) { + if (store != null && typeof store.subscribe !== 'function') { + throw new Error(`'${name}' is not a store with a 'subscribe' method`); + } +} +function subscribe(store, ...callbacks) { + if (store == null) { + return noop; + } + const unsub = store.subscribe(...callbacks); + return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub; +} +function component_subscribe(component, store, callback) { + component.$$.on_destroy.push(subscribe(store, callback)); +} +function append(target, node) { + target.appendChild(node); +} +function insert(target, node, anchor) { + target.insertBefore(node, anchor || null); +} +function detach(node) { + node.parentNode.removeChild(node); +} +function destroy_each(iterations, detaching) { + for (let i = 0; i < iterations.length; i += 1) { + if (iterations[i]) + iterations[i].d(detaching); + } +} +function element(name) { + return document.createElement(name); +} +function svg_element(name) { + return document.createElementNS('http://www.w3.org/2000/svg', name); +} +function text(data) { + return document.createTextNode(data); +} +function space() { + return text(' '); +} +function empty() { + return text(''); +} +function listen(node, event, handler, options) { + node.addEventListener(event, handler, options); + return () => node.removeEventListener(event, handler, options); +} +function attr(node, attribute, value) { + if (value == null) + node.removeAttribute(attribute); + else if (node.getAttribute(attribute) !== value) + node.setAttribute(attribute, value); +} +function set_custom_element_data(node, prop, value) { + if (prop in node) { + node[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value; + } + else { + attr(node, prop, value); + } +} +function children(element) { + return Array.from(element.childNodes); +} +function set_input_value(input, value) { + input.value = value == null ? '' : value; +} +function set_style(node, key, value, important) { + if (value === null) { + node.style.removeProperty(key); + } + else { + node.style.setProperty(key, value, important ? 'important' : ''); + } +} +function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) { + const e = document.createEvent('CustomEvent'); + e.initCustomEvent(type, bubbles, cancelable, detail); + return e; +} +class HtmlTag { + constructor(is_svg = false) { + this.is_svg = false; + this.is_svg = is_svg; + this.e = this.n = null; + } + c(html) { + this.h(html); + } + m(html, target, anchor = null) { + if (!this.e) { + if (this.is_svg) + this.e = svg_element(target.nodeName); + else + this.e = element(target.nodeName); + this.t = target; + this.c(html); + } + this.i(anchor); + } + h(html) { + this.e.innerHTML = html; + this.n = Array.from(this.e.childNodes); + } + i(anchor) { + for (let i = 0; i < this.n.length; i += 1) { + insert(this.t, this.n[i], anchor); + } + } + p(html) { + this.d(); + this.h(html); + this.i(this.a); + } + d() { + this.n.forEach(detach); + } +} +function attribute_to_object(attributes) { + const result = {}; + for (const attribute of attributes) { + result[attribute.name] = attribute.value; + } + return result; +} + +let current_component; +function set_current_component(component) { + current_component = component; +} +function get_current_component() { + if (!current_component) + throw new Error('Function called outside component initialization'); + return current_component; +} +/** + * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM. + * It must be called during the component's initialisation (but doesn't need to live *inside* the component; + * it can be called from an external module). + * + * `onMount` does not run inside a [server-side component](/docs#run-time-server-side-component-api). + * + * https://svelte.dev/docs#run-time-svelte-onmount + */ +function onMount(fn) { + get_current_component().$$.on_mount.push(fn); +} +/** + * Schedules a callback to run immediately after the component has been updated. + * + * The first time the callback runs will be after the initial `onMount` + */ +function afterUpdate(fn) { + get_current_component().$$.after_update.push(fn); +} +/** + * Associates an arbitrary `context` object with the current component and the specified `key` + * and returns that object. The context is then available to children of the component + * (including slotted content) with `getContext`. + * + * Like lifecycle functions, this must be called during component initialisation. + * + * https://svelte.dev/docs#run-time-svelte-setcontext + */ +function setContext(key, context) { + get_current_component().$$.context.set(key, context); + return context; +} +/** + * Retrieves the context that belongs to the closest parent component with the specified `key`. + * Must be called during component initialisation. + * + * https://svelte.dev/docs#run-time-svelte-getcontext + */ +function getContext(key) { + return get_current_component().$$.context.get(key); +} + +const dirty_components = []; +const binding_callbacks = []; +const render_callbacks = []; +const flush_callbacks = []; +const resolved_promise = Promise.resolve(); +let update_scheduled = false; +function schedule_update() { + if (!update_scheduled) { + update_scheduled = true; + resolved_promise.then(flush); + } +} +function add_render_callback(fn) { + render_callbacks.push(fn); +} +// flush() calls callbacks in this order: +// 1. All beforeUpdate callbacks, in order: parents before children +// 2. All bind:this callbacks, in reverse order: children before parents. +// 3. All afterUpdate callbacks, in order: parents before children. EXCEPT +// for afterUpdates called during the initial onMount, which are called in +// reverse order: children before parents. +// Since callbacks might update component values, which could trigger another +// call to flush(), the following steps guard against this: +// 1. During beforeUpdate, any updated components will be added to the +// dirty_components array and will cause a reentrant call to flush(). Because +// the flush index is kept outside the function, the reentrant call will pick +// up where the earlier call left off and go through all dirty components. The +// current_component value is saved and restored so that the reentrant call will +// not interfere with the "parent" flush() call. +// 2. bind:this callbacks cannot trigger new flush() calls. +// 3. During afterUpdate, any updated components will NOT have their afterUpdate +// callback called a second time; the seen_callbacks set, outside the flush() +// function, guarantees this behavior. +const seen_callbacks = new Set(); +let flushidx = 0; // Do *not* move this inside the flush() function +function flush() { + const saved_component = current_component; + do { + // first, call beforeUpdate functions + // and update components + while (flushidx < dirty_components.length) { + const component = dirty_components[flushidx]; + flushidx++; + set_current_component(component); + update(component.$$); + } + set_current_component(null); + dirty_components.length = 0; + flushidx = 0; + while (binding_callbacks.length) + binding_callbacks.pop()(); + // then, once components are updated, call + // afterUpdate functions. This may cause + // subsequent updates... + for (let i = 0; i < render_callbacks.length; i += 1) { + const callback = render_callbacks[i]; + if (!seen_callbacks.has(callback)) { + // ...so guard against infinite loops + seen_callbacks.add(callback); + callback(); + } + } + render_callbacks.length = 0; + } while (dirty_components.length); + while (flush_callbacks.length) { + flush_callbacks.pop()(); + } + update_scheduled = false; + seen_callbacks.clear(); + set_current_component(saved_component); +} +function update($$) { + if ($$.fragment !== null) { + $$.update(); + run_all($$.before_update); + const dirty = $$.dirty; + $$.dirty = [-1]; + $$.fragment && $$.fragment.p($$.ctx, dirty); + $$.after_update.forEach(add_render_callback); + } +} +const outroing = new Set(); +function transition_in(block, local) { + if (block && block.i) { + outroing.delete(block); + block.i(local); + } +} + +const globals = (typeof window !== 'undefined' + ? window + : typeof globalThis !== 'undefined' + ? globalThis + : global); +function mount_component(component, target, anchor, customElement) { + const { fragment, after_update } = component.$$; + fragment && fragment.m(target, anchor); + if (!customElement) { + // onMount happens before the initial afterUpdate + add_render_callback(() => { + const new_on_destroy = component.$$.on_mount.map(run).filter(is_function); + // if the component was destroyed immediately + // it will update the `$$.on_destroy` reference to `null`. + // the destructured on_destroy may still reference to the old array + if (component.$$.on_destroy) { + component.$$.on_destroy.push(...new_on_destroy); + } + else { + // Edge case - component was destroyed immediately, + // most likely as a result of a binding initialising + run_all(new_on_destroy); + } + component.$$.on_mount = []; + }); + } + after_update.forEach(add_render_callback); +} +function destroy_component(component, detaching) { + const $$ = component.$$; + if ($$.fragment !== null) { + run_all($$.on_destroy); + $$.fragment && $$.fragment.d(detaching); + // TODO null out other refs, including component.$$ (but need to + // preserve final state?) + $$.on_destroy = $$.fragment = null; + $$.ctx = []; + } +} +function make_dirty(component, i) { + if (component.$$.dirty[0] === -1) { + dirty_components.push(component); + schedule_update(); + component.$$.dirty.fill(0); + } + component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); +} +function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) { + const parent_component = current_component; + set_current_component(component); + const $$ = component.$$ = { + fragment: null, + ctx: [], + // state + props, + update: noop, + not_equal, + bound: blank_object(), + // lifecycle + on_mount: [], + on_destroy: [], + on_disconnect: [], + before_update: [], + after_update: [], + context: new Map(options.context || (parent_component ? parent_component.$$.context : [])), + // everything else + callbacks: blank_object(), + dirty, + skip_bound: false, + root: options.target || parent_component.$$.root + }; + append_styles && append_styles($$.root); + let ready = false; + $$.ctx = instance + ? instance(component, options.props || {}, (i, ret, ...rest) => { + const value = rest.length ? rest[0] : ret; + if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { + if (!$$.skip_bound && $$.bound[i]) + $$.bound[i](value); + if (ready) + make_dirty(component, i); + } + return ret; + }) + : []; + $$.update(); + ready = true; + run_all($$.before_update); + // `false` as a special case of no DOM component + $$.fragment = create_fragment ? create_fragment($$.ctx) : false; + if (options.target) { + if (options.hydrate) { + const nodes = children(options.target); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + $$.fragment && $$.fragment.l(nodes); + nodes.forEach(detach); + } + else { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + $$.fragment && $$.fragment.c(); + } + if (options.intro) + transition_in(component.$$.fragment); + mount_component(component, options.target, options.anchor, options.customElement); + flush(); + } + set_current_component(parent_component); +} +let SvelteElement; +if (typeof HTMLElement === 'function') { + SvelteElement = class extends HTMLElement { + constructor() { + super(); + this.attachShadow({ mode: 'open' }); + } + connectedCallback() { + const { on_mount } = this.$$; + this.$$.on_disconnect = on_mount.map(run).filter(is_function); + // @ts-ignore todo: improve typings + for (const key in this.$$.slotted) { + // @ts-ignore todo: improve typings + this.appendChild(this.$$.slotted[key]); + } + } + attributeChangedCallback(attr, _oldValue, newValue) { + this[attr] = newValue; + } + disconnectedCallback() { + run_all(this.$$.on_disconnect); + } + $destroy() { + destroy_component(this, 1); + this.$destroy = noop; + } + $on(type, callback) { + // TODO should this delegate to addEventListener? + if (!is_function(callback)) { + return noop; + } + const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = [])); + callbacks.push(callback); + return () => { + const index = callbacks.indexOf(callback); + if (index !== -1) + callbacks.splice(index, 1); + }; + } + $set($$props) { + if (this.$$set && !is_empty($$props)) { + this.$$.skip_bound = true; + this.$$set($$props); + this.$$.skip_bound = false; + } + } + }; +} + +function dispatch_dev(type, detail) { + document.dispatchEvent(custom_event(type, Object.assign({ version: '3.52.0' }, detail), { bubbles: true })); +} +function append_dev(target, node) { + dispatch_dev('SvelteDOMInsert', { target, node }); + append(target, node); +} +function insert_dev(target, node, anchor) { + dispatch_dev('SvelteDOMInsert', { target, node, anchor }); + insert(target, node, anchor); +} +function detach_dev(node) { + dispatch_dev('SvelteDOMRemove', { node }); + detach(node); +} +function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) { + const modifiers = options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : []; + if (has_prevent_default) + modifiers.push('preventDefault'); + if (has_stop_propagation) + modifiers.push('stopPropagation'); + dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers }); + const dispose = listen(node, event, handler, options); + return () => { + dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers }); + dispose(); + }; +} +function attr_dev(node, attribute, value) { + attr(node, attribute, value); + if (value == null) + dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute }); + else + dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value }); +} +function prop_dev(node, property, value) { + node[property] = value; + dispatch_dev('SvelteDOMSetProperty', { node, property, value }); +} +function set_data_dev(text, data) { + data = '' + data; + if (text.wholeText === data) + return; + dispatch_dev('SvelteDOMSetData', { node: text, data }); + text.data = data; +} +function validate_each_argument(arg) { + if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && 'length' in arg)) { + let msg = '{#each} only iterates over array-like objects.'; + if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) { + msg += ' You can use a spread to convert this iterable into an array.'; + } + throw new Error(msg); + } +} +function validate_slots(name, slot, keys) { + for (const slot_key of Object.keys(slot)) { + if (!~keys.indexOf(slot_key)) { + console.warn(`<${name}> received an unexpected slot "${slot_key}".`); + } + } +} + +export { set_custom_element_data as A, validate_each_argument as B, text as C, set_data_dev as D, destroy_each as E, prop_dev as F, set_style as G, svg_element as H, HtmlTag as I, afterUpdate as J, set_input_value as K, SvelteElement as S, attribute_to_object as a, insert_dev as b, setContext as c, dispatch_dev as d, globals as e, element as f, getContext as g, space as h, init as i, add_location as j, attr_dev as k, append_dev as l, listen_dev as m, noop as n, onMount as o, detach_dev as p, binding_callbacks as q, run_all as r, safe_not_equal as s, flush as t, is_function as u, validate_slots as v, validate_store as w, component_subscribe as x, empty as y, src_url_equal as z }; diff --git a/Server/public/js/components/profile-groups.js b/Server/public/js/components/profile-groups.js index dba7e55..d79aae6 100644 --- a/Server/public/js/components/profile-groups.js +++ b/Server/public/js/components/profile-groups.js @@ -1 +1 @@ -import{S as t,i as e,a as n,b as i,s,q as o,n as l,g as r,t as a,m as u,o as c,j as p,e as d,c as f,w as m,d as h,z as g,f as v,A as b,l as y,p as x,x as w,r as k,y as j}from"./index-5b685137.js";import{w as C}from"./index-8744cf8a.js";import{getData as z,sendData as E}from"../../../../../../../../../js/libraries/serverTools.js";import"../../../../../../../../../js/components/select-component.js";import"../../../../../../../../../js/components/switch-component.js";function T(t,e,n){const i=t.slice();return i[62]=e[n],i[64]=n,i}function q(t){let e,n,o,l,a,u,c,p,j,C,z,E,T,q,A,M,G,I,N,H,S,_,U,F,J,K,Q,B,D,P,V,W,X,Y,Z,$,tt,et,nt,it,st,ot,lt,rt,at,ut,ct,pt,dt,ft,mt,ht,gt=t[1],vt=L(t);return{c(){e=d("div"),n=d("h2"),n.textContent="Groups",o=f(),l=d("div"),a=d("h3"),a.textContent="My group",u=f(),c=d("span"),p=f(),j=d("section"),C=d("div"),z=d("div"),E=d("span"),E.textContent="Location:",T=f(),q=d("div"),A=d("button"),M=m(t[10]),G=f(),I=d("object"),N=f(),H=d("div"),S=d("div"),_=d("span"),_.textContent="Members:",U=f(),F=d("div"),J=d("div"),K=d("button"),K.textContent="save",Q=f(),B=d("input"),D=f(),P=d("button"),V=d("object"),W=f(),X=d("div"),Y=d("div"),Z=d("span"),Z.textContent="Contact:",$=f(),tt=d("div"),et=d("div"),nt=d("button"),nt.textContent="save",it=f(),st=d("input"),ot=f(),lt=d("button"),rt=d("object"),at=f(),ut=d("h3"),ut.textContent="Requests",ct=f(),pt=d("section"),vt.c(),dt=f(),ft=d("groups-add-component"),h(a,"class","group-heading"),h(c,"class","status"),h(I,"type","image/svg+xml"),h(I,"data","/img/profile/icons/pencil.svg"),h(I,"title","pencil-icon"),h(I,"class","pencil"),h(A,"class","change-field-button"),h(q,"class","change-field-div"),h(z,"class","change-field-line"),h(K,"class","save-button"),g(K,"display","none"),h(J,"class","save-button-wrapper"),h(B,"id","membersInput"),h(B,"class","text-input"),h(B,"type","text"),h(V,"type","image/svg+xml"),h(V,"data","/img/profile/icons/pencil.svg"),h(V,"title","pencil-icon"),h(V,"class","pencil"),h(P,"class","text-input-pencil-button"),h(F,"class","change-field-div input-pencil"),h(S,"class","change-field-line"),h(nt,"class","save-button"),g(nt,"display","none"),h(et,"class","save-button-wrapper"),h(st,"id","contactInput"),h(st,"class","text-input"),h(st,"type","text"),h(rt,"type","image/svg+xml"),h(rt,"data","/img/profile/icons/pencil.svg"),h(rt,"title","pencil-icon"),h(rt,"class","pencil"),h(lt,"class","text-input-pencil-button"),h(tt,"class","change-field-div input-pencil"),h(Y,"class","change-field-line"),h(j,"class","entries-section"),h(pt,"class","entries-section"),g(ft,"display","none")},m(s,r){i(s,e,r),v(e,n),v(e,o),v(e,l),v(l,a),v(l,u),v(l,c),t[27](c),v(e,p),v(e,j),v(j,C),v(C,z),v(z,E),v(z,T),v(z,q),v(q,A),v(A,M),v(A,G),v(A,I),t[28](A),v(j,N),v(j,H),v(H,S),v(S,_),v(S,U),v(S,F),v(F,J),v(J,K),t[29](K),v(F,Q),v(F,B),t[30](B),b(B,t[12]),v(F,D),v(F,P),v(P,V),t[33](V),t[34](P),t[36](F),v(j,W),v(j,X),v(X,Y),v(Y,Z),v(Y,$),v(Y,tt),v(tt,et),v(et,nt),t[37](nt),v(tt,it),v(tt,st),t[38](st),b(st,t[11]),v(tt,ot),v(tt,lt),v(lt,rt),t[41](rt),t[42](lt),t[43](tt),t[44](j),v(e,at),v(e,ut),v(e,ct),v(e,pt),vt.m(pt,null),t[47](pt),t[48](e),i(s,dt,r),i(s,ft,r),t[49](ft),mt||(ht=[y(A,"click",t[26]),y(K,"click",t[23]),y(B,"input",t[31]),y(B,"click",t[32]),y(P,"click",t[35]),y(nt,"click",O),y(st,"input",t[39]),y(st,"click",t[40]),y(lt,"click",(function(){x(R(t[7]))&&R(t[7]).apply(this,arguments)}))],mt=!0)},p(e,n){t=e,1024&n[0]&&w(M,t[10]),4096&n[0]&&B.value!==t[12]&&b(B,t[12]),2048&n[0]&&st.value!==t[11]&&b(st,t[11]),2&n[0]&&s(gt,gt=t[1])?(vt.d(1),vt=L(t),vt.c(),vt.m(pt,null)):vt.p(t,n)},d(n){n&&r(e),t[27](null),t[28](null),t[29](null),t[30](null),t[33](null),t[34](null),t[36](null),t[37](null),t[38](null),t[41](null),t[42](null),t[43](null),t[44](null),vt.d(n),t[47](null),t[48](null),n&&r(dt),n&&r(ft),t[49](null),mt=!1,k(ht)}}}function A(t){let e,n,s,o,l,a,u,c,p,b,x,w,j=t[62].email+"";function C(){return t[45](t[64],t[62])}function z(){return t[46](t[64],t[62])}return{c(){e=d("div"),n=d("div"),s=d("span"),o=m(j),l=f(),a=d("div"),u=d("button"),u.textContent="approve",c=f(),p=d("button"),p.textContent="reject",b=f(),h(u,"class","approve-button"),h(p,"class","approve-button"),g(p,"display","visible"),h(a,"class","request-button-wrapper"),h(n,"class","change-field-line")},m(t,r){i(t,e,r),v(e,n),v(n,s),v(s,o),v(n,l),v(n,a),v(a,u),v(a,c),v(a,p),v(e,b),x||(w=[y(u,"click",C),y(p,"click",z)],x=!0)},p(e,n){t=e},d(t){t&&r(e),x=!1,k(w)}}}function L(t){let e,n=t[20],s=[];for(let e=0;en(52,t)));let d=C(0);a(t,d,(t=>n(19,i=t)));let f,m,h,g,v,b,y,x,w,k,j,T,q,A,L,M,G,O=0,H=u("profile-component"),S=H.maps;function _(t){if(null!=t){return[t.country,t.state,t.town].filter((t=>null!=t)).map((t=>t)).join(", ")}return"Create or join group"}function U(){n(5,g.style.display="none",g)}function F(){n(8,y.style.display="none",y)}function J(t){null!=t&&n(17,M.innerHTML=_(t),M)}function K(){if(i==I&&[g,y,v,x].every((t=>null!=t&&null!=t)))if(document.addEventListener("click",(function(t){let e,n=this.activeElement.shadowRoot;null!=n&&(e=n.activeElement,n=e.shadowRoot,null!=n&&(e=n.activeElement)),e==h||e==g?F():e==b||e==y?U():(U(),F())})),H.updateUserGroup=J,n(10,w=_(o[0])),0==o.length)n(11,k=""),n(12,j="");else{let e=o[0];n(11,(t=e.contact,k=null==t?"https://discord.gg/Qk8KUk787z":t)),n(12,j=e.members);let i=e.status;null!=i&&(0==i?(n(18,G.innerHTML="(pending)",G),n(18,G.style.color="#FFC90E",G)):2==i&&(n(18,G.innerHTML="(rejected)",G),n(18,G.style.color="#c52a28",G)),n(13,T.style.display="none",T),n(14,q.style.display="none",q),n(16,L.style.cursor="default",L),n(15,A.style.cursor="default",A),n(4,h.readOnly=!0,h),n(7,b.readOnly=!0,b))}else{setTimeout((()=>K()),100)}var t}function Q(t,e){E("/xx/group-approve-request",{user_id:e}),l.splice(t,1),n(1,O+=1)}function B(t,e){E("/xx/group-reject-request",{user_id:e}),l.splice(t,1),n(1,O+=1)}function D(){n(3,m.style.display="block",m),n(2,f.style.display="none",f),null!=S.groupsAdd&&S.groupsAdd.invalidateSize()}z("/xx/get-user-groups",(function(t){o=JSON.parse(t),H.userGroups=o,d.update((t=>t+1))})),z("/xx/get-group-requests",(function(t){let e=JSON.parse(t);l.push(...e),d.update((t=>t+1))})),H.onLoadedGroups=K,H.launchGroupsAdd=D,H.closeGroupsAdd=function(){n(3,m.style.display="none",m),n(2,f.style.display="block",f)},c((()=>{K()}));return[s,O,f,m,h,g,v,b,y,x,w,k,j,T,q,A,L,M,G,i,l,r,d,function(){let t=emailInput.value;AuthTools.checkEmail(t,emailMsg)&&(t!=user.email&&AuthTools.changeUser("email",t,user),U())},Q,B,D,function(t){p[t?"unshift":"push"]((()=>{G=t,n(18,G)}))},function(t){p[t?"unshift":"push"]((()=>{M=t,n(17,M)}))},function(t){p[t?"unshift":"push"]((()=>{g=t,n(5,g)}))},function(t){p[t?"unshift":"push"]((()=>{h=t,n(4,h)}))},function(){j=this.value,n(12,j)},()=>N(g,h),function(t){p[t?"unshift":"push"]((()=>{T=t,n(13,T)}))},function(t){p[t?"unshift":"push"]((()=>{A=t,n(15,A)}))},()=>{R(h)},function(t){p[t?"unshift":"push"]((()=>{v=t,n(6,v)}))},function(t){p[t?"unshift":"push"]((()=>{y=t,n(8,y)}))},function(t){p[t?"unshift":"push"]((()=>{b=t,n(7,b)}))},function(){k=this.value,n(11,k)},()=>N(y,b),function(t){p[t?"unshift":"push"]((()=>{q=t,n(14,q)}))},function(t){p[t?"unshift":"push"]((()=>{L=t,n(16,L)}))},function(t){p[t?"unshift":"push"]((()=>{x=t,n(9,x)}))},function(t){p[t?"unshift":"push"]((()=>{s=t,n(0,s)}))},(t,e)=>Q(t,e.user_id),(t,e)=>B(t,e.user_id),function(t){p[t?"unshift":"push"]((()=>{s=t,n(0,s)}))},function(t){p[t?"unshift":"push"]((()=>{f=t,n(2,f)}))},function(t){p[t?"unshift":"push"]((()=>{m=t,n(3,m)}))}]}class S extends t{constructor(t){super(),this.shadowRoot.innerHTML="",e(this,{target:this.shadowRoot,props:n(this.attributes),customElement:!0},H,G,s,{},null,[-1,-1,-1]),t&&t.target&&i(t.target,this,t.anchor)}}customElements.define("profile-groups",S);export{S as default}; +import{S as t,i as e,a as n,b as i,s,q as o,n as l,g as r,t as a,m as c,o as u,j as p,e as d,c as f,w as m,d as h,z as g,f as v,A as b,l as y,p as x,x as w,r as k,y as j}from"./index-5b685137.js";import{w as C}from"./index-8744cf8a.js";import{getData as z,sendData as q}from"../../../../../../../../../js/libraries/serverTools.js";import"../../../../../../../../../js/components/select-component.js";import"../../../../../../../../../js/components/switch-component.js";function E(t,e,n){const i=t.slice();return i[64]=e[n],i[66]=n,i}function L(t){let e,n,o,l,a,c,u,p,j,C,z,q,E,L,G,T,A,I,N,R,H,S,_,F,J,U,K,Q,B,D,P,V,W,X,Y,Z,$,tt,et,nt,it,st,ot,lt,rt,at,ct,ut,pt,dt,ft,mt,ht=t[1],gt=M(t);return{c(){e=d("div"),n=d("h2"),n.textContent="Groups",o=f(),l=d("div"),a=d("h3"),a.textContent="My group",c=f(),u=d("span"),p=f(),j=d("section"),C=d("div"),z=d("div"),q=d("span"),q.textContent="Location:",E=f(),L=d("div"),G=d("button"),T=m(t[10]),A=f(),I=d("object"),N=f(),R=d("div"),H=d("div"),S=d("span"),S.textContent="Members:",_=f(),F=d("div"),J=d("div"),U=d("button"),U.textContent="save",K=f(),Q=d("input"),B=f(),D=d("button"),P=d("object"),V=f(),W=d("div"),X=d("div"),Y=d("span"),Y.textContent="Contact:",Z=f(),$=d("div"),tt=d("div"),et=d("button"),et.textContent="save",nt=f(),it=d("input"),st=f(),ot=d("button"),lt=d("object"),rt=f(),at=d("h3"),at.textContent="Requests",ct=f(),ut=d("section"),gt.c(),pt=f(),dt=d("groups-add-component"),h(a,"class","group-heading"),h(u,"class","status"),h(I,"type","image/svg+xml"),h(I,"data","/img/profile/icons/pencil.svg"),h(I,"title","pencil-icon"),h(I,"class","pencil"),h(G,"class","change-field-button"),h(L,"class","change-field-div"),h(z,"class","change-field-line"),h(U,"class","save-button"),g(U,"display","none"),h(J,"class","save-button-wrapper"),h(Q,"id","membersInput"),h(Q,"class","text-input"),h(Q,"type","text"),h(P,"type","image/svg+xml"),h(P,"data","/img/profile/icons/pencil.svg"),h(P,"title","pencil-icon"),h(P,"class","pencil"),h(D,"class","text-input-pencil-button"),h(F,"class","change-field-div input-pencil"),h(H,"class","change-field-line"),h(et,"class","save-button"),g(et,"display","none"),h(tt,"class","save-button-wrapper"),h(it,"id","contactInput"),h(it,"class","text-input"),h(it,"type","text"),h(lt,"type","image/svg+xml"),h(lt,"data","/img/profile/icons/pencil.svg"),h(lt,"title","pencil-icon"),h(lt,"class","pencil"),h(ot,"class","text-input-pencil-button"),h($,"class","change-field-div input-pencil"),h(X,"class","change-field-line"),h(j,"class","entries-section"),h(ut,"class","entries-section"),g(dt,"display","none")},m(s,r){i(s,e,r),v(e,n),v(e,o),v(e,l),v(l,a),v(l,c),v(l,u),t[28](u),v(e,p),v(e,j),v(j,C),v(C,z),v(z,q),v(z,E),v(z,L),v(L,G),v(G,T),v(G,A),v(G,I),t[29](G),v(j,N),v(j,R),v(R,H),v(H,S),v(H,_),v(H,F),v(F,J),v(J,U),t[30](U),v(F,K),v(F,Q),t[31](Q),b(Q,t[12]),v(F,B),v(F,D),v(D,P),t[34](P),t[35](D),t[37](F),v(j,V),v(j,W),v(W,X),v(X,Y),v(X,Z),v(X,$),v($,tt),v(tt,et),t[38](et),v($,nt),v($,it),t[39](it),b(it,t[11]),v($,st),v($,ot),v(ot,lt),t[42](lt),t[43](ot),t[44]($),t[45](j),v(e,rt),v(e,at),v(e,ct),v(e,ut),gt.m(ut,null),t[48](ut),t[49](e),i(s,pt,r),i(s,dt,r),t[50](dt),ft||(mt=[y(G,"click",t[27]),y(U,"click",t[23]),y(Q,"input",t[32]),y(Q,"click",t[33]),y(D,"click",t[36]),y(et,"click",t[24]),y(it,"input",t[40]),y(it,"click",t[41]),y(ot,"click",(function(){x(O(t[7]))&&O(t[7]).apply(this,arguments)}))],ft=!0)},p(e,n){t=e,1024&n[0]&&w(T,t[10]),4096&n[0]&&Q.value!==t[12]&&b(Q,t[12]),2048&n[0]&&it.value!==t[11]&&b(it,t[11]),2&n[0]&&s(ht,ht=t[1])?(gt.d(1),gt=M(t),gt.c(),gt.m(ut,null)):gt.p(t,n)},d(n){n&&r(e),t[28](null),t[29](null),t[30](null),t[31](null),t[34](null),t[35](null),t[37](null),t[38](null),t[39](null),t[42](null),t[43](null),t[44](null),t[45](null),gt.d(n),t[48](null),t[49](null),n&&r(pt),n&&r(dt),t[50](null),ft=!1,k(mt)}}}function G(t){let e,n,s,o,l,a,c,u,p,b,x,w,j=t[64].email+"";function C(){return t[46](t[66],t[64])}function z(){return t[47](t[66],t[64])}return{c(){e=d("div"),n=d("div"),s=d("span"),o=m(j),l=f(),a=d("div"),c=d("button"),c.textContent="approve",u=f(),p=d("button"),p.textContent="reject",b=f(),h(c,"class","approve-button"),h(p,"class","approve-button"),g(p,"display","visible"),h(a,"class","request-button-wrapper"),h(n,"class","change-field-line")},m(t,r){i(t,e,r),v(e,n),v(n,s),v(s,o),v(n,l),v(n,a),v(a,c),v(a,u),v(a,p),v(e,b),x||(w=[y(c,"click",C),y(p,"click",z)],x=!0)},p(e,n){t=e},d(t){t&&r(e),x=!1,k(w)}}}function M(t){let e,n=t[20],s=[];for(let e=0;en(54,t)));let d=C(0);a(t,d,(t=>n(19,i=t)));let f,m,h,g,v,b,y,x,w,k,j,E,L,G,M,T,A,R=0,H={contact:null,members:null},S=c("profile-component"),_=S.maps;function F(t){if(null!=t){return[t.country,t.state,t.town].filter((t=>null!=t)).map((t=>t)).join(", ")}return"Create or join group"}function J(){n(5,g.style.display="none",g),n(12,j=H.members)}function U(){n(8,y.style.display="none",y),n(11,k=H.contact)}function K(t){null!=t&&n(17,T.innerHTML=F(t),T)}function Q(){if(i==I&&[g,y,v,x].every((t=>null!=t&&null!=t)))if(document.addEventListener("click",(function(t){let e,n=this.activeElement.shadowRoot;null!=n&&(e=n.activeElement,n=e.shadowRoot,null!=n&&(e=n.activeElement)),e==h||e==g?U():e==b||e==y?J():(J(),U())})),S.updateUserGroup=K,n(10,w=F(o[0])),0==o.length)n(11,k=""),n(12,j="");else{let e=o[0];n(11,(t=e.contact,k=null==t?"https://discord.gg/Qk8KUk787z":t)),H.contact=k,n(12,j=e.members),H.members=j;let i=e.status;null!=i&&(0==i?(n(18,A.innerHTML="(pending)",A),n(18,A.style.color="#FFC90E",A)):2==i&&(n(18,A.innerHTML="(rejected)",A),n(18,A.style.color="#c52a28",A)),n(13,E.style.display="none",E),n(14,L.style.display="none",L),n(16,M.style.cursor="default",M),n(15,G.style.cursor="default",G),n(4,h.readOnly=!0,h),n(7,b.readOnly=!0,b))}else{setTimeout((()=>Q()),100)}var t}function B(t,e){q("/xx/group-approve-request",{user_id:e}),l.splice(t,1),n(1,R+=1)}function D(t,e){q("/xx/group-reject-request",{user_id:e}),l.splice(t,1),n(1,R+=1)}function P(){n(3,m.style.display="block",m),n(2,f.style.display="none",f),null!=_.groupsAdd&&_.groupsAdd.invalidateSize()}z("/xx/get-user-groups",(function(t){o=JSON.parse(t),S.userGroups=o,d.update((t=>t+1))})),z("/xx/get-group-requests",(function(t){let e=JSON.parse(t);l.push(...e),d.update((t=>t+1))})),S.onLoadedGroups=Q,S.launchGroupsAdd=P,S.closeGroupsAdd=function(){n(3,m.style.display="none",m),n(2,f.style.display="block",f)},u((()=>{Q()}));return[s,R,f,m,h,g,v,b,y,x,w,k,j,E,L,G,M,T,A,i,l,r,d,function(){let t=parseInt(h.value);q("/xx/group-change",{members:t}),H.members=t,n(5,g.style.display="none",g)},function(){let t=b.value;q("/xx/group-change",{contact:t}),H.contact=t,n(8,y.style.display="none",y)},B,D,P,function(t){p[t?"unshift":"push"]((()=>{A=t,n(18,A)}))},function(t){p[t?"unshift":"push"]((()=>{T=t,n(17,T)}))},function(t){p[t?"unshift":"push"]((()=>{g=t,n(5,g)}))},function(t){p[t?"unshift":"push"]((()=>{h=t,n(4,h)}))},function(){j=this.value,n(12,j)},()=>N(g,h),function(t){p[t?"unshift":"push"]((()=>{E=t,n(13,E)}))},function(t){p[t?"unshift":"push"]((()=>{G=t,n(15,G)}))},()=>{O(h)},function(t){p[t?"unshift":"push"]((()=>{v=t,n(6,v)}))},function(t){p[t?"unshift":"push"]((()=>{y=t,n(8,y)}))},function(t){p[t?"unshift":"push"]((()=>{b=t,n(7,b)}))},function(){k=this.value,n(11,k)},()=>N(y,b),function(t){p[t?"unshift":"push"]((()=>{L=t,n(14,L)}))},function(t){p[t?"unshift":"push"]((()=>{M=t,n(16,M)}))},function(t){p[t?"unshift":"push"]((()=>{x=t,n(9,x)}))},function(t){p[t?"unshift":"push"]((()=>{s=t,n(0,s)}))},(t,e)=>B(t,e.user_id),(t,e)=>D(t,e.user_id),function(t){p[t?"unshift":"push"]((()=>{s=t,n(0,s)}))},function(t){p[t?"unshift":"push"]((()=>{f=t,n(2,f)}))},function(t){p[t?"unshift":"push"]((()=>{m=t,n(3,m)}))}]}class H extends t{constructor(t){super(),this.shadowRoot.innerHTML="",e(this,{target:this.shadowRoot,props:n(this.attributes),customElement:!0},R,A,s,{},null,[-1,-1,-1]),t&&t.target&&i(t.target,this,t.anchor)}}customElements.define("profile-groups",H);export{H as default}; diff --git a/Server/routes.jl b/Server/routes.jl index cde01d9..a46e883 100644 --- a/Server/routes.jl +++ b/Server/routes.jl @@ -50,6 +50,10 @@ route("/:locale/group-approve-request/*", GroupsController.approve_request, meth route("/:locale/group-reject-request/*", GroupsController.reject_request, method = POST, named = :group_reject_request) +route("/:locale/group-change/*", GroupsController.change_group, method = POST, named = :group_change) + +route("/:locale/add-verified-groups/*", GroupsController.add_verified_groups, named = :add_verified_groups) + route("/:locale/add-verified-groups/*", GroupsController.add_verified_groups, named = :add_verified_groups) #---Coops----------------------------------------------------------