This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

question about creating custom App
#1
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!
Reply
#2
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..
Reply
#3
(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
Reply
#4
nothing ?
Reply
#5
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);
}
Reply
#6
(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 ?
Reply
#7
Create a HTML page with a file input element that has id="file".
Reply
#8
(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 ?
Reply
#9
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...input/file
Reply


Forum Jump: