Skip to content

Commit 37e9fad

Browse files
authored
Merge pull request #4 from ZenUml/feat/editor-built-time
Feat/editor built time
2 parents 0ca6ee4 + aae4fd6 commit 37e9fad

File tree

5 files changed

+110
-3
lines changed

5 files changed

+110
-3
lines changed

build.gradle.kts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ tasks.register("buildZenUMLWebView") {
141141
outputs.dir("src/main/resources/assets/zenuml")
142142

143143
doLast {
144+
// Generate build timestamp in ISO 8601 format (JavaScript-friendly)
145+
val buildTimestamp = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").format(Date())
146+
144147
// Set working directory to the ZenUML web view
145148
val zenUmlDir = File(projectDir, "src/webview/zenuml")
146149

@@ -150,9 +153,10 @@ tasks.register("buildZenUMLWebView") {
150153
commandLine("npm", "install")
151154
}
152155

153-
// Run npm build
156+
// Run npm build with timestamp environment variable
154157
exec {
155158
workingDir = zenUmlDir
159+
environment("VITE_BUILD_TIMESTAMP", buildTimestamp)
156160
commandLine("npm", "run", "build")
157161
}
158162

@@ -162,7 +166,7 @@ tasks.register("buildZenUMLWebView") {
162166
into("${projectDir}/src/main/resources/assets/zenuml")
163167
}
164168

165-
println("ZenUML web view built and copied to resources")
169+
println("ZenUML web view built and copied to resources (built at: $buildTimestamp)")
166170
}
167171
}
168172

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<template>
2+
<div class="build-timestamp" :title="`Built at: ${buildTimestamp}`">
3+
<span class="timestamp-text">{{ formatTimestamp(buildTimestamp) }}</span>
4+
</div>
5+
</template>
6+
7+
<script setup>
8+
import { computed } from 'vue'
9+
10+
// Get build timestamp from environment variable
11+
const buildTimestamp = import.meta.env.VITE_BUILD_TIMESTAMP || 'Development'
12+
13+
const formatTimestamp = (timestamp) => {
14+
if (timestamp === 'Development') {
15+
return '1970-01-01T00:00:00.000Z'
16+
}
17+
18+
try {
19+
const date = new Date(timestamp)
20+
// Check if the date is valid
21+
if (Number.isNaN(date.getTime())) {
22+
console.warn('Invalid timestamp:', timestamp)
23+
return 'Invalid'
24+
}
25+
26+
// Format as "MMM dd, HH:mm"
27+
return date.toLocaleDateString('en-US', {
28+
month: 'short',
29+
day: '2-digit',
30+
hour: '2-digit',
31+
minute: '2-digit',
32+
hour12: false
33+
}).replace(',', '')
34+
} catch (e) {
35+
console.error('Error parsing timestamp:', e, timestamp)
36+
return 'Error'
37+
}
38+
}
39+
</script>
40+
41+
<style scoped>
42+
.build-timestamp {
43+
display: flex;
44+
align-items: center;
45+
gap: 2px;
46+
padding: 2px 4px;
47+
font-size: 9px;
48+
color: var(--text-muted, #ccc);
49+
white-space: nowrap;
50+
user-select: none;
51+
cursor: default;
52+
opacity: 0.4;
53+
}
54+
55+
.timestamp-icon {
56+
font-size: 8px;
57+
opacity: 0.8;
58+
}
59+
60+
.timestamp-text {
61+
font-family: monospace;
62+
font-size: 8px;
63+
font-weight: 300;
64+
}
65+
66+
/* Dark theme support */
67+
:global(.dark-theme) .build-timestamp {
68+
color: var(--text-muted, #666);
69+
opacity: 0.4;
70+
}
71+
</style>

src/webview/zenuml/src/components/Editor.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<template>
22
<div class="editor-container">
3-
<div ref="editorElement" class="editor-content"></div>
3+
<div ref="editorElement" class="editor-content">
4+
<BuildTimestamp class="editor-timestamp" />
5+
</div>
46
</div>
57
</template>
68

@@ -10,6 +12,7 @@ import {baseExtensionsFactory, zenumlExtensions} from "./extensions";
1012
import {EditorView} from '@codemirror/view'
1113
import {Compartment, EditorState} from '@codemirror/state'
1214
import {useHostCommunication} from '../composables/useHostCommunication'
15+
import BuildTimestamp from './BuildTimestamp.vue'
1316
1417
const props = defineProps({
1518
initialContent: {
@@ -97,6 +100,25 @@ onMounted(() => {
97100
</script>
98101

99102
<style scoped>
103+
.editor-container {
104+
display: flex;
105+
flex-direction: column;
106+
height: 100%;
107+
}
108+
109+
.editor-content {
110+
flex: 1;
111+
min-height: 0;
112+
position: relative;
113+
}
114+
115+
.editor-timestamp {
116+
position: absolute;
117+
bottom: 8px;
118+
right: 8px;
119+
z-index: 10;
120+
}
121+
100122
/* Styles are in main.css */
101123
:deep(.cm-editor) {
102124
min-height: 200px;

src/webview/zenuml/src/styles/main.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ body {
2222
--editor-bg: white;
2323
--preview-bg: white;
2424
--resizer-hover: #0078d7;
25+
--background-primary: white;
26+
--background-secondary: #f5f5f5;
27+
--text-muted: #666;
2528
}
2629

2730
.dark-theme {
@@ -32,6 +35,9 @@ body {
3235
--editor-bg: #3c3f41;
3336
--preview-bg: #3c3f41;
3437
--resizer-hover: #0078d7;
38+
--background-primary: #1e1e1e;
39+
--background-secondary: #2d2d2d;
40+
--text-muted: #aaa;
3541
}
3642

3743
body {

src/webview/zenuml/vite.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ export default defineConfig({
1414
build: {
1515
outDir: 'dist',
1616
emptyOutDir: true
17+
},
18+
define: {
19+
// Make build timestamp available as a global constant
20+
__BUILD_TIMESTAMP__: JSON.stringify(process.env.VITE_BUILD_TIMESTAMP || 'Development')
1721
}
1822
})

0 commit comments

Comments
 (0)