Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
Louis Chemineau 2024-01-03 12:27:06 +01:00
Родитель c52f7ea963
Коммит 58ee88df45
Не найден ключ, соответствующий данной подписи
10 изменённых файлов: 59 добавлений и 64 удалений

14
package-lock.json сгенерированный
Просмотреть файл

@ -9,8 +9,10 @@
"version": "1.0.0",
"license": "agpl",
"dependencies": {
"@mdi/svg": "^7.4.47",
"@nextcloud/axios": "^2.4.0",
"@nextcloud/dialogs": "^4.2.2",
"@nextcloud/files": "^3.0.0",
"@nextcloud/l10n": "^1.6.0",
"@nextcloud/logger": "^2.7.0",
"@nextcloud/moment": "^1.2.2",
@ -3119,9 +3121,9 @@
}
},
"node_modules/@mdi/svg": {
"version": "7.3.67",
"resolved": "https://registry.npmjs.org/@mdi/svg/-/svg-7.3.67.tgz",
"integrity": "sha512-KNr7D8jbu8DEprgRckVywVBkajsGGqocFjOzlekv35UedLjpkMDTkFO8VYnhnLySL0QaPBa568fe8BZsB0TBJQ=="
"version": "7.4.47",
"resolved": "https://registry.npmjs.org/@mdi/svg/-/svg-7.4.47.tgz",
"integrity": "sha512-WQ2gDll12T9WD34fdRFgQVgO8bag3gavrAgJ0frN4phlwdJARpE6gO1YvLEMJR0KKgoc+/Ea/A0Pp11I00xBvw=="
},
"node_modules/@nextcloud/auth": {
"version": "2.2.1",
@ -21283,9 +21285,9 @@
}
},
"@mdi/svg": {
"version": "7.3.67",
"resolved": "https://registry.npmjs.org/@mdi/svg/-/svg-7.3.67.tgz",
"integrity": "sha512-KNr7D8jbu8DEprgRckVywVBkajsGGqocFjOzlekv35UedLjpkMDTkFO8VYnhnLySL0QaPBa568fe8BZsB0TBJQ=="
"version": "7.4.47",
"resolved": "https://registry.npmjs.org/@mdi/svg/-/svg-7.4.47.tgz",
"integrity": "sha512-WQ2gDll12T9WD34fdRFgQVgO8bag3gavrAgJ0frN4phlwdJARpE6gO1YvLEMJR0KKgoc+/Ea/A0Pp11I00xBvw=="
},
"@nextcloud/auth": {
"version": "2.2.1",

Просмотреть файл

@ -25,8 +25,10 @@
"stylelint:fix": "stylelint css/*.css css/*.scss src/**/*.scss src/**/*.vue --fix"
},
"dependencies": {
"@mdi/svg": "^7.4.47",
"@nextcloud/axios": "^2.4.0",
"@nextcloud/dialogs": "^4.2.2",
"@nextcloud/files": "^3.0.0",
"@nextcloud/l10n": "^1.6.0",
"@nextcloud/logger": "^2.7.0",
"@nextcloud/moment": "^1.2.2",

Просмотреть файл

@ -25,7 +25,7 @@ import Vue from 'vue'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import { generateFilePath } from '@nextcloud/router'
import BackupAdminSettings from './views/BackupAdminSettings'
import BackupAdminSettings from './views/BackupAdminSettings.vue'
// eslint-disable-next-line
__webpack_public_path__ = generateFilePath(appName, '', 'js/')

Просмотреть файл

@ -94,7 +94,7 @@ import { generateOcsUrl } from '@nextcloud/router'
import { showSuccess, showError } from '@nextcloud/dialogs'
import { NcModal, NcButton, NcCheckboxRadioSwitch, NcSettingsSection } from '@nextcloud/vue'
import logger from '../logger'
import logger from '../logger.js'
/**
* @typedef {object} ExternalLocation

Просмотреть файл

@ -107,7 +107,7 @@ import { generateOcsUrl } from '@nextcloud/router'
import { showSuccess, showError } from '@nextcloud/dialogs'
import { NcSettingsSection, NcEmptyContent, NcButton } from '@nextcloud/vue'
import logger from '../logger'
import logger from '../logger.js'
/**
* @typedef {object} ExternalLocation

Просмотреть файл

@ -252,7 +252,7 @@ import { generateOcsUrl } from '@nextcloud/router'
import { showSuccess, showError } from '@nextcloud/dialogs'
import { NcSettingsSection, NcCheckboxRadioSwitch, NcButton, NcModal } from '@nextcloud/vue'
import logger from '../logger'
import logger from '../logger.js'
import SettingsModel from '../models/SettingsModel.js'
export default {

Просмотреть файл

@ -181,7 +181,7 @@ import RestoringPointHealthIcon from './RestoringPointHealthIcon.vue'
import RestoringPointStatusIcon from './RestoringPointStatusIcon.vue'
import SettingsModel from '../models/SettingsModel.js'
import RestoringPoint from '../models/RestoringPointModel.js'
import logger from '../logger'
import logger from '../logger.js'
/**
* @typedef {object} ExternalLocation
@ -303,11 +303,11 @@ export default {
*/
/**
* @typedef {object<string, PointLocation>} RestoringPoints
* @typedef {{[key: string]: PointLocation}} RestoringPoints
*/
/**
* @param {object<string, RestoringPoints>} restoringPoints - The list of restoring points
* @param {RestoringPoints} restoringPoints - The list of restoring points
*/
handleRestoringPoints(restoringPoints) {
return Object.keys(restoringPoints)
@ -332,7 +332,7 @@ export default {
}
// The variable assignment is useful to have type completion.
/** @type {Array<ExternalLocation>} */
/** @type {ExternalLocation[]} */
const externalStorages = this.externalStorages
return externalStorages.find(storage => storage.storageId === parseInt(storageId.split(':')[1])).storage
},

Просмотреть файл

@ -5,8 +5,9 @@
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @author Louis Chmn <louis@chmn.me>
* @copyright 2021, Maxence Lange <maxence@artificial-owl.com>
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@ -23,54 +24,36 @@
*
*/
/** global: OCA */
import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
import { showSuccess, showWarning } from '@nextcloud/dialogs'
const Backup = function() {
this.init()
}
Backup.prototype = {
fileActions: null,
init() {
this._initFileActions()
},
_initFileActions() {
const self = this
this.fileActions = OCA.Files.fileActions
this.fileActions.registerAction({
name: 'ScanBackupFolder',
displayName: t('backup', 'Scan Backup Folder'),
mime: 'file',
filename: 'restoring-point.data',
order: -50,
iconClass: 'icon-folder',
permissions: OC.PERMISSION_READ,
actionHandler: self.scanBackupFile,
})
},
async scanBackupFile(fileName, context) {
const fileId = context.$file.data('id')
try {
const res = await axios.post(generateOcsUrl('apps/backup/action/scan/') + fileId + '?format=json')
showSuccess(res.data.ocs.data.message)
} catch (e) {
showWarning((e.message) || 'failed to initiate scan')
}
},
}
OCA.Files.Backup = Backup
import { translate as t } from '@nextcloud/l10n'
import Folder from '@mdi/svg/svg/folder.svg'
import {
FileAction,
registerFileAction,
Permission,
FileType,
} from '@nextcloud/files'
window.addEventListener('DOMContentLoaded', function() {
OCA.Files.Backup = new Backup()
registerFileAction(new FileAction({
id: 'ScanBackupFolder',
displayName() { return t('backup', 'Scan Backup Folder') },
iconSvgInline: () => Folder,
enabled(nodes) {
return nodes.length === 1 && nodes[0].type === FileType.File && nodes[0].basename === 'restoring-point.data' && (nodes[0].permissions & Permission.READ) !== 0
},
async exec({ fileid }) {
try {
const res = await axios.post(generateOcsUrl('apps/backup/action/scan/') + fileid + '?format=json')
showSuccess(res.data.ocs.data.message)
return true
} catch (e) {
showWarning((e.message) || 'failed to initiate scan')
return false
}
},
order: -50,
}))
})

Просмотреть файл

@ -30,10 +30,10 @@
</template>
<script>
import GeneralSettingsSection from '../components/GeneralSettingsSection'
import ExternalLocationsSection from '../components/ExternalLocationsSection'
import RestoringPointsListSection from '../components/RestoringPointsListSection'
import AppDataSection from '../components/AppDataSection'
import GeneralSettingsSection from '../components/GeneralSettingsSection.vue'
import ExternalLocationsSection from '../components/ExternalLocationsSection.vue'
import RestoringPointsListSection from '../components/RestoringPointsListSection.vue'
import AppDataSection from '../components/AppDataSection.vue'
import SettingsModel from '../models/SettingsModel.js'

Просмотреть файл

@ -1,6 +1,14 @@
const path = require('path')
const webpackConfig = require('@nextcloud/webpack-vue-config')
const webpackRules = require('@nextcloud/webpack-vue-config/rules')
webpackRules.RULE_RAW_SVGS = {
test: /\.svg$/,
type: 'asset/source',
}
webpackConfig.module.rules = Object.values(webpackRules)
webpackConfig.entry = {
adminSettings: path.join(__dirname, 'src', 'adminSettings.js'),