Skip to content

Commit

Permalink
force values to use numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
astroanu committed Sep 5, 2024
1 parent db8a000 commit 0b57b75
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 85 deletions.
110 changes: 59 additions & 51 deletions vue/js/components/CodeView.vue
Original file line number Diff line number Diff line change
@@ -1,64 +1,72 @@
<template>
<div class="floating">
<div class="row">
<button @click="drawerAction">{{ drawerTitle }}</button>
</div>
<div class="row panel" v-bind:class="{ 'expanded': expanded }">
<div class="column column-30" ref="requestView">
<select class="float-right" @change="generateSnippet" v-model="store.language">
<option value="javascript">Javascript</option>
<option value="node">NodeJs</option>
<option value="php">PHP</option>
<option value="java">Java</option>
<option value="go">Go</option>
<option value="python">Python</option>
<option value="csharp">C#</option>
</select>
<h6>Request</h6>
<pre :style="{ width: requestViewWidth + 'px' }">{{ store.request }}</pre>
</div>
<div class="column column-60" ref="responseView">
<h6>Response</h6>
<pre :style="{ width: responseViewWidth + 'px' }">{{ store.response }}</pre>
</div>
</div>
<div class="floating">
<div class="row">
<button @click="drawerAction">{{ drawerTitle }}</button>
</div>
<div class="row panel" v-bind:class="{ expanded: expanded }">
<div class="column column-30" ref="requestView">
<select
class="float-right"
@change="generateSnippet"
v-model="store.language"
>
<option value="javascript">Javascript</option>
<option value="node">NodeJs</option>
<option value="php">PHP</option>
<option value="java">Java</option>
<option value="go">Go</option>
<option value="python">Python</option>
<option value="csharp">C#</option>
</select>
<h6>Request</h6>
<pre :style="{ width: requestViewWidth + 'px' }">{{
store.request
}}</pre>
</div>
<div class="column column-60" ref="responseView">
<h6>Response</h6>
<pre :style="{ width: responseViewWidth + 'px' }">{{
store.response
}}</pre>
</div>
</div>
</div>
</template>

<script>
import mixins from "../mixins.js";
import { store } from "../store.js";
export default {
mixins: [mixins],
data() {
return {
store,
expanded: false,
drawerTitle: 'ᐃ Show Console',
requestViewWidth: 0,
responseViewWidth: 0
};
},
methods: {
drawerAction() {
this.expanded = !this.expanded
this.drawerTitle = this.expanded ? 'ᐁ Hide Console' : 'ᐃ Show Console'
setTimeout(this.changeWidth, 100)
},
changeWidth() {
this.requestViewWidth = this.$refs.requestView.clientWidth
this.responseViewWidth = this.$refs.responseView.clientWidth - 40
}
},
created() {
window.addEventListener("resize", this.changeWidth);
},
destroyed() {
window.removeEventListener("resize", this.changeWidth);
mixins: [mixins],
data() {
return {
store,
expanded: false,
drawerTitle: "ᐃ Show Console",
requestViewWidth: 0,
responseViewWidth: 0
};
},
methods: {
drawerAction() {
this.expanded = !this.expanded;
this.drawerTitle = this.expanded ? "ᐁ Hide Console" : "ᐃ Show Console";
setTimeout(this.changeWidth, 100);
},
mounted() {
this.changeWidth();
changeWidth() {
this.requestViewWidth = this.$refs.requestView.clientWidth;
this.responseViewWidth = this.$refs.responseView.clientWidth - 40;
}
},
created() {
window.addEventListener("resize", this.changeWidth);
},
destroyed() {
window.removeEventListener("resize", this.changeWidth);
},
mounted() {
this.changeWidth();
}
};
</script>
8 changes: 4 additions & 4 deletions vue/js/components/MoonPhase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
this.loading = true;
this.status = "Loading...";
const url = `${store.apiEndpoint}/api/v2/studio/moon-phase`
const url = `${store.apiEndpoint}/api/v2/studio/moon-phase`;
const params = {
style: this.style,
Expand All @@ -114,14 +114,14 @@ export default {
type: this.viewType,
parameters: {}
}
}
};
const headers = {
"X-Requested-With": "XMLHttpRequest",
Authorization: `Basic ${btoa(`${store.appId}:${store.appSecret}`)}`
}
};
this.setSnippetData('POST', url, params, headers)
this.setSnippetData("POST", url, params, headers);
axios.post(url, params, { headers }).then(response => {
this.imageUrl = response.data.data.imageUrl;
Expand Down
46 changes: 30 additions & 16 deletions vue/js/components/Positions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@
<label>Time</label>
<input @change="getData" v-model="time" type="time" />
<label>Coordinates</label>
<input v-model="coordinates" value="equatorial" type="radio" />Equatorial
<input v-model="coordinates" value="horizonal" type="radio" />Horizonal
<input
v-model="coordinates"
value="equatorial"
type="radio"
/>Equatorial
<input
v-model="coordinates"
value="horizonal"
type="radio"
/>Horizonal
</fieldset>
</form>
</div>
Expand All @@ -39,17 +47,24 @@
<td>
{{ row.entry.name }}
</td>
<td :key="ci" v-for="(cell, ci) in row.cells" v-if="coordinates == 'equatorial'">
<td
:key="ci"
v-for="(cell, ci) in row.cells"
v-if="coordinates == 'equatorial'"
>
RA {{ cell.position.equatorial.rightAscension.string }}<br />
Dec
{{
decodeURIComponent(cell.position.equatorial.declination.string)
}}
</td>
<td :key="ci" v-for="(cell, ci) in row.cells" v-if="coordinates == 'horizonal'">
<td
:key="ci"
v-for="(cell, ci) in row.cells"
v-if="coordinates == 'horizonal'"
>
Alt
{{
decodeURIComponent(cell.position.horizonal.altitude.string)
{{ decodeURIComponent(cell.position.horizonal.altitude.string)
}}<br />
Az
{{ decodeURIComponent(cell.position.horizonal.azimuth.string) }}
Expand Down Expand Up @@ -91,7 +106,7 @@ export default {
getData() {
this.loading = true;
const url = `${store.apiEndpoint}/api/v2/bodies/positions`
const url = `${store.apiEndpoint}/api/v2/bodies/positions`;
const params = {
longitude: this.longitude,
Expand All @@ -100,22 +115,21 @@ export default {
from_date: moment(this.fromDate).format("YYYY-MM-DD"),
to_date: moment(this.toDate).format("YYYY-MM-DD"),
time: moment(this.time, "HH:mm:ss").format("HH:mm:ss")
}
};
const headers = {
"X-Requested-With": "XMLHttpRequest",
Authorization: `Basic ${btoa(`${store.appId}:${store.appSecret}`)}`
}
};
this.setSnippetData('GET', url, params, headers)
this.setSnippetData("GET", url, params, headers);
axios
.get(url, { params, headers }).then(response => {
this.data = response.data.data;
store.response = JSON.stringify(response.data, null, 2);
axios.get(url, { params, headers }).then(response => {
this.data = response.data.data;
store.response = JSON.stringify(response.data, null, 2);
this.loading = false;
});
this.loading = false;
});
}
},
mounted() {
Expand Down
19 changes: 12 additions & 7 deletions vue/js/components/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@
<tr :key="i" v-for="(item, i) in data">
<td>{{ item.name }}</td>
<td>{{ item.type.name }}</td>
<td><span v-if="item.subType">{{ item.subType.name }}</span></td>
<td><span v-if="item.position.constellation">{{ item.position.constellation.name }}</span></td>
<td>
<span v-if="item.subType">{{ item.subType.name }}</span>
</td>
<td>
<span v-if="item.position.constellation">{{
item.position.constellation.name
}}</span>
</td>
<td>
{{ item.position.equatorial.rightAscension.string }}
{{ item.position.equatorial.declination.string }}
Expand Down Expand Up @@ -74,24 +80,23 @@ export default {
getData() {
this.loading = true;
const url = `${store.apiEndpoint}/api/v2/search`
const url = `${store.apiEndpoint}/api/v2/search`;
const params = {
term: this.term,
ra: this.ra,
dec: this.dec,
match_type: this.match_type
}
};
const headers = {
"X-Requested-With": "XMLHttpRequest",
Authorization: `Basic ${btoa(`${store.appId}:${store.appSecret}`)}`
}
};
this.setSnippetData('GET', url, params, headers)
this.setSnippetData("GET", url, params, headers);
axios.get(url, { params, headers }).then(response => {
this.data = response.data.data;
store.response = JSON.stringify(response.data, null, 2);
Expand Down
14 changes: 7 additions & 7 deletions vue/js/components/StarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ export default {
if (this.type == "area") {
parameters["position"] = {
equatorial: {
rightAscension: this.ra,
declination: this.dec
rightAscension: parseInt(this.ra),
declination: parseInt(this.dec)
}
};
parameters["zoom"] = this.zoom;
parameters["zoom"] = parseInt(this.zoom);
}
const url = `${store.apiEndpoint}/api/v2/studio/star-chart`
const url = `${store.apiEndpoint}/api/v2/studio/star-chart`;
const params = {
style: this.style,
Expand All @@ -211,14 +211,14 @@ export default {
type: this.type,
parameters
}
}
};
const headers = {
"X-Requested-With": "XMLHttpRequest",
Authorization: `Basic ${btoa(`${store.appId}:${store.appSecret}`)}`
}
};
this.setSnippetData('POST', url, params, headers)
this.setSnippetData("POST", url, params, headers);
axios.post(url, params, { headers }).then(response => {
this.imageUrl = response.data.data.imageUrl;
Expand Down

0 comments on commit 0b57b75

Please sign in to comment.