Compare commits
13 Commits
b0509818b2
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b49ac4b48 | |||
| 94e2b8bd47 | |||
| 030060286f | |||
| b7ad2dc406 | |||
| 2023542229 | |||
| eaac266ebb | |||
| ed782f2fc6 | |||
| f2fd36664c | |||
| 456a0490a7 | |||
| 306dd8cabc | |||
| 50b3e421df | |||
| 963295e76b | |||
| e12b48b3e1 |
@@ -13,9 +13,10 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install SSH client
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
apt-get update -y && apt-get install -y openssh-client
|
apt-get update -y && apt-get install -y openssh-client
|
||||||
|
apt-get install -y git
|
||||||
|
|
||||||
- name: Setup SSH inside container
|
- name: Setup SSH inside container
|
||||||
run: |
|
run: |
|
||||||
@@ -33,7 +34,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Build frontend
|
- name: Build frontend
|
||||||
run: |
|
run: |
|
||||||
docker build -t git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-frontend:latest ./frontend
|
docker build -t git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-frontend:latest \
|
||||||
|
--build-arg NUXT_PUBLIC_GIT_COMMIT=$(git rev-parse --short HEAD) \
|
||||||
|
--build-arg NUXT_PUBLIC_GIT_TAG=$(git describe --tags --abbrev=0) \
|
||||||
|
--build-arg NUXT_PUBLIC_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) \
|
||||||
|
./frontend
|
||||||
docker push git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-frontend:latest
|
docker push git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-frontend:latest
|
||||||
|
|
||||||
- name: Build backend
|
- name: Build backend
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
API_BASE_URL=https://dragonroll.aranroig.com/api
|
NUXT_PUBLIC_API_BASE_URL=https://dragonroll.aranroig.com/api
|
||||||
@@ -1,6 +1,14 @@
|
|||||||
# ---------- Build Stage ----------
|
# ---------- Build Stage ----------
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
|
ARG NUXT_PUBLIC_GIT_COMMIT
|
||||||
|
ARG NUXT_PUBLIC_GIT_TAG
|
||||||
|
ARG NUXT_PUBLIC_GIT_BRANCH
|
||||||
|
|
||||||
|
ENV NUXT_PUBLIC_GIT_COMMIT=$NUXT_PUBLIC_GIT_COMMIT
|
||||||
|
ENV NUXT_PUBLIC_GIT_TAG=$NUXT_PUBLIC_GIT_TAG
|
||||||
|
ENV NUXT_PUBLIC_GIT_BRANCH=$NUXT_PUBLIC_GIT_BRANCH
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package files
|
# Copy package files
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ $themes: (
|
|||||||
|
|
||||||
red: #e06c75,
|
red: #e06c75,
|
||||||
green: #98c379,
|
green: #98c379,
|
||||||
|
gray: #cccccc,
|
||||||
|
|
||||||
icon-invert: 100%
|
icon-invert: 100%
|
||||||
),
|
),
|
||||||
@@ -63,6 +64,7 @@ $themes: (
|
|||||||
|
|
||||||
red: #e06c75,
|
red: #e06c75,
|
||||||
green: #98c379,
|
green: #98c379,
|
||||||
|
gray: #cccccc,
|
||||||
|
|
||||||
icon-invert: 0%
|
icon-invert: 0%
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,78 +2,57 @@
|
|||||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { useCampaignService } from '~/services/Campaign.js';
|
import { useCampaignService } from '~/services/Campaign.js';
|
||||||
|
import { FetchCampaignNotes, PushNote, TotalNotes } from '~/services/Content';
|
||||||
import { emitter } from '~/services/Emitter';
|
import { emitter } from '~/services/Emitter';
|
||||||
import Server from '~/services/Server';
|
import Server from '~/services/Server';
|
||||||
import { CreateWindow } from '~/services/Windows';
|
|
||||||
|
|
||||||
const { Campaign } = useCampaignService();
|
const { Campaign } = useCampaignService();
|
||||||
const notes = ref([]);
|
|
||||||
const loadingNotes = ref(false);
|
const loadingNotes = ref(false);
|
||||||
const notesError = ref('');
|
const notesError = ref('');
|
||||||
const sidebarCollapsed = ref(false);
|
const sidebarCollapsed = ref(false);
|
||||||
|
|
||||||
|
const selectedTool = ref('');
|
||||||
|
|
||||||
const campaignId = computed(() => {
|
const campaignId = computed(() => {
|
||||||
return Campaign.value?._id ?? Campaign.value?.id ?? null;
|
return Campaign.value?._id ?? Campaign.value?.id ?? null;
|
||||||
});
|
});
|
||||||
|
|
||||||
const notesMeta = computed(() => {
|
const notesMeta = computed(() => {
|
||||||
const count = notes.value.length;
|
const count = TotalNotes.value.length;
|
||||||
return `${count} ${count === 1 ? 'note' : 'notes'}`;
|
return `${count} ${count === 1 ? 'note' : 'notes'}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
async function fetchCampaignNotes() {
|
|
||||||
if (!campaignId.value) {
|
|
||||||
notes.value = [];
|
|
||||||
notesError.value = '';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
loadingNotes.value = true;
|
|
||||||
notesError.value = '';
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await Server().get('/note/list', {
|
|
||||||
params: {
|
|
||||||
campaign: campaignId.value
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.data.status !== 'ok') {
|
|
||||||
notes.value = [];
|
|
||||||
notesError.value = response.data.msg ?? 'Unable to load notes.';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
notes.value = response.data.notes.map((note) => {
|
|
||||||
return {
|
|
||||||
key: note._id,
|
|
||||||
title: note.title,
|
|
||||||
text: note.content ?? '',
|
|
||||||
date: note.date
|
|
||||||
};
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
notes.value = [];
|
|
||||||
notesError.value = 'Unable to load notes.';
|
|
||||||
} finally {
|
|
||||||
loadingNotes.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleSidebar() {
|
function toggleSidebar() {
|
||||||
sidebarCollapsed.value = !sidebarCollapsed.value;
|
sidebarCollapsed.value = !sidebarCollapsed.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openCreateNoteWindow() {
|
async function createNote() {
|
||||||
if (!Campaign.value) {
|
if (!Campaign.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateWindow('create_note');
|
const campaignId = Campaign.value?._id
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await Server().post('/note/create', {
|
||||||
|
title: 'New note',
|
||||||
|
content: "",
|
||||||
|
campaign: campaignId
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.data.status !== 'ok') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emitter.emit('note-created', response.data.note);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function openNote(note) {
|
function openNote(note) {
|
||||||
emitter.emit('push-note', note);
|
PushNote(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleNoteCreated(note) {
|
function handleNoteCreated(note) {
|
||||||
@@ -93,14 +72,16 @@ function handleNoteCreated(note) {
|
|||||||
date: note.date
|
date: note.date
|
||||||
};
|
};
|
||||||
|
|
||||||
notes.value = notes.value.filter((currentNote) => {
|
TotalNotes.value = TotalNotes.value.filter((currentNote) => {
|
||||||
return currentNote.key !== createdNote.key;
|
return currentNote.key !== createdNote.key;
|
||||||
});
|
});
|
||||||
notes.value.unshift(createdNote);
|
TotalNotes.value.unshift(createdNote);
|
||||||
openNote(createdNote);
|
openNote(createdNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
selectedTool.value = 'notes';
|
||||||
|
FetchCampaignNotes();
|
||||||
emitter.on('note-created', handleNoteCreated);
|
emitter.on('note-created', handleNoteCreated);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -109,13 +90,13 @@ onUnmounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch(Campaign, () => {
|
watch(Campaign, () => {
|
||||||
fetchCampaignNotes();
|
FetchCampaignNotes();
|
||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="sidebar-shell">
|
<div class="sidebar-shell">
|
||||||
<nav class="sidebar-actions" aria-label="Campaign tools">
|
<nav class="sidebar-tools" aria-label="Campaign tools">
|
||||||
<button
|
<button
|
||||||
class="sidebar-action"
|
class="sidebar-action"
|
||||||
type="button"
|
type="button"
|
||||||
@@ -136,27 +117,43 @@ watch(Campaign, () => {
|
|||||||
<button
|
<button
|
||||||
class="sidebar-action"
|
class="sidebar-action"
|
||||||
type="button"
|
type="button"
|
||||||
@click="openCreateNoteWindow"
|
@click="selectedTool = 'notes'"
|
||||||
:disabled="!Campaign"
|
:class="{ active: selectedTool === 'notes' }"
|
||||||
title="New note"
|
|
||||||
aria-label="New note"
|
|
||||||
>
|
>
|
||||||
<img class="sidebar-action-icon" src="/icons/iconoir/regular/plus.svg" alt="" aria-hidden="true">
|
<img
|
||||||
</button>
|
class="sidebar-action-icon"
|
||||||
|
:src="'/icons/iconoir/regular/bookmark-book.svg'"
|
||||||
<button
|
alt=""
|
||||||
class="sidebar-action"
|
aria-hidden="true"
|
||||||
type="button"
|
>
|
||||||
@click="fetchCampaignNotes"
|
|
||||||
:disabled="!Campaign || loadingNotes"
|
|
||||||
title="Refresh notes"
|
|
||||||
aria-label="Refresh notes"
|
|
||||||
>
|
|
||||||
<img class="sidebar-action-icon" src="/icons/iconoir/regular/refresh.svg" alt="" aria-hidden="true">
|
|
||||||
</button>
|
</button>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<aside class="notes-sidebar" :class="{ collapsed: sidebarCollapsed }">
|
<aside class="notes-sidebar" :class="{ collapsed: sidebarCollapsed }">
|
||||||
|
<div class="sidebar-actions">
|
||||||
|
<button
|
||||||
|
class="sidebar-action"
|
||||||
|
type="button"
|
||||||
|
@click="createNote"
|
||||||
|
:disabled="!Campaign"
|
||||||
|
title="New note"
|
||||||
|
aria-label="New note"
|
||||||
|
>
|
||||||
|
<img class="sidebar-action-icon" src="/icons/iconoir/regular/plus.svg" alt="" aria-hidden="true">
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="sidebar-action"
|
||||||
|
type="button"
|
||||||
|
@click="fetchCampaignNotes"
|
||||||
|
:disabled="!Campaign || loadingNotes"
|
||||||
|
title="Refresh notes"
|
||||||
|
aria-label="Refresh notes"
|
||||||
|
>
|
||||||
|
<img class="sidebar-action-icon" src="/icons/iconoir/regular/refresh.svg" alt="" aria-hidden="true">
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="sidebar-header">
|
<div class="sidebar-header">
|
||||||
<div class="sidebar-copy">
|
<div class="sidebar-copy">
|
||||||
<span class="sidebar-eyebrow">Campaign</span>
|
<span class="sidebar-eyebrow">Campaign</span>
|
||||||
@@ -174,13 +171,13 @@ watch(Campaign, () => {
|
|||||||
{{ notesError }}
|
{{ notesError }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="notes.length === 0" class="sidebar-state">
|
<div v-else-if="TotalNotes.length === 0" class="sidebar-state">
|
||||||
No notes in this campaign yet.
|
No notes in this campaign yet.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<button
|
<button
|
||||||
v-for="note in notes"
|
v-for="note in TotalNotes"
|
||||||
:key="note.key"
|
:key="note.key"
|
||||||
type="button"
|
type="button"
|
||||||
class="note-link"
|
class="note-link"
|
||||||
@@ -201,7 +198,7 @@ watch(Campaign, () => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-actions {
|
.sidebar-tools {
|
||||||
width: 32px;
|
width: 32px;
|
||||||
min-width: 32px;
|
min-width: 32px;
|
||||||
padding: 8px 6px;
|
padding: 8px 6px;
|
||||||
@@ -213,6 +210,11 @@ watch(Campaign, () => {
|
|||||||
gap: 4px;
|
gap: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar-action {
|
.sidebar-action {
|
||||||
width: 34px;
|
width: 34px;
|
||||||
height: 34px;
|
height: 34px;
|
||||||
@@ -226,10 +228,18 @@ watch(Campaign, () => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: var(--color-selected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-action:hover {
|
.sidebar-action:hover {
|
||||||
background: var(--color-button-hover);
|
background: var(--color-button-hover);
|
||||||
|
&.active {
|
||||||
|
background-color: var(--color-selected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-action:disabled {
|
.sidebar-action:disabled {
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { GetUser, LogoutUser } from '@/services/User'
|
import { GetUser, LogoutUser } from '@/services/User'
|
||||||
|
|
||||||
import Server from '@/services/Server'
|
import Server, { getBaseUrl } from '@/services/Server'
|
||||||
|
|
||||||
import { CreateWindow, CreateChildWindow, ClearWindow, GetFirstWindowId } from '../../services/Windows';
|
import { CreateWindow, CreateChildWindow, ClearWindow, GetFirstWindowId } from '../../services/Windows';
|
||||||
import { backendUrl } from '../../services/BackendURL';
|
|
||||||
import Spinner from './Spinner.vue';
|
import Spinner from './Spinner.vue';
|
||||||
const loadedIcon = ref(false);
|
const loadedIcon = ref(false);
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@ function retrieveAvatar(){
|
|||||||
Server().get('/user/retrieve-avatar?username=' + GetUser().username)
|
Server().get('/user/retrieve-avatar?username=' + GetUser().username)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if(response.data.image){
|
if(response.data.image){
|
||||||
const imgUrl = backendUrl + "/public/" + response.data.image;
|
const imgUrl = getBaseUrl() + "/public/" + response.data.image;
|
||||||
|
|
||||||
// Wait for the image to fully load
|
// Wait for the image to fully load
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
|||||||
@@ -10,14 +10,6 @@ const campaignName = computed(() => {
|
|||||||
return Campaign.value?.name ?? 'Campaign';
|
return Campaign.value?.name ?? 'Campaign';
|
||||||
});
|
});
|
||||||
|
|
||||||
function openCreateNoteWindow() {
|
|
||||||
if (!Campaign.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateWindow('create_note');
|
|
||||||
}
|
|
||||||
|
|
||||||
function exitToMainMenu() {
|
function exitToMainMenu() {
|
||||||
SetCampaign(null);
|
SetCampaign(null);
|
||||||
SetShowContent(false);
|
SetShowContent(false);
|
||||||
@@ -42,10 +34,6 @@ function exitToMainMenu() {
|
|||||||
<img class="top-bar-button-icon" src="/icons/iconoir/regular/nav-arrow-left.svg" alt="" aria-hidden="true">
|
<img class="top-bar-button-icon" src="/icons/iconoir/regular/nav-arrow-left.svg" alt="" aria-hidden="true">
|
||||||
<span>Main Menu</span>
|
<span>Main Menu</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="note-button sound-click" type="button" @click="openCreateNoteWindow" :disabled="!Campaign">
|
|
||||||
<img class="note-button-icon" src="/icons/iconoir/regular/plus.svg" alt="" aria-hidden="true">
|
|
||||||
<span>New Note</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, onUnmounted, ref, createApp } from 'vue';
|
import { onMounted, onUnmounted, ref, createApp } from 'vue';
|
||||||
import ToastManager from '~/components/managers/ToastManager.vue';
|
|
||||||
import { emitter } from '~/services/Emitter';
|
|
||||||
import { GetWidget, ParseMarkdown } from '~/services/Marker';
|
import { GetWidget, ParseMarkdown } from '~/services/Marker';
|
||||||
import Server from '~/services/Server';
|
import Server from '~/services/Server';
|
||||||
import { DisplayToast } from '~/services/Toaster';
|
import { DeleteNote, FetchCampaignNotes } from '~/services/Content';
|
||||||
import TestWidget from '../widgets/TestWidget.vue';
|
|
||||||
|
|
||||||
// import { GetNote, GetContent } from '@/services/Content';
|
// import { GetNote, GetContent } from '@/services/Content';
|
||||||
const props = defineProps(['text', 'title', 'noteKey']);
|
const props = defineProps(['text', 'title', 'noteKey']);
|
||||||
@@ -15,12 +12,11 @@ const sourceText = ref(''); // Original markdown source, used for editing
|
|||||||
const displayText = ref(''); // Compiled HTML from markdown
|
const displayText = ref(''); // Compiled HTML from markdown
|
||||||
|
|
||||||
const editingMode = ref(false);
|
const editingMode = ref(false);
|
||||||
const editableTitle = ref(null);
|
|
||||||
const title = ref(props.title);
|
const title = ref(props.title);
|
||||||
const displayTitle = ref('');
|
const displayTitle = ref('');
|
||||||
|
|
||||||
function closeNote(){
|
function closeNote(){
|
||||||
emitter.emit('delete-note', props.noteKey);
|
DeleteNote(props.noteKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
const compiledMarkdown = computed(() => {
|
const compiledMarkdown = computed(() => {
|
||||||
@@ -28,11 +24,14 @@ const compiledMarkdown = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function mountComponents() {
|
function mountComponents() {
|
||||||
const nodes = document.querySelectorAll('.vue-component');
|
// Should no need more
|
||||||
|
const widget_types = ['display', 'inline', 'link'];
|
||||||
nodes.forEach(el => {
|
widget_types.forEach((widget_type) => {
|
||||||
const app = createApp(GetWidget(el.dataset.component), { content: el.dataset.content });
|
const nodes = document.querySelectorAll('.vue-component-' + widget_type);
|
||||||
app.mount(el);
|
nodes.forEach(el => {
|
||||||
|
const app = createApp(GetWidget(widget_type, el.dataset.component), { content: el.dataset.content });
|
||||||
|
app.mount(el);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
@@ -93,6 +92,7 @@ function SaveNote(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// DisplayToast('green', "Note saved successfully.", 500);
|
// DisplayToast('green', "Note saved successfully.", 500);
|
||||||
|
FetchCampaignNotes();
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
// Handle error (e.g., show a notification)
|
// Handle error (e.g., show a notification)
|
||||||
});
|
});
|
||||||
@@ -146,6 +146,7 @@ function setupCallout() {
|
|||||||
|
|
||||||
const editTitle = (e) => {
|
const editTitle = (e) => {
|
||||||
title.value = e.target.innerText;
|
title.value = e.target.innerText;
|
||||||
|
SaveNote();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, onUnmounted, ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import Note from './Note.vue';
|
import Note from './Note.vue';
|
||||||
import { emitter } from '~/services/Emitter';
|
import { CurrentNotes, TotalNotes } from '~/services/Content';
|
||||||
|
|
||||||
let noteData = ref([]);
|
|
||||||
|
|
||||||
const noteContainer = ref(null);
|
const noteContainer = ref(null);
|
||||||
|
|
||||||
|
const computedCurrentNotes = computed(() => {
|
||||||
|
return CurrentNotes.value
|
||||||
|
.map(key => TotalNotes.value.find(note => note.key === key))
|
||||||
|
.filter(Boolean);
|
||||||
|
})
|
||||||
|
|
||||||
function calculateContainerWidth(){
|
function calculateContainerWidth(){
|
||||||
let dom = noteContainer.value;
|
let dom = noteContainer.value;
|
||||||
if (!dom) {
|
if (!dom) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dom.style.width = noteData.value.length * 701 + "px";
|
dom.style.width = CurrentNotes.value.length * 701 + "px";
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
for(let i = 0; i < dom.children.length; i++){
|
for(let i = 0; i < dom.children.length; i++){
|
||||||
@@ -25,42 +29,14 @@ function calculateContainerWidth(){
|
|||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pushNote(note){
|
watch(CurrentNotes, calculateContainerWidth);
|
||||||
noteData.value = noteData.value.filter((currentNote) => {
|
|
||||||
return currentNote.key !== note.key;
|
|
||||||
});
|
|
||||||
noteData.value.push(note);
|
|
||||||
calculateContainerWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePushNote(note) {
|
|
||||||
pushNote(note);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleDeleteNote(key) {
|
|
||||||
noteData.value = noteData.value.filter((note) => {
|
|
||||||
return note.key !== key;
|
|
||||||
});
|
|
||||||
calculateContainerWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Moure aixo
|
|
||||||
onMounted(() => {
|
|
||||||
emitter.on("push-note", handlePushNote);
|
|
||||||
emitter.on("delete-note", handleDeleteNote);
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
emitter.off("push-note", handlePushNote);
|
|
||||||
emitter.off("delete-note", handleDeleteNote);
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="note-scrolling-container" id="note-scrolling-container">
|
<div class="note-scrolling-container" id="note-scrolling-container">
|
||||||
<div class="note-container" ref="noteContainer" >
|
<div class="note-container" ref="noteContainer" >
|
||||||
<Note v-for="element in noteData" :key="element.key" :text="element.text" :title="element.title" :noteKey="element.key"></Note>
|
<Note v-for="element in computedCurrentNotes" :key="element.key" :text="element.text" :title="element.title" :noteKey="element.key"></Note>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -0,0 +1,177 @@
|
|||||||
|
<script setup>
|
||||||
|
const props = defineProps(['content']);
|
||||||
|
|
||||||
|
import { parse } from '~/services/widgets/DiceParser';
|
||||||
|
import { AddSound } from '~/services/Sound';
|
||||||
|
|
||||||
|
const container = ref(null);
|
||||||
|
const resultText = ref("");
|
||||||
|
const steps = ref(null);
|
||||||
|
const stepsHtml = ref("");
|
||||||
|
|
||||||
|
const rollDice = () => {
|
||||||
|
const result = parse(props.content);
|
||||||
|
resultText.value = result.total;
|
||||||
|
stepsHtml.value = result.steps.map(renderStep).join('');
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderStep = (s) => {
|
||||||
|
if (s.type === 'op') {
|
||||||
|
const label = s.op === '*' ? '×' : s.op === '/' ? '÷' : s.op;
|
||||||
|
return `<span class="step-op">${label}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.type === 'const') {
|
||||||
|
return `<span class="step-const">${s.value}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.type === 'dice') {
|
||||||
|
const { entry } = s;
|
||||||
|
const { rawRolls, kept, sides, mod, value } = entry;
|
||||||
|
|
||||||
|
const keptCopy = [...kept];
|
||||||
|
const tagged = rawRolls.map(v => {
|
||||||
|
const i = keptCopy.indexOf(v);
|
||||||
|
if (i !== -1) { keptCopy.splice(i, 1); return { v, kept: true }; }
|
||||||
|
return { v, kept: false };
|
||||||
|
});
|
||||||
|
|
||||||
|
let html = '';
|
||||||
|
|
||||||
|
tagged.forEach(({ v, kept }) => {
|
||||||
|
const isMax = v === sides, isMin = v === 1;
|
||||||
|
const cls = !kept ? 'roll-val dropped'
|
||||||
|
: isMax ? 'roll-val max-val'
|
||||||
|
: isMin ? 'roll-val min-val'
|
||||||
|
: 'roll-val kept';
|
||||||
|
html += `<span class="${cls}">${v}</span>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (kept.length < rawRolls.length || kept.length > 1) {
|
||||||
|
html += `<span class="step-sum">=${value}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
AddSound(container.value);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="roll-widget" ref="container">
|
||||||
|
<div class="roll-widget-body">
|
||||||
|
<span class="result-text">{{ resultText || '-' }}</span>
|
||||||
|
<button class="btn-primary roll-btn sound-click" @click="rollDice">
|
||||||
|
<span class="dice-content">
|
||||||
|
<!-- Dice icon (SVG) -->
|
||||||
|
<img class="icon" src="/icons/iconoir/regular/dice-three.svg" draggable="false">
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="roll-widget-results">
|
||||||
|
<span class="formula">{{ "[" + props.content + "]" }}</span>
|
||||||
|
<div class="steps" v-html="stepsHtml"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.steps {
|
||||||
|
margin-left: 8px;
|
||||||
|
height: 22px;
|
||||||
|
> {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.steps :deep(.roll-val){
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 18px;
|
||||||
|
padding: 1px 2px;
|
||||||
|
border-radius: 3px;
|
||||||
|
margin: 2px;
|
||||||
|
font-size: 12px;
|
||||||
|
border: 1px solid;
|
||||||
|
}
|
||||||
|
.steps :deep(.roll-val.kept){
|
||||||
|
background: rgba(93,184,122,0.12);
|
||||||
|
border-color: #4a8c5c;
|
||||||
|
color: #a8d4b4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.steps :deep(.roll-val.dropped) {
|
||||||
|
background: transparent;
|
||||||
|
border-color: var(--color-border);
|
||||||
|
color: var(--color-text-tertiary);
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
|
||||||
|
.steps :deep(.roll-val.max-val) {
|
||||||
|
background: rgba(93,184,122,0.2);
|
||||||
|
border-color: #5db87a;
|
||||||
|
color: #5db87a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.steps :deep(.roll-val.min-val) {
|
||||||
|
background: rgba(201,95,95,0.12);
|
||||||
|
border-color: #c95f5f;
|
||||||
|
color: #c95f5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.steps :deep(.step-op) { color: var(--color-text-secondary); padding: 0 4px; font-size: 13px; }
|
||||||
|
.steps :deep(.step-const) { font-size: 13px; color: var(--color-text-primary); padding: 0 2px; }
|
||||||
|
.steps :deep(.step-dice-label) { font-size: 11px; color: var(--color-text-tertiary); margin-right: 2px; }
|
||||||
|
.steps :deep(.step-sum) { font-size: 11px; color: var(--color-text-tertiary); margin-left: 2px; }
|
||||||
|
.steps :deep(.dice-mod) { font-style: normal; margin-left: 2px; }
|
||||||
|
|
||||||
|
.result-text {
|
||||||
|
font-size: 24px;
|
||||||
|
vertical-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.roll-widget-body {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-text {
|
||||||
|
margin-left: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.formula {
|
||||||
|
margin-left: 12px;
|
||||||
|
font-family: ui-monospace, monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-gray);
|
||||||
|
}
|
||||||
|
|
||||||
|
.roll-widget-results {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.roll-widget {
|
||||||
|
width: 100%;
|
||||||
|
background-color: var(--color-background-light);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.roll-btn {
|
||||||
|
padding: 8px;
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
25
frontend/app/components/viewer/widgets/link/NoteLink.vue
Normal file
25
frontend/app/components/viewer/widgets/link/NoteLink.vue
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { PushNote, GetNoteByName } from '~/services/Content';
|
||||||
|
|
||||||
|
const props = defineProps(['content'])
|
||||||
|
|
||||||
|
const parts = computed(() => props.content?.split('|') ?? [])
|
||||||
|
|
||||||
|
const href = computed(() => parts.value[0] || '')
|
||||||
|
const text = computed(() => parts.value[1] || parts.value[0] || '')
|
||||||
|
|
||||||
|
|
||||||
|
function handleClick() {
|
||||||
|
// your custom logic here
|
||||||
|
PushNote(GetNoteByName(href.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<a href="#" @click.prevent="handleClick">
|
||||||
|
{{ text }}
|
||||||
|
</a>
|
||||||
|
</template>
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import { computed, onMounted, ref } from 'vue';
|
|
||||||
import { SetupHandle, SetSize, ResetPosition, Top, ClearWindow } from '@/services/Windows';
|
|
||||||
import WindowHandle from './partials/WindowHandle.vue';
|
|
||||||
import Server from '~/services/Server';
|
|
||||||
import { emitter } from '~/services/Emitter';
|
|
||||||
import { useCampaignService } from '~/services/Campaign';
|
|
||||||
|
|
||||||
const handle = ref(null);
|
|
||||||
const wrapper = ref(null);
|
|
||||||
|
|
||||||
const props = defineProps(['data']);
|
|
||||||
const data = props.data;
|
|
||||||
|
|
||||||
const { Campaign } = useCampaignService();
|
|
||||||
|
|
||||||
const id = data.id;
|
|
||||||
const title = ref('');
|
|
||||||
const content = ref('');
|
|
||||||
const isSaving = ref(false);
|
|
||||||
const error = ref('');
|
|
||||||
|
|
||||||
const campaignId = computed(() => {
|
|
||||||
return Campaign.value?._id ?? Campaign.value?.id ?? null;
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
Top(wrapper);
|
|
||||||
SetupHandle(id, handle);
|
|
||||||
SetSize(id, { width: 640, height: 520 });
|
|
||||||
ResetPosition(id, "center");
|
|
||||||
});
|
|
||||||
|
|
||||||
async function createNote() {
|
|
||||||
if (!campaignId.value || isSaving.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isSaving.value = true;
|
|
||||||
error.value = '';
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await Server().post('/note/create', {
|
|
||||||
title: title.value.trim() || 'Untitled Note',
|
|
||||||
content: content.value,
|
|
||||||
campaign: campaignId.value
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.data.status !== 'ok') {
|
|
||||||
error.value = response.data.msg ?? 'Unable to create note.';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
emitter.emit('note-created', response.data.note);
|
|
||||||
ClearWindow({ id });
|
|
||||||
} catch (err) {
|
|
||||||
error.value = 'Unable to create note.';
|
|
||||||
} finally {
|
|
||||||
isSaving.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="window-wrapper" :id="'window-wrapper-' + id" ref="wrapper">
|
|
||||||
<WindowHandle :window="id" ref="handle"></WindowHandle>
|
|
||||||
|
|
||||||
<div class="body">
|
|
||||||
<form @submit.prevent="createNote">
|
|
||||||
<div class="form-field">
|
|
||||||
<label>Title</label>
|
|
||||||
<input v-model="title" type="text" name="noteTitle" placeholder="Enter a note title" autocomplete="off">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-field stacked">
|
|
||||||
<label>Content</label>
|
|
||||||
<textarea v-model="content" name="noteContent" placeholder="Write your note here"></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="error" class="form-error">
|
|
||||||
{{ error }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-actions">
|
|
||||||
<button class="btn-primary sound-click" :disabled="isSaving">
|
|
||||||
{{ isSaving ? 'Creating...' : 'Create Note' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.window-wrapper {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.body {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
form {
|
|
||||||
margin: 10px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-field {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-field > * {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stacked {
|
|
||||||
align-items: stretch;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
label {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea {
|
|
||||||
min-height: 300px;
|
|
||||||
resize: vertical;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-error {
|
|
||||||
color: #9e2a2b;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-actions {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-actions button {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
6
frontend/app/plugins/api.ts
Normal file
6
frontend/app/plugins/api.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { initApi } from '../services/Server';
|
||||||
|
|
||||||
|
export default defineNuxtPlugin(() => {
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
initApi(config.public.apiBaseUrl);
|
||||||
|
});
|
||||||
@@ -5,7 +5,6 @@ function loadLocaleMessages() {
|
|||||||
const messages: Record<string, any> = {}
|
const messages: Record<string, any> = {}
|
||||||
|
|
||||||
for (const path in locales) {
|
for (const path in locales) {
|
||||||
console.log(path);
|
|
||||||
const matched = path.match(/i18n\/locales\/(\w+)\/(.*)\.json$/)
|
const matched = path.match(/i18n\/locales\/(\w+)\/(.*)\.json$/)
|
||||||
if (!matched) continue
|
if (!matched) continue
|
||||||
|
|
||||||
@@ -18,7 +17,6 @@ function loadLocaleMessages() {
|
|||||||
messages[locale][file] = (locales[path] as any).default
|
messages[locale][file] = (locales[path] as any).default
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(messages);
|
|
||||||
return messages
|
return messages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
const backendUrl = process.env.API_BASE_URL || 'http://localhost:5000/api'
|
|
||||||
|
|
||||||
export {
|
|
||||||
backendUrl
|
|
||||||
};
|
|
||||||
@@ -1,12 +1,76 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import { useCampaignService } from '~/services/Campaign.js';
|
||||||
|
import Server from './Server';
|
||||||
|
|
||||||
const ShowContent = ref(false);
|
const ShowContent = ref(false);
|
||||||
|
|
||||||
|
const TotalNotes = ref([]); // Full note data
|
||||||
|
const CurrentNotes = ref([]); // Current opened note keys
|
||||||
|
|
||||||
function SetShowContent(value) {
|
function SetShowContent(value) {
|
||||||
ShowContent.value = value;
|
ShowContent.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PushNote(note){
|
||||||
|
CurrentNotes.value = CurrentNotes.value.filter((currentNote) => {
|
||||||
|
return currentNote.key !== note.key;
|
||||||
|
});
|
||||||
|
CurrentNotes.value.push(note.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DeleteNote(key){
|
||||||
|
CurrentNotes.value = CurrentNotes.value.filter((k) => {
|
||||||
|
return k !== key;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function FetchCampaignNotes() {
|
||||||
|
// First we get campaign info
|
||||||
|
const { Campaign } = useCampaignService();
|
||||||
|
const campaignId = Campaign.value?._id ?? Campaign.value?.id ?? null;
|
||||||
|
|
||||||
|
if (!campaignId) {
|
||||||
|
TotalNotes.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await Server().get('/note/list', {
|
||||||
|
params: {
|
||||||
|
campaign: campaignId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.data.status !== 'ok') {
|
||||||
|
// TODO: ERROR
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TotalNotes.value = response.data.notes.map((note) => {
|
||||||
|
return {
|
||||||
|
key: note._id,
|
||||||
|
title: note.title,
|
||||||
|
text: note.content ?? '',
|
||||||
|
date: note.date
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
// TODO: ERROR
|
||||||
|
console.error(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetNoteByName(name){
|
||||||
|
return TotalNotes.value.find(note => note.title == name);
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ShowContent,
|
ShowContent,
|
||||||
SetShowContent
|
SetShowContent,
|
||||||
|
CurrentNotes,
|
||||||
|
FetchCampaignNotes,
|
||||||
|
TotalNotes,
|
||||||
|
PushNote,
|
||||||
|
DeleteNote,
|
||||||
|
GetNoteByName
|
||||||
}
|
}
|
||||||
@@ -1,27 +1,37 @@
|
|||||||
import { Marked } from "marked";
|
import { Marked } from "marked";
|
||||||
const widget_map = {
|
const widget_map = {
|
||||||
test: () => import("~/components/viewer/widgets/TestWidget.vue"),
|
inline: {
|
||||||
table: () => import("~/components/viewer/widgets/TableWidget.vue"),
|
roll: () => import("~/components/viewer/widgets/inline/RollWidgetInline.vue"),
|
||||||
roll: () => import("~/components/viewer/widgets/RollWidget.vue"),
|
},
|
||||||
|
display: {
|
||||||
|
roll: () => import("~/components/viewer/widgets/display/RollWidgetDisplay.vue"),
|
||||||
|
},
|
||||||
|
link: {
|
||||||
|
link: () => import("~/components/viewer/widgets/link/NoteLink.vue")
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const componentCache = {}
|
const componentCache = {
|
||||||
|
inline: {},
|
||||||
|
display: {},
|
||||||
|
link: {}
|
||||||
|
}
|
||||||
|
|
||||||
const GetWidget = (type) => {
|
const GetWidget = (type, name) => {
|
||||||
if (!componentCache[type]) {
|
if (!componentCache[type][name]) {
|
||||||
componentCache[type] = defineAsyncComponent(
|
componentCache[type][name] = defineAsyncComponent(
|
||||||
widget_map[type]
|
widget_map[type][name]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return componentCache[type]
|
return componentCache[type][name]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const marker = new Marked();
|
const marker = new Marked();
|
||||||
|
|
||||||
const extension = {
|
const extension = {
|
||||||
name: "something",
|
name: "widget",
|
||||||
level: "block",
|
level: "block",
|
||||||
|
|
||||||
tokenizer(src) {
|
tokenizer(src) {
|
||||||
@@ -31,7 +41,7 @@ const extension = {
|
|||||||
if (!match) return;
|
if (!match) return;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "something",
|
type: "widget",
|
||||||
raw: match[0],
|
raw: match[0],
|
||||||
name: match[1],
|
name: match[1],
|
||||||
text: match[2],
|
text: match[2],
|
||||||
@@ -39,12 +49,12 @@ const extension = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
return `<div class="vue-component" data-component="${token.name}" data-content="${token.text}"></div>`;
|
return `<div class="vue-component-display" data-component="${token.name}" data-content="${token.text}"></div>`;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const inlineExtension = {
|
const inlineExtension = {
|
||||||
name: "something_inline",
|
name: "widget_inline",
|
||||||
level: "inline",
|
level: "inline",
|
||||||
start(src) {
|
start(src) {
|
||||||
return src.indexOf("@");
|
return src.indexOf("@");
|
||||||
@@ -56,7 +66,7 @@ const inlineExtension = {
|
|||||||
if (!match) return;
|
if (!match) return;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "something_inline",
|
type: "widget_inline",
|
||||||
raw: match[0],
|
raw: match[0],
|
||||||
name: match[1],
|
name: match[1],
|
||||||
text: match[2],
|
text: match[2],
|
||||||
@@ -64,12 +74,36 @@ const inlineExtension = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
return `<span class="vue-component" data-component="${token.name}" data-content="${token.text}"></span>`;
|
return `<span class="vue-component-inline" data-component="${token.name}" data-content="${token.text}"></span>`;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const linkExtension = {
|
||||||
|
name: "link_to",
|
||||||
|
level: "inline",
|
||||||
|
start(src) {
|
||||||
|
return src.indexOf("[[");
|
||||||
|
},
|
||||||
|
|
||||||
|
tokenizer(src) {
|
||||||
|
const rule = /^\[\[([^\n]*)\]\]/;
|
||||||
|
const match = rule.exec(src);
|
||||||
|
if (!match) return;
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: "link_to",
|
||||||
|
raw: match[0],
|
||||||
|
link: match[1],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
renderer(token) {
|
||||||
|
return `<span class="vue-component-link" data-component="link" data-content="${token.link}"></span>`;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
marker.use({
|
marker.use({
|
||||||
extensions: [extension, inlineExtension],
|
extensions: [extension, inlineExtension, linkExtension],
|
||||||
});
|
});
|
||||||
|
|
||||||
function ParseMarkdown(source) {
|
function ParseMarkdown(source) {
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import { backendUrl } from './BackendURL';
|
|
||||||
|
|
||||||
const server = axios.create({
|
const server = axios.create({
|
||||||
baseURL: backendUrl,
|
baseURL: 'http://localhost:5000/api', // fallback only
|
||||||
headers: {
|
headers: {
|
||||||
"Access-Control-Allow-Origin": "*",
|
"Access-Control-Allow-Origin": "*",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attach token dynamically on each request via interceptor
|
export const initApi = (baseURL) => {
|
||||||
|
server.defaults.baseURL = baseURL;
|
||||||
|
};
|
||||||
|
|
||||||
server.interceptors.request.use((config) => {
|
server.interceptors.request.use((config) => {
|
||||||
const token = localStorage.getItem('token');
|
const token = localStorage.getItem('token');
|
||||||
if (token) {
|
if (token) {
|
||||||
@@ -18,4 +19,6 @@ server.interceptors.request.use((config) => {
|
|||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
|
|
||||||
export default () => server;
|
export default () => server;
|
||||||
|
|
||||||
|
export const getBaseUrl = () => server.defaults.baseURL;
|
||||||
3
frontend/app/services/StatusBar.js
Normal file
3
frontend/app/services/StatusBar.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
const statusMessage = ref("")
|
||||||
@@ -34,12 +34,6 @@ const defWindows = {
|
|||||||
component: () => import('~/components/windows/CreateCampaignWindow.vue'),
|
component: () => import('~/components/windows/CreateCampaignWindow.vue'),
|
||||||
close: () => ClearWindow({type: 'create_campaign'}),
|
close: () => ClearWindow({type: 'create_campaign'}),
|
||||||
movable: true
|
movable: true
|
||||||
},
|
|
||||||
create_note: {
|
|
||||||
title: "Create note",
|
|
||||||
component: () => import('~/components/windows/CreateNoteWindow.vue'),
|
|
||||||
close: () => ClearWindow({type: 'create_note'}),
|
|
||||||
movable: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// dice-parser.js
|
// DiceParser.js
|
||||||
|
|
||||||
function roll(sides) {
|
function roll(sides) {
|
||||||
return Math.floor(Math.random() * sides) + 1;
|
return Math.floor(Math.random() * sides) + 1;
|
||||||
@@ -27,10 +27,9 @@ export function parse(expr) {
|
|||||||
const tokens = tokenize(expr);
|
const tokens = tokenize(expr);
|
||||||
if (!tokens.length) throw new Error('Empty expression');
|
if (!tokens.length) throw new Error('Empty expression');
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
const rolls = [];
|
|
||||||
|
|
||||||
function peek() { return tokens[pos]; }
|
const peek = () => tokens[pos];
|
||||||
function consume() { return tokens[pos++]; }
|
const consume = () => tokens[pos++];
|
||||||
|
|
||||||
function parseExpr() { return parseAddSub(); }
|
function parseExpr() { return parseAddSub(); }
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ export function parse(expr) {
|
|||||||
const right = parseMulDiv();
|
const right = parseMulDiv();
|
||||||
left = {
|
left = {
|
||||||
value: op === '+' ? left.value + right.value : left.value - right.value,
|
value: op === '+' ? left.value + right.value : left.value - right.value,
|
||||||
rolls: [...left.rolls, ...right.rolls],
|
steps: [...left.steps, { type: 'op', op }, ...right.steps],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return left;
|
return left;
|
||||||
@@ -55,7 +54,7 @@ export function parse(expr) {
|
|||||||
if (op === '/' && right.value === 0) throw new Error('Division by zero');
|
if (op === '/' && right.value === 0) throw new Error('Division by zero');
|
||||||
left = {
|
left = {
|
||||||
value: op === '*' ? left.value * right.value : Math.floor(left.value / right.value),
|
value: op === '*' ? left.value * right.value : Math.floor(left.value / right.value),
|
||||||
rolls: [...left.rolls, ...right.rolls],
|
steps: [...left.steps, { type: 'op', op }, ...right.steps],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return left;
|
return left;
|
||||||
@@ -65,7 +64,7 @@ export function parse(expr) {
|
|||||||
if (peek() === '-') {
|
if (peek() === '-') {
|
||||||
consume();
|
consume();
|
||||||
const r = parsePrimary();
|
const r = parsePrimary();
|
||||||
return { value: -r.value, rolls: r.rolls };
|
return { value: -r.value, steps: [{ type: 'op', op: '-' }, ...r.steps] };
|
||||||
}
|
}
|
||||||
return parsePrimary();
|
return parsePrimary();
|
||||||
}
|
}
|
||||||
@@ -79,7 +78,10 @@ export function parse(expr) {
|
|||||||
const inner = parseExpr();
|
const inner = parseExpr();
|
||||||
if (peek() !== ')') throw new Error('Missing closing )');
|
if (peek() !== ')') throw new Error('Missing closing )');
|
||||||
consume();
|
consume();
|
||||||
return inner;
|
return {
|
||||||
|
value: inner.value,
|
||||||
|
steps: [{ type: 'op', op: '(' }, ...inner.steps, { type: 'op', op: ')' }],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const diceInfo = parseDiceToken(tok);
|
const diceInfo = parseDiceToken(tok);
|
||||||
@@ -90,7 +92,8 @@ export function parse(expr) {
|
|||||||
|
|
||||||
if (/^\d+$/.test(tok)) {
|
if (/^\d+$/.test(tok)) {
|
||||||
consume();
|
consume();
|
||||||
return { value: parseInt(tok), rolls: [] };
|
const v = parseInt(tok);
|
||||||
|
return { value: v, steps: [{ type: 'const', value: v }] };
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Unexpected token: ${tok}`);
|
throw new Error(`Unexpected token: ${tok}`);
|
||||||
@@ -119,12 +122,13 @@ export function parse(expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const entry = { sides, rawRolls, kept, mod, value: kept.reduce((a, b) => a + b, 0) };
|
const entry = { sides, rawRolls, kept, mod, value: kept.reduce((a, b) => a + b, 0) };
|
||||||
rolls.push(entry);
|
return {
|
||||||
return { value: entry.value, rolls: [entry] };
|
value: entry.value,
|
||||||
|
steps: [{ type: 'dice', entry }],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = parseExpr();
|
const result = parseExpr();
|
||||||
if (pos < tokens.length) throw new Error(`Unexpected token: ${tokens[pos]}`);
|
if (pos < tokens.length) throw new Error(`Unexpected token: ${tokens[pos]}`);
|
||||||
|
return { total: result.value, steps: result.steps };
|
||||||
return { total: result.value, rolls: result.rolls };
|
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ export default defineNuxtConfig({
|
|||||||
|
|
||||||
runtimeConfig: {
|
runtimeConfig: {
|
||||||
public: {
|
public: {
|
||||||
apiBaseUrl: process.env.API_BASE_URL || 'http://localhost:5000/api',
|
apiBaseUrl: process.env.NUXT_PUBLIC_API_BASE_URL || 'http://localhost:5000/api',
|
||||||
gitCommit: git.commit,
|
gitCommit: git.commit,
|
||||||
gitTag: git.tag,
|
gitTag: git.tag,
|
||||||
gitBranch: git.branch,
|
gitBranch: git.branch,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nuxt build",
|
"build": "nuxt build --dotenv .env.production",
|
||||||
"dev": "nuxt dev",
|
"dev": "nuxt dev",
|
||||||
"generate": "nuxt generate",
|
"generate": "nuxt generate",
|
||||||
"preview": "nuxt preview",
|
"preview": "nuxt preview",
|
||||||
|
|||||||
Reference in New Issue
Block a user