Initial commit

This commit is contained in:
2019-05-26 03:55:28 +05:30
parent f11fd0f256
commit 4e4285d33f
6 changed files with 762 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
/*
* static/app.js
* Created: Sat May 25 2019 22:14:15 GMT+0530 (IST)
* Copyright 2019 Harish.K<harish2704@gmail.com>
*/
function api( method, url, data ){
const opts = {
method,
};
if( data ){
opts.headers = {
'Content-Type': 'application/json',
};
opts.body = JSON.stringify( data );
}
return fetch( url, opts )
.then(function(response) {
if( response.status === 200 ){
return response.json();
}
return response.json().then( v =>{
throw v;
});
});
}
var app = new Vue({
el: '#app',
data: {
ips: ['Loading....'],
},
mounted(){
this.updateIpList();
},
methods:{
updateIpList(){
api('get', 'ips')
.then( res => this.ips = res.ips );
},
addIp(){
const ip = this.$refs.ip.value;
api('post', 'ips', { ip })
.then( res =>{
this.ips = res.ips;
})
.catch( res =>{
console.log( res );
// alert( res.error )
});
}
}
});
+25
View File
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>IPV6 global ip test</title>
</head>
<body>
<div id="app">
<h3>List of global IPv6 address assigned to this server</h3>
<ul id="cont-ip-list">
<li v-for="ip in ips">
<a :href="'http://[' + ip + ']:3553'">
{{ ip }}
</a>
</li>
</ul>
<form action="./ips" method="post" @submit.prevent="addIp()">
<input ref="ip" type="text" minlength="24" maxlength="39" pattern="^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$">
<button type="submit">Add IP</button>
</form>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="./app.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>