Some falukant fixes, added undeground ui - no save right now, changed menu (and verification)
@@ -58,6 +58,8 @@ class FalukantController {
|
||||
this.renovate = this.renovate.bind(this);
|
||||
this.renovateAll = this.renovateAll.bind(this);
|
||||
this.createBranch = this.createBranch.bind(this);
|
||||
this.getUndergroundTypes = this.getUndergroundTypes.bind(this);
|
||||
this.getNotifications = this.getNotifications.bind(this);
|
||||
}
|
||||
|
||||
async getUser(req, res) {
|
||||
@@ -806,6 +808,28 @@ class FalukantController {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getUndergroundTypes(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const result = await FalukantService.getUndergroundTypes(hashedUserId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getNotifications(req, res) {
|
||||
try {
|
||||
const { userid: hashedUserId } = req.headers;
|
||||
const result = await FalukantService.getNotifications(hashedUserId);
|
||||
res.status(200).json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default FalukantController;
|
||||
|
||||
@@ -56,6 +56,19 @@ const menuStructure = {
|
||||
diary: {
|
||||
visible: ["all"],
|
||||
path: "/socialnetwork/diary"
|
||||
},
|
||||
erotic: {
|
||||
visible: ["over18"],
|
||||
children: {
|
||||
pictures: {
|
||||
visible: ["over18"],
|
||||
path: "/socialnetwork/erotic/pictures"
|
||||
},
|
||||
videos: {
|
||||
visible: ["over18"],
|
||||
path: "/socialnetwork/erotic/videos"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -70,6 +83,10 @@ const menuStructure = {
|
||||
randomChat: {
|
||||
visible: ["over12"],
|
||||
action: "openRanomChat"
|
||||
},
|
||||
eroticChat: {
|
||||
visible: ["over18"],
|
||||
action: "openEroticChat"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -248,6 +265,8 @@ class NavigationController {
|
||||
if (value.visible.includes("all")
|
||||
|| value.visible.some(v => rights.includes(v) || (value.visible.includes("anyadmin") && rights.length > 0))
|
||||
|| (value.visible.includes("over14") && age >= 14)
|
||||
|| (value.visible.includes("over12") && age >= 12)
|
||||
|| (value.visible.includes("over18") && age >= 18)
|
||||
|| (value.visible.includes('nofalukantaccount') && !hasFalukantAccount)
|
||||
|| (value.visible.includes('hasfalukantaccount') && hasFalukantAccount)) {
|
||||
const { visible, ...itemWithoutVisible } = value;
|
||||
|
||||
@@ -88,6 +88,8 @@ import PoliticalOfficeRequirement from './falukant/predefine/political_office_pr
|
||||
import PoliticalOfficePrerequisite from './falukant/predefine/political_office_prerequisite.js';
|
||||
import PoliticalOfficeHistory from './falukant/log/political_office_history.js';
|
||||
import ElectionHistory from './falukant/log/election_history.js';
|
||||
import Underground from './falukant/data/underground.js';
|
||||
import UndergroundType from './falukant/type/underground.js';
|
||||
|
||||
export default function setupAssociations() {
|
||||
// UserParam related associations
|
||||
@@ -696,5 +698,34 @@ export default function setupAssociations() {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'electionHistory',
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
Underground.belongsTo(UndergroundType, {
|
||||
foreignKey: 'undergroundTypeId',
|
||||
as: 'undergroundType'
|
||||
});
|
||||
UndergroundType.hasMany(Underground, {
|
||||
foreignKey: 'undergroundTypeId',
|
||||
as: 'undergrounds'
|
||||
});
|
||||
|
||||
// 2) Täter (performer)
|
||||
Underground.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'performerId',
|
||||
as: 'performer'
|
||||
});
|
||||
FalukantCharacter.hasMany(Underground, {
|
||||
foreignKey: 'performerId',
|
||||
as: 'performedUndergrounds'
|
||||
});
|
||||
|
||||
// 3) Opfer (victim)
|
||||
Underground.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'victimId',
|
||||
as: 'victim'
|
||||
});
|
||||
FalukantCharacter.hasMany(Underground, {
|
||||
foreignKey: 'victimId',
|
||||
as: 'victimUndergrounds'
|
||||
});
|
||||
}
|
||||
|
||||
36
backend/models/falukant/data/underground.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class Underground extends Model { }
|
||||
|
||||
Underground.init({
|
||||
undergroundTypeId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
performerId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
victimId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
parameters: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
},
|
||||
result: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Underground',
|
||||
tableName: 'underground',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default Underground;
|
||||
25
backend/models/falukant/type/underground.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class UndergroundType extends Model { }
|
||||
|
||||
UndergroundType.init({
|
||||
tr: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
cost: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'UndergroundType',
|
||||
tableName: 'underground',
|
||||
schema: 'falukant_type',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default UndergroundType;
|
||||
@@ -96,6 +96,8 @@ import Vote from './falukant/data/vote.js';
|
||||
import ElectionResult from './falukant/data/election_result.js';
|
||||
import PoliticalOfficeHistory from './falukant/log/political_office_history.js';
|
||||
import ElectionHistory from './falukant/log/election_history.js';
|
||||
import UndergroundType from './falukant/type/underground.js';
|
||||
import Underground from './falukant/data/underground.js';
|
||||
|
||||
const models = {
|
||||
SettingsType,
|
||||
@@ -182,8 +184,6 @@ const models = {
|
||||
Credit,
|
||||
DebtorsPrism,
|
||||
HealthActivity,
|
||||
|
||||
// Politics
|
||||
PoliticalOfficeType,
|
||||
PoliticalOfficeRequirement,
|
||||
PoliticalOfficeBenefitType,
|
||||
@@ -195,6 +195,8 @@ const models = {
|
||||
ElectionResult,
|
||||
PoliticalOfficeHistory,
|
||||
ElectionHistory,
|
||||
UndergroundType,
|
||||
Underground,
|
||||
};
|
||||
|
||||
export default models;
|
||||
|
||||
@@ -69,5 +69,7 @@ router.post('/politics/elections', falukantController.vote);
|
||||
router.get('/politics/open', falukantController.getOpenPolitics);
|
||||
router.post('/politics/open', falukantController.applyForElections);
|
||||
router.get('/cities', falukantController.getRegions);
|
||||
router.get('/underground/types', falukantController.getUndergroundTypes);
|
||||
router.get('/notifications', falukantController.getNotifications);
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -53,6 +53,8 @@ import Candidate from '../models/falukant/data/candidate.js';
|
||||
import Vote from '../models/falukant/data/vote.js';
|
||||
import PoliticalOfficePrerequisite from '../models/falukant/predefine/political_office_prerequisite.js';
|
||||
import PoliticalOfficeHistory from '../models/falukant/log/political_office_history.js';
|
||||
import UndergroundType from '../models/falukant/type/underground.js';
|
||||
import Notification from '../models/falukant/log/notification.js';
|
||||
|
||||
function calcAge(birthdate) {
|
||||
const b = new Date(birthdate); b.setHours(0, 0);
|
||||
@@ -1063,8 +1065,8 @@ class FalukantService extends BaseService {
|
||||
]
|
||||
});
|
||||
if (regionUserDirectorProposals.length > 0) {
|
||||
for (const proposal of regionUserDirectorProposals) {
|
||||
await DirectorProposal.destroy();
|
||||
for (const p of regionUserDirectorProposals) {
|
||||
await p.destroy();
|
||||
}
|
||||
}
|
||||
notifyUser(hashedUserId, 'directorchanged');
|
||||
@@ -1772,7 +1774,7 @@ class FalukantService extends BaseService {
|
||||
}
|
||||
const housePrice = this.housePrice(house);
|
||||
const oldHouse = await UserHouse.findOne({ where: { userId: falukantUser.id } });
|
||||
if (falukantUser.money < housePrice) {
|
||||
if (Number(falukantUser.money) < Number(housePrice)) {
|
||||
throw new Error('notenoughmoney.');
|
||||
}
|
||||
if (oldHouse) {
|
||||
@@ -2779,6 +2781,20 @@ class FalukantService extends BaseService {
|
||||
return { cost: totalCost };
|
||||
}
|
||||
|
||||
async getUndergroundTypes(hashedUserId) {
|
||||
const user = await getFalukantUserOrFail(hashedUserId);
|
||||
const undergroundTypes = await UndergroundType.findAll();
|
||||
return undergroundTypes;
|
||||
}
|
||||
|
||||
async getNotifications(hashedUserId) {
|
||||
const user = await getFalukantUserOrFail(hashedUserId);
|
||||
const notifications = await Notification.findAll({
|
||||
where: { userId: user.id, shown: false },
|
||||
order: [['createdAt', 'DESC']]
|
||||
});
|
||||
return user.notifications;
|
||||
}
|
||||
}
|
||||
|
||||
export default new FalukantService();
|
||||
|
||||
@@ -14,6 +14,7 @@ import BanquetteType from "../../models/falukant/type/banquette.js";
|
||||
import LearnRecipient from "../../models/falukant/type/learn_recipient.js";
|
||||
import PoliticalOfficeType from "../../models/falukant/type/political_office_type.js";
|
||||
import PoliticalOfficePrerequisite from "../../models/falukant/predefine/political_office_prerequisite.js";
|
||||
import UndergroundType from "../../models/falukant/type/underground.js";
|
||||
|
||||
export const initializeFalukantTypes = async () => {
|
||||
await initializeFalukantTypeRegions();
|
||||
@@ -29,6 +30,7 @@ export const initializeFalukantTypes = async () => {
|
||||
await initializeLearnerTypes();
|
||||
await initializePoliticalOfficeTypes();
|
||||
await initializePoliticalOfficePrerequisites();
|
||||
await initializeUndergroundTypes();
|
||||
};
|
||||
|
||||
const regionTypes = [];
|
||||
@@ -537,6 +539,29 @@ const politicalOfficePrerequisites = [
|
||||
}
|
||||
];
|
||||
|
||||
const undergroundTypes = [
|
||||
{
|
||||
"tr": "spyin",
|
||||
"cost": 3000
|
||||
},
|
||||
{
|
||||
"tr": "assassin",
|
||||
"cost": 5000
|
||||
},
|
||||
{
|
||||
"tr": "sabotage",
|
||||
"cost": 10000
|
||||
},
|
||||
{
|
||||
"tr": "corrupt_politician",
|
||||
"cost": 15000
|
||||
},
|
||||
{
|
||||
"tr": "rob",
|
||||
"cost": 500
|
||||
},
|
||||
];
|
||||
|
||||
{
|
||||
const giftNames = promotionalGifts.map(g => g.name);
|
||||
const traitNames = characterTraits.map(t => t.name);
|
||||
@@ -777,13 +802,11 @@ export const initializePoliticalOfficeTypes = async () => {
|
||||
|
||||
export const initializePoliticalOfficePrerequisites = async () => {
|
||||
for (const prereq of politicalOfficePrerequisites) {
|
||||
// zunächst den OfficeType anhand seines Namens (tr) ermitteln
|
||||
const office = await PoliticalOfficeType.findOne({
|
||||
where: { name: prereq.officeTr }
|
||||
});
|
||||
if (!office) continue;
|
||||
|
||||
// Nun findOrCreate mit dem neuen Spaltennamen:
|
||||
await PoliticalOfficePrerequisite.findOrCreate({
|
||||
where: { office_type_id: office.id },
|
||||
defaults: {
|
||||
@@ -794,3 +817,14 @@ export const initializePoliticalOfficePrerequisites = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
export const initializeUndergroundTypes = async () => {
|
||||
for (const underground of undergroundTypes) {
|
||||
await UndergroundType.findOrCreate({
|
||||
where: { tr: underground.tr },
|
||||
defaults: {
|
||||
tr: underground.tr,
|
||||
cost: underground.cost
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
BIN
frontend/public/images/icons/falukant/shortmap/bank.png
Normal file
|
After Width: | Height: | Size: 2.3 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/church.png
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/darknet.png
Normal file
|
After Width: | Height: | Size: 2.3 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/directors.png
Normal file
|
After Width: | Height: | Size: 2.1 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/education.png
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/family.png
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/guild.png
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/health.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/house.png
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/moneyhistory.png
Normal file
|
After Width: | Height: | Size: 2.9 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/nobility.png
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/overview.png
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/politics.png
Normal file
|
After Width: | Height: | Size: 2.5 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/reputation.png
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
frontend/public/images/icons/falukant/shortmap/towns.png
Normal file
|
After Width: | Height: | Size: 1.6 MiB |
@@ -7,7 +7,7 @@
|
||||
:columns="branchColumns"
|
||||
v-model="localSelectedBranch"
|
||||
:placeholder="$t('falukant.branch.selection.placeholder')"
|
||||
@input="updateSelectedBranch"
|
||||
@update:modelValue="updateSelectedBranch"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
@@ -70,7 +70,6 @@ export default {
|
||||
},
|
||||
|
||||
handleCreateBranch() {
|
||||
// wird ausgelöst, sobald der Dialog onConfirm erfolgreich abschließt
|
||||
this.$emit('createBranch');
|
||||
},
|
||||
},
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" v-model="director.mayProduce" @change="saveSetting('mayProduce', director.mayProduce)">
|
||||
<input type="checkbox" v-model="director.mayProduce"
|
||||
@change="saveSetting('mayProduce', director.mayProduce)">
|
||||
{{ $t('falukant.branch.director.produce') }}
|
||||
</label>
|
||||
</td>
|
||||
@@ -68,14 +69,30 @@
|
||||
await this.loadDirector();
|
||||
},
|
||||
methods: {
|
||||
async refresh() {
|
||||
await this.loadDirector();
|
||||
},
|
||||
|
||||
async loadDirector() {
|
||||
try {
|
||||
const response = await apiClient.get(`/api/falukant/director/${this.branchId}`);
|
||||
this.director = Object.keys(response.data).length === 0 || !response.data.director ? null : response.data.director;
|
||||
const data = response.data;
|
||||
if (
|
||||
!data ||
|
||||
(Array.isArray(data) && data.length === 0) ||
|
||||
typeof data.director === 'undefined' ||
|
||||
data.director === null
|
||||
) {
|
||||
this.director = null;
|
||||
} else {
|
||||
this.director = data.director;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading director:', error);
|
||||
this.director = null;
|
||||
}
|
||||
},
|
||||
|
||||
async saveSetting(settingKey, value) {
|
||||
if (!this.director) return;
|
||||
try {
|
||||
@@ -89,13 +106,16 @@
|
||||
console.error(`Error saving setting ${settingKey}:`, error);
|
||||
}
|
||||
},
|
||||
|
||||
openNewDirectorDialog() {
|
||||
console.log('openNewDirectorDialog');
|
||||
this.$refs.newDirectorDialog.open(this.branchId);
|
||||
},
|
||||
|
||||
fireDirector() {
|
||||
alert(this.$t('falukant.branch.director.fireAlert'));
|
||||
},
|
||||
|
||||
teachDirector() {
|
||||
alert(this.$t('falukant.branch.director.teachAlert'));
|
||||
},
|
||||
@@ -110,11 +130,12 @@
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.director-info-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.director-info-container>div {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</template>
|
||||
<span v-if="statusItems.length > 0">
|
||||
<template v-for="(menuItem, key) in menu.falukant.children" :key="menuItem.id" >
|
||||
<img :src="'/images/icons/falukant/' + key + '.jpg'" class="menu-icon" @click="openPage(menuItem)" :title="$t(`navigation.m-falukant.${key}`)" />
|
||||
<img :src="'/images/icons/falukant/shortmap/' + key + '.png'" class="menu-icon" @click="openPage(menuItem)" :title="$t(`navigation.m-falukant.${key}`)" />
|
||||
</template>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -334,7 +334,8 @@
|
||||
"salary": "Gehalt",
|
||||
"skills": "Wissen",
|
||||
"product": "Produkt",
|
||||
"knowledge": "Produktwissen"
|
||||
"knowledge": "Produktwissen",
|
||||
"hire": "Einstellen"
|
||||
},
|
||||
"skillKnowledges": {
|
||||
"excelent": "Exzellent",
|
||||
@@ -434,7 +435,8 @@
|
||||
"type": {
|
||||
"backyard_room": "Hinterhofzimmer",
|
||||
"wooden_house": "Holzhütte",
|
||||
"straw_hut": "Strohhütte"
|
||||
"straw_hut": "Strohhütte",
|
||||
"family_house": "Familienhaus"
|
||||
}
|
||||
},
|
||||
"nobility": {
|
||||
@@ -675,6 +677,46 @@
|
||||
"councillor": "Stadtrat",
|
||||
"assessor": "Schätzer"
|
||||
}
|
||||
},
|
||||
"underground": {
|
||||
"title": "Untergrund",
|
||||
"tabs": {
|
||||
"activities": "Aktivitäten",
|
||||
"attacks": "Angriffe"
|
||||
},
|
||||
"activities": {
|
||||
"none": "Keine Aktivitäten vorhanden.",
|
||||
"create": "Neue Aktivität erstellen",
|
||||
"type": "Aktivitätstyp",
|
||||
"victim": "Zielperson",
|
||||
"cost": "Kosten",
|
||||
"additionalInfo": "Zusätzliche Informationen",
|
||||
"victimPlaceholder": "Benutzername eingeben",
|
||||
"sabotageTarget": "Sabotageziel",
|
||||
"corruptGoal": "Ziel der Korruption"
|
||||
},
|
||||
"attacks": {
|
||||
"target": "Angreifer",
|
||||
"date": "Datum",
|
||||
"success": "Erfolg",
|
||||
"none": "Keine Angriffe aufgezeichnet."
|
||||
},
|
||||
"types": {
|
||||
"spyin": "Spionage",
|
||||
"assassin": "Attentat",
|
||||
"sabotage": "Sabotage",
|
||||
"corrupt_politician": "Korruption",
|
||||
"rob": "Raub"
|
||||
},
|
||||
"targets": {
|
||||
"house": "Wohnhaus",
|
||||
"storage": "Lager"
|
||||
},
|
||||
"goals": {
|
||||
"elect": "Amtseinsetzung",
|
||||
"taxIncrease": "Steuern erhöhen",
|
||||
"taxDecrease": "Steuern senken"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,8 @@
|
||||
"administration": "Verwaltung",
|
||||
"m-chats": {
|
||||
"multiChat": "Multiuser-Chat",
|
||||
"randomChat": "Zufalls-Singlechat"
|
||||
"randomChat": "Zufalls-Singlechat",
|
||||
"eroticChat": "Erotikchat"
|
||||
},
|
||||
"m-socialnetwork": {
|
||||
"guestbook": "Gästebuch",
|
||||
@@ -20,7 +21,12 @@
|
||||
"gallery": "Galerie",
|
||||
"blockedUsers": "Blockierte Benutzer",
|
||||
"oneTimeInvitation": "Einmal-Einladungen",
|
||||
"diary": "Tagebuch"
|
||||
"diary": "Tagebuch",
|
||||
"erotic": "Erotik",
|
||||
"m-erotic": {
|
||||
"pictures": "Bilder",
|
||||
"videos": "Videos"
|
||||
}
|
||||
},
|
||||
"m-settings": {
|
||||
"homepage": "Startseite",
|
||||
|
||||
@@ -12,6 +12,7 @@ import BankView from '../views/falukant/BankView.vue';
|
||||
import DirectorView from '../views/falukant/DirectorView.vue';
|
||||
import HealthView from '../views/falukant/HealthView.vue';
|
||||
import PoliticsView from '../views/falukant/PoliticsView.vue';
|
||||
import UndergroundView from '../views/falukant/UndergroundView.vue';
|
||||
|
||||
const falukantRoutes = [
|
||||
{
|
||||
@@ -98,6 +99,12 @@ const falukantRoutes = [
|
||||
component: PoliticsView,
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/falukant/darknet',
|
||||
name: 'UndergroundView',
|
||||
component: UndergroundView,
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
];
|
||||
|
||||
export default falukantRoutes;
|
||||
|
||||
@@ -4,47 +4,21 @@
|
||||
<div class="contentscroll">
|
||||
<h2>{{ $t('falukant.branch.title') }}</h2>
|
||||
|
||||
<BranchSelection
|
||||
:branches="branches"
|
||||
:selectedBranch="selectedBranch"
|
||||
@branchSelected="onBranchSelected"
|
||||
@createBranch="createBranch"
|
||||
@upgradeBranch="upgradeBranch"
|
||||
ref="branchSelection"
|
||||
/>
|
||||
<BranchSelection :branches="branches" :selectedBranch="selectedBranch" @branchSelected="onBranchSelected"
|
||||
@createBranch="createBranch" @upgradeBranch="upgradeBranch" ref="branchSelection" />
|
||||
|
||||
<DirectorInfo
|
||||
v-if="selectedBranch"
|
||||
:branchId="selectedBranch.id"
|
||||
ref="directorInfo"
|
||||
/>
|
||||
<DirectorInfo v-if="selectedBranch" :branchId="selectedBranch.id" ref="directorInfo" />
|
||||
|
||||
<SaleSection
|
||||
v-if="selectedBranch"
|
||||
:branchId="selectedBranch.id"
|
||||
ref="saleSection"
|
||||
/>
|
||||
<SaleSection v-if="selectedBranch" :branchId="selectedBranch.id" ref="saleSection" />
|
||||
|
||||
<ProductionSection
|
||||
v-if="selectedBranch"
|
||||
:branchId="selectedBranch.id"
|
||||
:products="products"
|
||||
ref="productionSection"
|
||||
/>
|
||||
<ProductionSection v-if="selectedBranch" :branchId="selectedBranch.id" :products="products"
|
||||
ref="productionSection" />
|
||||
|
||||
<StorageSection
|
||||
v-if="selectedBranch"
|
||||
:branchId="selectedBranch.id"
|
||||
ref="storageSection"
|
||||
/>
|
||||
<StorageSection v-if="selectedBranch" :branchId="selectedBranch.id" ref="storageSection" />
|
||||
|
||||
<RevenueSection
|
||||
v-if="selectedBranch"
|
||||
:products="products"
|
||||
:calculateProductRevenue="calculateProductRevenue"
|
||||
:calculateProductProfit="calculateProductProfit"
|
||||
ref="revenueSection"
|
||||
/>
|
||||
<RevenueSection v-if="selectedBranch" :products="products"
|
||||
:calculateProductRevenue="calculateProductRevenue" :calculateProductProfit="calculateProductProfit"
|
||||
ref="revenueSection" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -170,12 +144,19 @@
|
||||
}
|
||||
},
|
||||
|
||||
onBranchSelected(newBranch) {
|
||||
async onBranchSelected(newBranch) {
|
||||
this.selectedBranch = newBranch;
|
||||
await this.loadProducts();
|
||||
this.$nextTick(() => {
|
||||
this.$refs.directorInfo?.refresh();
|
||||
this.$refs.saleSection?.loadInventory();
|
||||
this.$refs.productionSection?.loadProductions();
|
||||
this.$refs.storageSection?.loadStorageData();
|
||||
this.$refs.revenueSection?.refresh && this.$refs.revenueSection.refresh();
|
||||
});
|
||||
},
|
||||
|
||||
async createBranch() {
|
||||
// Nach erfolgreichem Dialog-Event: neu laden
|
||||
await this.loadBranches();
|
||||
},
|
||||
|
||||
@@ -288,4 +269,3 @@
|
||||
padding-top: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -101,7 +101,7 @@ export default {
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/health');
|
||||
this.age = data.age;
|
||||
this.healthStatus = data.status;
|
||||
this.healthStatus = data.health;
|
||||
this.measuresTaken = data.history;
|
||||
this.availableMeasures = data.healthActivities;
|
||||
} catch (err) {
|
||||
|
||||
343
frontend/src/views/falukant/UndergroundView.vue
Normal file
@@ -0,0 +1,343 @@
|
||||
<template>
|
||||
<div class="underground-view">
|
||||
<StatusBar />
|
||||
|
||||
<h2>{{ $t('falukant.underground.title') }}</h2>
|
||||
|
||||
<SimpleTabs v-model="activeTab" :tabs="tabs" @change="onTabChange" />
|
||||
|
||||
<div class="tab-content">
|
||||
<!-- Aktivitäten -->
|
||||
<div v-if="activeTab === 'activities'" class="tab-pane">
|
||||
<!-- Neues Activity-Formular -->
|
||||
<div class="create-activity">
|
||||
<h3>{{ $t('falukant.underground.activities.create') }}</h3>
|
||||
|
||||
<label class="form-label">
|
||||
{{ $t('falukant.underground.activities.type') }}
|
||||
<select v-model="newActivityTypeId" class="form-control">
|
||||
<option v-for="type in undergroundTypes" :key="type.id" :value="type.id">
|
||||
{{ $t(`falukant.underground.types.${type.tr}`) }}
|
||||
({{ formatCost(type.cost) }})
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label class="form-label">
|
||||
{{ $t('falukant.underground.activities.victim') }}
|
||||
<input v-model="newVictimUsername" type="text" class="form-control"
|
||||
:placeholder="$t('falukant.underground.activities.victimPlaceholder')" />
|
||||
</label>
|
||||
|
||||
<!-- Bei sabotage: Ziel auswählen -->
|
||||
<label v-if="selectedType && selectedType.tr === 'sabotage'" class="form-label">
|
||||
{{ $t('falukant.underground.activities.sabotageTarget') }}
|
||||
<select v-model="newSabotageTarget" class="form-control">
|
||||
<option value="house">{{ $t('falukant.underground.targets.house') }}</option>
|
||||
<option value="storage">{{ $t('falukant.underground.targets.storage') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<!-- Bei corrupt_politician: Ziel erreichen -->
|
||||
<label v-if="selectedType && selectedType.tr === 'corrupt_politician'" class="form-label">
|
||||
{{ $t('falukant.underground.activities.corruptGoal') }}
|
||||
<select v-model="newCorruptGoal" class="form-control">
|
||||
<option value="elect">{{ $t('falukant.underground.goals.elect') }}</option>
|
||||
<option value="tax_increase">{{ $t('falukant.underground.goals.taxIncrease') }}</option>
|
||||
<option value="tax_decrease">{{ $t('falukant.underground.goals.taxDecrease') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<button class="btn-create-activity" :disabled="!canCreate" @click="createActivity">
|
||||
{{ $t('falukant.underground.activities.create') }}
|
||||
</button>
|
||||
</div>
|
||||
<!-- /Neues Activity-Formular -->
|
||||
|
||||
<div v-if="loading.activities" class="loading">
|
||||
{{ $t('loading') }}
|
||||
</div>
|
||||
<div v-else class="activities-table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ $t('falukant.underground.activities.type') }}</th>
|
||||
<th>{{ $t('falukant.underground.activities.victim') }}</th>
|
||||
<th>{{ $t('falukant.underground.activities.cost') }}</th>
|
||||
<th>{{ $t('falukant.underground.activities.additionalInfo') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="act in activities" :key="act.id">
|
||||
<!-- Typ -->
|
||||
<td>{{ $t(`falukant.underground.types.${act.type}`) }}</td>
|
||||
<!-- Victim -->
|
||||
<td>{{ act.victimName }}</td>
|
||||
<!-- Cost -->
|
||||
<td>{{ formatCost(act.cost) }}</td>
|
||||
<!-- Zusätzliche Informationen -->
|
||||
<td>
|
||||
<template v-if="act.type === 'sabotage'">
|
||||
{{ $t(`falukant.underground.targets.${act.target}`) }}
|
||||
</template>
|
||||
<template v-else-if="act.type === 'corrupt_politician'">
|
||||
{{ $t(`falukant.underground.goals.${act.goal}`) }}
|
||||
</template>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!activities.length">
|
||||
<td colspan="4">{{ $t('falukant.underground.activities.none') }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Angriffe -->
|
||||
<div v-else-if="activeTab === 'attacks'" class="tab-pane">
|
||||
<div v-if="loading.attacks" class="loading">
|
||||
{{ $t('loading') }}
|
||||
</div>
|
||||
<div v-else class="attacks-list">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ $t('falukant.underground.attacks.source') }}</th>
|
||||
<th>{{ $t('falukant.underground.attacks.date') }}</th>
|
||||
<th>{{ $t('falukant.underground.attacks.success') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="atk in attacks" :key="atk.id">
|
||||
<td>{{ atk.targetName }}</td>
|
||||
<td>{{ formatDate(atk.date) }}</td>
|
||||
<td>{{ atk.success ? $t('yes') : $t('no') }}</td>
|
||||
</tr>
|
||||
<tr v-if="!attacks.length">
|
||||
<td colspan="3">
|
||||
{{ $t('falukant.underground.attacks.none') }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import StatusBar from '@/components/falukant/StatusBar.vue';
|
||||
import SimpleTabs from '@/components/SimpleTabs.vue';
|
||||
import apiClient from '@/utils/axios.js';
|
||||
|
||||
export default {
|
||||
name: 'UndergroundView',
|
||||
components: { StatusBar, SimpleTabs },
|
||||
data() {
|
||||
return {
|
||||
activeTab: 'activities',
|
||||
tabs: [
|
||||
{ value: 'activities', label: 'falukant.underground.tabs.activities' },
|
||||
{ value: 'attacks', label: 'falukant.underground.tabs.attacks' }
|
||||
],
|
||||
undergroundTypes: [],
|
||||
activities: [],
|
||||
attacks: [],
|
||||
loading: { activities: false, attacks: false },
|
||||
|
||||
// Neue Activity-Formfelder
|
||||
newActivityTypeId: null,
|
||||
newVictimUsername: '',
|
||||
newSabotageTarget: 'house',
|
||||
newCorruptGoal: 'elect'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
selectedType() {
|
||||
return this.undergroundTypes.find(t => t.id === this.newActivityTypeId) || null;
|
||||
},
|
||||
canCreate() {
|
||||
if (!this.newActivityTypeId || !this.newVictimUsername.trim()) return false;
|
||||
if (this.selectedType.tr === 'sabotage' && !this.newSabotageTarget) return false;
|
||||
if (this.selectedType.tr === 'corrupt_politician' && !this.newCorruptGoal) return false;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.loadUndergroundTypes();
|
||||
if (this.undergroundTypes.length) {
|
||||
this.newActivityTypeId = this.undergroundTypes[0].id;
|
||||
}
|
||||
await this.loadActivities();
|
||||
},
|
||||
methods: {
|
||||
onTabChange(tab) {
|
||||
if (tab === 'activities' && !this.activities.length) {
|
||||
this.loadActivities();
|
||||
}
|
||||
if (tab === 'attacks' && !this.attacks.length) {
|
||||
this.loadAttacks();
|
||||
}
|
||||
},
|
||||
|
||||
async loadUndergroundTypes() {
|
||||
const { data } = await apiClient.get('/api/falukant/underground/types');
|
||||
this.undergroundTypes = data;
|
||||
},
|
||||
|
||||
async loadActivities() {
|
||||
this.loading.activities = true;
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/underground/activities');
|
||||
this.activities = data;
|
||||
} catch (err) {
|
||||
console.error('Error loading activities', err);
|
||||
} finally {
|
||||
this.loading.activities = false;
|
||||
}
|
||||
},
|
||||
|
||||
async loadAttacks() {
|
||||
this.loading.attacks = true;
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/underground/attacks');
|
||||
this.attacks = data;
|
||||
} catch (err) {
|
||||
console.error('Error loading attacks', err);
|
||||
} finally {
|
||||
this.loading.attacks = false;
|
||||
}
|
||||
},
|
||||
|
||||
async createActivity() {
|
||||
if (!this.canCreate) return;
|
||||
const payload = {
|
||||
typeId: this.newActivityTypeId,
|
||||
victimUsername: this.newVictimUsername.trim()
|
||||
};
|
||||
// je nach Typ noch ergänzen:
|
||||
if (this.selectedType.tr === 'sabotage') {
|
||||
payload.target = this.newSabotageTarget;
|
||||
}
|
||||
if (this.selectedType.tr === 'corrupt_politician') {
|
||||
payload.goal = this.newCorruptGoal;
|
||||
}
|
||||
try {
|
||||
await apiClient.post('/api/falukant/underground/activities', payload);
|
||||
// zurücksetzen & neu laden
|
||||
this.newVictimUsername = '';
|
||||
this.newSabotageTarget = 'house';
|
||||
this.newCorruptGoal = 'elect';
|
||||
await this.loadActivities();
|
||||
} catch (err) {
|
||||
console.error('Error creating activity', err);
|
||||
}
|
||||
},
|
||||
|
||||
formatDate(ts) {
|
||||
return new Date(ts).toLocaleDateString(this.$i18n.locale, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
},
|
||||
|
||||
formatCost(value) {
|
||||
return new Intl.NumberFormat(navigator.language, {
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0
|
||||
}).format(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.underground-view {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
h2 {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.tab-pane {
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.loading {
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
/* --- Create Activity --- */
|
||||
.create-activity {
|
||||
border: 1px solid #ccc;
|
||||
padding: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
border-radius: 4px;
|
||||
background: #fafafa;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.create-activity h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 0.4rem;
|
||||
margin-bottom: 1rem;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.btn-create-activity {
|
||||
padding: 0.5rem 1rem;
|
||||
cursor: pointer;
|
||||
background: #4caf50;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.btn-create-activity:disabled {
|
||||
background: #ccc;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* --- Activities List --- */
|
||||
.activities-list ul {
|
||||
list-style: disc;
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
/* --- Attacks Table --- */
|
||||
.attacks-list table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.attacks-list th,
|
||||
.attacks-list td {
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||