Start working on services
This commit is contained in:
parent
4b99158309
commit
26ae054e65
|
@ -0,0 +1,26 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
||||
"git.happydns.org/happydns/struct"
|
||||
)
|
||||
|
||||
func init() {
|
||||
router.GET("/api/services", apiHandler(listServices))
|
||||
//router.POST("/api/services", apiHandler(newService))
|
||||
}
|
||||
|
||||
func listServices(_ httprouter.Params, _ io.Reader) Response {
|
||||
if services, err := happydns.GetServices(); err != nil {
|
||||
return APIErrorResponse{
|
||||
err: err,
|
||||
}
|
||||
} else {
|
||||
return APIResponse{
|
||||
response: services,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,6 +43,13 @@ const routes = [
|
|||
component: function () {
|
||||
return import(/* webpackChunkName: "zone" */ '../views/zone-details.vue')
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'services',
|
||||
name: 'zone-services',
|
||||
component: function () {
|
||||
return import(/* webpackChunkName: "zone" */ '../views/zone-services.vue')
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="d-flex flex-row justify-content-around flex-wrap align-self-center">
|
||||
<div class="p-3 service" v-for="(svc, index) in services" v-bind:key="index">
|
||||
<img :src="svc.logo" :alt="svc.name">
|
||||
Utiliser {{ svc.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
data: function () {
|
||||
return {
|
||||
error: '',
|
||||
services: [],
|
||||
zone: {}
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
axios
|
||||
.get('/api/services')
|
||||
.then(response => (this.services = response.data))
|
||||
|
||||
var myzone = this.$route.params.zone
|
||||
axios
|
||||
.get('/api/zones/' + myzone)
|
||||
.then(response => (this.zone = response.data))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.services {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.service {
|
||||
box-shadow: 2px 2px black;
|
||||
border: 1px solid black;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin: 2.5%;
|
||||
width: 20%;
|
||||
height: 150px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.service img {
|
||||
max-width: 100%;
|
||||
max-height: 90%;
|
||||
padding: 2%;
|
||||
}
|
||||
</style>
|
13
static.go
13
static.go
|
@ -55,6 +55,18 @@ func init() {
|
|||
fwd_request(w, r, DevProxy)
|
||||
}
|
||||
})
|
||||
api.Router().GET("/services/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
if DevProxy == "" {
|
||||
if data, err := Asset("htdocs/dist/index.html"); err != nil {
|
||||
fmt.Fprintf(w, "{\"errmsg\":%q}", err)
|
||||
} else {
|
||||
w.Write(data)
|
||||
}
|
||||
} else {
|
||||
r.URL.Path = "/"
|
||||
fwd_request(w, r, DevProxy)
|
||||
}
|
||||
})
|
||||
api.Router().GET("/zones/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
if DevProxy == "" {
|
||||
if data, err := Asset("htdocs/dist/index.html"); err != nil {
|
||||
|
@ -73,6 +85,7 @@ func init() {
|
|||
if data, err := Asset(path.Join(StaticDir, r.URL.Path)); err != nil {
|
||||
fmt.Fprintf(w, "{\"errmsg\":%q}", err)
|
||||
} else {
|
||||
w.Header().Set("Content-Type", "text/css")
|
||||
w.Write(data)
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package happydns
|
||||
|
||||
import ()
|
||||
|
||||
type StepInput struct {
|
||||
Type string `json:"type"`
|
||||
Label string `json:"label"`
|
||||
Placeholder string `json:"placeholder"`
|
||||
varname string `json:"varname"`
|
||||
value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
type StepEntries struct {
|
||||
EntryContent string `json:"entry_content"`
|
||||
Condition string `json:"condition"`
|
||||
}
|
||||
|
||||
type SStep struct {
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Inputs []StepInput `json:"inputs"`
|
||||
Entries []StepEntries `json:"entries"`
|
||||
Condition string `json:"condition"`
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
Id int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Logo string `json:"logo"`
|
||||
MainResource string `json:"main_resource"`
|
||||
ActiveVar string `json:"active_var"`
|
||||
Steps []SStep `json:"steps"`
|
||||
}
|
||||
|
||||
func GetServices() ([]Service, error) {
|
||||
return []Service{
|
||||
Service{Id: 1, Name: "G Suite", Logo: "/img/services/gsuite.svg", MainResource: "MX"},
|
||||
Service{Id: 2, Name: "WordPress", Logo: "/img/services/wordpress.svg", MainResource: "A"},
|
||||
Service{Id: 3, Name: "Wix.com", Logo: "/img/services/wix.png", MainResource: "A"},
|
||||
Service{Id: 4, Name: "AWS", Logo: "/img/services/aws.svg", MainResource: "A"},
|
||||
Service{Id: 5, Name: "GCP", Logo: "/img/services/gcp.svg", MainResource: "A"},
|
||||
Service{Id: 6, Name: "Azure", Logo: "/img/services/azure.svg", MainResource: "A"},
|
||||
Service{Id: 7, Name: "Clef PGP", Logo: "/img/services/pgp.svg", MainResource: "OPENPGPKEY"},
|
||||
Service{Id: 8, Name: "Let's encrypt", Logo: "/img/services/letsencrypt.svg", MainResource: "TXT"},
|
||||
Service{Id: 9, Name: "Mailo", Logo: "/img/services/mailo.png", MainResource: "MX"},
|
||||
Service{Id: 10, Name: "ProtonMail", Logo: "/img/services/protonmail.svg", MainResource: "MX"},
|
||||
Service{Id: 11, Name: "Outlook.com", Logo: "/img/services/outlook.svg", MainResource: "MX"},
|
||||
Service{Id: 12, Name: "Drupal", Logo: "/img/services/drupal.svg", MainResource: "A"},
|
||||
Service{Id: 13, Name: "Dotclear", Logo: "/img/services/dotclear.png", MainResource: "A"},
|
||||
Service{Id: 14, Name: "OVH web", Logo: "/img/services/ovh.svg", MainResource: "A"},
|
||||
Service{Id: 15, Name: "OVH mail", Logo: "/img/services/ovh.svg", MainResource: "MX"},
|
||||
Service{Id: 16, Name: "Infomaniak mail", Logo: "/img/services/infomaniak.jpg", MainResource: "MX"},
|
||||
}, nil
|
||||
}
|
Loading…
Reference in New Issue