Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
337
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
23
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
TransFem.org
Sharkey
Commits
2faa5892
Commit
2faa5892
authored
6 years ago
by
MeiMei
Committed by
syuilo
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Format uptimes (#3629)
* Format uptime * 逆だわ * ザ * 1個多い * Fix comment
parent
ffb80efe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/client/app/common/scripts/format-uptime.ts
+25
-0
25 additions, 0 deletions
src/client/app/common/scripts/format-uptime.ts
src/client/app/common/views/widgets/server.uptimes.vue
+5
-4
5 additions, 4 deletions
src/client/app/common/views/widgets/server.uptimes.vue
with
30 additions
and
4 deletions
src/client/app/common/scripts/format-uptime.ts
0 → 100644
+
25
−
0
View file @
2faa5892
/**
* Format like the uptime command
*/
export
default
function
(
sec
)
{
if
(
!
sec
)
return
sec
;
const
day
=
Math
.
floor
(
sec
/
86400
);
const
tod
=
sec
%
86400
;
// Days part in string: 2 days, 1 day, null
const
d
=
day
>=
2
?
`
${
day
}
days`
:
day
>=
1
?
`
${
day
}
day`
:
null
;
// Time part in string: 1 sec, 1 min, 1:01
const
t
=
tod
<
60
?
`
${
Math
.
floor
(
tod
)}
sec`
:
tod
<
3600
?
`
${
Math
.
floor
(
tod
/
60
)}
min`
:
`
${
Math
.
floor
(
tod
/
60
/
60
)}
:
${
Math
.
floor
((
tod
/
60
)
%
60
).
toString
().
padStart
(
2
,
"
0
"
)}
`
;
let
str
=
''
;
if
(
d
)
str
+=
`
${
d
}
, `
;
str
+=
t
;
return
str
;
}
This diff is collapsed.
Click to expand it.
src/client/app/common/views/widgets/server.uptimes.vue
+
5
−
4
View file @
2faa5892
<
template
>
<div
class=
"uptimes"
>
<p>
Uptimes
</p>
<p>
Process:
{{
process
?
process
.
toFixed
(
0
)
:
'
---
'
}}
s
</p>
<p>
OS:
{{
os
?
os
.
toFixed
(
0
)
:
'
---
'
}}
s
</p>
<p>
Process:
{{
process
}}
</p>
<p>
OS:
{{
os
}}
</p>
</div>
</
template
>
<
script
lang=
"ts"
>
import
Vue
from
'
vue
'
;
import
formatUptime
from
'
../../scripts/format-uptime
'
;
export
default
Vue
.
extend
({
props
:
[
'
connection
'
],
...
...
@@ -25,8 +26,8 @@ export default Vue.extend({
},
methods
:
{
onStats
(
stats
)
{
this
.
process
=
stats
.
process_uptime
;
this
.
os
=
stats
.
os_uptime
;
this
.
process
=
formatUptime
(
stats
.
process_uptime
)
;
this
.
os
=
formatUptime
(
stats
.
os_uptime
)
;
}
}
});
...
...
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