Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gui/browsable/inc/ROOT/Browsable/RElement.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public:
static std::string GetPathAsString(const RElementPath_t &path);

static int ExtractItemIndex(std::string &name);

static bool IsLastKeyCycle();

static void SetLastKeyCycle(bool on = true);
};

} // namespace Browsable
Expand Down
2 changes: 1 addition & 1 deletion gui/browsable/inc/ROOT/Browsable/RSysFileItem.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public:
if (method == "size") {
auto fb = dynamic_cast<const RSysFileItem *> (b);
if (fb)
return size < fb->size;
return size > fb->size;
}

return GetName() < b->GetName();
Expand Down
18 changes: 18 additions & 0 deletions gui/browsable/src/RElement.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,21 @@ int RElement::ExtractItemIndex(std::string &name)
name.resize(p1);
return indx;
}

bool gRElementLastKeyCycle = false;

/////////////////////////////////////////////////////////////////////
/// Is only last cycle from the list of keys is shown

bool RElement::IsLastKeyCycle()
{
return gRElementLastKeyCycle;
}

/////////////////////////////////////////////////////////////////////
/// Set flag to show only last cycle from the list of keys

void RElement::SetLastKeyCycle(bool on)
{
gRElementLastKeyCycle = on;
}
18 changes: 2 additions & 16 deletions gui/browsable/src/TDirectoryElement.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class TDirectoryLevelIter : public RLevelIter {
TDirectory *fDir{nullptr}; ///<! current directory handle
std::unique_ptr<TIterator> fIter; ///<! created iterator
bool fKeysIter{true}; ///<! iterating over keys list (default)
bool fOnlyLastCycle{false}; ///<! show only last cycle in list of keys
TKey *fKey{nullptr}; ///<! currently selected key
TObject *fObj{nullptr}; ///<! currently selected object
std::string fCurrentName; ///<! current key name
Expand Down Expand Up @@ -110,7 +109,8 @@ class TDirectoryLevelIter : public RLevelIter {
return false;
}

if (!fOnlyLastCycle) break;
if (!RElement::IsLastKeyCycle())
break;

TIter iter(fDir->GetListOfKeys());
TKey *key = nullptr;
Expand All @@ -137,20 +137,6 @@ class TDirectoryLevelIter : public RLevelIter {
public:
explicit TDirectoryLevelIter(TDirectory *dir) : fDir(dir)
{
const char *undef = "<undefined>";
const char *value = gEnv->GetValue("WebGui.LastCycle", undef);
if (value) {
std::string svalue = value;
if (svalue != undef) {
if (svalue == "yes")
fOnlyLastCycle = true;
else if (svalue == "no")
fOnlyLastCycle = false;
else
R__LOG_ERROR(ROOT::BrowsableLog()) << "WebGui.LastCycle must be yes or no";
}
}

CreateIter();
}

Expand Down
1 change: 0 additions & 1 deletion gui/browserv7/inc/ROOT/RBrowserRequest.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public:
bool reverse{false}; ///< reverse item order
bool hidden{false}; ///< show hidden files
bool reload{false}; ///< force items reload
int lastcycle{0}; ///< show only last cycle, -1 - off, 0 - not change, +1 on,
std::string regex; ///< applied regex
};

Expand Down
36 changes: 36 additions & 0 deletions gui/browserv7/src/RBrowser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "TSystem.h"
#include "TError.h"
#include "TTimer.h"
#include "TEnv.h"
#include "TROOT.h"
#include "TBufferJSON.h"
#include "TApplication.h"
Expand Down Expand Up @@ -268,6 +269,14 @@ Chrome or Firefox browsers are though required when running ROOT in batch mode.
Most configuration options for RBrowser, such as default web browser, server mode are not specific to this class,
but are rather applied for all web widgets: canvases, geometry viewer, eve7, browser, fit panel, etc.

Following `.rootrc` parameters can be configured for the browser:

* WebGui.Browser.SortBy: sort by "name", "size", "none" (default "name")
* WebGui.Browser.Reverse: reverse item order (default off)
* WebGui.Browser.ShowHidden: show hidden files (default off)
* WebGui.Browser.LastCycle: show only last key cycle (default off)
* WebGui.Browser.Expand: expand browsable area (default off)

\note See major settings in RWebWindowWindowsManager::CreateServer and RWebWindowsManager::ShowWindow
*/

Expand All @@ -294,6 +303,23 @@ RBrowser::RBrowser(bool use_rcanvas)
fWebWindow = RWebWindow::Create();
fWebWindow->SetDefaultPage("file:rootui5sys/browser/browser.html");

std::string sortby = gEnv->GetValue("WebGui.Browser.SortBy", "name"),
reverse = gEnv->GetValue("WebGui.Browser.Reverse", "no"),
hidden = gEnv->GetValue("WebGui.Browser.ShowHidden", "no"),
lastcycle = gEnv->GetValue("WebGui.Browser.LastCycle", "");

if (sortby != "name" && sortby != "size" && sortby != "none")
sortby = "name";

reverse = (reverse == "on" || reverse == "yes" || reverse == "1") ? "true" : "false";
hidden = (hidden == "on" || hidden == "yes" || hidden == "1") ? "true" : "false";
if (lastcycle == "on" || lastcycle == "yes" || lastcycle == "1")
Browsable::RElement::SetLastKeyCycle(true);
else if (lastcycle == "off" || lastcycle == "no" || lastcycle == "0")
Browsable::RElement::SetLastKeyCycle(false);

fWebWindow->SetUserArgs(TString::Format("{ sort: \"%s\", reverse: %s, hidden: %s }", sortby.c_str(), reverse.c_str(), hidden.c_str()).Data());

// this is call-back, invoked when message received via websocket
fWebWindow->SetCallBacks([this](unsigned connid) { fConnId = connid; SendInitMsg(connid); },
[this](unsigned connid, const std::string &arg) { ProcessMsg(connid, arg); });
Expand Down Expand Up @@ -743,6 +769,12 @@ void RBrowser::SendInitMsg(unsigned connid)
Browsable::RProvider::GetClassDrawOption("TProfile")
}));

reply.emplace_back(std::vector<std::string>({
"settings"s,
gEnv->GetValue("WebGui.Browser.Expand", "no"),
Browsable::RElement::IsLastKeyCycle() ? "1" : "0"
}));

std::string msg = "INMSG:";
msg.append(TBufferJSON::ToJSON(&reply, TBufferJSON::kNoSpaces).Data());

Expand Down Expand Up @@ -864,6 +896,10 @@ void RBrowser::ProcessMsg(unsigned connid, const std::string &arg0)
auto json = ProcessBrowserRequest(msg);
if (!json.empty()) fWebWindow->Send(connid, json);

} else if (kind == "LASTCYCLE") {
// when changed on clients side
Browsable::RElement::SetLastKeyCycle(msg == "1");

} else if (kind == "DBLCLK") {

auto arr = TBufferJSON::FromJSON<std::vector<std::string>>(msg);
Expand Down
7 changes: 1 addition & 6 deletions gui/browserv7/src/RBrowserData.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ bool RBrowserData::ProcessBrowserRequest(const RBrowserRequest &request, RBrowse
(fLastSortReverse != request.reverse)) {
fLastSortedItems.resize(fLastItems.size(), nullptr);
int id = 0;
if (request.sort.empty()) {
if (request.sort.empty() || (request.sort == "none")) {
// no sorting, just move all folders up
for (auto &item : fLastItems)
if (item->IsFolder())
Expand Down Expand Up @@ -268,11 +268,6 @@ bool RBrowserData::ProcessBrowserRequest(const RBrowserRequest &request, RBrowse

std::string RBrowserData::ProcessRequest(const RBrowserRequest &request)
{
if (request.lastcycle < 0)
gEnv->SetValue("WebGui.LastCycle", "no");
else if (request.lastcycle > 0)
gEnv->SetValue("WebGui.LastCycle", "yes");

RBrowserReply reply;

reply.path = request.path;
Expand Down
42 changes: 26 additions & 16 deletions ui5/browser/controller/Browser.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,24 @@ sap.ui.define(['sap/ui/core/mvc/Controller',

this.handleChangeOrientation(uiDevice.orientation.landscape);

let data = this.getView().getViewData();
this.websocket = data?.conn_handle;
this.jsroot = data?.jsroot;

const SortMethod = this.websocket.getUserArgs('sort') ?? 'name',
ReverseOrder = this.websocket.getUserArgs('reverse') ?? false,
ShowHiddenFiles = this.websocket.getUserArgs('hidden') ?? false;

this._oSettingsModel = new JSONModel({
SortMethods: [
{ name: 'name', value: 'name' },
{ name: 'size', value: 'size' },
{ name: 'none', value: '' }
{ name: 'none', value: 'none' }
],
SortMethod: 'name',
ReverseOrder: false,
ShowHiddenFiles: false,
SortMethod,
ReverseOrder,
ShowHiddenFiles,
OnlyLastCycle: false,
AppendToCanvas: false,
HandleDoubleClick: true,
DBLCLKRun: false,
Expand Down Expand Up @@ -166,10 +175,6 @@ sap.ui.define(['sap/ui/core/mvc/Controller',
]
});

let data = this.getView().getViewData();
this.websocket = data?.conn_handle;
this.jsroot = data?.jsroot;

// this is code for the Components.js
// this.websocket = Component.getOwnerComponentFor(this.getView()).getComponentData().conn_handle;

Expand All @@ -185,6 +190,9 @@ sap.ui.define(['sap/ui/core/mvc/Controller',

// create model only for browser - no need for anybody else
this.model = new BrowserModel();
this.model.setSortMethod(SortMethod);
this.model.setReverseOrder(ReverseOrder);
this.model.setShowHidden(ShowHiddenFiles);

// copy extra attributes from element to node in the browser
// later can be done automatically
Expand Down Expand Up @@ -775,7 +783,7 @@ sap.ui.define(['sap/ui/core/mvc/Controller',
onSettingsPress() {
this._oSettingsModel.setProperty("/AppendToCanvas", this.model.isAppendToCanvas());
this._oSettingsModel.setProperty("/HandleDoubleClick", this.model.isHandleDoubleClick());
this._oSettingsModel.setProperty("/OnlyLastCycle", (this.model.getOnlyLastCycle() > 0));
this._oSettingsModel.setProperty("/OnlyLastCycle", this.model.getOnlyLastCycle());
this._oSettingsModel.setProperty("/ShowHiddenFiles", this.model.isShowHidden());
this._oSettingsModel.setProperty("/SortMethod", this.model.getSortMethod());
this._oSettingsModel.setProperty("/ReverseOrder", this.model.isReverseOrder());
Expand Down Expand Up @@ -816,9 +824,10 @@ sap.ui.define(['sap/ui/core/mvc/Controller',
changed_dblclick = true;
}

if (lastcycle != (this.model.getOnlyLastCycle() > 0)) {
if (lastcycle != this.model.getOnlyLastCycle()) {
changed = true;
this.model.setOnlyLastCycle(lastcycle ? 1 : -1);
this.model.setOnlyLastCycle(lastcycle);
this.websocket.send('LASTCYCLE:' + (lastcycle ? '1' : '0'));
}

if (hidden != this.model.isShowHidden()) {
Expand Down Expand Up @@ -1090,8 +1099,6 @@ sap.ui.define(['sap/ui/core/mvc/Controller',
return oEvent.preventDefault();

oDragSession.setComplexData("item_property", prop);

console.log('start dragging ', prop.path);
},

onDrop(oEvent) {
Expand Down Expand Up @@ -1194,8 +1201,6 @@ sap.ui.define(['sap/ui/core/mvc/Controller',
if (typeof msg != "string")
return console.error("Browser do not uses binary messages len = " + mgs.byteLength);

// console.log('MSG', msg.substr(0,20));

let p = msg.indexOf(':'), mhdr = '';
if (p > 0) {
mhdr = msg.slice(0, p);
Expand Down Expand Up @@ -1393,7 +1398,7 @@ sap.ui.define(['sap/ui/core/mvc/Controller',

/** @summary process initial message, now it is list of existing canvases */
processInitMsg(msg) {
let arr = this.jsroot.parse(msg);
const arr = this.jsroot.parse(msg);
if (!arr) return;

this.updateBReadcrumbs(arr[0]);
Expand All @@ -1412,6 +1417,11 @@ sap.ui.define(['sap/ui/core/mvc/Controller',
this._oSettingsModel.setProperty('/optTH1', arr[k][1] || '<dflt>');
this._oSettingsModel.setProperty('/optTH2', arr[k][2]|| '<dflt>');
this._oSettingsModel.setProperty('/optTProfile', arr[k][3]|| '<dflt>');
} else if (kind == "settings") {
const expand = (arr[k][1] == 'on' || arr[k][1] == 'yes' || arr[k][1] == '1');
if (expand)
this.onExpandMaster();
this.model.setOnlyLastCycle(arr[k][2] == '1');
} else {
const pr = this.createElement(kind, arr[k][1], arr[k][2], arr[k][3], arr[k][4]);
Promise.resolve(pr).then(tab => {
Expand Down
3 changes: 1 addition & 2 deletions ui5/browser/model/BrowserModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sap.ui.define([
this.showHidden = false;
this.appendToCanvas = false;
this.handleDoubleClick = true;
this.onlyLastCycle = 0; // 0 - not changed, -1 off , +1 on
this.onlyLastCycle = false;

this.threshold = 100; // default threshold to prefetch items
},
Expand Down Expand Up @@ -280,7 +280,6 @@ sap.ui.define([
sort: this.sortMethod || '',
reverse: this.reverseOrder || false,
hidden: this.showHidden ? true : false,
lastcycle: this.onlyLastCycle ?? 0,
reload: force_reload ? true : false, // re-scan items by server even when path was not changed
regex
};
Expand Down
Loading