genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0

[TASK] change traffic lights to be better seen

This commit is contained in:
mlabusch 2017-05-12 11:50:51 +02:00
parent c0ad2028fb
commit 0ffcf653c9
6 changed files with 19 additions and 14 deletions

View File

@ -5,15 +5,11 @@
<!-- ex. {procent .Count 10}%-->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<g class="arcs">
{{if lt .Count 4}}
<circle cx="50" cy="50" r="40" fill="#fff" stroke="#aaa" stroke-width="5"/>
<circle cx="50" cy="50" r="40" fill="none" stroke="#b02" stroke-width="5" stroke-dasharray="251.33" stroke-dashoffset="{{process_radius .Count 10 40}}"/>
{{ else if and (lt .Count 7) (gt .Count 3)}}
<circle cx="50" cy="50" r="40" fill="#fff" stroke="#aaa" stroke-width="5"/>
<circle cx="50" cy="50" r="40" fill="none" stroke="#e72" stroke-width="5" stroke-dasharray="251.33" stroke-dashoffset="{{process_radius .Count 10 40}}"/>
{{if eq .Count 0}}
<circle cx="50" cy="50" r="40" fill="#fff" stroke="#b02" stroke-width="8"/>
{{else}}
<circle cx="50" cy="50" r="40" fill="#fff" stroke="#aaa" stroke-width="5"/>
<circle cx="50" cy="50" r="40" fill="none" stroke="#6a4" stroke-width="5" stroke-dasharray="251.33" stroke-dashoffset="{{process_radius .Count 10 40}}"/>
<circle cx="50" cy="50" r="40" fill="#fff" stroke="#b02" stroke-width="8"/>
<circle cx="50" cy="50" r="40" fill="none" stroke="#093" stroke-width="8" stroke-dasharray="251.33" stroke-dashoffset="{{process_radius .Count 10 40}}"/>
{{end}}
</g>
<text x="50" y="65" fill="#555" text-anchor="middle" style="font: 50px Roboto,Verdana,sans-serif;">{{.Count}}</text>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 854 B

View File

@ -2,9 +2,9 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<g class="arcs">
{{if eq .Fresh false}}
<circle cx="50" cy="50" r="40" fill="#b02" stroke="#aaa" stroke-width="5"/>
<circle cx="50" cy="50" r="40" fill="#b02" stroke="#b02" stroke-width="5"/>
{{else}}
<circle cx="50" cy="50" r="40" fill="#fff" stroke="#6a4" stroke-width="5"/>
<circle cx="50" cy="50" r="40" fill="#093" stroke="#093" stroke-width="5"/>
{{end}}
</g>
</svg>

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 442 B

View File

@ -101,7 +101,7 @@ func getGoodFreshness(w http.ResponseWriter, r *http.Request){
}
fresh := false
if good.FouledAt != nil {
fresh = time.Now().Add(-time.Duration(3) * time.Hour * 24).Before(*good.FouledAt)
fresh = time.Now().Before(*good.FouledAt)
}
log = log.WithField("type", r.Header.Get("Content-Type"))

View File

@ -7,6 +7,7 @@ import (
"time"
"github.com/genofire/hs_master-kss-monolith/lib/log"
"sync"
)
// URL to the microservice which manages permissions
@ -31,12 +32,15 @@ type permissionMicroServiceCache struct {
LastCheck time.Time
session string
permissions map[Permission]boolMicroServiceCache
sync.Mutex
}
// Function to check, if a user has a permission
func (c *permissionMicroServiceCache) HasPermission(p Permission) (bool, error) {
c.LastCheck = time.Now()
c.Lock()
defer c.Unlock()
if cache, ok := c.permissions[p]; ok {
before := time.Now().Add(-CacheConfig.After.Duration)
if before.After(cache.LastCheck) {
@ -63,7 +67,7 @@ func (c *permissionMicroServiceCache) HasPermission(p Permission) (bool, error)
// Cache for permissions
var permissionCache map[string]*permissionMicroServiceCache
var permissionMutex sync.Mutex
// Function to initialize the permission cache
func init() {
permissionCache = make(map[string]*permissionMicroServiceCache)
@ -71,6 +75,8 @@ func init() {
// Function to check, if the current session has any permissions
func HasPermission(session string, p int) (bool, error) {
permissionMutex.Lock()
defer permissionMutex.Unlock()
_, ok := permissionCache[session]
if !ok {
permissionCache[session] = &permissionMicroServiceCache{

View File

@ -7,6 +7,7 @@ import (
"time"
"github.com/genofire/hs_master-kss-monolith/lib/log"
"sync"
)
// URL to the microservice which manages the products (product catalogue)
@ -20,6 +21,7 @@ type boolMicroServiceCache struct {
// Cache for existing products
var productExistCache map[int64]boolMicroServiceCache
var productMutex sync.Mutex
// Function to initialize the cache for existing products
func init() {
@ -28,6 +30,8 @@ func init() {
// Function to check on the other microservice (product catalogue) if the product exists
func ProductExists(id int64) (bool, error) {
productMutex.Lock()
defer productMutex.Unlock()
if cache, ok := productExistCache[id]; ok {
return cache.Value, nil
}

View File

@ -31,9 +31,8 @@
<td>{{item.position}}</td>
<td>{{item.comment}}</td>
<td></td>
<td>
<td valign="middle">
<img class="icon" ng-src="/api/good/freshness/{{item.id}}"/>
{{item.fouled_at|date:"shortDate"}}
</td>
<td><i class="trash icon" ng-click="delete(item.id)"></i></td>
</tr>