diff --git a/js-src/conquer/interface/node-view.ts b/js-src/conquer/interface/node-view.ts index 1405ee1..a1fc80b 100644 --- a/js-src/conquer/interface/node-view.ts +++ b/js-src/conquer/interface/node-view.ts @@ -1,9 +1,17 @@ import AbstractTopBarInterface from '@burguillosinfo/conquer/interface/abstract-top-bar-interface' import Conquer from '@burguillosinfo/conquer' import MapNode from '@burguillosinfo/conquer/map-node' +import ConquerUser from '@burguillosinfo/conquer/user' export default class NodeView extends AbstractTopBarInterface { private node: MapNode; + private user: ConquerUser; + private view: HTMLElement | null = null; + + public getNode(): MapNode { + return this.node; + } + private getNodeNameH2(): HTMLElement { const element = this.getMainNode().querySelector('h2.node-name'); if (!(element instanceof HTMLElement)) { @@ -12,6 +20,15 @@ export default class NodeView extends AbstractTopBarInterface { return element; } + private getView(): HTMLElement { + if (this.view === null) { + const view = this.getNodeFromTemplateId('conquer-view-node-template') + this.view = view; + } + return this.view; + } + + private getNodeDescriptionParagraph(): HTMLElement { const element = this.getMainNode().querySelector('p.node-description'); if (!(element instanceof HTMLElement)) { @@ -24,7 +41,14 @@ export default class NodeView extends AbstractTopBarInterface { super() this.node = node; } + public async run() { + const user = await ConquerUser.getSelfUser(); + if (user === null) { + this.runCallbacks('close'); + return; + } + this.user = user; const mainNode = this.getMainNode() this.runCallbacks('update-nodes'); try { @@ -32,15 +56,36 @@ export default class NodeView extends AbstractTopBarInterface { } catch (error) { this.runCallbacks('close'); } - const view = this.getNodeFromTemplateId('conquer-view-node-template') - mainNode.append(view) + mainNode.append(this.getView()) this.getNodeNameH2().innerText = this.node.getName(); this.getNodeDescriptionParagraph().innerText = this.node.getDescription() + "\n" + (this.node.isNear() ? 'Estas cerca y puedes interactuar con este sitio.' : 'Estás demasiado lejos para hacer nada aquí.'); - view.classList.remove('conquer-display-none') + if (this.node.isNear()) { + await this.runIfNear(); + } + this.getView().classList.remove('conquer-display-none') mainNode.classList.remove('conquer-display-none') } + + private async runIfNear(): Promise { + const team = await this.user.getTeam(); + if (team === null) { + const paragraphNoTeam = document.createElement('p'); + paragraphNoTeam.innerText = 'Parece que no has seleccionado equipo aun,' + + ' pulsa el botón de seleccionar equipo para comenzar tu aventura,' + + ' si quieres cambiar de equipo en el futuro puedes hacerlo sin problemas.'; + this.getView().append(paragraphNoTeam); + } + const selectTeamButton = document.createElement('button'); + selectTeamButton.innerText = 'Seleccionar equipo'; + selectTeamButton.addEventListener('click', () => { + this.runCallbacks('open-select-team'); + this.runCallbacks('close'); + }); + this.getView().append(selectTeamButton); + } + } diff --git a/js-src/conquer/interface/select-team.ts b/js-src/conquer/interface/select-team.ts new file mode 100644 index 0000000..1c0a14b --- /dev/null +++ b/js-src/conquer/interface/select-team.ts @@ -0,0 +1,57 @@ +import Conquer from '@burguillosinfo/conquer' +import ConquerUser from '@burguillosinfo/conquer/user' +import AbstractTopBarInterface from '@burguillosinfo/conquer/interface/abstract-top-bar-interface' +import MapNode from '@burguillosinfo/conquer/map-node' +import ConquerTeam from '@burguillosinfo/conquer/team'; + +export default class SelectTeamUI extends AbstractTopBarInterface { + private node: MapNode; + private user: ConquerUser; + private form: HTMLElement | null = null; + + constructor(node: MapNode) { + super(); + this.node = node; + } + + public async run(): Promise { + const user = await ConquerUser.getSelfUser() + if (user === null) { + this.runCallbacks('close') + return + } + this.user = user + await this.populateTeams(); + this.getForm().classList.remove('conquer-display-none'); + this.getMainNode().append(this.getForm()); + this.getMainNode().classList.remove('conquer-display-none'); + } + + private async populateTeams() { + const teams = await ConquerTeam.getTeams(); + for (const team of teams) { + this.populateTeam(team); + } + } + + private populateTeam(team: ConquerTeam) { + const teamDiv = this.getNodeFromTemplateId('conquer-team-to-select-template') + const nameParagraph = teamDiv.querySelector('p.conquer-name'); + const descriptionParagraph = teamDiv.querySelector('p.conquer-description'); + if (!(nameParagraph instanceof HTMLParagraphElement) || !(descriptionParagraph instanceof HTMLParagraphElement)) { + Conquer.fail('Select team name inclusive or description container are not correctly defined in template.'); + } + nameParagraph.innerText = team.getName(); + descriptionParagraph.innerText = team.getDescription(); + nameParagraph.style.color = team.getColor(); + this.getForm().append(teamDiv); + } + + private getForm(): HTMLElement { + if (this.form === null) { + const form = this.getNodeFromTemplateId('conquer-select-team-list-template') + this.form = form; + } + return this.form; + } +} diff --git a/js-src/conquer/interface/self-player.ts b/js-src/conquer/interface/self-player.ts index 451efe8..a568389 100644 --- a/js-src/conquer/interface/self-player.ts +++ b/js-src/conquer/interface/self-player.ts @@ -13,15 +13,6 @@ export default class SelfPlayerUI extends AbstractTopBarInterface { this.isExplorerModeEnabled = isExplorerModeEnabled; } - protected generateNodes(): HTMLElement[] { - const player = this.getNodeFromTemplateId('conquer-interface-with-top-bar-template') - return [player] - } - - public generateInterfaceElementCentered(): HTMLElement { - return this.getNodeFromTemplateId('conquer-interface-element-padded-template') - } - public async run(): Promise { const selfPlayerNode = this.getMainNode() const user = await ConquerUser.getSelfUser() diff --git a/js-src/conquer/map-node.ts b/js-src/conquer/map-node.ts index e86bfd6..2ea58c7 100644 --- a/js-src/conquer/map-node.ts +++ b/js-src/conquer/map-node.ts @@ -8,6 +8,7 @@ import Stroke from 'ol/style/Stroke' import InterfaceManager from '@burguillosinfo/conquer/interface-manager' import NodeView from '@burguillosinfo/conquer/interface/node-view' import JsonSerializer from '@burguillosinfo/conquer/serializer'; +import SelectTeamUI from '@burguillosinfo/conquer/interface/select-team'; @JsonObject() export default class MapNode { @@ -58,10 +59,21 @@ export default class MapNode { viewNodeInterface.on('update-nodes', () => { this.runCallbacks('update-nodes'); }); + viewNodeInterface.on('open-select-team', () => { + this.openSelectTeam(interfaceManager); + }); interfaceManager.push(viewNodeInterface); this.runCallbacks('click'); } + public openSelectTeam(interfaceManager: InterfaceManager): void { + const selectTeamUI = new SelectTeamUI(this); + selectTeamUI.on('close', () => { + interfaceManager.remove(selectTeamUI); + }); + interfaceManager.push(selectTeamUI); + } + public on(eventName: string, callback: () => void): void { if (this.callbacks[eventName] === undefined) { this.callbacks[eventName] = [] diff --git a/js-src/conquer/team.ts b/js-src/conquer/team.ts index 16e5c57..62b08f4 100644 --- a/js-src/conquer/team.ts +++ b/js-src/conquer/team.ts @@ -1,5 +1,6 @@ import JsonSerializer from '@burguillosinfo/conquer/serializer'; import { JsonObject, JsonProperty } from 'typescript-json-serializer'; +import Conquer from '@burguillosinfo/conquer' @JsonObject() export default class ConquerTeam { @@ -37,6 +38,35 @@ export default class ConquerTeam { this.color = color; } + public static async getTeams(): Promise { + const urlTeam = new URL('/conquer/teams', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port) + try { + const response = await fetch(urlTeam) + if (response.status !== 200) { + throw new Error('Invalid response fetching teams.') + } + const teamData = await response.json() + const teams = JsonSerializer.deserialize(teamData, ConquerTeam); + if (teams === undefined || teams === null) { + Conquer.fail('Teams cannot be null, server error.'); + } + if (!(teams instanceof Array)) { + throw new Error('Unable to parse team.'); + } + const teamsSanitized: ConquerTeam[] = []; + for (const team of teams) { + if (!(team instanceof ConquerTeam)) { + console.error('Received null team from server, fix this error.'); + continue; + } + teamsSanitized.push(team); + } + return teamsSanitized; + } catch (error) { + console.error(error) + throw new Error('Unable to fetch Teams.'); + } + } public static async getTeam(uuid: string): Promise { const urlTeam = new URL('/conquer/team/' + uuid, window.location.protocol + '//' + window.location.hostname + ':' + window.location.port) try { diff --git a/lib/BurguillosInfo.pm b/lib/BurguillosInfo.pm index 044eb7f..21a4d22 100644 --- a/lib/BurguillosInfo.pm +++ b/lib/BurguillosInfo.pm @@ -96,6 +96,7 @@ sub startup ($self) { $r->post('/conquer/user/coordinates')->to('UserConquer#setCoordinates'); $r->get('/conquer/team/')->to('ConquerTeam#get'); $r->put('/conquer/team')->to('ConquerTeam#put'); + $r->get('/conquer/teams')->to('ConquerTeam#getAll'); $r->put('/conquer/node')->to('ConquerNode#create'); $r->get('/conquer/node/near')->to('ConquerNode#nearbyNodes'); $r->get('/conquer/node/')->to('ConquerNode#get'); diff --git a/lib/BurguillosInfo/Controller/ConquerTeam.pm b/lib/BurguillosInfo/Controller/ConquerTeam.pm index dc5e877..3c77909 100644 --- a/lib/BurguillosInfo/Controller/ConquerTeam.pm +++ b/lib/BurguillosInfo/Controller/ConquerTeam.pm @@ -14,6 +14,22 @@ use JSON; use BurguillosInfo::Schema; +sub getAll ($self) { + my $user = $self->current_user; + if ( !defined $user ) { + return $self->render( + status => 401, + json => { + error => 'You must be logged to fetch teams.', + } + ); + } + my $uuid = $self->param('uuid'); + my $resultset = BurguillosInfo::Schema->Schema->resultset('ConquerTeam'); + my @teams = $resultset->search({}); + return $self->render( json => [ map { $_->serialize } @teams ] ); +} + sub get ($self) { my $user = $self->current_user; if ( !defined $user ) { @@ -40,7 +56,7 @@ sub get ($self) { ); } my $team = $teams[0]; - return $self->render( json => $team ); + return $self->render( json => $team->serialize ); } sub getSelfTeam ($self) { diff --git a/public/css/styles.css b/public/css/styles.css index d1b59a4..94d997f 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -9,6 +9,13 @@ body { min-height: 100%; width: 100%; height: 100%; } + body div.conquer-team-to-select { + padding: 5px; + border-radius: 5px; + background: beige; + border: solid black; } + body div.conquer-team-to-select button { + height: 60px; } body p.conquer-register-error, body p.conquer-login-error, body p.conquer-login-success, body p.conquer-error { color: red; margin: 3px; @@ -42,6 +49,8 @@ body { padding-right: 30px; display: flex; justify-content: center; } + body div.conquer-interface-element-padded.conquer-display-block { + display: block; } body div.conquer-interface-element-padded.conquer-display-none { display: none; } body div.create-node-slide { @@ -90,7 +99,8 @@ body { height: calc(100% - 22px); margin: 5px; margin-top: 10px; - margin-bottom: 10px; } + margin-bottom: 10px; + overflow-y: scroll; } body div.conquer-top-bar { display: flex; width: calc(100% - 20px); diff --git a/public/css/styles.scss b/public/css/styles.scss index 544bc38..700ccd1 100644 --- a/public/css/styles.scss +++ b/public/css/styles.scss @@ -17,6 +17,15 @@ html { } body { + div.conquer-team-to-select { + padding: 5px; + border-radius: 5px; + background: beige; + border: solid black; + button { + height: 60px; + } + } p.conquer-register-error, p.conquer-login-error, p.conquer-login-success,p.conquer-error { color: red; margin: 3px; @@ -55,6 +64,9 @@ body { padding-right: 30px; display: flex; justify-content: center; + &.conquer-display-block { + display: block; + } &.conquer-display-none { display: none; } @@ -111,6 +123,7 @@ body { margin: 5px; margin-top: 10px; margin-bottom: 10px; + overflow-y: scroll; } div.conquer-top-bar { display: flex; diff --git a/public/js/bundle.js b/public/js/bundle.js index d185440..4b0aab1 100644 --- a/public/js/bundle.js +++ b/public/js/bundle.js @@ -166,7 +166,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ NodeView)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/abstract-top-bar-interface */ \"./js-src/conquer/interface/abstract-top-bar-interface.ts\");\n/* harmony import */ var _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer */ \"./js-src/conquer/index.ts\");\n\n\nclass NodeView extends _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n getNodeNameH2() {\n const element = this.getMainNode().querySelector('h2.node-name');\n if (!(element instanceof HTMLElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fail('h2.node-name is not a H2 or does not exist.');\n }\n return element;\n }\n getNodeDescriptionParagraph() {\n const element = this.getMainNode().querySelector('p.node-description');\n if (!(element instanceof HTMLElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fail('p.node-description is not a P or does not exist.');\n }\n return element;\n }\n constructor(node) {\n super();\n this.node = node;\n }\n async run() {\n const mainNode = this.getMainNode();\n this.runCallbacks('update-nodes');\n try {\n this.node = await this.node.fetch();\n }\n catch (error) {\n this.runCallbacks('close');\n }\n const view = this.getNodeFromTemplateId('conquer-view-node-template');\n mainNode.append(view);\n this.getNodeNameH2().innerText = this.node.getName();\n this.getNodeDescriptionParagraph().innerText = this.node.getDescription()\n + \"\\n\"\n + (this.node.isNear()\n ? 'Estas cerca y puedes interactuar con este sitio.'\n : 'Estás demasiado lejos para hacer nada aquí.');\n view.classList.remove('conquer-display-none');\n mainNode.classList.remove('conquer-display-none');\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/interface/node-view.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ NodeView)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/abstract-top-bar-interface */ \"./js-src/conquer/interface/abstract-top-bar-interface.ts\");\n/* harmony import */ var _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer */ \"./js-src/conquer/index.ts\");\n/* harmony import */ var _burguillosinfo_conquer_user__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @burguillosinfo/conquer/user */ \"./js-src/conquer/user.ts\");\n\n\n\nclass NodeView extends _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n getNode() {\n return this.node;\n }\n getNodeNameH2() {\n const element = this.getMainNode().querySelector('h2.node-name');\n if (!(element instanceof HTMLElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fail('h2.node-name is not a H2 or does not exist.');\n }\n return element;\n }\n getView() {\n if (this.view === null) {\n const view = this.getNodeFromTemplateId('conquer-view-node-template');\n this.view = view;\n }\n return this.view;\n }\n getNodeDescriptionParagraph() {\n const element = this.getMainNode().querySelector('p.node-description');\n if (!(element instanceof HTMLElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fail('p.node-description is not a P or does not exist.');\n }\n return element;\n }\n constructor(node) {\n super();\n this.view = null;\n this.node = node;\n }\n async run() {\n const user = await _burguillosinfo_conquer_user__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getSelfUser();\n if (user === null) {\n this.runCallbacks('close');\n return;\n }\n this.user = user;\n const mainNode = this.getMainNode();\n this.runCallbacks('update-nodes');\n try {\n this.node = await this.node.fetch();\n }\n catch (error) {\n this.runCallbacks('close');\n }\n mainNode.append(this.getView());\n this.getNodeNameH2().innerText = this.node.getName();\n this.getNodeDescriptionParagraph().innerText = this.node.getDescription()\n + \"\\n\"\n + (this.node.isNear()\n ? 'Estas cerca y puedes interactuar con este sitio.'\n : 'Estás demasiado lejos para hacer nada aquí.');\n if (this.node.isNear()) {\n await this.runIfNear();\n }\n this.getView().classList.remove('conquer-display-none');\n mainNode.classList.remove('conquer-display-none');\n }\n async runIfNear() {\n const team = await this.user.getTeam();\n if (team === null) {\n const paragraphNoTeam = document.createElement('p');\n paragraphNoTeam.innerText = 'Parece que no has seleccionado equipo aun,'\n + ' pulsa el botón de seleccionar equipo para comenzar tu aventura,'\n + ' si quieres cambiar de equipo en el futuro puedes hacerlo sin problemas.';\n this.getView().append(paragraphNoTeam);\n }\n const selectTeamButton = document.createElement('button');\n selectTeamButton.innerText = 'Seleccionar equipo';\n selectTeamButton.addEventListener('click', () => {\n this.runCallbacks('open-select-team');\n this.runCallbacks('close');\n });\n this.getView().append(selectTeamButton);\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/interface/node-view.ts?"); + +/***/ }), + +/***/ "./js-src/conquer/interface/select-team.ts": +/*!*************************************************!*\ + !*** ./js-src/conquer/interface/select-team.ts ***! + \*************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ SelectTeamUI)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer */ \"./js-src/conquer/index.ts\");\n/* harmony import */ var _burguillosinfo_conquer_user__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer/user */ \"./js-src/conquer/user.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/abstract-top-bar-interface */ \"./js-src/conquer/interface/abstract-top-bar-interface.ts\");\n/* harmony import */ var _burguillosinfo_conquer_team__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @burguillosinfo/conquer/team */ \"./js-src/conquer/team.ts\");\n\n\n\n\nclass SelectTeamUI extends _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_2__[\"default\"] {\n constructor(node) {\n super();\n this.form = null;\n this.node = node;\n }\n async run() {\n const user = await _burguillosinfo_conquer_user__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getSelfUser();\n if (user === null) {\n this.runCallbacks('close');\n return;\n }\n this.user = user;\n await this.populateTeams();\n this.getForm().classList.remove('conquer-display-none');\n this.getMainNode().append(this.getForm());\n this.getMainNode().classList.remove('conquer-display-none');\n }\n async populateTeams() {\n const teams = await _burguillosinfo_conquer_team__WEBPACK_IMPORTED_MODULE_3__[\"default\"].getTeams();\n for (const team of teams) {\n this.populateTeam(team);\n }\n }\n populateTeam(team) {\n const teamDiv = this.getNodeFromTemplateId('conquer-team-to-select-template');\n const nameParagraph = teamDiv.querySelector('p.conquer-name');\n const descriptionParagraph = teamDiv.querySelector('p.conquer-description');\n if (!(nameParagraph instanceof HTMLParagraphElement) || !(descriptionParagraph instanceof HTMLParagraphElement)) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].fail('Select team name inclusive or description container are not correctly defined in template.');\n }\n nameParagraph.innerText = team.getName();\n descriptionParagraph.innerText = team.getDescription();\n nameParagraph.style.color = team.getColor();\n this.getForm().append(teamDiv);\n }\n getForm() {\n if (this.form === null) {\n const form = this.getNodeFromTemplateId('conquer-select-team-list-template');\n this.form = form;\n }\n return this.form;\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/interface/select-team.ts?"); /***/ }), @@ -177,7 +188,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ SelfPlayerUI)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer_user__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer/user */ \"./js-src/conquer/user.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/abstract-top-bar-interface */ \"./js-src/conquer/interface/abstract-top-bar-interface.ts\");\n\n\nclass SelfPlayerUI extends _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_1__[\"default\"] {\n constructor(isExplorerModeEnabled) {\n super();\n this.selfPlayer = null;\n this.userWelcome = null;\n this.userTeamData = null;\n this.isExplorerModeEnabled = isExplorerModeEnabled;\n }\n generateNodes() {\n const player = this.getNodeFromTemplateId('conquer-interface-with-top-bar-template');\n return [player];\n }\n generateInterfaceElementCentered() {\n return this.getNodeFromTemplateId('conquer-interface-element-padded-template');\n }\n async run() {\n const selfPlayerNode = this.getMainNode();\n const user = await _burguillosinfo_conquer_user__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelfUser();\n if (user === null) {\n this.runCallbacks('close');\n return;\n }\n this.selfPlayer = user;\n this.populateWelcome();\n this.populateCreateNodeOption();\n this.populateToggleExplorerModeOption();\n this.populateCreateTeamButton();\n await this.populateUserTeamData();\n selfPlayerNode.classList.remove('conquer-display-none');\n }\n populateToggleExplorerModeOption() {\n const toggleExplorerModeButton = document.createElement('button');\n this.setTextToggleExplorerModeButton(toggleExplorerModeButton);\n toggleExplorerModeButton.addEventListener('click', () => {\n (() => {\n if (this.isExplorerModeEnabled) {\n this.runCallbacks('disable-explorer-mode');\n return;\n }\n this.runCallbacks('enable-explorer-mode');\n })();\n this.runCallbacks('close');\n });\n const toggleExplorerModeInterface = this.generateInterfaceElementCentered();\n toggleExplorerModeInterface.appendChild(toggleExplorerModeButton);\n this.getMainNode().appendChild(toggleExplorerModeInterface);\n }\n populateCreateTeamButton() {\n // Only admins can create teams.\n if (!this.selfPlayer?.isAdmin()) {\n return;\n }\n const createTeamButton = document.createElement('button');\n createTeamButton.innerText = 'Crea un nuevo equipo';\n createTeamButton.addEventListener('click', () => {\n this.runCallbacks('open-create-team');\n this.runCallbacks('close');\n });\n const createTeamButtonInterface = this.generateInterfaceElementCentered();\n createTeamButtonInterface.append(createTeamButton);\n this.getMainNode().appendChild(createTeamButtonInterface);\n }\n setTextToggleExplorerModeButton(button) {\n if (this.isExplorerModeEnabled) {\n button.innerText = 'Desactivar movimiento libre en el mapa.';\n return;\n }\n button.innerText = 'Activar movimiento libre en el mapa.';\n }\n populateCreateNodeOption() {\n // Only admins can create nodes.\n if (!this.selfPlayer?.isAdmin()) {\n return;\n }\n const createNodeButton = document.createElement('button');\n createNodeButton.innerText = 'Crear Nuevo Nodo';\n createNodeButton.addEventListener('click', () => {\n this.runCallbacks('createNodeStart');\n // We close because it is a sensible thing to do.\n this.runCallbacks('close');\n });\n const createNodeButtonInterface = this.generateInterfaceElementCentered();\n createNodeButtonInterface.appendChild(createNodeButton);\n this.getMainNode().appendChild(createNodeButtonInterface);\n }\n async getUserTeamData() {\n if (this.userTeamData !== null) {\n return this.userTeamData;\n }\n const element = document.createElement('p');\n this.userTeamData = element;\n if (this.selfPlayer === null) {\n throw new Error('User still not set');\n }\n const team = await this.selfPlayer.getTeam();\n if (team === null) {\n element.innerText = 'No tienes equipo aun,'\n + ' ve al nodo más cercano para unirte a un equipo.';\n return this.userTeamData;\n }\n const spanCircle = document.createElement('span');\n spanCircle.classList.add('conquer-team-circle');\n spanCircle.style.backgroundColor = team.getColor();\n element.append(spanCircle);\n const spanText = document.createElement('span');\n spanText.innerText = 'Perteneces al equipo: ';\n element.append(spanText);\n const spanTeamName = document.createElement('span');\n spanTeamName.style.color = team.getColor();\n spanTeamName.style.backgroundColor = 'white';\n spanTeamName.innerText = team.getName();\n element.append(spanTeamName);\n return this.userTeamData;\n }\n async populateUserTeamData() {\n const userTeamData = await this.getUserTeamData();\n const userTeamDataInterface = this.generateInterfaceElementCentered();\n userTeamDataInterface.append(userTeamData);\n this.getMainNode().append(userTeamDataInterface);\n }\n populateWelcome() {\n const userWelcome = this.getUserWelcome();\n const userWelcomeInterface = this.generateInterfaceElementCentered();\n userWelcomeInterface.appendChild(userWelcome);\n this.getMainNode().appendChild(userWelcomeInterface);\n }\n getUserWelcome() {\n if (this.userWelcome !== null) {\n return this.userWelcome;\n }\n const element = document.createElement('h2');\n if (this.selfPlayer === null) {\n throw new Error('User still not set');\n }\n element.innerText = `¡Hola, ${this.selfPlayer.getUsername()}!`;\n this.userWelcome = element;\n return this.userWelcome;\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/interface/self-player.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ SelfPlayerUI)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer_user__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer/user */ \"./js-src/conquer/user.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/abstract-top-bar-interface */ \"./js-src/conquer/interface/abstract-top-bar-interface.ts\");\n\n\nclass SelfPlayerUI extends _burguillosinfo_conquer_interface_abstract_top_bar_interface__WEBPACK_IMPORTED_MODULE_1__[\"default\"] {\n constructor(isExplorerModeEnabled) {\n super();\n this.selfPlayer = null;\n this.userWelcome = null;\n this.userTeamData = null;\n this.isExplorerModeEnabled = isExplorerModeEnabled;\n }\n async run() {\n const selfPlayerNode = this.getMainNode();\n const user = await _burguillosinfo_conquer_user__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelfUser();\n if (user === null) {\n this.runCallbacks('close');\n return;\n }\n this.selfPlayer = user;\n this.populateWelcome();\n this.populateCreateNodeOption();\n this.populateToggleExplorerModeOption();\n this.populateCreateTeamButton();\n await this.populateUserTeamData();\n selfPlayerNode.classList.remove('conquer-display-none');\n }\n populateToggleExplorerModeOption() {\n const toggleExplorerModeButton = document.createElement('button');\n this.setTextToggleExplorerModeButton(toggleExplorerModeButton);\n toggleExplorerModeButton.addEventListener('click', () => {\n (() => {\n if (this.isExplorerModeEnabled) {\n this.runCallbacks('disable-explorer-mode');\n return;\n }\n this.runCallbacks('enable-explorer-mode');\n })();\n this.runCallbacks('close');\n });\n const toggleExplorerModeInterface = this.generateInterfaceElementCentered();\n toggleExplorerModeInterface.appendChild(toggleExplorerModeButton);\n this.getMainNode().appendChild(toggleExplorerModeInterface);\n }\n populateCreateTeamButton() {\n // Only admins can create teams.\n if (!this.selfPlayer?.isAdmin()) {\n return;\n }\n const createTeamButton = document.createElement('button');\n createTeamButton.innerText = 'Crea un nuevo equipo';\n createTeamButton.addEventListener('click', () => {\n this.runCallbacks('open-create-team');\n this.runCallbacks('close');\n });\n const createTeamButtonInterface = this.generateInterfaceElementCentered();\n createTeamButtonInterface.append(createTeamButton);\n this.getMainNode().appendChild(createTeamButtonInterface);\n }\n setTextToggleExplorerModeButton(button) {\n if (this.isExplorerModeEnabled) {\n button.innerText = 'Desactivar movimiento libre en el mapa.';\n return;\n }\n button.innerText = 'Activar movimiento libre en el mapa.';\n }\n populateCreateNodeOption() {\n // Only admins can create nodes.\n if (!this.selfPlayer?.isAdmin()) {\n return;\n }\n const createNodeButton = document.createElement('button');\n createNodeButton.innerText = 'Crear Nuevo Nodo';\n createNodeButton.addEventListener('click', () => {\n this.runCallbacks('createNodeStart');\n // We close because it is a sensible thing to do.\n this.runCallbacks('close');\n });\n const createNodeButtonInterface = this.generateInterfaceElementCentered();\n createNodeButtonInterface.appendChild(createNodeButton);\n this.getMainNode().appendChild(createNodeButtonInterface);\n }\n async getUserTeamData() {\n if (this.userTeamData !== null) {\n return this.userTeamData;\n }\n const element = document.createElement('p');\n this.userTeamData = element;\n if (this.selfPlayer === null) {\n throw new Error('User still not set');\n }\n const team = await this.selfPlayer.getTeam();\n if (team === null) {\n element.innerText = 'No tienes equipo aun,'\n + ' ve al nodo más cercano para unirte a un equipo.';\n return this.userTeamData;\n }\n const spanCircle = document.createElement('span');\n spanCircle.classList.add('conquer-team-circle');\n spanCircle.style.backgroundColor = team.getColor();\n element.append(spanCircle);\n const spanText = document.createElement('span');\n spanText.innerText = 'Perteneces al equipo: ';\n element.append(spanText);\n const spanTeamName = document.createElement('span');\n spanTeamName.style.color = team.getColor();\n spanTeamName.style.backgroundColor = 'white';\n spanTeamName.innerText = team.getName();\n element.append(spanTeamName);\n return this.userTeamData;\n }\n async populateUserTeamData() {\n const userTeamData = await this.getUserTeamData();\n const userTeamDataInterface = this.generateInterfaceElementCentered();\n userTeamDataInterface.append(userTeamData);\n this.getMainNode().append(userTeamDataInterface);\n }\n populateWelcome() {\n const userWelcome = this.getUserWelcome();\n const userWelcomeInterface = this.generateInterfaceElementCentered();\n userWelcomeInterface.appendChild(userWelcome);\n this.getMainNode().appendChild(userWelcomeInterface);\n }\n getUserWelcome() {\n if (this.userWelcome !== null) {\n return this.userWelcome;\n }\n const element = document.createElement('h2');\n if (this.selfPlayer === null) {\n throw new Error('User still not set');\n }\n element.innerText = `¡Hola, ${this.selfPlayer.getUsername()}!`;\n this.userWelcome = element;\n return this.userWelcome;\n }\n}\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/interface/self-player.ts?"); /***/ }), @@ -199,7 +210,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! typescript-json-serializer */ \"./node_modules/typescript-json-serializer/dist/index.esm.js\");\n/* harmony import */ var ol_style_Style__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ol/style/Style */ \"./node_modules/ol/style/Style.js\");\n/* harmony import */ var ol_Feature__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ol/Feature */ \"./node_modules/ol/Feature.js\");\n/* harmony import */ var ol_style_Circle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ol/style/Circle */ \"./node_modules/ol/style/Circle.js\");\n/* harmony import */ var ol_geom_Point__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ol/geom/Point */ \"./node_modules/ol/geom/Point.js\");\n/* harmony import */ var ol_style_Fill__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ol/style/Fill */ \"./node_modules/ol/style/Fill.js\");\n/* harmony import */ var ol_style_Stroke__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ol/style/Stroke */ \"./node_modules/ol/style/Stroke.js\");\n/* harmony import */ var _burguillosinfo_conquer_interface_node_view__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/node-view */ \"./js-src/conquer/interface/node-view.ts\");\n/* harmony import */ var _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @burguillosinfo/conquer/serializer */ \"./js-src/conquer/serializer.ts\");\nvar __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __metadata = (undefined && undefined.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};\nvar __param = (undefined && undefined.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};\nvar MapNode_1;\n\n\n\n\n\n\n\n\n\nlet MapNode = MapNode_1 = class MapNode {\n constructor(uuid, coordinate_1, coordinate_2, type, name, description, kind, is_near) {\n this.uuid = uuid;\n this.coordinate_1 = coordinate_1;\n this.coordinate_2 = coordinate_2;\n this.type = type;\n this.name = name;\n this.description = description;\n this.kind = kind;\n this.is_near = is_near;\n this.feature = null;\n this.callbacks = {};\n }\n async fetch() {\n const urlNode = new URL('/conquer/node/' + this.uuid, window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n const response = await fetch(urlNode);\n let responseBody;\n const errorThrow = new Error('Unable to fetch node updated.');\n try {\n responseBody = await response.json();\n }\n catch (error) {\n console.error('Error parseando json: ' + responseBody);\n console.error(error);\n throw errorThrow;\n }\n if (response.status !== 200) {\n console.error(responseBody.error);\n throw errorThrow;\n }\n const node = _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_2__[\"default\"].deserialize(responseBody, MapNode_1);\n if (!(node instanceof MapNode_1)) {\n console.error('Unexpected JSON value for MapNode.');\n throw errorThrow;\n }\n return node;\n }\n click(interfaceManager) {\n const viewNodeInterface = new _burguillosinfo_conquer_interface_node_view__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this);\n viewNodeInterface.on('close', () => {\n interfaceManager.remove(viewNodeInterface);\n });\n viewNodeInterface.on('update-nodes', () => {\n this.runCallbacks('update-nodes');\n });\n interfaceManager.push(viewNodeInterface);\n this.runCallbacks('click');\n }\n on(eventName, callback) {\n if (this.callbacks[eventName] === undefined) {\n this.callbacks[eventName] = [];\n }\n this.callbacks[eventName].push(callback);\n }\n runCallbacks(eventName) {\n const callbacks = this.callbacks[eventName];\n if (callbacks === undefined) {\n return;\n }\n for (const callback of callbacks) {\n callback();\n }\n }\n getType() {\n return this.type;\n }\n isNear() {\n return this.is_near;\n }\n getName() {\n return this.name;\n }\n getDescription() {\n return this.description;\n }\n getId() {\n return 'node-' + this.uuid;\n }\n getFeature() {\n if (this.feature === null) {\n this.feature = new ol_Feature__WEBPACK_IMPORTED_MODULE_3__[\"default\"]({\n geometry: new ol_geom_Point__WEBPACK_IMPORTED_MODULE_4__[\"default\"]([this.coordinate_1, this.coordinate_2]),\n type: 'node-' + this.uuid,\n });\n }\n return this.feature;\n }\n getStyle() {\n return new ol_style_Style__WEBPACK_IMPORTED_MODULE_5__[\"default\"]({\n image: new ol_style_Circle__WEBPACK_IMPORTED_MODULE_6__[\"default\"]({\n radius: 14,\n fill: new ol_style_Fill__WEBPACK_IMPORTED_MODULE_7__[\"default\"]({ color: 'white' }),\n stroke: new ol_style_Stroke__WEBPACK_IMPORTED_MODULE_8__[\"default\"]({\n color: 'gray',\n width: 2,\n })\n })\n });\n }\n};\nMapNode = MapNode_1 = __decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonObject)(),\n __param(0, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(1, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(2, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(3, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(4, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(5, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(6, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(7, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __metadata(\"design:paramtypes\", [String, Number, Number, String, String, String, String, Boolean])\n], MapNode);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (MapNode);\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/map-node.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! typescript-json-serializer */ \"./node_modules/typescript-json-serializer/dist/index.esm.js\");\n/* harmony import */ var ol_style_Style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ol/style/Style */ \"./node_modules/ol/style/Style.js\");\n/* harmony import */ var ol_Feature__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ol/Feature */ \"./node_modules/ol/Feature.js\");\n/* harmony import */ var ol_style_Circle__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ol/style/Circle */ \"./node_modules/ol/style/Circle.js\");\n/* harmony import */ var ol_geom_Point__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ol/geom/Point */ \"./node_modules/ol/geom/Point.js\");\n/* harmony import */ var ol_style_Fill__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ol/style/Fill */ \"./node_modules/ol/style/Fill.js\");\n/* harmony import */ var ol_style_Stroke__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ol/style/Stroke */ \"./node_modules/ol/style/Stroke.js\");\n/* harmony import */ var _burguillosinfo_conquer_interface_node_view__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/node-view */ \"./js-src/conquer/interface/node-view.ts\");\n/* harmony import */ var _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @burguillosinfo/conquer/serializer */ \"./js-src/conquer/serializer.ts\");\n/* harmony import */ var _burguillosinfo_conquer_interface_select_team__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @burguillosinfo/conquer/interface/select-team */ \"./js-src/conquer/interface/select-team.ts\");\nvar __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __metadata = (undefined && undefined.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};\nvar __param = (undefined && undefined.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};\nvar MapNode_1;\n\n\n\n\n\n\n\n\n\n\nlet MapNode = MapNode_1 = class MapNode {\n constructor(uuid, coordinate_1, coordinate_2, type, name, description, kind, is_near) {\n this.uuid = uuid;\n this.coordinate_1 = coordinate_1;\n this.coordinate_2 = coordinate_2;\n this.type = type;\n this.name = name;\n this.description = description;\n this.kind = kind;\n this.is_near = is_near;\n this.feature = null;\n this.callbacks = {};\n }\n async fetch() {\n const urlNode = new URL('/conquer/node/' + this.uuid, window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n const response = await fetch(urlNode);\n let responseBody;\n const errorThrow = new Error('Unable to fetch node updated.');\n try {\n responseBody = await response.json();\n }\n catch (error) {\n console.error('Error parseando json: ' + responseBody);\n console.error(error);\n throw errorThrow;\n }\n if (response.status !== 200) {\n console.error(responseBody.error);\n throw errorThrow;\n }\n const node = _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_2__[\"default\"].deserialize(responseBody, MapNode_1);\n if (!(node instanceof MapNode_1)) {\n console.error('Unexpected JSON value for MapNode.');\n throw errorThrow;\n }\n return node;\n }\n click(interfaceManager) {\n const viewNodeInterface = new _burguillosinfo_conquer_interface_node_view__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this);\n viewNodeInterface.on('close', () => {\n interfaceManager.remove(viewNodeInterface);\n });\n viewNodeInterface.on('update-nodes', () => {\n this.runCallbacks('update-nodes');\n });\n viewNodeInterface.on('open-select-team', () => {\n this.openSelectTeam(interfaceManager);\n });\n interfaceManager.push(viewNodeInterface);\n this.runCallbacks('click');\n }\n openSelectTeam(interfaceManager) {\n const selectTeamUI = new _burguillosinfo_conquer_interface_select_team__WEBPACK_IMPORTED_MODULE_3__[\"default\"](this);\n selectTeamUI.on('close', () => {\n interfaceManager.remove(selectTeamUI);\n });\n interfaceManager.push(selectTeamUI);\n }\n on(eventName, callback) {\n if (this.callbacks[eventName] === undefined) {\n this.callbacks[eventName] = [];\n }\n this.callbacks[eventName].push(callback);\n }\n runCallbacks(eventName) {\n const callbacks = this.callbacks[eventName];\n if (callbacks === undefined) {\n return;\n }\n for (const callback of callbacks) {\n callback();\n }\n }\n getType() {\n return this.type;\n }\n isNear() {\n return this.is_near;\n }\n getName() {\n return this.name;\n }\n getDescription() {\n return this.description;\n }\n getId() {\n return 'node-' + this.uuid;\n }\n getFeature() {\n if (this.feature === null) {\n this.feature = new ol_Feature__WEBPACK_IMPORTED_MODULE_4__[\"default\"]({\n geometry: new ol_geom_Point__WEBPACK_IMPORTED_MODULE_5__[\"default\"]([this.coordinate_1, this.coordinate_2]),\n type: 'node-' + this.uuid,\n });\n }\n return this.feature;\n }\n getStyle() {\n return new ol_style_Style__WEBPACK_IMPORTED_MODULE_6__[\"default\"]({\n image: new ol_style_Circle__WEBPACK_IMPORTED_MODULE_7__[\"default\"]({\n radius: 14,\n fill: new ol_style_Fill__WEBPACK_IMPORTED_MODULE_8__[\"default\"]({ color: 'white' }),\n stroke: new ol_style_Stroke__WEBPACK_IMPORTED_MODULE_9__[\"default\"]({\n color: 'gray',\n width: 2,\n })\n })\n });\n }\n};\nMapNode = MapNode_1 = __decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonObject)(),\n __param(0, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(1, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(2, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(3, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(4, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(5, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(6, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __param(7, (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_0__.JsonProperty)()),\n __metadata(\"design:paramtypes\", [String, Number, Number, String, String, String, String, Boolean])\n], MapNode);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (MapNode);\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/map-node.ts?"); /***/ }), @@ -232,7 +243,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer/serializer */ \"./js-src/conquer/serializer.ts\");\n/* harmony import */ var typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! typescript-json-serializer */ \"./node_modules/typescript-json-serializer/dist/index.esm.js\");\nvar __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __metadata = (undefined && undefined.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};\nvar ConquerTeam_1;\n\n\nlet ConquerTeam = ConquerTeam_1 = class ConquerTeam {\n getName() {\n return this.name;\n }\n getDescription() {\n return this.description;\n }\n getColor() {\n return this.color;\n }\n constructor(uuid, name, description, points, color) {\n this.kind = 'ConquerTeam';\n this.uuid = uuid;\n this.name = name;\n this.description = description;\n this.points = points;\n this.color = color;\n }\n static async getTeam(uuid) {\n const urlTeam = new URL('/conquer/team/' + uuid, window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n try {\n const response = await fetch(urlTeam);\n if (response.status !== 200) {\n throw new Error('Invalid response fetching team.');\n }\n const teamData = await response.json();\n let team = _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].deserialize(teamData, ConquerTeam_1);\n if (team === undefined) {\n team = null;\n }\n if (!(team instanceof ConquerTeam_1)) {\n throw new Error('Unable to parse team.');\n }\n return team;\n }\n catch (error) {\n console.error(error);\n throw new Error('Unable to fetch Team.');\n }\n }\n static async getSelfTeam() {\n const urlTeam = new URL('/conquer/user/team', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n try {\n const response = await fetch(urlTeam);\n if (response.status !== 200) {\n throw new Error('Invalid response fetching team.');\n }\n const teamData = await response.json();\n let team = _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].deserialize(teamData, ConquerTeam_1);\n if (team === undefined) {\n team = null;\n }\n if (team !== null && !(team instanceof ConquerTeam_1)) {\n throw new Error('Unable to parse team.');\n }\n return team;\n }\n catch (error) {\n console.error(error);\n throw new Error('Unable to fetch Team.');\n }\n }\n};\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", String)\n], ConquerTeam.prototype, \"kind\", void 0);\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", String)\n], ConquerTeam.prototype, \"uuid\", void 0);\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", String)\n], ConquerTeam.prototype, \"name\", void 0);\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", String)\n], ConquerTeam.prototype, \"description\", void 0);\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", Number)\n], ConquerTeam.prototype, \"points\", void 0);\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", String)\n], ConquerTeam.prototype, \"color\", void 0);\nConquerTeam = ConquerTeam_1 = __decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonObject)(),\n __metadata(\"design:paramtypes\", [String, String, String, Number, String])\n], ConquerTeam);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ConquerTeam);\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/team.ts?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @burguillosinfo/conquer/serializer */ \"./js-src/conquer/serializer.ts\");\n/* harmony import */ var typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! typescript-json-serializer */ \"./node_modules/typescript-json-serializer/dist/index.esm.js\");\n/* harmony import */ var _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @burguillosinfo/conquer */ \"./js-src/conquer/index.ts\");\nvar __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __metadata = (undefined && undefined.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};\nvar ConquerTeam_1;\n\n\n\nlet ConquerTeam = ConquerTeam_1 = class ConquerTeam {\n getName() {\n return this.name;\n }\n getDescription() {\n return this.description;\n }\n getColor() {\n return this.color;\n }\n constructor(uuid, name, description, points, color) {\n this.kind = 'ConquerTeam';\n this.uuid = uuid;\n this.name = name;\n this.description = description;\n this.points = points;\n this.color = color;\n }\n static async getTeams() {\n const urlTeam = new URL('/conquer/teams', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n try {\n const response = await fetch(urlTeam);\n if (response.status !== 200) {\n throw new Error('Invalid response fetching teams.');\n }\n const teamData = await response.json();\n const teams = _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].deserialize(teamData, ConquerTeam_1);\n if (teams === undefined || teams === null) {\n _burguillosinfo_conquer__WEBPACK_IMPORTED_MODULE_2__[\"default\"].fail('Teams cannot be null, server error.');\n }\n if (!(teams instanceof Array)) {\n throw new Error('Unable to parse team.');\n }\n const teamsSanitized = [];\n for (const team of teams) {\n if (!(team instanceof ConquerTeam_1)) {\n console.error('Received null team from server, fix this error.');\n continue;\n }\n teamsSanitized.push(team);\n }\n return teamsSanitized;\n }\n catch (error) {\n console.error(error);\n throw new Error('Unable to fetch Teams.');\n }\n }\n static async getTeam(uuid) {\n const urlTeam = new URL('/conquer/team/' + uuid, window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n try {\n const response = await fetch(urlTeam);\n if (response.status !== 200) {\n throw new Error('Invalid response fetching team.');\n }\n const teamData = await response.json();\n let team = _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].deserialize(teamData, ConquerTeam_1);\n if (team === undefined) {\n team = null;\n }\n if (!(team instanceof ConquerTeam_1)) {\n throw new Error('Unable to parse team.');\n }\n return team;\n }\n catch (error) {\n console.error(error);\n throw new Error('Unable to fetch Team.');\n }\n }\n static async getSelfTeam() {\n const urlTeam = new URL('/conquer/user/team', window.location.protocol + '//' + window.location.hostname + ':' + window.location.port);\n try {\n const response = await fetch(urlTeam);\n if (response.status !== 200) {\n throw new Error('Invalid response fetching team.');\n }\n const teamData = await response.json();\n let team = _burguillosinfo_conquer_serializer__WEBPACK_IMPORTED_MODULE_0__[\"default\"].deserialize(teamData, ConquerTeam_1);\n if (team === undefined) {\n team = null;\n }\n if (team !== null && !(team instanceof ConquerTeam_1)) {\n throw new Error('Unable to parse team.');\n }\n return team;\n }\n catch (error) {\n console.error(error);\n throw new Error('Unable to fetch Team.');\n }\n }\n};\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", String)\n], ConquerTeam.prototype, \"kind\", void 0);\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", String)\n], ConquerTeam.prototype, \"uuid\", void 0);\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", String)\n], ConquerTeam.prototype, \"name\", void 0);\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", String)\n], ConquerTeam.prototype, \"description\", void 0);\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", Number)\n], ConquerTeam.prototype, \"points\", void 0);\n__decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonProperty)(),\n __metadata(\"design:type\", String)\n], ConquerTeam.prototype, \"color\", void 0);\nConquerTeam = ConquerTeam_1 = __decorate([\n (0,typescript_json_serializer__WEBPACK_IMPORTED_MODULE_1__.JsonObject)(),\n __metadata(\"design:paramtypes\", [String, String, String, Number, String])\n], ConquerTeam);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ConquerTeam);\n\n\n//# sourceURL=webpack://BurguillosInfo/./js-src/conquer/team.ts?"); /***/ }), diff --git a/templates/conquer/index.html.ep b/templates/conquer/index.html.ep index 228ade2..fa882c3 100644 --- a/templates/conquer/index.html.ep +++ b/templates/conquer/index.html.ep @@ -16,12 +16,18 @@ %= include 'conquer/_login-template'; %= include 'conquer/_register-template'; %= include 'conquer/_new-team-form-creation-template'; -
-
-

Vista de nodo.

-

-

-
+
+

Encuentra tu equipo ideal.

+
+
+

+

+ +
+
+

Vista de nodo.

+

+