Introduce group basic federation, event new page and notifications

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-02-18 08:57:00 +01:00
parent 300ef8f245
commit 4144e9ffd0
416 changed files with 32220 additions and 16750 deletions

View File

@@ -1,4 +1,4 @@
async function asyncForEach(array, callback) {
async function asyncForEach(array: Array<any>, callback: Function) {
for (let index = 0; index < array.length; index += 1) {
await callback(array[index], index, array);
}

View File

@@ -5,14 +5,14 @@ import {
AUTH_USER_EMAIL,
AUTH_USER_ID,
AUTH_USER_ROLE,
} from '@/constants';
import { ILogin, IToken } from '@/types/login.model';
import { UPDATE_CURRENT_USER_CLIENT } from '@/graphql/user';
import { onLogout } from '@/vue-apollo';
import ApolloClient from 'apollo-client';
import { ICurrentUserRole } from '@/types/current-user.model';
import { IPerson } from '@/types/actor';
import { IDENTITIES, UPDATE_CURRENT_ACTOR_CLIENT } from '@/graphql/actor';
} from "@/constants";
import { ILogin, IToken } from "@/types/login.model";
import { UPDATE_CURRENT_USER_CLIENT } from "@/graphql/user";
import ApolloClient from "apollo-client";
import { ICurrentUserRole } from "@/types/current-user.model";
import { IPerson } from "@/types/actor";
import { IDENTITIES, UPDATE_CURRENT_ACTOR_CLIENT } from "@/graphql/actor";
import { NormalizedCacheObject } from "apollo-cache-inmemory";
export function saveUserData(obj: ILogin) {
localStorage.setItem(AUTH_USER_ID, `${obj.user.id}`);
@@ -49,21 +49,21 @@ export async function initializeCurrentActor(apollo: ApolloClient<any>) {
const result = await apollo.query({
query: IDENTITIES,
fetchPolicy: 'network-only',
fetchPolicy: "network-only",
});
const identities = result.data.identities;
const { identities } = result.data;
if (identities.length < 1) {
console.warn('Logged user has no identities!');
throw new NoIdentitiesException;
console.warn("Logged user has no identities!");
throw new NoIdentitiesException();
}
const activeIdentity = identities.find(identity => identity.id === actorId) || identities[0] as IPerson;
const activeIdentity = identities.find((identity: IPerson) => identity.id === actorId) || (identities[0] as IPerson);
if (activeIdentity) {
return await changeIdentity(apollo, activeIdentity);
}
}
export async function changeIdentity(apollo: ApolloClient<any>, identity: IPerson) {
export async function changeIdentity(apollo: ApolloClient<NormalizedCacheObject>, identity: IPerson) {
await apollo.mutate({
mutation: UPDATE_CURRENT_ACTOR_CLIENT,
variables: identity,
@@ -71,7 +71,7 @@ export async function changeIdentity(apollo: ApolloClient<any>, identity: IPerso
saveActorData(identity);
}
export async function logout(apollo: ApolloClient<any>) {
export async function logout(apollo: ApolloClient<NormalizedCacheObject>) {
await apollo.mutate({
mutation: UPDATE_CURRENT_USER_CLIENT,
variables: {
@@ -93,6 +93,4 @@ export async function logout(apollo: ApolloClient<any>) {
});
deleteUserData();
await onLogout();
}

View File

@@ -2,7 +2,7 @@ function localeMonthNames(): string[] {
const monthNames: string[] = [];
for (let i = 0; i < 12; i += 1) {
const d = new Date(2019, i, 1);
const month = d.toLocaleString('default', { month: 'long' });
const month = d.toLocaleString("default", { month: "long" });
monthNames.push(month);
}
return monthNames;
@@ -12,7 +12,7 @@ function localeShortWeekDayNames(): string[] {
const weekDayNames: string[] = [];
for (let i = 13; i < 20; i += 1) {
const d = new Date(2019, 9, i);
const weekDay = d.toLocaleString('default', { weekday: 'short' });
const weekDay = d.toLocaleString("default", { weekday: "short" });
weekDayNames.push(weekDay);
}
return weekDayNames;

View File

@@ -1,51 +1,57 @@
import { i18n } from '@/utils/i18n';
import { i18n } from "@/utils/i18n";
export const refreshSuggestion = i18n.t('Please refresh the page and retry.') as string;
export const refreshSuggestion = i18n.t("Please refresh the page and retry.") as string;
export const defaultError: IError = {
match: / /,
value: i18n.t('An error has occurred.') as string,
value: i18n.t("An error has occurred.") as string,
};
export interface IError { match: RegExp; value: string|null; suggestRefresh?: boolean; }
export interface IError {
match: RegExp;
value: string | null;
suggestRefresh?: boolean;
}
export const errors: IError[] = [
{
match: /^Event with UUID .* not found$/,
value: i18n.t('Page not found') as string,
value: i18n.t("Page not found") as string,
suggestRefresh: false,
},
{
match: /^Event not found$/,
value: i18n.t('Event not found.') as string,
value: i18n.t("Event not found.") as string,
},
{
match: /^Event with this ID .* doesn't exist$/,
value: i18n.t('Event not found.') as string,
value: i18n.t("Event not found.") as string,
},
{
match: /^Error while saving report$/,
value: i18n.t('Error while saving report.') as string,
value: i18n.t("Error while saving report.") as string,
},
{
match: /^Participant already has role rejected$/,
value: i18n.t('Participant already was rejected.') as string,
value: i18n.t("Participant already was rejected.") as string,
},
{
match: /^Participant already has role participant$/,
value: i18n.t('Participant has already been approved as participant.') as string,
value: i18n.t("Participant has already been approved as participant.") as string,
},
{
match: /^You are already a participant of this event$/,
value: i18n.t('You are already a participant of this event.') as string,
value: i18n.t("You are already a participant of this event.") as string,
},
{
match: /NetworkError when attempting to fetch resource.$/,
value: i18n.t('Error while communicating with the server.') as string,
value: i18n.t("Error while communicating with the server.") as string,
},
{
match: /Provided moderator actor ID doesn't have permission on this event$/,
value: i18n.t("The current identity doesn't have any permission on this event. You should probably change it.") as string,
value: i18n.t(
"The current identity doesn't have any permission on this event. You should probably change it."
) as string,
suggestRefresh: false,
},
{

View File

@@ -1,3 +1,3 @@
export function nl2br(text: string) {
return text.replace(/(?:\r\n|\r|\n)/g, '<br>');
return text.replace(/(?:\r\n|\r|\n)/g, "<br>");
}

View File

@@ -1,14 +1,15 @@
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import messages from '@/i18n/index';
import Vue from "vue";
import VueI18n from "vue-i18n";
import messages from "../i18n/index";
const language = ((window.navigator as any).userLanguage || window.navigator.language).replace(/-/, '_');
const locale = messages.hasOwnProperty(language) ? language : language.split('-')[0];
let language = document.documentElement.getAttribute("lang") as string;
language = language || ((window.navigator as any).userLanguage || window.navigator.language).replace(/-/, "_");
const locale = language && messages.hasOwnProperty(language) ? language : language.split("-")[0];
Vue.use(VueI18n);
export const i18n = new VueI18n({
locale, // set locale
messages, // set locale messages
fallbackLocale: 'en_US',
fallbackLocale: "en_US",
});

View File

@@ -1,4 +1,4 @@
import { IPicture } from '@/types/picture.model';
import { IPicture } from "@/types/picture.model";
export async function buildFileFromIPicture(obj: IPicture | null) {
if (!obj) return null;
@@ -23,7 +23,7 @@ export function buildFileVariable<T>(file: File | null, name: string, alt?: stri
};
}
export function readFileAsync(file: File): Promise<string|ArrayBuffer|null> {
export function readFileAsync(file: File): Promise<string | ArrayBuffer | null> {
return new Promise((resolve, reject) => {
const reader = new FileReader();

View File

@@ -1,5 +1,5 @@
export function buildObjectCollection<T, U>(collection: T[] | undefined, builder: (new (p: T) => U)) {
export function buildObjectCollection<T, U>(collection: T[] | undefined, builder: new (p: T) => U) {
if (!collection || Array.isArray(collection) === false) return [];
return collection.map(v => new builder(v));
return collection.map((v) => new builder(v));
}

View File

@@ -1,61 +1,70 @@
export default {
export interface IPOIIcon {
icon: string;
color?: string;
}
interface IPOIIcons {
[key: string]: IPOIIcon;
}
export const poiIcons: IPOIIcons = {
default: {
icon: 'map-marker',
color: '#5C6F84',
icon: "map-marker",
color: "#5C6F84",
},
defaultAdministrative: {
icon: 'city',
color: '#5c6f84',
icon: "city",
color: "#5c6f84",
},
defaultStreet: {
icon: 'road-variant',
color: '#5c6f84',
icon: "road-variant",
color: "#5c6f84",
},
defaultAddress: {
icon: 'home',
color: '#5c6f84',
icon: "home",
color: "#5c6f84",
},
place_house: {
icon: 'home',
color: '#5c6f84',
icon: "home",
color: "#5c6f84",
},
theatre: {
icon: 'drama-masks',
icon: "drama-masks",
},
parking: {
icon: 'parking',
icon: "parking",
},
police: {
icon: 'police-badge',
icon: "police-badge",
},
post_office: {
icon: 'email',
icon: "email",
},
university: {
icon: 'school',
icon: "school",
},
college: {
icon: 'school',
icon: "school",
},
park: {
icon: 'pine-tree',
icon: "pine-tree",
},
garden: {
icon: 'pine-tree',
icon: "pine-tree",
},
bicycle_rental: {
icon: 'bicycle',
icon: "bicycle",
},
hospital: {
icon: 'hospital-box',
icon: "hospital-box",
},
townhall: {
icon: 'office-building',
icon: "office-building",
},
toilets: {
icon: 'human-male-female',
icon: "human-male-female",
},
hairdresser: {
icon: 'content-cut',
icon: "content-cut",
},
};

View File

@@ -3,8 +3,8 @@
*/
export function listenFileUpload(): Promise<File> {
return new Promise((resolve, reject) => {
const inputElement = document.createElement('input');
inputElement.type = 'file';
const inputElement = document.createElement("input");
inputElement.type = "file";
inputElement.onchange = () => {
if (inputElement.files && inputElement.files.length > 0) {
resolve(inputElement.files[0]);
@@ -21,8 +21,8 @@ export function listenFileUpload(): Promise<File> {
*/
export function listenFileUploads(): Promise<FileList> {
return new Promise((resolve, reject) => {
const inputElement = document.createElement('input');
inputElement.type = 'file';
const inputElement = document.createElement("input");
inputElement.type = "file";
inputElement.multiple = true;
inputElement.onchange = () => {
if (inputElement.files && inputElement.files.length > 0) {

View File

@@ -1,7 +1,7 @@
export function validateEmailField(value: string) {
return value.includes('@') || 'Invalid e-mail.';
return value.includes("@") || "Invalid e-mail.";
}
export function validateRequiredField(value: any) {
return !!value || 'Required.';
return !!value || "Required.";
}