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

Adds drawn signature to asset acceptance #2846

Merged
merged 7 commits into from
Nov 1, 2016
Merged

Conversation

snipe
Copy link
Owner

@snipe snipe commented Oct 29, 2016

No description provided.

This is still a little broken - the history is displaying “Deleted user”, since there is no item type listed. Saving the item_type as App\Models\User tries to update accepted on the users table, which obviously doesn’t exist.
It shoudl fail if you’re not authorized since you’re not logged in, but better safe than sorry
Copy link
Contributor

@dmeltzer dmeltzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts/opinions. Most of these are more me pondering what we do about actionlogs in the future than specifics here-

One thought I had when looking through this is whether declined acceptance should require a signature, or just accepting it. Presently it looks like it's both, but not sure that is what everyone will expect?

{

$file = config('app.private_uploads') . '/signatures/' . $filename;
$filetype = Helper::checkUploadIsImage($file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to rename this helper method? I don't expect a "checkXisY" method to return anything but a boolean.

@@ -378,6 +380,9 @@ public function getActivityReportDataTable()
} else {
$activity_target = '';
}
} elseif (($activity->action_type=='accepted') || ($activity->action_type=='declined')) {
$activity_target = '<a href="' . route('view/user', $activity->item->assigneduser->id) . '">' . e($activity->item->assigneduser->fullName()) . '</a>';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate from this... but I'm thinking maybe we want to go towards a Helper::generateHtmLinkFromItem($item) that does something like

return "a href=" . route("view/${metaprogramming_classname_somethigorother_from_item}", $item->id) . ">" . $item->displayableName . "</a>"

because we seem to do this so often... not sure if this is the best way though.. thoughts?

$encoded_image = explode(",", $data_uri);
$decoded_image = base64_decode($encoded_image[1]);
file_put_contents($path."/".$sig_filename, $decoded_image);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another place that has a lot of specifics about file writing.. . should we abstract these bits to a method or just wait for the 5.3 switch where laravel does it for us?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually--don't we have access to a Symfony uploadedFile instance here? That would let us use move() and guessFileExtension() and things like that.

$logaction->note = e(Input::get('note'));
$logaction->user_id = $user->id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this an intentional removal of the user ID? Hard to tell from this context, just want to make sure.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user_id has typically been a strictly admin id (it's how to populate "Admin" everywhere). There is no admin involved in the acceptance of a asset. It sort of doesn't make any sense to make them a target either, but everywhere else, user_id = admin actor

@@ -91,15 +90,14 @@ public function parentlog()
/**
* Check if the file exists, and if it does, force a download
**/
public function get_src($type = 'assets')
public function get_src($type = 'assets', $fieldname = 'filename')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed like a strange place for this method to exist to me when I was polymorphicating everything, but I was afraid to touch it... also unclear exactly what the method does when looking at it quickly. Does associating files with a log in general make sense? (The signatures do, wondering about the asset files)--Not really related to your sig, just a ponder I had when staring at all this code a few weeks ago.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have them in the log action table strictly for ease of use when displaying history stuff. Otherwise we'll end up pulling in pivot tables for uploads, etc.

{
Schema::table('settings', function ($table) {
$table->dropColumn('require_accept_signature');
$table->dropColumn('accept_signature');
Copy link
Contributor

@dmeltzer dmeltzer Oct 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line shouldn't exist, right? It belongs to the action_logs table.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, you're right - good catch, thanks!

</div>
@endif

@if (\App\Models\Setting::getSettings()->require_accept_signature=='1')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we want to look at injecting settings globally, could be nice to always have access to a $settings variables in views to clean this up.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy enough to do via middleware, but I think we'd still need something like $request->settings->blah, which doesn't seem shorter. We cache the value of the settings query at least, so we're not running it every time we need a setting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we can use the hard to find view()->share() method in an app service provider to share a value with all views... https://laravel.com/docs/5.3/views#passing-data-to-views

I could see this getting confusing if we had to many of these, wonder if making a global settings() or snipeSettings() variable would be more clear.

@snipe
Copy link
Owner Author

snipe commented Oct 31, 2016

These are all good suggestions, but most are not directly related to this PR :) Thanks for taking a look.

@snipe snipe merged commit a914dac into develop Nov 1, 2016
@snipe snipe removed the in progress label Nov 1, 2016
dmeltzer pushed a commit to dmeltzer/snipe-it that referenced this pull request Nov 5, 2016
* Adds digital signature to asset acceptance

This is still a little broken - the history is displaying “Deleted user”, since there is no item type listed. Saving the item_type as App\Models\User tries to update accepted on the users table, which obviously doesn’t exist.

* Use asset facade for folks in subdirs

* Possible fix for weird accepted/declined display

* Display signature in modal popup if sigs are required

* Wrap that display file in auth middleware, just to be sure.

It shoudl fail if you’re not authorized since you’re not logged in, but better safe than sorry

* Fixed header section of layout

* Removed extra drop from migration rollback
dmeltzer pushed a commit to dmeltzer/snipe-it that referenced this pull request Nov 6, 2016
* Adds digital signature to asset acceptance

This is still a little broken - the history is displaying “Deleted user”, since there is no item type listed. Saving the item_type as App\Models\User tries to update accepted on the users table, which obviously doesn’t exist.

* Use asset facade for folks in subdirs

* Possible fix for weird accepted/declined display

* Display signature in modal popup if sigs are required

* Wrap that display file in auth middleware, just to be sure.

It shoudl fail if you’re not authorized since you’re not logged in, but better safe than sorry

* Fixed header section of layout

* Removed extra drop from migration rollback
@snipe snipe deleted the features/drawn_signature branch November 17, 2016 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants