Skip to content

Commit 3275c71

Browse files
committed
Serve application from CPM web api
1 parent 5db5017 commit 3275c71

File tree

9 files changed

+71
-26
lines changed

9 files changed

+71
-26
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ deploy:
1616
file: "dist/cpm-map-*.tgz"
1717
api_key: $GITHUB_TOKEN
1818
on:
19-
branch: master
19+
branch: master
20+
tags: true

public/img/steamlogin.png

5.9 KB
Loading

src/components/ClaimsModal.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ export default {
125125
}
126126
},
127127
getClaimType(type) {
128-
return fetch(
129-
`${window.requestProxy}/api/claims?ip=${this.connectionInfo.ip}&port=${this.cpmPort}&type=${type}`
130-
)
128+
return fetch(`/api/getmapclaims?type=${type}`)
131129
.then(function(response) {
132130
if (response) {
133131
return response.json();

src/components/CommandsModal.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ export default {
102102
async execute() {
103103
this.executing = true;
104104
for (const command of this.commands) {
105-
const result = await fetch(
106-
`${window.requestProxy}/api/command?ip=${this.connectionInfo.ip}&port=${this.connectionInfo.port}&command=${command}&adminUser=${this.connectionInfo.adminUser}&adminToken=${this.connectionInfo.adminToken}`
107-
);
105+
const result = await fetch(`/api/createadvclaim?command=${command}`);
108106
const historyObj = {
109107
success: result.ok,
110108
command: command,

src/components/SdtdMap.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ export default {
7777
this.connectionInfo = JSON.parse(localStorage.connectionInfo);
7878
}
7979
80-
if (this.connectionInfo.ip && this.connectionInfo.port) {
81-
this.createMap();
82-
}
80+
this.createMap();
81+
8382
eventBus.$on("connection-info", connectionInfo => {
8483
this.connectionInfo = connectionInfo;
8584
if (this.map != null) {
@@ -199,7 +198,7 @@ export default {
199198
},
200199
GetSdtdTileLayer(mapinfo) {
201200
var tileLayer = L.tileLayer(
202-
`http://${this.connectionInfo.ip}:${this.connectionInfo.port}/map/{z}/{x}/{y}.png?adminUser={adminUser}&adminToken={adminToken}`,
201+
`${window.allocsMap.protocol}//${window.allocsMap.host}:${window.allocsMap.port}/map/{z}/{x}/{y}.png?adminUser={adminUser}&adminToken={adminToken}`,
203202
{
204203
maxZoom: mapinfo.maxzoom + 1,
205204
minZoom: Math.max(0, mapinfo.maxzoom - 5),
@@ -252,9 +251,7 @@ export default {
252251
}).setView([0, 0], Math.max(0, this.mapInfo.maxzoom - 1));
253252
},
254253
getClaims(type) {
255-
return fetch(
256-
`${window.requestProxy}/api/claims?ip=${this.connectionInfo.ip}&port=${this.cpmPort}&type=${type}`
257-
)
254+
return fetch(`/api/getmapclaims?type=${type}`)
258255
.then(function(response) {
259256
if (response) {
260257
return response.json();

src/components/ServerSettings.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
@ok="onSubmit"
88
>
99
<div class="my-4">
10-
<b-form-group id="input-group-1" label="IP address:" label-for="input-1">
11-
<b-form-input id="input-1" v-model="form.ip" required placeholder="123.456.7.8"></b-form-input>
12-
</b-form-group>
13-
14-
<b-form-group id="input-group-1" label="Port:" label-for="input-1">
15-
<b-form-input id="input-1" v-model="form.port" required placeholder="8082"></b-form-input>
16-
</b-form-group>
17-
1810
<b-form-group id="input-group-1" label="Admin user:" label-for="input-1">
1911
<b-form-input id="input-1" v-model="form.adminUser" placeholder="user"></b-form-input>
2012
</b-form-group>
@@ -44,8 +36,6 @@ export default {
4436
data() {
4537
return {
4638
form: {
47-
ip: "",
48-
port: "",
4939
adminUser: "",
5040
adminToken: ""
5141
},

src/components/SessionHandler.vue

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<div class="session">
3+
<a v-if="!userStatus.loggedin" href="/session/login">
4+
<img src="img/steamlogin.png" />
5+
</a>
6+
<div v-else>
7+
{{this.userStatus.username}} - Permission level: {{this.userStatus.permissionlevel}}
8+
<br />
9+
<a href="/session/logout">
10+
<button class="btn btn-danger" type="button">Logout</button>
11+
</a>
12+
</div>
13+
</div>
14+
</template>
15+
16+
<script>
17+
export default {
18+
name: "SessionHandler",
19+
data() {
20+
return {
21+
userStatus: {
22+
loggedin: false,
23+
username: null,
24+
permissionlevel: 2000,
25+
permissions: []
26+
}
27+
};
28+
},
29+
async mounted() {
30+
this.userStatus = await this.getUserStatus();
31+
},
32+
methods: {
33+
getUserStatus() {
34+
return fetch("/userstatus")
35+
.then(response => {
36+
return response.json();
37+
})
38+
.then(data => {
39+
return data;
40+
});
41+
}
42+
}
43+
};
44+
</script>
45+
46+
<style scoped>
47+
.session {
48+
bottom: 0%;
49+
text-align: center;
50+
position: absolute;
51+
}
52+
</style>

src/components/SideBar.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="sidenav">
3-
<h1>CPM Advanced Claim creator</h1>
3+
<h1>CPM</h1>
44
<a href="#" v-b-modal.server-settings>Server settings</a>
55
<a href="#" v-b-modal.claims>Claims</a>
66
<a href="#" v-b-modal.commands>
@@ -15,6 +15,7 @@
1515
Discord
1616
<font-awesome-icon icon="external-link-alt" size="xs" />
1717
</a>
18+
<session-handler></session-handler>
1819
<server-settings></server-settings>
1920
<claims></claims>
2021
<commands-modal></commands-modal>
@@ -51,6 +52,7 @@ export default {
5152
background-color: #111; /* Black */
5253
overflow-x: hidden; /* Disable horizontal scroll */
5354
padding-top: 20px;
55+
color: #818181;
5456
}
5557
5658
.sidenav h1 {
@@ -63,7 +65,6 @@ export default {
6365
padding: 6px 8px 6px 16px;
6466
text-decoration: none;
6567
font-size: 25px;
66-
color: #818181;
6768
display: block;
6869
}
6970

src/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import ServerSettings from './components/ServerSettings.vue';
2222
import ClaimsModal from './components/ClaimsModal.vue';
2323
import ClaimCreator from './components/ClaimCreator.vue';
2424
import CommandsModal from './components/CommandsModal.vue';
25+
import SessionHandler from './components/SessionHandler.vue';
2526

2627
require('../node_modules/leaflet/dist/leaflet.css');
2728

@@ -42,6 +43,12 @@ window.claimTypes = [
4243
// Since most maps are not accesible via https, we have to proxy requests through a https enabled API
4344
window.requestProxy = "https://cpm-api.herokuapp.com"
4445

46+
window.allocsMap = {
47+
host: location.hostname,
48+
port: parseInt(location.port) - 1,
49+
protocol: location.protocol,
50+
};
51+
4552
library.add(faExternalLinkAlt);
4653
library.add(faTrashAlt);
4754
Vue.component('font-awesome-icon', FontAwesomeIcon)
@@ -51,6 +58,7 @@ Vue.component('server-settings', ServerSettings)
5158
Vue.component('claims', ClaimsModal);
5259
Vue.component('claim-creator', ClaimCreator);
5360
Vue.component('commands-modal', CommandsModal);
61+
Vue.component('session-handler', SessionHandler);
5462

5563
Vue.use(BootstrapVue)
5664

0 commit comments

Comments
 (0)