|
@@ -2,30 +2,10 @@
|
|
|
const https = require("https");
|
|
|
let id = "";
|
|
|
let devices;
|
|
|
- let policy;
|
|
|
+ let policy, profile;
|
|
|
export let privat;
|
|
|
- function fetch_json(id) {
|
|
|
- const url = encodeURI(
|
|
|
- `https://${privat.MDMSERVER}/relution/api/v1/autoenrollments?getNonpagedCount=true&limit=1&filter={"type":"containsString","fieldName":"serialNumber","contains":"${id}"}&field=uuid`
|
|
|
- );
|
|
|
- const options = { headers: { "X-User-Access-Token": privat.MDMKEY } };
|
|
|
- https.get(url, options, async (res) => {
|
|
|
- try {
|
|
|
- let body = "";
|
|
|
- res.setEncoding("utf-8");
|
|
|
- for await (const chunk of res) {
|
|
|
- body += chunk;
|
|
|
- }
|
|
|
- devices = JSON.parse(body);
|
|
|
- } catch (e) {
|
|
|
- console.log(e);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- function get_policies() {
|
|
|
- const url = encodeURI(
|
|
|
- `https://${privat.MDMSERVER}/relution/api/v1/policies?getNonpagedCount=true&limit=100&offset=0&sortOrder=-modificationDate&filter={"type":"logOp","operation":"AND","filters":[{"type":"stringEnum","fieldName":"platform","values":["IOS"]},{"type":"boolean","fieldName":"versions.published","value":true},{"type":"string","fieldName":"deletionDate","value":"NULL"}]}`
|
|
|
- );
|
|
|
+
|
|
|
+ function getter (url) {
|
|
|
const options = { headers: { "X-User-Access-Token": privat.MDMKEY } };
|
|
|
return new Promise((resolve, reject) => {
|
|
|
https.get(url, options, async (res) => {
|
|
@@ -42,10 +22,29 @@
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
+ async function fetch_json(id) {
|
|
|
+ const url = encodeURI(
|
|
|
+ `https://${privat.MDMSERVER}/relution/api/v1/autoenrollments?getNonpagedCount=true&limit=1&filter={"type":"containsString","fieldName":"serialNumber","contains":"${id}"}&field=uuid`
|
|
|
+ );
|
|
|
+ devices = await getter(url);
|
|
|
+ }
|
|
|
+
|
|
|
+ function get_profiles() {
|
|
|
+ const url = encodeURI(
|
|
|
+ `https://${privat.MDMSERVER}/relution/api/v1/devices/deps/profiles?getItems=true&getNonpagedCount=false`
|
|
|
+ );
|
|
|
+ return getter(url)
|
|
|
+ }
|
|
|
+ function get_policies() {
|
|
|
+ const url = encodeURI(
|
|
|
+ `https://${privat.MDMSERVER}/relution/api/v1/policies?getNonpagedCount=true&limit=100&offset=0&sortOrder=-modificationDate&filter={"type":"logOp","operation":"AND","filters":[{"type":"stringEnum","fieldName":"platform","values":["IOS"]},{"type":"boolean","fieldName":"versions.published","value":true},{"type":"string","fieldName":"deletionDate","value":"NULL"}]}`
|
|
|
+ );
|
|
|
+ return getter(url)
|
|
|
+ }
|
|
|
function set_policy(device) {
|
|
|
- console.log("SET");
|
|
|
if (devices.total !== 1 && !policy) return;
|
|
|
device.defaultPolicy = { uuid: policy };
|
|
|
+ if (profile) device.profileUuid = profile
|
|
|
const data = JSON.stringify(device);
|
|
|
console.log(data);
|
|
|
const options = {
|
|
@@ -72,8 +71,18 @@
|
|
|
req.write(data);
|
|
|
req.end();
|
|
|
}
|
|
|
+ $: console.log(profile)
|
|
|
</script>
|
|
|
|
|
|
+Verfügbare DEP-Profile:
|
|
|
+{#await get_profiles() then profiles}
|
|
|
+ {#each profiles.results as p}
|
|
|
+ <br /><input type="radio" bind:group={profile} value={p.uuid} />{p.profileName}
|
|
|
+ {/each}
|
|
|
+ <br />ausgewählt {profiles.results.find((p) => p.uuid === profile)?.profileName ||
|
|
|
+ "keins, bzw vorausgewählt"}
|
|
|
+{/await}
|
|
|
+<br />
|
|
|
Verfügbare Policies:
|
|
|
{#await get_policies() then policies}
|
|
|
{#each policies.results as p}
|