Provider's icons

This commit is contained in:
nemunaire 2021-05-22 02:00:23 +02:00
parent 7c05c6199c
commit 1d38f399fc
9 changed files with 24 additions and 32 deletions

View File

@ -34,6 +34,7 @@ package api
import (
"fmt"
"net/http"
"strings"
"github.com/gin-gonic/gin"
@ -45,9 +46,9 @@ import (
func declareProviderSpecsRoutes(router *gin.RouterGroup) {
router.GET("/providers/_specs", listProviders)
router.GET("/providers/_specs/:ssid/icon.png", getProviderSpecIcon)
router.GET("/providers/_specs/:psid/icon.png", getProviderSpecIcon)
apiProviderSpecsRoutes := router.Group("/providers/_specs/:ssid")
apiProviderSpecsRoutes := router.Group("/providers/_specs/:psid")
apiProviderSpecsRoutes.Use(ProviderSpecsHandler)
apiProviderSpecsRoutes.GET("", getProviderSpec)
@ -65,17 +66,14 @@ func listProviders(c *gin.Context) {
}
func getProviderSpecIcon(c *gin.Context) {
/*
ssid := string(c.Param("ssid"))
psid := string(c.Param("psid"))
cnt, ok := providers.Icons[strings.TrimSuffix(ssid, ".png")]
if !ok {
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": "Icon not found."})
}
cnt, ok := providers.Icons[strings.TrimSuffix(psid, ".png")]
if !ok {
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": "Icon not found."})
}
c.Data(http.StatusOK, "image/png", cnt)
*/
c.AbortWithStatusJSON(http.StatusNotImplemented, gin.H{"errmsg": "Icon not found."})
c.Data(http.StatusOK, "image/png", cnt)
}
func ProviderSpecsHandler(c *gin.Context) {

View File

@ -32,5 +32,5 @@
package main
//go:generate go run generators/gen_database_migration.go
//go:generate go run generators/gen_icon.go sources sources
//go:generate go run generators/gen_icon.go providers providers
//go:generate go run generators/gen_icon.go services svcs

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

BIN
providers/OVHAPI.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

11
providers/icons.go Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,7 @@
</b-list-group-item>
<b-list-group-item v-for="(src, idx) in providers" :key="idx" :active="srcSelected === idx" button class="d-flex" @click="selectProvider(idx)">
<div class="align-self-center text-center" style="min-width:50px;width:50px;">
<img :src="'/api/source_specs/' + idx + '/icon.png'" :alt="src.name" style="max-width: 100%; max-height: 2.5em; margin: -.6em .4em -.6em -.6em">
<img :src="'/api/providers/_specs/' + idx + '/icon.png'" :alt="src.name" style="max-width: 100%; max-height: 2.5em; margin: -.6em .4em -.6em -.6em">
</div>
<div class="align-self-center" style="line-height: 1.1">
<strong>{{ src.name }}</strong> &ndash;

View File

@ -101,7 +101,7 @@
<div class="pr-2 pl-2">
<b-button class="p-3 w-100 text-left" type="button" variant="outline-info" @click="goToSource()">
<div class="d-inline-block text-center" style="width: 50px;">
<img :src="'/api/source_specs/' + sources_getAll[domain.id_source]._srctype + '/icon.png'" :alt="sources_getAll[domain.id_source]._srctype" :title="sources_getAll[domain.id_source]._srctype" style="max-width: 100%; max-height: 2.5em; margin: -.6em .4em -.6em -.6em">
<img :src="'/api/providers/_specs/' + providers_getAll[domain.id_provider]._srctype + '/icon.png'" :alt="providers_getAll[domain.id_provider]._srctype" :title="providers_getAll[domain.id_provider]._srctype" style="max-width: 100%; max-height: 2.5em; margin: -.6em .4em -.6em -.6em">
</div>
{{ sources_getAll[domain.id_source]._comment }}
</b-button>

View File

@ -39,7 +39,7 @@
<b-row v-else class="flex-grow-1">
<b-col lg="4" md="5" class="bg-light">
<div class="text-center mb-3">
<img :src="'/api/provider_specs/' + $route.params.provider + '/icon.png'" :alt="providerSpecs_getAll[$route.params.provider].name" style="max-width: 100%; max-height: 10em">
<img :src="'/api/providers/_specs/' + $route.params.provider + '/icon.png'" :alt="providerSpecs_getAll[$route.params.provider].name" style="max-width: 100%; max-height: 10em">
</div>
<h3>
{{ providerSpecs_getAll[$route.params.provider].name }}