mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 22:27:31 -04:00
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
/**
|
|
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
import { generateOcsUrl } from '@nextcloud/router'
|
|
import axios from '@nextcloud/axios'
|
|
|
|
export const getTemplates = async function() {
|
|
const response = await axios.get(generateOcsUrl('apps/files/api/v1/templates'))
|
|
return response.data.ocs.data
|
|
}
|
|
|
|
export const getTemplateFields = async function(fileId) {
|
|
const response = await axios.get(generateOcsUrl(`apps/files/api/v1/templates/fields/${fileId}`))
|
|
return response.data.ocs.data
|
|
}
|
|
|
|
/**
|
|
* Create a new file from a specified template
|
|
*
|
|
* @param {string} filePath The new file destination path
|
|
* @param {string} templatePath The template source path
|
|
* @param {string} templateType The template type e.g 'user'
|
|
* @param {object} templateFields The template fields to fill in (if any)
|
|
*/
|
|
export const createFromTemplate = async function(filePath, templatePath, templateType, templateFields) {
|
|
const response = await axios.post(generateOcsUrl('apps/files/api/v1/templates/create'), {
|
|
filePath,
|
|
templatePath,
|
|
templateType,
|
|
templateFields,
|
|
})
|
|
return response.data.ocs.data
|
|
}
|