Logic Machine Forum
question about creating custom App - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Application Store (https://forum.logicmachine.net/forumdisplay.php?fid=11)
+--- Thread: question about creating custom App (/showthread.php?tid=4586)



question about creating custom App - benjii - 17.02.2023

Hey guys, 

I am trying to make a very simple application, which allows the user to restore a project on the controller.
I created a button and I want for it to execute the command.
I know i should use the curl 'https://127.0.0.1/scade-main/general/restore' but not how and where to write it.
I have an index.html, script.js and style.css files in the directory and also the project.zip file in question.

Can someone help me ?
Thanks in advance!


RE: question about creating custom App - Erwin van der Zwart - 18.02.2023

Why don’t you just share the admin credentials so this user can restore the project through the normal process as i think this is quite a radical action that should only be allowed by an admin user, if you allow this through an app it would bypass all the security that is in the native firmware..


RE: question about creating custom App - benjii - 20.02.2023

(18.02.2023, 14:42)Erwin van der Zwart Wrote: Why don’t you just share the admin credentials so this user can restore the project through the normal process as i think this is quite a radical action that should only be allowed by an admin user, if you allow this through an app it would bypass all the security that is in the native firmware..

Yes this option should only be allowed to admin as this app would require admin-login


RE: question about creating custom App - benjii - 21.02.2023

nothing ?


RE: question about creating custom App - admin - 22.02.2023

Use this JavaScript as a starting point:
Code:
async function send() {
  var formdata = new FormData();
  var url = '/scada-main/general/restore';
  var el = document.getElementById('file');

  formdata.append('file', el.files[0]);

  var resp = await fetch(url, {
    method: 'POST',
    headers: { 'X-Requested-With': 'XMLHttpRequest' },
    body: formdata
  });

  var res = await resp.json();
  console.log(res);
}



RE: question about creating custom App - benjii - 27.02.2023

(22.02.2023, 14:10)admin Wrote: Use this JavaScript as a starting point:
Code:
async function send() {
  var formdata = new FormData();
  var url = '/scada-main/general/restore';
  var el = document.getElementById('file');

  formdata.append('file', el.files[0]);

  var resp = await fetch(url, {
    method: 'POST',
    headers: { 'X-Requested-With': 'XMLHttpRequest' },
    body: formdata
  });

  var res = await resp.json();
  console.log(res);
}

Where should I write the path of the project file i want to restore ?


RE: question about creating custom App - admin - 27.02.2023

Create a HTML page with a file input element that has id="file".


RE: question about creating custom App - benjii - 27.02.2023

(27.02.2023, 13:21)admin Wrote: Create a HTML page with a file input element that has id="file".

this way it allows the user to choose the path, right ?
i want to directly include files on the ftp server, is it possible ?


RE: question about creating custom App - admin - 27.02.2023

You cannot restore backups from FTP this way. This method allows to upload local files from PC to LM. See this for more info: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file