Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dccviewer-js
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DigitalDynamicMeasurement
dccviewer-js
Commits
d3dbbe48
Project 'Seeger/dccviewer-js' was moved to 'digitaldynamicmeasurement/dccviewer-js'. Please update any links and bookmarks that may still have the old path.
Commit
d3dbbe48
authored
3 months ago
by
Benedikt
Browse files
Options
Downloads
Patches
Plain Diff
added colored UUID
parent
a665dc7c
No related branches found
No related tags found
No related merge requests found
Pipeline
#52888
passed
3 months ago
Stage: test
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
package.json
+1
-1
1 addition, 1 deletion
package.json
src/renderers/AdminRenderer.js
+51
-10
51 additions, 10 deletions
src/renderers/AdminRenderer.js
with
52 additions
and
11 deletions
package.json
+
1
−
1
View file @
d3dbbe48
{
{
"name"
:
"dccviewer-js"
,
"name"
:
"dccviewer-js"
,
"version"
:
"0.1.
3
"
,
"version"
:
"0.1.
4
"
,
"description"
:
"A JS application for displaying digital calibration certificates."
,
"description"
:
"A JS application for displaying digital calibration certificates."
,
"main"
:
"dist/dccviewer-js.bundle.js"
,
"main"
:
"dist/dccviewer-js.bundle.js"
,
"files"
:
[
"files"
:
[
...
...
This diff is collapsed.
Click to expand it.
src/renderers/AdminRenderer.js
+
51
−
10
View file @
d3dbbe48
// src/renderers/AdminRenderer.js
// src/renderers/AdminRenderer.js
export
function
renderUUID
(
uuid
)
{
let
output
=
''
;
// Loop through each character of the uuid string.
for
(
let
i
=
0
;
i
<
uuid
.
length
;
i
++
)
{
let
ch
=
uuid
[
i
];
if
(
ch
===
'
-
'
)
{
// If the character is a hyphen, add it unstyled.
output
+=
ch
;
}
else
{
// Convert hex digit to a number (0-15)
let
value
=
parseInt
(
ch
,
16
);
if
(
isNaN
(
value
))
{
// If not a valid hex digit, add it unstyled.
output
+=
ch
;
}
else
{
// Compute hue: linear interpolation from 0 (red) for 0 to ~270 (violet) for F.
let
hue
=
(
value
/
15
)
*
270
;
// Adjust saturation and lightness as needed.
output
+=
`<span style="color: hsl(
${
hue
}
, 100%, 40%)">
${
ch
}
</span>`
;
}
}
}
return
output
;
}
export
function
renderAdminData
(
adminData
,
language
)
{
export
function
renderAdminData
(
adminData
,
language
)
{
const
container
=
document
.
getElementById
(
'
adminData
'
);
const
container
=
document
.
getElementById
(
'
adminData
'
);
...
@@ -6,7 +30,7 @@ export function renderAdminData(adminData, language) {
...
@@ -6,7 +30,7 @@ export function renderAdminData(adminData, language) {
// Title
// Title
const
title
=
document
.
createElement
(
'
h2
'
);
const
title
=
document
.
createElement
(
'
h2
'
);
title
.
textContent
=
`Administrative Data
(
${
language
}
)
`
;
title
.
textContent
=
`Administrative Data`
;
container
.
appendChild
(
title
);
container
.
appendChild
(
title
);
// ----- CORE DATA SECTION -----
// ----- CORE DATA SECTION -----
...
@@ -17,11 +41,19 @@ export function renderAdminData(adminData, language) {
...
@@ -17,11 +41,19 @@ export function renderAdminData(adminData, language) {
coreContainer
.
style
.
border
=
'
1px solid #ccc
'
;
coreContainer
.
style
.
border
=
'
1px solid #ccc
'
;
coreContainer
.
style
.
padding
=
'
8px
'
;
coreContainer
.
style
.
padding
=
'
8px
'
;
// Unique Identifier
// Get the UUID from coreData.
const
uuidDiv
=
document
.
createElement
(
'
div
'
);
const
uuid
=
coreData
[
'
dcc:uniqueIdentifier
'
];
uuidDiv
.
innerHTML
=
`<strong>Unique Identifier:</strong>
${
coreData
[
'
dcc:uniqueIdentifier
'
]
||
'
N/A
'
}
`
;
// If a UUID exists, format it using renderUUID; otherwise use 'N/A'
uuidDiv
.
style
.
marginBottom
=
'
10px
'
;
const
formattedUUID
=
uuid
?
renderUUID
(
uuid
)
:
'
N/A
'
;
coreContainer
.
appendChild
(
uuidDiv
);
const
uuidDivText
=
document
.
createElement
(
'
div
'
);
uuidDivText
.
innerHTML
=
`<strong>UUID:</strong>
${
formattedUUID
}
`
;
// Increase font size and boldness
uuidDivText
.
style
.
marginBottom
=
'
10px
'
;
uuidDivText
.
style
.
fontSize
=
'
24px
'
;
uuidDivText
.
style
.
fontWeight
=
'
bold
'
;
coreContainer
.
appendChild
(
uuidDivText
);
// Identifications table
// Identifications table
if
(
coreData
[
'
dcc:identifications
'
]
&&
coreData
[
'
dcc:identifications
'
][
'
dcc:identification
'
])
{
if
(
coreData
[
'
dcc:identifications
'
]
&&
coreData
[
'
dcc:identifications
'
][
'
dcc:identification
'
])
{
...
@@ -155,15 +187,24 @@ export function renderAdminData(adminData, language) {
...
@@ -155,15 +187,24 @@ export function renderAdminData(adminData, language) {
}
}
detailsDiv
.
innerHTML
+=
`<strong>Item:</strong>
${
itemName
}
<br>`
;
detailsDiv
.
innerHTML
+=
`<strong>Item:</strong>
${
itemName
}
<br>`
;
// Manufacturer details
// Manufacturer details
if
(
item
[
'
dcc:manufacturer
'
])
{
if
(
item
[
'
dcc:manufacturer
'
])
{
const
manu
=
item
[
'
dcc:manufacturer
'
];
const
manu
=
item
[
'
dcc:manufacturer
'
];
let
manuName
=
''
;
let
manuName
=
''
;
if
(
manu
[
'
dcc:name
'
]
&&
manu
[
'
dcc:name
'
][
'
dcc:content
'
])
{
if
(
manu
[
'
dcc:name
'
]
&&
manu
[
'
dcc:name
'
][
'
dcc:content
'
])
{
const
content
=
manu
[
'
dcc:name
'
][
'
dcc:content
'
];
const
content
=
manu
[
'
dcc:name
'
][
'
dcc:content
'
];
manuName
=
Array
.
isArray
(
content
)
if
(
Array
.
isArray
(
content
))
{
?
(
content
.
find
(
c
=>
c
.
$
&&
c
.
$
.
lang
===
language
)
||
content
[
0
]).
_
||
''
// Try to find an element matching the desired language.
:
content
.
_
||
''
;
let
found
=
content
.
find
(
c
=>
c
.
$
&&
c
.
$
.
lang
===
language
);
// If not found, look for an element without a language attribute.
if
(
!
found
)
{
found
=
content
.
find
(
c
=>
!
c
.
$
||
!
c
.
$
.
lang
);
}
manuName
=
found
?
(
typeof
found
===
'
string
'
?
found
:
found
.
_
||
''
)
:
''
;
}
else
{
// Handle the case where content is a plain string or an object.
manuName
=
typeof
content
===
'
string
'
?
content
:
content
.
_
||
''
;
}
}
}
detailsDiv
.
innerHTML
+=
`<strong>Manufacturer:</strong>
${
manuName
}
<br>`
;
detailsDiv
.
innerHTML
+=
`<strong>Manufacturer:</strong>
${
manuName
}
<br>`
;
if
(
manu
[
'
dcc:location
'
])
{
if
(
manu
[
'
dcc:location
'
])
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment