Skip to content

Commit 26eae52

Browse files
committed
fixup! feat: Vue
1 parent 95ead60 commit 26eae52

12 files changed

Lines changed: 243 additions & 28 deletions

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
22
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
/css/* binary
4+
/js/* binary
35
/vendor-bin/**/composer.lock binary
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: Npm audit fix and compile
10+
11+
on:
12+
workflow_dispatch:
13+
schedule:
14+
# At 2:30 on Sundays
15+
- cron: '30 2 * * 0'
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
branches:
28+
- ${{ github.event.repository.default_branch }}
29+
- 'stable34'
30+
- 'stable33'
31+
- 'stable32'
32+
33+
name: npm-audit-fix-${{ matrix.branches }}
34+
35+
steps:
36+
- name: Checkout
37+
id: checkout
38+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
39+
with:
40+
persist-credentials: false
41+
ref: ${{ matrix.branches }}
42+
continue-on-error: true
43+
44+
- name: Read package.json node and npm engines version
45+
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
46+
id: versions
47+
with:
48+
fallbackNode: '^24'
49+
fallbackNpm: '^11.3'
50+
51+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
52+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
53+
with:
54+
node-version: ${{ steps.versions.outputs.nodeVersion }}
55+
56+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
57+
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
58+
59+
- name: Fix npm audit
60+
id: npm-audit
61+
uses: nextcloud-libraries/npm-audit-action@1b1728b2b4a7a78d69de65608efcf4db0e3e42d0 # v0.2.0
62+
63+
- name: Run npm ci and npm run build
64+
if: steps.checkout.outcome == 'success'
65+
env:
66+
CYPRESS_INSTALL_BINARY: 0
67+
run: |
68+
npm ci
69+
npm run build --if-present
70+
71+
- name: Create Pull Request
72+
if: steps.checkout.outcome == 'success'
73+
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
74+
with:
75+
token: ${{ secrets.COMMAND_BOT_PAT }}
76+
commit-message: 'fix(deps): Fix npm audit'
77+
committer: GitHub <noreply@github.com>
78+
author: nextcloud-command <nextcloud-command@users.noreply.github.com>
79+
signoff: true
80+
branch: automated/noid/${{ matrix.branches }}-fix-npm-audit
81+
title: '[${{ matrix.branches }}] Fix npm audit'
82+
body: ${{ steps.npm-audit.outputs.markdown }}
83+
labels: |
84+
dependencies
85+
3. to review

.github/workflows/npm-build.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: Build Javascript
10+
11+
on: pull_request
12+
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
group: node-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
changes:
22+
runs-on: ubuntu-latest-low
23+
permissions:
24+
contents: read
25+
pull-requests: read
26+
27+
outputs:
28+
src: ${{ steps.changes.outputs.src}}
29+
30+
steps:
31+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
32+
id: changes
33+
continue-on-error: true
34+
with:
35+
filters: |
36+
src:
37+
- '.github/workflows/**'
38+
- 'src/**'
39+
- 'appinfo/info.xml'
40+
- 'package.json'
41+
- 'package-lock.json'
42+
- 'tsconfig.json'
43+
- '**.js'
44+
- '**.ts'
45+
- '**.vue'
46+
47+
build:
48+
runs-on: ubuntu-latest
49+
50+
needs: changes
51+
if: needs.changes.outputs.src != 'false'
52+
53+
name: NPM build
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
57+
with:
58+
persist-credentials: false
59+
60+
- name: Read package.json node and npm engines version
61+
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
62+
id: versions
63+
with:
64+
fallbackNode: '^24'
65+
fallbackNpm: '^11.3'
66+
67+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
68+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
69+
with:
70+
node-version: ${{ steps.versions.outputs.nodeVersion }}
71+
72+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
73+
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
74+
75+
- name: Validate package-lock.json # See https://github.com/npm/cli/issues/4460
76+
run: |
77+
npm i -g npm-package-lock-add-resolved@1.1.4
78+
npm-package-lock-add-resolved
79+
git --no-pager diff --exit-code
80+
81+
- name: Install dependencies & build
82+
env:
83+
CYPRESS_INSTALL_BINARY: 0
84+
PUPPETEER_SKIP_DOWNLOAD: true
85+
run: |
86+
npm ci
87+
npm run build --if-present
88+
89+
- name: Check build changes
90+
run: |
91+
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"
92+
93+
- name: Show changes on failure
94+
if: failure()
95+
run: |
96+
git status
97+
git --no-pager diff
98+
exit 1 # make it red to grab attention
99+
100+
summary:
101+
permissions:
102+
contents: none
103+
runs-on: ubuntu-latest-low
104+
needs: [changes, build]
105+
106+
if: always()
107+
108+
# This is the summary, we just avoid to rename it so that branch protection rules still match
109+
name: node
110+
111+
steps:
112+
- name: Summary status
113+
run: if ${{ needs.changes.outputs.src != 'false' && needs.build.result != 'success' }}; then exit 1; fi
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/serverinfo-main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/* extracted by css-entry-points-plugin */
2-
@import './main-CrF6ckF0.chunk.css';
2+
@import './main-BClh5c04.chunk.css';

js/serverinfo-main.mjs

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.

js/serverinfo-main.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/ActiveUsersSection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const props = defineProps<{
6060
* @param count number of active users in the period
6161
*/
6262
function percentageOfAllUsers(count: number): string {
63-
const percentage = props.numUsers === 0 ? 0 : Math.round(count * 100 / props.numUsers)
63+
const percentage = props.numUsers === 0 ? 0 : Math.round(count * 1000 / props.numUsers) / 10
6464
return t('serverinfo', '{0}% of all users', [String(percentage)])
6565
}
6666
</script>

src/components/CpuChartSection.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const chartOptions = {
9090
}
9191
9292
const footerText = computed(() => {
93-
if (props.cpuload === false || props.cpunum === -1) {
93+
if (props.cpuload === false || props.cpunum <= 0) {
9494
return t('serverinfo', 'CPU info not available')
9595
}
9696
const pct = props.cpuload.map((l) => ((l / props.cpunum) * 100).toFixed(1))
@@ -103,7 +103,7 @@ const footerText = computed(() => {
103103
104104
watch(() => props.tick, () => {
105105
const cpuload = props.cpuload
106-
if (cpuload === false || props.cpunum === -1) {
106+
if (cpuload === false || props.cpunum <= 0 || cpuload.length === 0) {
107107
return
108108
}
109109
const labels = [...chartData.value.labels.slice(1), new Date().toLocaleTimeString()]

src/components/DiskSection.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<script setup lang="ts">
5050
import { t } from '@nextcloud/l10n'
5151
import { ArcElement, Chart, DoughnutController, Tooltip } from 'chart.js'
52-
import { onMounted } from 'vue'
52+
import { onMounted, onUnmounted } from 'vue'
5353
import Harddisk from 'vue-material-design-icons/Harddisk.vue'
5454
import { formatBytes, formatMegabytes, primaryColor } from '../utils.ts'
5555
@@ -62,6 +62,7 @@ const props = defineProps<{
6262
Chart.register(ArcElement, DoughnutController, Tooltip)
6363
6464
const canvasRefs: HTMLCanvasElement[] = []
65+
const charts: Chart[] = []
6566
6667
/**
6768
*
@@ -84,7 +85,7 @@ onMounted(() => {
8485
if (!canvas) {
8586
return
8687
}
87-
new Chart(canvas, {
88+
charts.push(new Chart(canvas, {
8889
type: 'doughnut',
8990
data: {
9091
datasets: [{
@@ -99,7 +100,12 @@ onMounted(() => {
99100
},
100101
cutout: '60%',
101102
},
102-
})
103+
}))
103104
})
104105
})
106+
107+
onUnmounted(() => {
108+
charts.forEach((chart) => chart.destroy())
109+
charts.length = 0
110+
})
105111
</script>

0 commit comments

Comments
 (0)