mirror of https://github.com/Budibase/budibase.git
6 changed files with 106 additions and 1 deletions
@ -0,0 +1,31 @@ |
|||
const { |
|||
getGlobalDB, |
|||
getTenantId, |
|||
isUserInAppTenant, |
|||
} = require("@budibase/backend-core/tenancy") |
|||
const { sp2019Lists } = require("../../../utilities/sp2019") |
|||
|
|||
|
|||
|
|||
|
|||
exports.sp2019Lists = async ctx => { |
|||
let { |
|||
siteUrl, |
|||
username, |
|||
password, |
|||
domain, |
|||
} = ctx.request.body |
|||
let user |
|||
/*if (userId) { |
|||
const db = getGlobalDB() |
|||
user = await db.get(userId) |
|||
}*/ |
|||
const response = await sp2019Lists(siteUrl, |
|||
username, |
|||
password, |
|||
domain, |
|||
) |
|||
ctx.body = { |
|||
...response |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
const Router = require("@koa/router") |
|||
const controller = require("../../controllers/global/sp2019") |
|||
const { joiValidator } = require("@budibase/backend-core/auth") |
|||
const { adminOnly } = require("@budibase/backend-core/auth") |
|||
const Joi = require("joi") |
|||
|
|||
|
|||
const router = Router() |
|||
|
|||
function buildSP2019Validation() { |
|||
// prettier-ignore
|
|||
return joiValidator.body(Joi.object({ |
|||
siteUrl: Joi.string().allow("", null), |
|||
username: Joi.string().allow("", null), |
|||
password: Joi.string().allow("", null), |
|||
domain: Joi.string().allow("", null), |
|||
}).required().unknown(true)) |
|||
} |
|||
|
|||
router.post( |
|||
"/api/global/sp2019/lists", |
|||
buildSP2019Validation(), |
|||
adminOnly, |
|||
controller.sp2019Lists |
|||
) |
|||
|
|||
module.exports = router |
|||
@ -0,0 +1,37 @@ |
|||
|
|||
import { JsomNode } from "sp-jsom-node" |
|||
|
|||
exports.sp2019Lists = async (siteUrl,username,password,domain) => { |
|||
console.log("Site url :",siteUrl) |
|||
console.log("username :",username) |
|||
console.log("password :",password) |
|||
console.log("domain :",domain) |
|||
const sp2019 = new JsomNode({ |
|||
modules: ["taxonomy", "userprofiles"], |
|||
}) |
|||
const ctx = sp2019 |
|||
.init({ |
|||
siteUrl: siteUrl, |
|||
authOptions: { |
|||
username: username, |
|||
password: password, |
|||
domain: domain |
|||
} |
|||
}) |
|||
const spctx = await ctx.getContext() |
|||
const oListsCollection = spctx.get_web().get_lists() |
|||
spctx.load(oListsCollection, "Include(Title)") |
|||
await spctx.executeQueryPromise() |
|||
const arrList = [] |
|||
const listsTitlesArr = oListsCollection.get_data().map(l => { |
|||
arrList.push({ Title:l.get_title() }) |
|||
}) |
|||
|
|||
|
|||
console.log("List test :", arrList) |
|||
console.log("List :", listsTitlesArr) |
|||
|
|||
|
|||
|
|||
return arrList |
|||
} |
|||
Loading…
Reference in new issue