Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 [Frontend] Multiselect data #6896

Merged
merged 35 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1222d6d
refactor
odeimaiz Dec 3, 2024
74c1fd8
multiselect propoerty
odeimaiz Dec 3, 2024
67ed884
refactor
odeimaiz Dec 3, 2024
7cc1727
more compact icon
odeimaiz Dec 3, 2024
b5988fd
aesthetics
odeimaiz Dec 3, 2024
d129744
[skip ci] allowMultiselection
odeimaiz Dec 3, 2024
57448e3
Merge branch 'master' into enh/multiselect-data
odeimaiz Dec 4, 2024
3e1870d
Merge branch 'master' into enh/multiselect-data
odeimaiz Dec 4, 2024
a95fc6e
minor
odeimaiz Dec 4, 2024
82c013d
multiSelectionChanged
odeimaiz Dec 4, 2024
0d7e0e5
renaming
odeimaiz Dec 4, 2024
592cf3d
[skip ci] folders can't be selected
odeimaiz Dec 4, 2024
33d62ad
Merge branch 'master' into enh/multiselect-data
odeimaiz Dec 11, 2024
669e7a2
linting
odeimaiz Dec 11, 2024
906f050
[skip ci] resetItemSelected
odeimaiz Dec 11, 2024
c521306
Merge branch 'master' into enh/multiselect-data
odeimaiz Dec 12, 2024
b5ab786
openCategory
odeimaiz Dec 12, 2024
1f8a4ad
refactor
odeimaiz Dec 12, 2024
db82dde
more refactor
odeimaiz Dec 12, 2024
4a9f185
[skip ci] minor
odeimaiz Dec 12, 2024
6c24917
[skip ci] minor fix
odeimaiz Dec 12, 2024
4f02c03
rename event
odeimaiz Dec 12, 2024
72a4279
more renaming
odeimaiz Dec 12, 2024
ce6dfd8
[skip ci] multiSelect prop
odeimaiz Dec 12, 2024
5f2b900
[skip ci] pass multiSelectionChanged
odeimaiz Dec 12, 2024
0c22a60
[skip ci] refactor
odeimaiz Dec 12, 2024
c6dcd3b
[skip ci] refactor
odeimaiz Dec 12, 2024
589e9aa
multi action
odeimaiz Dec 12, 2024
a75d7d5
Merge branch 'master' into enh/multiselect-data
odeimaiz Dec 12, 2024
99ff70b
Promise all
odeimaiz Dec 12, 2024
e4c8835
minor
odeimaiz Dec 12, 2024
b0ddef1
Merge branch 'master' into enh/multiselect-data
odeimaiz Dec 12, 2024
49e850e
"importMessageSent"
odeimaiz Dec 12, 2024
0881037
sendMessageToIframe and sendCloseMessage
odeimaiz Dec 12, 2024
ae06040
Merge branch 'master' into enh/multiselect-data
odeimaiz Dec 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ qx.Class.define("osparc.dashboard.DataBrowser", {
const reloadButton = treeFolderView.getChildControl("reload-button");
reloadButton.addListener("execute", () => this.__reloadTree(), this);

const selectedFileLayout = treeFolderView.getChildControl("selected-file-layout");
const selectedFileLayout = treeFolderView.getChildControl("folder-viewer").getChildControl("selected-file-layout");
selectedFileLayout.addListener("fileDeleted", e => this.__fileDeleted(e.getData()), this);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,17 @@ qx.Class.define("osparc.data.model.Study", {
return !this.getUi().getSlideshow().isEmpty();
},

sendMessageToIframe: function(nodeId, msg) {
if (nodeId) {
const node = this.getWorkbench().getNode(nodeId);
if (node && node.getIFrame()) {
node.getIFrame().sendMessageToIframe(msg);
return true;
}
}
return false;
},

patchStudy: function(studyChanges) {
const matches = this.self().OwnPatch.filter(el => Object.keys(studyChanges).indexOf(el) !== -1);
if (matches.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,29 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
this.getChildControl("selected-label");

const downloadBtn = this.getChildControl("download-button");
downloadBtn.addListener("execute", () => this.__retrieveURLAndDownload(), this);
downloadBtn.addListener("execute", () => this.__retrieveURLAndDownloadSelected(), this);

const deleteBtn = this.getChildControl("delete-button");
deleteBtn.addListener("execute", () => this.__deleteFile(), this);
deleteBtn.addListener("execute", () => this.__deleteSelected(), this);
},

events: {
"fileDeleted": "qx.event.type.Data"
},

properties: {
multiSelect: {
check: "Boolean",
init: false,
nullable: false,
event: "changeMultiSelect",
apply: "__enableMultiSelection",
},
},

members: {
__selection: null,
__multiSelection: null,

_createChildControlImpl: function(id) {
let control;
Expand Down Expand Up @@ -88,26 +99,59 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
return control || this.base(arguments, id);
},

__enableMultiSelection: function() {
this.resetItemSelected();
this.__multiSelection = [];
},

setItemSelected: function(selectedItem) {
const isFile = osparc.file.FilesTree.isFile(selectedItem);
this.getChildControl("download-button").setEnabled(isFile);
this.getChildControl("delete-button").setEnabled(isFile);
const selectedLabel = this.getChildControl("selected-label");
if (isFile) {
this.__selection = selectedItem;
selectedLabel.set({
value: selectedItem.getLabel(),
toolTipText: selectedItem.getFileId()
});
if (selectedItem) {
const isFile = osparc.file.FilesTree.isFile(selectedItem);
this.getChildControl("download-button").setEnabled(isFile);
this.getChildControl("delete-button").setEnabled(isFile);
const selectedLabel = this.getChildControl("selected-label");
if (isFile) {
this.__selection = selectedItem;
selectedLabel.set({
value: selectedItem.getLabel(),
toolTipText: selectedItem.getFileId()
});
} else {
this.__selection = null;
selectedLabel.set({
value: "",
toolTipText: ""
});
}
} else {
this.__selection = null;
selectedLabel.set({
value: "",
toolTipText: ""
});
this.resetItemSelected();
}
},

setMultiItemSelected: function(multiSelectionData) {
this.__multiSelection = multiSelectionData;
if (multiSelectionData && multiSelectionData.length) {
if (multiSelectionData.length === 1) {
this.setItemSelected(multiSelectionData[0]);
} else {
const selectedLabel = this.getChildControl("selected-label");
selectedLabel.set({
value: multiSelectionData.length + " files"
});
}
} else {
this.resetItemSelected();
}
},

resetItemSelected: function() {
this.__selection = null;
this.__multiSelection = [];
this.getChildControl("download-button").setEnabled(false);
this.getChildControl("delete-button").setEnabled(false);
this.getChildControl("selected-label").resetValue();
},

getItemSelected: function() {
const selectedItem = this.__selection;
if (selectedItem && osparc.file.FilesTree.isFile(selectedItem)) {
Expand All @@ -116,40 +160,71 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
return null;
},

// Request to the server and download
__retrieveURLAndDownload: function() {
let selection = this.getItemSelected();
if (selection) {
const fileId = selection.getFileId();
const locationId = selection.getLocation();
osparc.utils.Utils.retrieveURLAndDownload(locationId, fileId)
.then(data => {
if (data) {
osparc.DownloadLinkTracker.getInstance().downloadLinkUnattended(data.link, data.fileName);
__retrieveURLAndDownloadSelected: function() {
if (this.isMultiSelect()) {
this.__multiSelection.forEach(selection => {
this.__retrieveURLAndDownloadFile(selection);
});
} else {
const selection = this.getItemSelected();
if (selection) {
this.__retrieveURLAndDownloadFile(selection);
}
}
},

__deleteSelected: function() {
if (this.isMultiSelect()) {
const requests = [];
this.__multiSelection.forEach(selection => {
const request = this.__deleteFile(selection);
if (request) {
requests.push(request);
}
});
Promise.all(requests)
.then(datas => {
if (datas.length) {
this.fireDataEvent("fileDeleted", datas[0]);
osparc.FlashMessenger.getInstance().logAs(this.tr("Files successfully deleted"), "ERROR");
}
});
requests
} else {
const selection = this.getItemSelected();
if (selection) {
const request = this.__deleteFile(selection);
if (request) {
request
.then(data => {
this.fireDataEvent("fileDeleted", data);
osparc.FlashMessenger.getInstance().logAs(this.tr("File successfully deleted"), "ERROR");
});
}
}
}
},

__deleteFile: function() {
let selection = this.getItemSelected();
if (selection) {
console.log("Delete ", selection);
const fileId = selection.getFileId();
const locationId = selection.getLocation();
if (locationId !== 0 && locationId !== "0") {
osparc.FlashMessenger.getInstance().logAs(this.tr("Only files in simcore.s3 can be deleted"));
return false;
}
const dataStore = osparc.store.Data.getInstance();
dataStore.addListenerOnce("deleteFile", e => {
if (e) {
this.fireDataEvent("fileDeleted", e.getData());
__retrieveURLAndDownloadFile: function(file) {
const fileId = file.getFileId();
const locationId = file.getLocation();
osparc.utils.Utils.retrieveURLAndDownload(locationId, fileId)
.then(data => {
if (data) {
osparc.DownloadLinkTracker.getInstance().downloadLinkUnattended(data.link, data.fileName);
}
}, this);
return dataStore.deleteFile(locationId, fileId);
});
},

__deleteFile: function(file) {
const fileId = file.getFileId();
const locationId = file.getLocation();
if (locationId !== 0 && locationId !== "0") {
osparc.FlashMessenger.getInstance().logAs(this.tr("Only files in simcore.s3 can be deleted"));
return null;
}
return false;
}
const dataStore = osparc.store.Data.getInstance();
return dataStore.deleteFile(locationId, fileId);
},
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ qx.Class.define("osparc.file.FilePicker", {
flex: 1
});
treeFolderLayout.add(treeLayout, 0);
const folderViewer = new osparc.file.FolderViewer();
const allowMultiselection = false;
const folderViewer = new osparc.file.FolderViewer(allowMultiselection);
treeFolderLayout.add(folderViewer, 1);

filesTree.addListener("selectionChanged", () => {
Expand All @@ -562,7 +563,7 @@ qx.Class.define("osparc.file.FilePicker", {
const selectionData = e.getData();
this.__selectionChanged(selectionData);
}, this);
folderViewer.addListener("itemSelected", e => {
folderViewer.addListener("openItemSelected", e => {
const selectionData = e.getData();
this.__selectionChanged(selectionData);
if (osparc.file.FilesTree.isFile(selectionData)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ qx.Class.define("osparc.file.FileTreeItem", {
construct: function() {
this.base(arguments);

this.set({
indent: 12, // defaults to 19,
decorator: "rounded",
});

// create a date format like "Oct. 19, 2018 11:31 AM"
this._dateFormat = new qx.util.format.DateFormat(
qx.locale.Date.getDateFormat("medium") + " " +
Expand Down
Loading
Loading