Commit e57e7d3b authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

appAPI.js - add registry doc api

parent 84d95ecf
...@@ -548,12 +548,64 @@ this.appAPI = { ...@@ -548,12 +548,64 @@ this.appAPI = {
}); });
}, },
modifyDoc: async function(dataUUID) { createDoc: async function(registryCode) {
return new Promise(resolve => {
rest.synergyGet(`api/registry/create_doc?registryCode=${registryCode}`, resolve, err => {
console.log(`ERROR [ createDoc ]: ${JSON.stringify(err)}`);
resolve(null);
});
});
},
createDocRCC: async function(registryCode, asfData, sendToActivation = false) {
return new Promise(async resolve => { return new Promise(async resolve => {
try {
const {login, password} = Cons.creds;
const auth = "Basic " + btoa(unescape(encodeURIComponent(`${login}:${password}`)));
const url = `../Synergy/rest/api/registry/create_doc_rcc`;
const response = await fetch(url, {
method: 'POST',
headers: {"Authorization": auth, "Content-Type": "application/json; charset=UTF-8"},
body: JSON.stringify({
registryCode: registryCode,
data: asfData,
sendToActivation: sendToActivation
})
});
if(!response.ok) throw new Error(`HTTP: ${response.status}, message: ${response.statusText} [ ${response.text()} ]`);
resolve(response.json());
} catch (err) {
console.log(`ERROR [ createDocRCC ]: ${JSON.stringify(err)}`);
resolve(null);
}
});
},
activateDoc: async function(dataUUID) {
return new Promise(resolve => {
rest.synergyGet(`api/registry/activate_doc?dataUUID=${dataUUID}&locale=${AS.OPTIONS.locale}`, resolve, err => {
console.log(`ERROR [ activateDoc ]: ${JSON.stringify(err)}`);
resolve(null);
});
});
},
modifyDoc: async function(dataUUID) {
return new Promise(resolve => {
rest.synergyGet(`api/registry/modify_doc?dataUUID=${dataUUID}&locale=${AS.OPTIONS.locale}`, resolve, err => { rest.synergyGet(`api/registry/modify_doc?dataUUID=${dataUUID}&locale=${AS.OPTIONS.locale}`, resolve, err => {
console.log(`ERROR [ modifyDoc ]: ${JSON.stringify(err)}`); console.log(`ERROR [ modifyDoc ]: ${JSON.stringify(err)}`);
resolve(null); resolve(null);
}); });
}); });
},
loadAsfData: async function(dataUUID, version = null) {
const url = version == null ? `api/asforms/data/${dataUUID}?locale=${AS.OPTIONS.locale}` : `api/asforms/data/${dataUUID}?version=${version}&locale=${AS.OPTIONS.locale}`;
return new Promise(resolve => {
rest.synergyGet(url, resolve, err => {
console.log(`ERROR [ loadAsfData ]: ${JSON.stringify(err)}`);
resolve(null);
});
});
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment