@nethserver/ns8-ui-lib 0.0.21 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nethserver/ns8-ui-lib",
3
- "version": "0.0.21",
3
+ "version": "0.0.25",
4
4
  "description": "Vue.js library for NethServer 8 UI",
5
5
  "keywords": [
6
6
  "nethserver",
@@ -1,6 +1,15 @@
1
1
  <template>
2
2
  <div class="empty-state">
3
- <NsPictogram title="empty state" class="image">
3
+ <NsLottieAnimation
4
+ v-if="animationData"
5
+ :animationData="animationData"
6
+ :refName="animationTitle"
7
+ :animateOnHover="true"
8
+ :loop="1"
9
+ :autoPlay="true"
10
+ class="animation image"
11
+ />
12
+ <NsPictogram v-else title="empty state" class="image">
4
13
  <template v-if="hasPictogramSlot">
5
14
  <slot name="pictogram"></slot>
6
15
  </template>
@@ -20,16 +29,19 @@
20
29
 
21
30
  <script>
22
31
  import NsPictogram from "./NsPictogram.vue";
32
+ import NsLottieAnimation from "./NsLottieAnimation";
23
33
  import ExclamationMark from "./pictograms/ExclamationMark";
24
34
 
25
35
  export default {
26
36
  name: "NsEmptyState",
27
- components: { NsPictogram, ExclamationMark },
37
+ components: { NsPictogram, ExclamationMark, NsLottieAnimation },
28
38
  props: {
29
39
  title: {
30
40
  type: String,
31
41
  required: true,
32
42
  },
43
+ animationData: Object,
44
+ animationTitle: String,
33
45
  },
34
46
  computed: {
35
47
  hasPictogramSlot() {
@@ -55,4 +67,10 @@ export default {
55
67
  .empty-state .description {
56
68
  margin-top: 1rem;
57
69
  }
70
+
71
+ .animation {
72
+ display: inline-block;
73
+ width: 64px;
74
+ height: 64px;
75
+ }
58
76
  </style>
@@ -64,6 +64,9 @@ export default {
64
64
  .title {
65
65
  margin-left: 0.25rem;
66
66
  margin-right: 0.25rem;
67
+ overflow: hidden;
68
+ text-overflow: ellipsis;
69
+ white-space: nowrap;
67
70
  }
68
71
 
69
72
  .description {
@@ -0,0 +1,68 @@
1
+ <template>
2
+ <div class="ns-lottie-animation" @mouseover="onMouseOver">
3
+ <LottieAnimation
4
+ :ref="refName"
5
+ :animationData="animationData"
6
+ :loop="loop"
7
+ :autoPlay="autoPlay"
8
+ @loopComplete="onLoopComplete"
9
+ @complete="onComplete"
10
+ @enterFrame="onEnterFrame"
11
+ />
12
+ </div>
13
+ </template>
14
+
15
+ <script>
16
+ import LottieAnimation from "lottie-web-vue";
17
+
18
+ export default {
19
+ name: "NsLottieAnimation",
20
+ components: { LottieAnimation },
21
+ props: {
22
+ animationData: {
23
+ type: Object,
24
+ required: true,
25
+ },
26
+ loop: {
27
+ type: [Boolean, Number],
28
+ default: false,
29
+ },
30
+ autoPlay: {
31
+ type: Boolean,
32
+ default: true,
33
+ },
34
+ refName: {
35
+ type: String,
36
+ default: "anim",
37
+ },
38
+ animateOnHover: {
39
+ type: Boolean,
40
+ default: true,
41
+ },
42
+ },
43
+ methods: {
44
+ onLoopComplete(eventData) {
45
+ this.$emit("loopComplete", eventData);
46
+ },
47
+ onComplete(eventData) {
48
+ this.$emit("complete", eventData);
49
+
50
+ if (this.animateOnHover) {
51
+ this.$refs[this.refName].stop();
52
+ }
53
+ },
54
+ onEnterFrame(eventData) {
55
+ this.$emit("enterFrame", eventData);
56
+ },
57
+ onMouseOver(eventData) {
58
+ this.$emit("mouseover", eventData);
59
+
60
+ if (this.animateOnHover) {
61
+ this.$refs[this.refName].play();
62
+ }
63
+ },
64
+ },
65
+ };
66
+ </script>
67
+
68
+ <style scoped lang="scss"></style>
@@ -1,212 +0,0 @@
1
- <template>
2
- <cv-tile kind="standard" :light="light" class="node-card">
3
- <!-- icon -->
4
- <div class="row">
5
- <NsSvg :svg="Chip32" />
6
- </div>
7
- <div class="row">
8
- <h3 class="title">{{ nodeLabel }} {{ nodeId }}</h3>
9
- </div>
10
- <div class="row">
11
- <cv-tag v-if="isLeader" kind="green" :label="leaderLabel"></cv-tag>
12
- <cv-tag v-else kind="blue" :label="workerLabel"></cv-tag>
13
- </div>
14
- <div v-if="loading" class="row node-card-skeleton">
15
- <cv-skeleton-text :paragraph="true" :line-count="5"></cv-skeleton-text>
16
- </div>
17
- <div v-else class="table-wrapper">
18
- <div class="table">
19
- <div class="tr">
20
- <div class="td label">{{ cpuUsageLabel }}</div>
21
- <div :class="['td', { warning: cpuUsage >= cpuUsageWarningTh }]">
22
- {{ cpuUsage }}%
23
- </div>
24
- </div>
25
- <div class="tr">
26
- <div class="td label">
27
- {{ cpuLoadLabel }}
28
- <cv-tooltip
29
- alignment="center"
30
- direction="bottom"
31
- :tip="cpuLoadTooltip"
32
- class="info"
33
- >
34
- <Information16 />
35
- </cv-tooltip>
36
- </div>
37
- <div class="td">
38
- <span :class="{ warning: load1Min >= cpuLoadWarningTh }"
39
- >{{ load1Min }}%</span
40
- >
41
- /
42
- <span :class="{ warning: load5Min >= cpuLoadWarningTh }"
43
- >{{ load5Min }}%</span
44
- >
45
- /
46
- <span :class="{ warning: load15Min >= cpuLoadWarningTh }"
47
- >{{ load15Min }}%</span
48
- >
49
- </div>
50
- </div>
51
- <div class="tr">
52
- <div class="td label">{{ memoryUsageLabel }}</div>
53
- <div :class="['td', { warning: memoryUsage >= memoryWarningTh }]">
54
- {{ memoryUsage }}%
55
- </div>
56
- </div>
57
- <div class="tr">
58
- <div class="td label">{{ swapUsageLabel }}</div>
59
- <div :class="['td', { warning: swapUsage >= swapWarningTh }]">
60
- {{ swapUsage }}%
61
- </div>
62
- </div>
63
- <div class="tr" v-for="(disk, index) in disksUsage" :key="index">
64
- <div class="td label">{{ disk.diskId }} {{ diskUsageLabel }}</div>
65
- <div :class="['td', { warning: disk.usage >= diskWarningTh }]">
66
- {{ disk.usage }}%
67
- </div>
68
- </div>
69
- </div>
70
- </div>
71
- <div class="row slot">
72
- <!-- Extra content -->
73
- <slot></slot>
74
- </div>
75
- </cv-tile>
76
- </template>
77
-
78
- <script>
79
- import NsSvg from "./NsSvg.vue";
80
- import { CvTile } from "@carbon/vue";
81
- import Chip32 from "@carbon/icons-vue/es/chip/32";
82
- import Information16 from "@carbon/icons-vue/es/information/16";
83
-
84
- export default {
85
- name: "NsNodeCard",
86
- //components added for storybook to work
87
- components: { NsSvg, CvTile, Information16 },
88
- props: {
89
- nodeId: String,
90
- nodeLabel: {
91
- type: String,
92
- default: "Node",
93
- },
94
- isLeader: Boolean,
95
- leaderLabel: {
96
- type: String,
97
- default: "leader",
98
- },
99
- workerLabel: {
100
- type: String,
101
- default: "worker",
102
- },
103
- cpuUsageLabel: {
104
- type: String,
105
- default: "CPU usage",
106
- },
107
- cpuLoadLabel: {
108
- type: String,
109
- default: "CPU load",
110
- },
111
- cpuLoadTooltip: {
112
- type: String,
113
- default: "CPU average load of last 1 / 5 / 15 minutes",
114
- },
115
- memoryUsageLabel: {
116
- type: String,
117
- default: "Memory usage",
118
- },
119
- swapUsageLabel: {
120
- type: String,
121
- default: "Swap usage",
122
- },
123
- diskUsageLabel: {
124
- type: String,
125
- default: "usage",
126
- },
127
- cpuUsage: Number,
128
- cpuUsageWarningTh: {
129
- type: Number,
130
- default: 90,
131
- },
132
- load1Min: Number,
133
- load5Min: Number,
134
- load15Min: Number,
135
- cpuLoadWarningTh: {
136
- type: Number,
137
- default: 90,
138
- },
139
- memoryUsage: Number,
140
- memoryWarningTh: {
141
- type: Number,
142
- default: 90,
143
- },
144
- swapUsage: Number,
145
- swapWarningTh: {
146
- type: Number,
147
- default: 90,
148
- },
149
- disksUsage: Array,
150
- diskWarningTh: {
151
- type: Number,
152
- default: 90,
153
- },
154
- loading: Boolean,
155
- light: Boolean,
156
- },
157
- data() {
158
- return {
159
- Chip32,
160
- };
161
- },
162
- };
163
- </script>
164
-
165
- <style scoped lang="scss">
166
- .node-card {
167
- display: flex;
168
- flex-direction: column;
169
- justify-content: center;
170
- min-height: 7rem;
171
- }
172
-
173
- .row {
174
- display: flex;
175
- align-items: center;
176
- justify-content: center;
177
- margin-bottom: 0.25rem;
178
- }
179
-
180
- .node-card-skeleton {
181
- margin: 1rem 3rem;
182
- }
183
-
184
- .label {
185
- padding-right: 0.5rem;
186
- font-weight: bold;
187
- text-align: right;
188
- padding-bottom: 0.5rem;
189
- }
190
-
191
- .slot {
192
- margin-top: 0.5rem;
193
- }
194
-
195
- .table-wrapper {
196
- display: flex;
197
- justify-content: center;
198
- margin-top: 0.5rem;
199
- }
200
-
201
- .table {
202
- display: table;
203
- }
204
-
205
- .tr {
206
- display: table-row;
207
- }
208
-
209
- .td {
210
- display: table-cell;
211
- }
212
- </style>