Fix issue #19: Add unified campaign sync

This commit is contained in:
Gitea OpenCode Agent
2026-10-14 14:07:52 +00:00
parent 9d9738b2b4
commit 0a8452b3c8
22 changed files with 1469 additions and 921 deletions

View File

@@ -2,7 +2,7 @@
import ContentManager from './components/managers/ContentManager.vue';
import ToastManager from './components/managers/ToastManager.vue';
import WindowManager from './components/managers/WindowManager.vue';
import DiscordAuthorize from './components/views/DiscordAuthorize.vue';
import ServiceLinkAuthorize from './components/views/ServiceLinkAuthorize.vue';
import { CreateWindow } from '@/services/Windows'
import { GetUser, HasAdmin } from './services/User';
@@ -12,10 +12,14 @@ import { useCampaignService } from './services/Campaign';
const { RestoreCampaign } = useCampaignService();
// El bot de Discord enllaça amb aquesta pantalla; no és part de l'aplicació i no ha d'arrencar
// les finestres normals.
// Els serveis (Discord, Foundry, Obsidian) enllacen amb aquesta pantalla única; no són part
// de l'aplicació i no han d'arrencar les finestres normals. La ruta antiga de Discord també
// hi porta, perquè els enllaços que ja corren per Discord no queden morts.
const requestUrl = useRequestURL();
const isDiscordAuthorize = computed(() => requestUrl.pathname.replace(/\/+$/, '') === '/discord/authorize');
const isServiceLink = computed(() => {
const path = requestUrl.pathname.replace(/\/+$/, '');
return path === '/link/authorize' || path === '/discord/authorize';
});
async function start(){
if(GetUser()){
@@ -46,14 +50,14 @@ useHead({
onMounted(() => {
setupTheme();
setTheme('dark');
if(!isDiscordAuthorize.value){
if(!isServiceLink.value){
start();
}
})
</script>
<template>
<DiscordAuthorize v-if="isDiscordAuthorize"></DiscordAuthorize>
<ServiceLinkAuthorize v-if="isServiceLink"></ServiceLinkAuthorize>
<div v-else class="viewer">
<ToastManager></ToastManager>
<TooltipManager></TooltipManager>

View File

@@ -1,260 +0,0 @@
<script setup>
import { onMounted, ref } from 'vue';
import Server from '~/services/Server';
import { GetUser, SetUser } from '~/services/User';
import { AddSound } from '~/services/Sound';
import Spinner from '../partials/Spinner.vue';
// Pantalla autònoma que el bot obre des de Discord: l'usuari s'identifica aquí
// i autoritza el servidor de Discord que s'ha rebut per la URL.
useHead({ title: 'Connect Dragonroll to Discord' });
const card = ref(null);
const code = ref('');
const guildName = ref('');
const discordUserName = ref('');
const signedInAs = ref('');
const connectedGuild = ref('');
// 'checking' | 'login' | 'approve' | 'connected' | 'error'
const status = ref('checking');
const messageKey = ref('');
const username = ref('');
const password = ref('');
const busy = ref(false);
function readCode() {
const hash = new URLSearchParams(window.location.hash.slice(1));
const search = new URLSearchParams(window.location.search);
return hash.get('code') || search.get('code') || '';
}
function ShowError(key) {
messageKey.value = key;
}
function PrepareApproval() {
const user = GetUser();
if (!user) {
status.value = 'login';
messageKey.value = '';
return;
}
signedInAs.value = user.username || user.name || user.email || 'Dragonroll';
status.value = 'approve';
messageKey.value = '';
}
async function LoadRequest() {
const response = await Server().post('/discord/link/details', { code: code.value });
const details = response.data;
if (details.status !== 'ok') {
status.value = 'error';
ShowError('discord.errors.link-expired');
return;
}
guildName.value = details.guildName;
discordUserName.value = details.discordUserName;
PrepareApproval();
}
async function SignIn() {
busy.value = true;
messageKey.value = '';
try {
const response = await Server().post('/user/login', {
usermail: username.value,
password: password.value
});
if (response.data.status !== 'ok' || !response.data.token) {
ShowError(response.data.msg || 'discord.errors.sign-in-failed');
return;
}
// El token passa al servei d'usuari perquè el client el reutilitzi en autoritzar.
SetUser(response.data.token);
password.value = '';
PrepareApproval();
} catch {
ShowError('discord.errors.sign-in-failed');
} finally {
busy.value = false;
}
}
async function Authorize() {
busy.value = true;
try {
const response = await Server().post('/discord/link/complete', { code: code.value });
if (response.data.status !== 'ok') {
status.value = 'error';
ShowError('discord.errors.link-expired');
return;
}
connectedGuild.value = response.data.guildName;
status.value = 'connected';
messageKey.value = '';
// El codi ja s'ha fet servir, treu-lo de la barra d'adreces.
window.history.replaceState(null, '', window.location.pathname);
} catch (error) {
if (error?.response?.status === 401) {
status.value = 'login';
ShowError('discord.errors.session-expired');
return;
}
status.value = 'error';
ShowError('discord.errors.link-expired');
} finally {
busy.value = false;
}
}
onMounted(() => {
AddSound(card.value);
code.value = readCode();
if (!code.value) {
status.value = 'error';
ShowError('discord.errors.missing-code');
return;
}
LoadRequest().catch(() => {
status.value = 'error';
ShowError('discord.errors.internal');
});
});
</script>
<template>
<div class="discord-authorize">
<main class="authorize-card" ref="card">
<h1>{{ $t('discord.title') }}</h1>
<p v-if="guildName" class="summary">
{{ $t('discord.summary', { guild: guildName, user: discordUserName }) }}
</p>
<p v-else-if="status !== 'error'" class="summary">
<Spinner v-if="status === 'checking'"></Spinner>
<span v-else>{{ $t('discord.checking') }}</span>
</p>
<form v-if="status === 'login'" v-on:submit.prevent="SignIn">
<p>{{ $t('discord.sign-in-lead') }}</p>
<div class="form-field">
<label for="discord-authorize-usermail">{{ $t('login.username') }}</label>
<input
id="discord-authorize-usermail"
type="text"
:placeholder="$t('login.username-placeholder')"
name="usermail"
autocomplete="username"
v-model="username"
required
>
</div>
<div class="form-field">
<label for="discord-authorize-password">{{ $t('login.password') }}</label>
<input
id="discord-authorize-password"
type="password"
name="password"
autocomplete="current-password"
v-model="password"
required
>
</div>
<button class="btn-primary sound-click" type="submit" :disabled="busy">
<Spinner v-if="busy"></Spinner>
<span v-else>{{ $t('login.log-in') }}</span>
</button>
</form>
<section v-if="status === 'approve'">
<p>{{ $t('discord.signed-in-as', { user: signedInAs }) }}</p>
<p class="hint">{{ $t('discord.next-step') }}</p>
<p class="hint">{{ $t('discord.replace-warning') }}</p>
<button class="btn-primary sound-click" type="button" :disabled="busy" v-on:click="Authorize">
<Spinner v-if="busy"></Spinner>
<span v-else>{{ $t('discord.approve') }}</span>
</button>
</section>
<section v-if="status === 'connected'">
<p class="success">{{ $t('discord.connected', { guild: connectedGuild }) }}</p>
<p class="hint">{{ $t('discord.next-step') }}</p>
</section>
<p v-if="messageKey" class="error" role="status">
{{ $t(messageKey) }}
</p>
</main>
</div>
</template>
<style scoped>
.discord-authorize {
display: grid;
place-items: center;
width: 100%;
min-height: 100vh;
padding: 24px;
box-sizing: border-box;
background-color: var(--color-background);
color: var(--color-text);
}
.authorize-card {
width: min(100%, 460px);
padding: 28px;
box-sizing: border-box;
background-color: var(--color-window-background);
border: 1px solid var(--color-window-border);
border-radius: 12px;
box-shadow: 0 8px 24px var(--color-window-shadow);
text-align: center;
user-select: none;
}
.authorize-card h1 {
margin-top: 0;
font-family: 'MrEavesRemake', serif;
font-size: 1.5rem;
}
.authorize-card p {
line-height: 1.5;
}
.summary {
color: var(--color-gray);
}
form,
section {
margin-top: 18px;
}
.hint {
color: var(--color-gray);
font-size: 0.95rem;
}
.success {
color: var(--color-green);
}
.error {
color: var(--color-red);
}
button {
width: 100%;
}
</style>

View File

@@ -0,0 +1,395 @@
<script setup>
import { computed, onMounted, ref } from 'vue';
import Server from '~/services/Server';
import { GetUser, SetUser } from '~/services/User';
import { AddSound } from '~/services/Sound';
import Spinner from '../partials/Spinner.vue';
// Pantalla única d'enllaç de serveis (Discord, Foundry, Obsidian): el servei demana
// l'enllaç al backend, l'usuari hi entra, s'identifica i tria la campanya que el
// servei podrà fer servir. Abans cada servei tenia la seva pròpia pantalla.
const card = ref(null);
const service = ref('');
const serviceName = ref('Dragonroll');
const code = ref('');
const targetName = ref('');
const targetUser = ref('');
const system = ref('');
const signedInAs = ref('');
const campaigns = ref([]);
const selectedCampaign = ref('');
const connectedCampaign = ref('');
// 'checking' | 'login' | 'pick' | 'connected' | 'error'
const status = ref('checking');
const messageKey = ref('');
const username = ref('');
const password = ref('');
const busy = ref(false);
// El nom propi del servei és l'últim recurs: el backend el dona amb la petició.
const serviceLabel = computed(() => serviceName.value || serviceNameOf(service.value));
// Cada servei explica d'una manera què és el que demana i què cal fer després.
const targetKey = computed(() => `link.target.${service.value || 'other'}`);
const nextKey = computed(() => `link.next.${service.value || 'other'}`);
function serviceNameOf(value) {
if (value === 'discord') return 'Discord';
if (value === 'foundry') return 'Foundry VTT';
if (value === 'obsidian') return 'Obsidian';
return 'Dragonroll';
}
// El codi viatja al fragment de la URL, així que el navegador no l'envia mai al
// servidor. El servei, que és qui demana l'enllaç, hi posa també el seu nom.
function readLinkParams() {
const hash = new URLSearchParams(window.location.hash.slice(1));
const search = new URLSearchParams(window.location.search);
return {
code: hash.get('code') || search.get('code') || '',
service: hash.get('service') || search.get('service') || ''
};
}
function ShowError(key) {
messageKey.value = key;
}
function AskForLogin() {
const user = GetUser();
if (!user) {
status.value = 'login';
messageKey.value = '';
return;
}
signedInAs.value = user.username || user.name || user.email || 'Dragonroll';
status.value = 'pick';
messageKey.value = '';
LoadCampaigns();
}
async function LoadLinkDetails() {
const response = await Server().post('/link/details', { code: code.value });
const details = response.data;
if (details.status !== 'ok') {
status.value = 'error';
ShowError('link.errors.expired');
return;
}
service.value = details.service || service.value;
serviceName.value = details.serviceName || serviceNameOf(service.value);
targetName.value = details.targetName || '';
targetUser.value = details.targetUser || '';
system.value = details.system || '';
AskForLogin();
}
async function LoadCampaigns() {
try {
const response = await Server().get('/campaign/list');
campaigns.value = (response.data.status === 'ok' && Array.isArray(response.data.campaigns))
? response.data.campaigns
: [];
if (campaigns.value.length === 1) selectedCampaign.value = String(campaigns.value[0]._id);
} catch {
campaigns.value = [];
}
}
async function SignIn() {
busy.value = true;
messageKey.value = '';
try {
const response = await Server().post('/user/login', {
usermail: username.value,
password: password.value
});
if (response.data.status !== 'ok' || !response.data.token) {
ShowError(response.data.msg || 'link.errors.sign-in-failed');
return;
}
// El token passa al servei d'usuari perquè el client el reutilitzi en connectar.
SetUser(response.data.token);
password.value = '';
AskForLogin();
} catch {
ShowError('link.errors.sign-in-failed');
} finally {
busy.value = false;
}
}
// A campaign that already has this very service on it is being re-connected, and
// saying so is what keeps the picker honest.
function AlreadyLinked(campaign) {
if (service.value === 'foundry') return !!campaign.foundryWorldId;
if (service.value === 'discord') return !!campaign.discordGuildId;
return false;
}
async function Connect() {
if (!selectedCampaign.value) {
ShowError('link.errors.no-campaign');
return;
}
busy.value = true;
messageKey.value = '';
try {
const response = await Server().post('/link/complete', {
code: code.value,
campaignId: selectedCampaign.value
});
if (response.data.status !== 'ok') {
ShowError(response.data.msg || 'link.errors.expired');
return;
}
connectedCampaign.value = response.data.campaign?.name || '';
status.value = 'connected';
// El codi ja s'ha fet servir, treu-lo de la barra d'adreces.
window.history.replaceState(null, '', window.location.pathname);
} catch (error) {
if (error?.response?.status === 401) {
status.value = 'login';
ShowError('link.errors.session-expired');
return;
}
ShowError('link.errors.internal');
} finally {
busy.value = false;
}
}
useHead({
title: computed(() => `Connect ${serviceLabel.value} to Dragonroll`)
});
onMounted(() => {
AddSound(card.value);
const params = readLinkParams();
code.value = params.code;
service.value = params.service || (window.location.pathname.startsWith('/discord') ? 'discord' : '');
if (!code.value) {
status.value = 'error';
ShowError('link.errors.missing-code');
return;
}
LoadLinkDetails().catch(() => {
status.value = 'error';
ShowError('link.errors.internal');
});
});
</script>
<template>
<div class="service-link">
<main class="link-card" ref="card">
<h1>{{ $t('link.title', { service: serviceLabel }) }}</h1>
<p v-if="targetName" class="summary">
{{ $t(targetKey, {
target: targetName,
user: targetUser,
system: system ? $t('link.system', { system }) : ''
}) }}
</p>
<p v-else-if="status !== 'error'" class="summary">
<Spinner v-if="status === 'checking'"></Spinner>
<span v-else>{{ $t('link.checking') }}</span>
</p>
<form v-if="status === 'login'" v-on:submit.prevent="SignIn">
<p>{{ $t('link.sign-in-lead', { service: serviceLabel }) }}</p>
<div class="form-field">
<label for="service-link-usermail">{{ $t('login.username') }}</label>
<input
id="service-link-usermail"
type="text"
:placeholder="$t('login.username-placeholder')"
name="usermail"
autocomplete="username"
v-model="username"
required
>
</div>
<div class="form-field">
<label for="service-link-password">{{ $t('login.password') }}</label>
<input
id="service-link-password"
type="password"
name="password"
autocomplete="current-password"
v-model="password"
required
>
</div>
<button class="btn-primary sound-click" type="submit" :disabled="busy">
<Spinner v-if="busy"></Spinner>
<span v-else>{{ $t('login.log-in') }}</span>
</button>
</form>
<section v-if="status === 'pick'">
<p>{{ $t('link.signed-in-as', { user: signedInAs }) }}</p>
<p class="question">{{ $t('link.pick-campaign', { service: serviceLabel }) }}</p>
<p v-if="!campaigns.length" class="hint">{{ $t('link.no-campaigns') }}</p>
<ul v-else class="campaigns">
<li v-for="campaign in campaigns" :key="campaign._id">
<label class="campaign" :class="{ selected: selectedCampaign === String(campaign._id) }">
<input
type="radio"
name="campaign"
:value="String(campaign._id)"
v-model="selectedCampaign"
>
<span class="swatch" :style="{ backgroundColor: campaign.color || 'var(--color-accent)' }"></span>
<span class="campaign-name">{{ campaign.name }}</span>
<span v-if="AlreadyLinked(campaign)" class="badge">
{{ $t('link.already-linked', { service: serviceLabel }) }}
</span>
</label>
</li>
</ul>
<p class="hint">{{ $t('link.trust-warning', { service: serviceLabel }) }}</p>
<p class="hint">{{ $t('link.replace-warning') }}</p>
<button
class="btn-primary sound-click"
type="button"
:disabled="busy || !selectedCampaign"
v-on:click="Connect"
>
<Spinner v-if="busy"></Spinner>
<span v-else>{{ $t('link.connect', { service: serviceLabel }) }}</span>
</button>
</section>
<section v-if="status === 'connected'">
<p class="success">{{ $t('link.connected', { campaign: connectedCampaign }) }}</p>
<p class="hint">{{ $t(nextKey, { service: serviceLabel }) }}</p>
</section>
<p v-if="messageKey" class="error" role="status">
{{ $t(messageKey) }}
</p>
</main>
</div>
</template>
<style scoped>
.service-link {
display: grid;
place-items: center;
width: 100%;
min-height: 100vh;
padding: 24px;
box-sizing: border-box;
background-color: var(--color-background);
color: var(--color-text);
}
.link-card {
width: min(100%, 460px);
padding: 28px;
box-sizing: border-box;
background-color: var(--color-window-background);
border: 1px solid var(--color-window-border);
border-radius: 12px;
box-shadow: 0 8px 24px var(--color-window-shadow);
text-align: center;
user-select: none;
}
.link-card h1 {
margin-top: 0;
font-family: 'MrEavesRemake', serif;
font-size: 1.5rem;
}
.link-card p {
line-height: 1.5;
}
.summary {
color: var(--color-gray);
}
form,
section {
margin-top: 18px;
}
.question {
font-weight: bold;
}
.campaigns {
list-style: none;
margin: 0 0 14px 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 8px;
text-align: left;
}
.campaign {
display: flex;
align-items: center;
gap: 10px;
padding: 10px;
border: 1px solid var(--color-border);
border-radius: 8px;
cursor: pointer;
}
.campaign.selected {
border-color: var(--color-accent);
background-color: var(--color-background-soft);
}
.swatch {
width: 14px;
height: 14px;
border-radius: 4px;
flex: 0 0 auto;
border: 1px solid var(--color-border);
}
.campaign-name {
flex: 1;
}
.badge {
font-size: 0.8rem;
color: var(--color-gray);
}
.hint {
color: var(--color-gray);
font-size: 0.95rem;
}
.success {
color: var(--color-green);
}
.error {
color: var(--color-red);
}
button {
width: 100%;
}
</style>

View File

@@ -1,5 +1,5 @@
<script setup>
import { onBeforeUnmount, onMounted, ref } from 'vue';
import { onMounted, ref } from 'vue';
import WindowHandle from './partials/WindowHandle.vue';
import Tabs from '../layouts/Tabs.vue';
import { SetupHandle, SetSize, ResetPosition, Top, SetResizable, SetMinSize } from '@/services/Windows';
@@ -17,18 +17,20 @@ const name = ref(campaign.name || '');
const color = ref(campaign.color || '#6b6b6b');
const settings = ref(campaign.settings && typeof campaign.settings === 'object' ? campaign.settings : {});
const foundryUrl = ref(settings.value.integrations?.foundryUrl || '');
const pairingCode = ref('');
const requestId = ref('');
const linking = ref(false);
const id = data.id;
let statusPoll;
let checkingStatus = false;
// Els serveis s'enllacen tots igual: ells mostren un enllaç de Dragonroll i aquí
// només es mira què té connectat la campanya i se'n desenllaça el que calgui.
const services = ref([]);
const unlinked = ref('');
const rows = [
{ id: 'basic', value: 'campaigns.settings.tabs.basic' },
{ id: 'integrations', value: 'campaigns.settings.tabs.integrations' }
];
const serviceKeys = ['foundry', 'discord', 'obsidian'];
onMounted(() => {
Top(wrapper);
SetupHandle(id, handle);
@@ -36,11 +38,7 @@ onMounted(() => {
ResetPosition(id, 'center');
SetResizable(id, true);
SetMinSize(id, { width: 440, height: 340 });
ResumePendingFoundryLink();
});
onBeforeUnmount(() => {
clearInterval(statusPoll);
LoadServices();
});
function ApplyCampaignUpdate(updatedCampaign) {
@@ -100,95 +98,56 @@ async function SaveSettings() {
}
}
async function StartFoundryLink() {
linking.value = true;
async function LoadServices() {
try {
const response = await Server().post('/campaign/foundry-link/start', { campaignId: campaign._id });
if (response.data.status !== 'ok') {
DisplayToast('red', $t(response.data.msg || 'errors.internal'), 3000);
return;
}
pairingCode.value = response.data.code;
requestId.value = response.data.requestId;
clearInterval(statusPoll);
statusPoll = setInterval(CheckFoundryLinkStatus, 2500);
const response = await Server().get(`/campaign/services?campaignId=${campaign._id}`);
services.value = response.data.status === 'ok' && Array.isArray(response.data.services)
? response.data.services
: [];
} catch {
DisplayToast('red', $t('errors.internal'), 3000);
} finally {
linking.value = false;
services.value = [];
}
}
// The pairing code lives server-side until it expires, so re-attach to it when
// the window opens again after a reload, restart or closing the window.
async function ResumePendingFoundryLink() {
try {
const response = await Server().get(`/campaign/foundry-link/pending?campaignId=${campaign._id}`);
if (response.data.status !== 'ok' || !response.data.request) return;
pairingCode.value = response.data.request.code || '';
requestId.value = response.data.request.requestId;
clearInterval(statusPoll);
statusPoll = setInterval(CheckFoundryLinkStatus, 2500);
} catch {
// Showing the stored pairing code is best-effort; ignore resume failures.
}
function LinkFor(service) {
return services.value.find((link) => link.service === service) || null;
}
async function CheckFoundryLinkStatus() {
if (!requestId.value || checkingStatus) return;
checkingStatus = true;
try {
const response = await Server().get(`/campaign/foundry-link/status/${requestId.value}`);
if (response.data.status !== 'ok' || response.data.state === 'expired') {
clearInterval(statusPoll);
pairingCode.value = '';
requestId.value = '';
const error = response.data.state === 'expired'
? 'campaigns.settings.errors.link-expired'
: response.data.msg || 'campaigns.settings.errors.link-expired';
DisplayToast('red', $t(error), 3000);
return;
}
if (response.data.state === 'complete') {
ApplyCampaignUpdate(response.data.campaign);
clearInterval(statusPoll);
pairingCode.value = '';
requestId.value = '';
DisplayToast('green', $t('campaigns.settings.linked'), 3000);
}
} catch {
// Keep polling while the Foundry module completes the pairing.
} finally {
checkingStatus = false;
}
// El món de Foundry es descriu amb el que la campanya ja en sap, per si el món
// es va enllaçar abans que els serveis tinguessin un registre comú.
function ServiceTarget(service, link) {
if (link?.targetName) return link.targetName;
if (service === 'foundry' && campaign.foundryWorldTitle) return campaign.foundryWorldTitle;
if (service === 'discord' && campaign.discordGuildId) return campaign.discordGuildId;
return '';
}
async function UnlinkFoundry() {
linking.value = true;
function WhoConnected(link) {
return link?.dragonrollUserName ? $t('campaigns.settings.services.connected-by', { user: link.dragonrollUserName }) : '';
}
async function Unlink(service) {
unlinked.value = service;
try {
const response = await Server().post('/campaign/foundry-unlink', { campaignId: campaign._id });
const response = await Server().post('/campaign/service-unlink', {
campaignId: campaign._id,
service
});
if (response.data.status !== 'ok') {
DisplayToast('red', $t(response.data.msg || 'errors.internal'), 3000);
return;
}
ApplyCampaignUpdate(response.data.campaign);
DisplayToast('green', $t('campaigns.settings.unlinked'), 3000);
services.value = Array.isArray(response.data.services) ? response.data.services : [];
DisplayToast('green', $t('campaigns.settings.services.unlinked', {
service: $t(`campaigns.settings.services.${service}.name`)
}), 3000);
} catch {
DisplayToast('red', $t('errors.internal'), 3000);
} finally {
linking.value = false;
}
}
async function CopyPairingCode() {
try {
await navigator.clipboard.writeText(pairingCode.value);
DisplayToast('green', $t('campaigns.settings.code-copied'), 2000);
} catch {
DisplayToast('red', $t('campaigns.settings.errors.copy-code'), 3000);
unlinked.value = '';
}
}
</script>
@@ -212,29 +171,33 @@ async function CopyPairingCode() {
</div>
</template>
<template #integrations>
<p class="help-text standalone">{{ $t('campaigns.settings.services.help') }}</p>
<div class="settings-fields">
<div class="world-link">
<div v-if="campaign.foundryWorldId" class="linked-world">
<strong>{{ campaign.foundryWorldTitle || campaign.foundryWorldId }}</strong>
<span v-if="campaign.foundrySystem">{{ campaign.foundrySystem }}</span>
<button class="btn-primary sound-click" type="button" :disabled="linking" @click="UnlinkFoundry">
{{ $t('campaigns.settings.unlink-foundry') }}
</button>
</div>
<p v-else class="help-text standalone">{{ $t('campaigns.settings.no-foundry-world') }}</p>
<button class="btn-primary sound-click" type="button" :disabled="linking" @click="StartFoundryLink">
{{ $t('campaigns.settings.start-foundry-link') }}
</button>
<p class="help-text standalone">{{ $t('campaigns.settings.start-foundry-link-help') }}</p>
<div v-if="pairingCode" class="pairing-code">
<code>{{ pairingCode }}</code>
<button class="btn-primary sound-click" type="button" @click="CopyPairingCode">
{{ $t('campaigns.settings.copy-code') }}
<div v-for="service in serviceKeys" :key="service" class="service">
<div class="service-head">
<strong>{{ $t(`campaigns.settings.services.${service}.name`) }}</strong>
<button
v-if="LinkFor(service)"
class="btn-primary sound-click"
type="button"
:disabled="unlinked !== ''"
@click="Unlink(service)"
>
{{ $t('campaigns.settings.services.unlink') }}
</button>
</div>
<p class="service-state" :class="{ linked: LinkFor(service) }">
{{ ServiceTarget(service, LinkFor(service)) || $t('campaigns.settings.services.not-connected') }}
<span v-if="WhoConnected(LinkFor(service))" class="who">
{{ WhoConnected(LinkFor(service)) }}
</span>
</p>
<p class="help-text standalone">
{{ $t(`campaigns.settings.services.${service}.how`) }}
</p>
</div>
</div>
<div class="settings-fields">
<label class="field">
<span>{{ $t('campaigns.settings.foundry-url') }}</span>
<input
@@ -313,40 +276,36 @@ input {
margin: 0;
}
.world-link {
.service {
display: flex;
flex-direction: column;
gap: 10px;
gap: 6px;
padding-bottom: 14px;
border-bottom: 1px solid var(--color-border);
}
.linked-world {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
.linked-world span {
opacity: 0.75;
}
.pairing-code {
.service-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 10px;
border: 1px solid var(--color-border);
border-radius: 6px;
}
.pairing-code code {
user-select: text;
.service-state {
margin: 0;
font-size: 14px;
overflow-wrap: anywhere;
}
.service-state.linked {
color: var(--color-green);
}
.who {
opacity: 0.75;
font-size: 13px;
}
.actions {
display: flex;
justify-content: flex-end;

View File

@@ -10,21 +10,30 @@
"color": "Color de la campanya",
"foundry-url": "URL de Foundry VTT",
"foundry-url-help": "Introdueix l'URL base de la instància de Foundry VTT que executa el mòdul Dragonroll Foundry.",
"no-foundry-world": "Aquesta campanya no té cap món de Foundry enllaçat.",
"start-foundry-link": "Crea un codi per a Foundry",
"start-foundry-link-help": "Copia aquest codi a l'opció Dragonroll Campaign Pairing Code del mòdul de Foundry. Dragonroll Endpoint utilitza https://dragonroll.aranroig.com de manera predeterminada. El codi caduca al cap de 10 minuts.",
"unlink-foundry": "Desenllaça",
"saved": "S'ha desat la configuració de la campanya.",
"linked": "S'ha enllaçat el món de Foundry amb aquesta campanya.",
"unlinked": "S'ha desenllaçat el món de Foundry d'aquesta campanya.",
"copy-code": "Copia el codi",
"code-copied": "S'ha copiat el codi d'enllaç.",
"saving": "Desant...",
"services": {
"help": "Tots els serveis es connecten igual: demanen a Dragonroll un enllaç de registre, te'l mostren i tries aquesta campanya allà. Des d'aquí no es connecta res.",
"not-connected": "No connectat",
"unlink": "Desenllaça",
"unlinked": "{service} ja no està connectat amb aquesta campanya.",
"connected-by": "connectat per {user}",
"foundry": {
"name": "Foundry VTT",
"how": "Obre l'enllaç de Dragonroll des de la configuració del mòdul del teu món i tria aquesta campanya."
},
"discord": {
"name": "Discord",
"how": "Executa /dragonroll connect al teu servidor i tria aquesta campanya."
},
"obsidian": {
"name": "Obsidian",
"how": "Prem Connect to Dragonroll a la configuració del connector d'Obsidian i tria aquesta campanya."
}
},
"errors": {
"name-required": "Introdueix un nom per a la campanya.",
"invalid-foundry-url": "Introdueix una URL vàlida de Foundry VTT amb http o https.",
"link-expired": "El codi d'enllaç ha caducat. Crea'n un de nou.",
"copy-code": "No s'ha pogut copiar el codi d'enllaç."
"invalid-foundry-url": "Introdueix una URL vàlida de Foundry VTT amb http o https."
}
},
"sidebar-label": "Campanya",

View File

@@ -0,0 +1,35 @@
{
"title": "Connecta {service} amb Dragonroll",
"checking": "Comprovant aquest enllaç…",
"system": " · {system}",
"target": {
"discord": "Servidor de Discord: {target}. Sol·licitat per {user}.",
"foundry": "Món de Foundry: {target}{system}. Sol·licitat per {user}.",
"obsidian": "Vault d'Obsidian: {target}.",
"other": "{target} vol fer servir una de les teves campanyes."
},
"sign-in-lead": "Inicia sessió amb el compte de Dragonroll propietari de la campanya que ha de fer servir {service}.",
"signed-in-as": "Has iniciat sessió com a {user}.",
"pick-campaign": "Quina campanya pot fer servir {service}?",
"no-campaigns": "Aquest compte encara no té campanyes. Crea'n una primer a Dragonroll.",
"already-linked": "ja connectat a un {service}",
"connect": "Connecta aquesta campanya",
"connected": "Aquesta campanya ja està connectada amb {target}.",
"trust-warning": "Connecta només serveis de confiança: poden llegir i modificar el que conté la seva campanya.",
"replace-warning": "Connectar una campanya reemplaça el que aquest servei tenia connectat abans.",
"next": {
"discord": "Torna a Discord: el bot hi confirmarà la connexió.",
"foundry": "Torna a Foundry: el mòdul es connectarà sol.",
"obsidian": "Torna a Obsidian: el connector ho agafarà sol.",
"other": "Torna al servei d'on vens."
},
"errors": {
"missing-code": "A aquest enllaç li falta el codi. Demana'n un de nou al servei.",
"expired": "Aquest enllaç no és vàlid o ha caducat. Demana'n un de nou al servei.",
"sign-in-failed": "No s'ha pogut iniciar sessió a Dragonroll. Revisa l'usuari i la contrasenya.",
"session-expired": "La teva sessió de Dragonroll ha caducat. Inicia sessió de nou per continuar.",
"no-campaign": "Tria la campanya que ha de fer servir aquest servei.",
"notfound": "Aquesta campanya no és teva. Inicia sessió amb el compte propietari.",
"internal": "No s'ha pogut carregar aquest enllaç."
}
}

View File

@@ -14,21 +14,30 @@
"color": "Campaign color",
"foundry-url": "Foundry VTT URL",
"foundry-url-help": "Enter the base URL of the Foundry VTT instance running the Dragonroll Foundry module.",
"no-foundry-world": "No Foundry world is linked to this campaign.",
"start-foundry-link": "Create a code for Foundry",
"start-foundry-link-help": "Copy this code into the Dragonroll Campaign Pairing Code setting in the Foundry module. The Dragonroll Endpoint defaults to https://dragonroll.aranroig.com. The code expires after 10 minutes.",
"unlink-foundry": "Unlink",
"saved": "Campaign settings saved.",
"linked": "Foundry world linked to this campaign.",
"unlinked": "Foundry world unlinked from this campaign.",
"copy-code": "Copy code",
"code-copied": "Pairing code copied.",
"saving": "Saving...",
"services": {
"help": "Every service connects the same way: it asks Dragonroll for a sign-up link, shows it to you, and you pick this campaign there. Nothing connects from here.",
"not-connected": "Not connected",
"unlink": "Unlink",
"unlinked": "{service} is no longer connected to this campaign.",
"connected-by": "connected by {user}",
"foundry": {
"name": "Foundry VTT",
"how": "Open the Dragonroll link from the module settings of your world and pick this campaign."
},
"discord": {
"name": "Discord",
"how": "Run /dragonroll connect in your server and pick this campaign."
},
"obsidian": {
"name": "Obsidian",
"how": "Press Connect to Dragonroll in the Obsidian plugin settings and pick this campaign."
}
},
"errors": {
"name-required": "Enter a campaign name.",
"invalid-foundry-url": "Enter a valid Foundry VTT URL using http or https.",
"link-expired": "This pairing code expired. Create a new one.",
"copy-code": "Unable to copy the pairing code."
"invalid-foundry-url": "Enter a valid Foundry VTT URL using http or https."
}
},
"sidebar-label": "Campaign",

View File

@@ -0,0 +1,35 @@
{
"title": "Connect {service} to Dragonroll",
"checking": "Checking this link…",
"system": " · {system}",
"target": {
"discord": "Discord server: {target}. Requested by {user}.",
"foundry": "Foundry world: {target}{system}. Requested by {user}.",
"obsidian": "Obsidian vault: {target}.",
"other": "{target} wants to use one of your campaigns."
},
"sign-in-lead": "Sign in with the Dragonroll account that owns the campaign {service} should use.",
"signed-in-as": "Signed in as {user}.",
"pick-campaign": "Which campaign may {service} use?",
"no-campaigns": "This account has no campaigns yet. Create one in Dragonroll first.",
"already-linked": "already connected to a {service}",
"connect": "Connect this campaign",
"connected": "This campaign is now connected to {target}.",
"trust-warning": "Only connect a service you trust: it can read and change what its campaign holds.",
"replace-warning": "Connecting a campaign replaces whatever this service was connected to before.",
"next": {
"discord": "Return to Discord: the bot confirms the connection there.",
"foundry": "Return to Foundry: the module connects on its own.",
"obsidian": "Return to Obsidian: the plugin picks this up on its own.",
"other": "Return to the service you came from."
},
"errors": {
"missing-code": "This link is missing its code. Ask the service for a new one.",
"expired": "This link is invalid or has expired. Ask the service for a new one.",
"sign-in-failed": "Dragonroll sign in failed. Check your username and password.",
"session-expired": "Your Dragonroll session has expired. Sign in again to continue.",
"no-campaign": "Choose the campaign this service should use.",
"notfound": "That campaign is not one of yours. Sign in with the account that owns it.",
"internal": "Could not load this link."
}
}

View File

@@ -10,21 +10,30 @@
"color": "Color de la campaña",
"foundry-url": "URL de Foundry VTT",
"foundry-url-help": "Introduce la URL base de la instancia de Foundry VTT que ejecuta el módulo Dragonroll Foundry.",
"no-foundry-world": "Esta campaña no tiene ningún mundo de Foundry vinculado.",
"start-foundry-link": "Crear un código para Foundry",
"start-foundry-link-help": "Copia este código en el ajuste Dragonroll Campaign Pairing Code del módulo de Foundry. Dragonroll Endpoint usa https://dragonroll.aranroig.com de forma predeterminada. El código caduca en 10 minutos.",
"unlink-foundry": "Desvincular",
"saved": "Se han guardado los ajustes de la campaña.",
"linked": "El mundo de Foundry se ha vinculado a esta campaña.",
"unlinked": "Se ha desvinculado el mundo de Foundry de esta campaña.",
"copy-code": "Copiar código",
"code-copied": "Código de vinculación copiado.",
"saving": "Guardando...",
"services": {
"help": "Todos los servicios se conectan igual: piden a Dragonroll un enlace de registro, te lo muestran y eliges esta campaña allí. Desde aquí no se conecta nada.",
"not-connected": "Sin conectar",
"unlink": "Desvincular",
"unlinked": "{service} ya no está conectado a esta campaña.",
"connected-by": "conectado por {user}",
"foundry": {
"name": "Foundry VTT",
"how": "Abre el enlace de Dragonroll desde los ajustes del módulo de tu mundo y elige esta campaña."
},
"discord": {
"name": "Discord",
"how": "Ejecuta /dragonroll connect en tu servidor y elige esta campaña."
},
"obsidian": {
"name": "Obsidian",
"how": "Pulsa Connect to Dragonroll en los ajustes del plugin de Obsidian y elige esta campaña."
}
},
"errors": {
"name-required": "Introduce un nombre para la campaña.",
"invalid-foundry-url": "Introduce una URL válida de Foundry VTT con http o https.",
"link-expired": "El código de vinculación ha caducado. Crea uno nuevo.",
"copy-code": "No se pudo copiar el código de vinculación."
"invalid-foundry-url": "Introduce una URL válida de Foundry VTT con http o https."
}
},
"sidebar-label": "Campaña",

View File

@@ -0,0 +1,35 @@
{
"title": "Conectar {service} con Dragonroll",
"checking": "Comprobando este enlace…",
"system": " · {system}",
"target": {
"discord": "Servidor de Discord: {target}. Solicitado por {user}.",
"foundry": "Mundo de Foundry: {target}{system}. Solicitado por {user}.",
"obsidian": "Vault de Obsidian: {target}.",
"other": "{target} quiere usar una de tus campañas."
},
"sign-in-lead": "Inicia sesión con la cuenta de Dragonroll propietaria de la campaña que debe usar {service}.",
"signed-in-as": "Has iniciado sesión como {user}.",
"pick-campaign": "¿Qué campaña puede usar {service}?",
"no-campaigns": "Esta cuenta todavía no tiene campañas. Crea una primero en Dragonroll.",
"already-linked": "ya conectado a un {service}",
"connect": "Conectar esta campaña",
"connected": "Esta campaña ya está conectada a {target}.",
"trust-warning": "Conecta solo servicios de confianza: pueden leer y modificar lo que contenga su campaña.",
"replace-warning": "Conectar una campaña reemplaza lo que este servicio tuviera conectado antes.",
"next": {
"discord": "Vuelve a Discord: el bot confirmará la conexión allí.",
"foundry": "Vuelve a Foundry: el módulo se conectará solo.",
"obsidian": "Vuelve a Obsidian: el plugin lo detectará solo.",
"other": "Vuelve al servicio desde el que has venido."
},
"errors": {
"missing-code": "A este enlace le falta el código. Pide uno nuevo al servicio.",
"expired": "Este enlace no es válido o ha caducado. Pide uno nuevo al servicio.",
"sign-in-failed": "No se ha podido iniciar sesión en Dragonroll. Revisa el usuario y la contraseña.",
"session-expired": "Tu sesión de Dragonroll ha caducado. Inicia sesión de nuevo para continuar.",
"no-campaign": "Elige la campaña que debe usar este servicio.",
"notfound": "Esa campaña no es tuya. Inicia sesión con la cuenta propietaria.",
"internal": "No se ha podido cargar este enlace."
}
}