@appscode/design-system 1.0.43-alpha.175 → 1.0.43-alpha.178

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": "@appscode/design-system",
3
- "version": "1.0.43-alpha.175",
3
+ "version": "1.0.43-alpha.178",
4
4
  "description": "A design system for Appscode websites and dashboards made using Bulma",
5
5
  "main": "main.scss",
6
6
  "scripts": {
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <div
3
+ @mouseenter="notificationPanelOpen = true"
4
+ @mouseleave="notificationPanelOpen = false"
5
+ >
6
+ <button class="button ac-nav-button">
7
+ <span v-if="unreadCount">{{ unreadCount }}</span>
8
+ <i
9
+ class="fa fa-bell"
10
+ :class="{ 'ac-shake': unreadCount }"
11
+ aria-hidden="true"
12
+ ></i>
13
+ </button>
14
+ <div class="ac-menu-content is-notification">
15
+ <div class="notification-header">
16
+ <div class="left-content">
17
+ <p>
18
+ Notifications <span>({{ notifications.length }})</span>
19
+ </p>
20
+ </div>
21
+ <div class="right-content"></div>
22
+ </div>
23
+ <div :key="notificationPanelOpen ? 1 : 0" class="notification-body">
24
+ <transition-group v-if="notifications.length" name="slide-right">
25
+ <notification-item
26
+ v-for="notification in notifications"
27
+ :key="`${notification.id}${unreadCount}`"
28
+ :notification="notification"
29
+ />
30
+ </transition-group>
31
+ <span v-else class="single-notification-item"
32
+ >No new notifications</span
33
+ >
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </template>
38
+
39
+ <script>
40
+ import { StringCodec } from "nats.ws/cjs/nats";
41
+ export default {
42
+ components: {
43
+ NotificationItem: () => import("./NotificationItem.vue"),
44
+ },
45
+ data() {
46
+ return {
47
+ notifications: [],
48
+ notificationsRead: 0,
49
+
50
+ notificationPanelOpen: false,
51
+ subscription: null,
52
+ };
53
+ },
54
+ computed: {
55
+ unreadCount() {
56
+ return this.notifications.length - this.notificationsRead;
57
+ },
58
+ },
59
+ watch: {
60
+ notificationPanelOpen(n) {
61
+ if (n) {
62
+ this.notificationsRead = this.notifications.length;
63
+ }
64
+ },
65
+ },
66
+ created() {
67
+ this.subscribeToNotifcations();
68
+ },
69
+ methods: {
70
+ addNewNotification(notification) {
71
+ this.notifications.unshift(notification);
72
+ if (this.notificationPanelOpen) {
73
+ this.notificationsRead = this.notifications.length;
74
+ }
75
+ },
76
+ async subscribeToNotifcations() {
77
+ this.subscription = this.$nc?.subscribe("notifications");
78
+ console.log("Started listening to Notifications");
79
+
80
+ if (this.subscription) {
81
+ // listen to channel events
82
+ for await (const msg of this.subscription) {
83
+ console.log("notifications ===>");
84
+ console.log({ data: StringCodec().decode(msg.data) });
85
+ const log = JSON.parse(StringCodec().decode(msg.data));
86
+ console.log({ log });
87
+ const currentTime = new Date().getTime();
88
+ this.addNewNotification({
89
+ ...log,
90
+ id: currentTime,
91
+ time: currentTime,
92
+ });
93
+ msg.respond();
94
+ }
95
+ console.log("Stopped listening to Notifications");
96
+ console.log("Closed Channel Notifications");
97
+ }
98
+ },
99
+ },
100
+ };
101
+ </script>
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <a class="single-notification-item is-complete">
3
+ <p>
4
+ {{ notification.msg }}
5
+ </p>
6
+ <div class="notification-status">
7
+ <p
8
+ :class="{
9
+ 'is-success': notification.status === 'Success',
10
+ 'is-danger': notification.status === 'Failed',
11
+ 'is-info':
12
+ notification.status === 'Started' ||
13
+ notification.status === 'Running',
14
+ 'is-warning': notification.status === 'Pending',
15
+ }"
16
+ >
17
+ <i
18
+ class="fa mr-5"
19
+ :class="{
20
+ 'fa-check': notification.status === 'Success',
21
+ 'fa-exclamation-triangle': notification.status === 'Failed',
22
+ 'fa-info-circle':
23
+ notification.status === 'Started' ||
24
+ notification.status === 'Pending' ||
25
+ notification.status === 'Running',
26
+ }"
27
+ />
28
+ {{ notification.status }}
29
+ </p>
30
+ <p>{{ notification.time | getDayDifferences }} ago</p>
31
+ </div>
32
+ </a>
33
+ </template>
34
+
35
+ <script>
36
+ export default {
37
+ props: {
38
+ notification: {
39
+ type: Object,
40
+ default: () => ({}),
41
+ },
42
+ },
43
+ };
44
+ </script>
@@ -71,6 +71,7 @@
71
71
  </ul>
72
72
  <long-running-task-terminal
73
73
  :key="activeTask?.step"
74
+ :theme="theme"
74
75
  :logs="activeTask?.logs"
75
76
  class="task-log"
76
77
  />
@@ -131,6 +132,7 @@ defineEmits(["close"]);
131
132
  const props = withDefaults(
132
133
  defineProps<{
133
134
  open: boolean;
135
+ theme: string;
134
136
  title: string;
135
137
  simple: boolean;
136
138
  natsSubject: string;
@@ -148,6 +150,7 @@ const props = withDefaults(
148
150
  }>(),
149
151
  {
150
152
  open: true,
153
+ theme: "light",
151
154
  simple: true,
152
155
  title: "Sample title",
153
156
  natsSubject: "",
@@ -3,74 +3,146 @@
3
3
  </template>
4
4
 
5
5
  <script setup lang="ts">
6
- import { computed, nextTick, ref, toRefs, watch, watchPostEffect } from 'vue'
7
- import { Terminal } from 'xterm'
8
- import { FitAddon } from 'xterm-addon-fit'
9
- import { WebglAddon } from 'xterm-addon-webgl'
10
- import { Material, MaterialDark } from 'xterm-theme' //https://github.com/ysk2014/xterm-theme/tree/master/src/iterm
11
-
12
- const props = withDefaults(
13
- defineProps<{
14
- logs: string[]
15
- }>(),
16
- { logs: () => [] }
17
- )
18
- // terminal print logic
19
- const { logs } = toRefs(props)
20
- const lastPrintIdx = ref(0)
21
- watch(
22
- logs,
23
- (n) => {
24
- if (n.length > lastPrintIdx.value) {
25
- nextTick(() => {
26
- writeOnTerminal(n.slice(lastPrintIdx.value).join('\n'))
27
- lastPrintIdx.value = n.length
28
- })
29
- }
30
- },
31
- { immediate: true, deep: true }
32
- )
33
-
34
- //theme
35
- const theme = ref('light') // handle theme logic later, without the useStore function because they are different in console and kubedb ui
36
- const bodyBgc = computed(() =>
37
- theme.value === 'light' ? '#eaeaea' : '#232322'
38
- )
39
-
40
- // xterm component logic
41
- const terminalRef = ref<HTMLElement>()
42
- const terminal = new Terminal({
43
- windowsMode: false,
44
- theme: theme.value === 'light' ? Material : MaterialDark,
45
- })
46
- const fitAddon = new FitAddon()
47
- terminal.loadAddon(fitAddon)
48
- const webGlAddon = new WebglAddon()
49
- webGlAddon.onContextLoss(() => {
50
- webGlAddon.dispose()
51
- })
52
- watchPostEffect(() => {
53
- if (terminalRef.value) {
54
- terminal.open(terminalRef.value)
55
- fitAddon.fit()
56
- terminal.focus()
57
- terminal.loadAddon(webGlAddon)
58
- }
59
- })
60
- function writeOnTerminal(msg: string) {
61
- const lines = msg.split('\n')
62
- lines.forEach((line, index) => {
63
- if (lines.length === 1 || index < lines.length - 1) terminal.writeln(line)
64
- else terminal.write(line)
65
- })
6
+ import { computed, nextTick, ref, toRefs, watch, watchPostEffect } from "vue";
7
+ import { Terminal } from "xterm";
8
+ import { FitAddon } from "xterm-addon-fit";
9
+ import { WebglAddon } from "xterm-addon-webgl";
10
+ import { Material, MaterialDark } from "xterm-theme"; //https://github.com/ysk2014/xterm-theme/tree/master/src/iterm
11
+
12
+ const props = withDefaults(
13
+ defineProps<{
14
+ theme: string;
15
+ logs: string[];
16
+ }>(),
17
+ { theme: "light", logs: () => [] }
18
+ );
19
+ // terminal print logic
20
+ const { logs, theme } = toRefs(props);
21
+ const lastPrintIdx = ref(0);
22
+ watch(
23
+ logs,
24
+ (n) => {
25
+ if (n.length > lastPrintIdx.value) {
26
+ nextTick(() => {
27
+ writeOnTerminal(n.slice(lastPrintIdx.value).join("\n"));
28
+ lastPrintIdx.value = n.length;
29
+ });
30
+ }
31
+ },
32
+ { immediate: true, deep: true }
33
+ );
34
+
35
+ //theme
36
+ const bodyBgc = computed(() =>
37
+ theme.value === "light" ? "#eaeaea" : "#232322"
38
+ );
39
+
40
+ // xterm component logic
41
+ const terminalRef = ref<HTMLElement>();
42
+ const terminal = new Terminal({
43
+ windowsMode: false,
44
+ theme: theme.value === "light" ? Material : MaterialDark,
45
+ });
46
+ const fitAddon = new FitAddon();
47
+ terminal.loadAddon(fitAddon);
48
+ const webGlAddon = new WebglAddon();
49
+ webGlAddon.onContextLoss(() => {
50
+ webGlAddon.dispose();
51
+ });
52
+ watchPostEffect(() => {
53
+ if (terminalRef.value) {
54
+ terminal.open(terminalRef.value);
55
+ fitAddon.fit();
56
+ terminal.focus();
57
+ terminal.loadAddon(webGlAddon);
66
58
  }
59
+ });
60
+ function writeOnTerminal(msg: string) {
61
+ const lines = msg.split("\n");
62
+ lines.forEach((line, index) => {
63
+ if (lines.length === 1 || index < lines.length - 1) terminal.writeln(line);
64
+ else terminal.write(line);
65
+ });
66
+ }
67
67
  </script>
68
68
 
69
69
  <style lang="scss">
70
- .terminal-body {
71
- width: 100%;
72
- height: 100%;
73
- background-color: v-bind(bodyBgc);
74
- padding: 5px 0px 0px 10px;
70
+ .terminal-body {
71
+ width: 100%;
72
+ height: 100%;
73
+ background-color: v-bind(bodyBgc);
74
+ padding: 5px 0px 0px 10px;
75
+
76
+ // for terminal scroll bar style
77
+ .xterm .xterm-viewport {
78
+ &::-webkit-scrollbar {
79
+ border-radius: 50px;
80
+ width: 3px;
81
+ }
82
+
83
+ &::-moz-scrollbar {
84
+ border-radius: 50px;
85
+ width: 3px;
86
+ }
87
+
88
+ &::-ms-scrollbar {
89
+ border-radius: 50px;
90
+ width: 3px;
91
+ }
92
+
93
+ &::-webkit-scrollbar:hover {
94
+ width: 7px;
95
+ }
96
+
97
+ &::-moz-scrollbar:hover {
98
+ width: 7px;
99
+ }
100
+
101
+ &::-ms-scrollbar:hover {
102
+ width: 7px;
103
+ }
104
+
105
+ &::-webkit-scrollbar-thumb {
106
+ background-color: #929292;
107
+ border-radius: 50px;
108
+ height: 2px !important;
109
+ }
110
+
111
+ &::-moz-scrollbar-thumb {
112
+ background-color: #929292;
113
+ border-radius: 50px;
114
+ height: 2px !important;
115
+ }
116
+
117
+ &::-ms-scrollbar-thumb {
118
+ background-color: #929292;
119
+ border-radius: 50px;
120
+ height: 2px !important;
121
+ }
122
+
123
+ &::-webkit-scrollbar-thumb:hover {
124
+ background-color: #929292;
125
+ }
126
+
127
+ &::-moz-scrollbar-thumb:hover {
128
+ background-color: #929292;
129
+ }
130
+
131
+ &::-ms-scrollbar-thumb:hover {
132
+ background-color: #929292;
133
+ }
134
+
135
+ &:hover::-webkit-scrollbar-corner {
136
+ height: 40px;
137
+ }
138
+
139
+ &:hover::-moz-scrollbar-corner {
140
+ height: 40px;
141
+ }
142
+
143
+ &:hover::-ms-scrollbar-corner {
144
+ height: 40px;
145
+ }
75
146
  }
147
+ }
76
148
  </style>