Skip to content

File Manager: Finalize migration to JSON (file_manager API) #2514

@mgutt

Description

@mgutt

With PR #2429 we changed some API responses of file_manager to JSON as for example:

        $reply['status'] = json_encode([
          'action' => $action,
          'text' => [htmlspecialchars(mb_strimhalf(exec("tail -1 $status"), 70, '...'), ENT_QUOTES, 'UTF-8')]
        ]);

And we added the processing part to BrowseButton.page as follows:

function dfm_showProgress(data) {
  if (!data) return 0;

  // Try to parse as JSON first
  try {
    let parsed = JSON.parse(data);

    // Universal JSON format: {action: int, text: [text0, text1]}
    // text[0] = file/main text, text[1] = progress info (optional)
    if (parsed.action !== undefined && Array.isArray(parsed.text)) {
...

We should complete this change and return JSON only. Steps:

  • obtain all actions still returning raw HTML in file_manager
  • change their response to JSON
  • check if dfm_showProgress() needs additional code to handle the response (e.g. add switch case per action id)
  • remove legacy code from dfm_showProgress() which handles raw HTML

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions