This repository has been archived by the owner on Oct 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
vue-dlpage.js
65 lines (64 loc) · 2.17 KB
/
vue-dlpage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const DownloadPage = {
template: `
<section>
<h2>Download EssentialsX</h2>
<p v-if="buildNo">The latest version of EssentialsX is <b>{{build}}</b>.</p>
<p v-if="failed" class="warning">
Could not retrieve information about the latest version.
Click <a href="https://ci.ender.zone/job/EssentialsX">here</a> to visit the build server.
</p>
<table v-if="buildNo">
<tr>
<th>Plugin</th>
<th>Main</th>
<th>Mirror</th>
</tr>
<tr v-for="plugin in plugins" :key="plugin.name">
<td>{{ plugin.name }}</td>
<td><a :href="plugin.main">Download</a></td>
<td><a :href="plugin.mirror">Download</a></td>
</tr>
</table>
<button @click="updateInfo">Update</button>
</section>
`,
data() {
return {
buildNo: null,
failed: null,
plugins: [],
};
},
computed: {
build() {
return this.buildNo ? `b${this.buildNo}` : "unknown";
},
},
methods: {
updateInfo() {
axios.get("lastSuccessfulBuild/api/json")
.then(response => {
this.buildNo = response.data.id;
this.plugins = response.data.artifacts.map(artifact => {
return {
name: `EssentialsX ${artifact.displayPath.match(/EssentialsX([A-Za-z]*)/)[1]}`,
main: `${mainCI}lastSuccessfulBuild/artifact/${artifact.relativePath}`,
mirror: `${mirrorCI}lastSuccessfulBuild/artifact/${artifact.relativePath}`,
};
});
this.failed = null;
}, error => {
if (error.response) {
this.failed = error.response.data;
} else {
this.failed = error.message;
}
}
);
}
},
mounted: function () {
this.updateInfo();
}
};
window.DownloadPage = DownloadPage;