-
Notifications
You must be signed in to change notification settings - Fork 99
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
Added possibility to link spreadsheet for automatic submission export in multiple formats #1758
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much! Nice work!
Some first thought about your code, besides there are quite a lot of linter issues to fix.
I think we do not need to implement this as a breaking change API wise but can make this compatible with the current API by just extending.
Moreover I do not know if it makes much sense to store the file path in the database. We probably should just work with the file id.
Mates, any idea how to fix that?
I haven't touched Also I'm trying to run Psalm locally and got 27 errors which is completely unrelated to my changes and not present in pipeline 😕 Also pipeline not starting for my commits due to lack of approvals 🤷♂️ |
9cb08e7
to
adac3e2
Compare
Yes, it's doable but little bit tricky because we can choose file or folder. If it is a blocker for merge - just say and I will rework. Because now it sounds like you are not 100% sure :) |
Yes that error is unrelated, needs to be fixed on the server, so you can ignore it.
Folders also have a file id. The reason why I would prefer to only use the ID rather then hard coding the path is:
So it would make things more robust and safe for the future if we already stick with the ID. |
Super nice! :)
I do agree that the action menu looks a bit crowded, we can easily fix that :)
Recording.2023-10-24.190452.mp4What do you think? |
Can be silenced like this: |
@nimishavijay yes, we are automatically update spreadsheet once new response added. But sometimes we can get into trouble with a race conditions. Imagine that Employee edits file with submissions in a browser and overwrites changes that exported after new response added. In this case we should have mechanism to force re-export responses to file after Employee finishes his work. |
533353d
to
f0580ec
Compare
@nimishavijay I've added nested menu, you can find a video record for it in the PR description. Also disabling of non-active buttons has been replaced with hidding. @susnux I've reworked PR, now we are storing Also I've fixed all pipelines (I hope 🤞 ). Can we enable full pipeline for an every push commit for this PR? |
@Koc The workflows will run automatically once you have contributed to this repository. Until then we have to manually start it :) |
f0580ec
to
065381d
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
065381d
to
3b66bbc
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1758 +/- ##
============================================
+ Coverage 44.61% 44.79% +0.17%
- Complexity 662 686 +24
============================================
Files 58 59 +1
Lines 2600 2697 +97
============================================
+ Hits 1160 1208 +48
- Misses 1440 1489 +49 |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
3b66bbc
to
035a318
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
wow, we have completely green pipeline for the very first time! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look at the code, but not everything in-depth. Added some comments :) I will run the code in the next few days and see how it works.
My bad... I forgot to escape the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works and I think we are close to merge!
I just have some nitpicks and some issues like wrong copyright, wrong version in migration and one more specific issue:
I still would like to see the API using fileids if possible. Or do you have some reason for using paths there?
@@ -132,6 +139,9 @@ Returns the full-depth object of the requested form (without submissions). | |||
"showToAllUsers": false | |||
}, | |||
"expires": 0, | |||
"fileFormat": "csv", | |||
"fileId": 157, | |||
"filePath": "foo/bar", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the real path? If yes we should change it, as everywhere else in nextcloud we use absolute paths to the root of a user (which is for DAV /files/USERID
thus the path would be /foo/bar
).
"data": { | ||
"fileFormat": "csv", | ||
"fileId": 157, | ||
"filePath": "foo/bar", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
* @throws OCSForbiddenException | ||
*/ | ||
public function linkFile(string $hash, string $path, string $fileFormat): DataResponse { | ||
$this->logger->debug('Linking form {hash} to file at /{path} in format {fileFormat}', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above the path should be absolute so you can get ride of the manual / before
|
||
// Get Data | ||
$csvData = $this->getSubmissionsCsv($hash); | ||
$this->logger->debug('Export submissions for form: {hash} to Cloud at: /{path} in format {fileFormat}', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above probably should be absolute path so the extra / can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's written the same like it now in current main branch.
|
||
/** @var \OCP\Files\Folder|File $node */ | ||
if ($ownerId) { | ||
$node = $this->storage->getUserFolder($ownerId)->get($path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said above, I do not think relative paths make much sense, I would either use an absolute one and remove the leading / here.
Or as initally said just use the file id, you can simply get the file then with $this->storage->getById(FILEID)
(this returns an array if I am right, just take the first node then).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also about relative vs absolute path: current codebase also uses relative path. I'm using literally same method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right this PR is big enough lets do optional refactoring in the future and keep the current way :)
0a72b8c
to
7d9d4e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Just fix the rest of the routes (API version) then this is good to go 🎉
…xport in multiple formats Signed-off-by: Konstantin Myakshin <[email protected]>
Signed-off-by: Ferdinand Thiessen <[email protected]>
3815adb
to
d6f5cb6
Compare
@Koc Thank you very much for this fantastic work! 🚀 |
very happy to hear that, thanx! It was hard 😃 |
Yes, thank you very much @Koc :) We'd be glad if you continue contributing here 🙂 |
Awesome work @Koc! Do you already have a guest account on our instance? We could add you there so you can join the Forms community Talk channel. :) |
@jancborchardt no, I haven't. You can find my email address in copyrights 😃 |
Having this error when attempting to create a spreadsheet: "no app in context","method":"POST","url":"/ocs/v2.php/apps/forms/api/v2.4/form/link/ods","message":"Exception thrown: OCP\Files\NotFoundException","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36","version":"28.0.2.5","exception":{"Exception":"OCP\Files\NotFoundException","Message":"/admin/files/Documents/folder/TCC \nData Usage Assessment Form (responses).ods","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Files/Node/Folder.php","line":135,"function":"get","class":"OC\Files\Node\Root","type":"->","args":["/TCC/files/Documents/folder/TCC \nData Usage Assessment Form (responses).ods"]},{"file":"/var/www/html/custom_apps/forms/lib/Service/SubmissionService.php","line":216,"function":"get","class":"OC\Files\Node\Folder","type":"->","args":["TCC \nData Usage Assessment Form (responses).ods"]},{"file":"/var/www/html/custom_apps/forms/lib/Controller/ApiController.php","line":1324,"function":"writeFileToCloud","class":"OCA\Forms\Service\SubmissionService","type":"->","args":[["OCA\Forms\Db\Form",1],"/Documents/folder","ods"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"linkFile","class":"OCA\Forms\Controller\ApiController","type":"->","args":["LZyTtsgDfqtFWbNo","/Documents/folder","ods"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\AppFramework\Http\Dispatcher","type":"->","args":[["OCA\Forms\Controller\ApiController"],"linkFile"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\AppFramework\Http\Dispatcher","type":"->","args":[["OCA\Forms\Controller\ApiController"],"linkFile"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\AppFramework\App","type":"::","args":["OCA\Forms\Controller\ApiController","linkFile",["OC\AppFramework\DependencyInjection\DIContainer"],["v2.4","ods","ocs.forms.api.linkFile"]]},{"file":"/var/www/html/ocs/v1.php","line":65,"function":"match","class":"OC\Route\Router","type":"->","args":["/ocsapp/apps/forms/api/v2.4/form/link/ods"]},{"file":"/var/www/html/ocs/v2.php","line":23,"args":["/var/www/html/ocs/v1.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Files/Node/Root.php","Line":207,"CustomMessage":"Exception thrown: OCP\Files\NotFoundException"},"id":"65c302dad2cd8"} Chat GPT Findings: The error log you've provided outlines a NotFoundException occurring within a Nextcloud instance, specifically when trying to access or link to an .ods file located in a user's documents folder. Here's a detailed breakdown of what happened, the probable cause, and how to address it: Error Summary Exception Type: OCP\Files\NotFoundException Probable Cause The error was triggered during a POST request to link an .ods file to a form submission. The path to the file includes a line break (\n) which might be unintentional or misinterpreted by the system as part of the file path. File paths typically do not include line breaks, and their presence can cause the system to search for a file in a non-existent location. Troubleshooting ActionsAttempted to remove and reinstall the app VersionLatest Nextcloud 28 |
@Gamechiefx please create a new issue for that and use the template for bug reports. Thank you! |
Done, I've opened #1970, #1971, #1972 and #1973 for these issues. |
Hello, I think this feature is what I look for, but I don't understand how to use it. Is it documented somewhere ? Thanks by advance. |
@JocelynDelalande Just have a look at the video in the OP. :) |
@Chartman123 Thanks for your answer, and nevermind: I was just using a version of NC that was too old for forms 4.1. Can't wait to test the new Forms :) |
Hello everyone!
I've added possibility to link form with spreadsheet in csv/ods/xlsx format and automatically export it once new submission added. Inspired from #1403 but with more formats. Also we edit already existent file, which give us possibility to add additional columns with notes/statuses/etc.
Here you can find few video/screenshots:
nextcloud-forms-export-03.mp4
Exported file
What is out of scope right now but can be added in upcoming PRs:
Todo: