This repository has been archived by the owner on Jul 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkube-service.html
85 lines (73 loc) · 2.3 KB
/
kube-service.html
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="kube-card.html">
<polymer-element name="kube-service" attributes="sid data core">
<template>
<link rel="stylesheet" href="kube-service.css">
<kube-card icon="settings-ethernet" top="{{data.id}}">
<main>
{{data.port}} › {{data.containerPort}}
<div class="top space">
<template repeat="{{k in data.selector | keys}}">
<div class="smaller inline">
<span class="slabel name">{{k}}
</span><span class="slabel value">{{data.selector[k]}}</span>
</div>
</template>
</div>
</main>
<template repeat="{{k in data.labels | keys}}">
<div class="smaller label item">
<span class="label name">{{k}}
</span><span class="label value">{{data.labels[k]}}</span>
</div>
</template>
<bottom>{{data.creationTimestamp | date}}</bottom>
<paper-icon-button id="close" icon="close" on-click="{{remove}}"></paper-icon-button>
</kube-card>
</template>
<script>
Polymer({
data: null,
// TODO: refresh on sid or core changes
// observe: {
// 'sid core': 'refresh'
// },
ready: function() {
if (!this.data) {
this.refresh();
}
},
date: function(v) {
return v ? new Date(v).toLocaleString() : null;
},
keys: function(obj) {
return obj ? Object.keys(obj) : [];
},
labels: function(obj) {
var labels = [];
for (var k in obj) {
labels.push(k + '=' + obj[k]);
}
return labels.join(', ');
},
receive: function(response) {
this.data = response;
this.sid = this.data.id;
},
refresh: function(force) {
this.refreshJob = this.job(this.refreshJob, function(){
this.core && this.core.getService({
sid: this.sid,
callback: this.receive.bind(this)
});
}, 0);
},
remove: function() {
this.core && this.core.removeService({sid: this.sid});
this.super();
}
});
</script>
</polymer-element>