[ZBX-8118] Don't allow to change image type for images used in maps Created: 2014 Apr 17  Updated: 2017 May 30  Resolved: 2015 Jan 13

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: None
Fix Version/s: 2.3.0

Type: Incident report Priority: Minor
Reporter: Oleg Egorov (Inactive) Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: images, maps
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBXNEXT-955 preselect image type in upload dialog Closed

 Description   

In Administration->Images change image type to background.
Image should be using in maps.

It possible save without any error message.

But should be displayed anything like
The image is used in maps "AAA"

Because map with this image in the future will be not possible to save.



 Comments   
Comment by Pavels Jelisejevs (Inactive) [ 2014 Apr 24 ]

To avoid such problems we've decided to remove the "Type" parameter from the image configuration form. Please make the following changes:

  • Remove the "type" select from the image configuration form
  • Change the title of the "Create image" button to "Create icon" and "Create background" depending on the selected type.
  • Change the header of the image configuration form from "Image" to either "Icon" or "Background".
  • Forbid updating the image "imagetype" parameter using the image.update method (see how it's done for item "state" and "templateid" in CItemGeneral::checkInput() line 203). Note, that it should still work in image.create.
Comment by richlv [ 2014 Apr 24 ]

hmm. in the past, accidentally uploading a background image as an icon could be corrected just by changing the type. with the suggested changes it would have to be deleted and re-uploaded.
it does sound like we will remove type selection from the upload, though - if so, that should mostly solve this problem.

as we are changing button label[s], i'd suggest to change them to "Upload icon" and "Upload background image" instead - having 'create' there is somewhat confusing

Eduards REOPEN Discussed with Sasha and Pavel, let's call button "Create icon" and "Create background"

kristsk RESOLVED in r44903. Chagned translatable strings:

  • 'Upload icon' => 'Create icon'
  • 'Upload background image' => 'Create background'

<richlv> in this context "create" is highly confusing and users have repeatedly asked why the button is labelled like that. please provide the reasoning to use "create" here.

Eduards CLOSED, "Create" is the name of business process, "upload" is method how we implement this functionality.

Comment by Krists Krigers (Inactive) [ 2014 Apr 24 ]

Resolved in r44746, r44747, branch svn://svn.zabbix.com/branches/dev/ZBX-8118.

Comment by Krists Krigers (Inactive) [ 2014 Apr 24 ]

(1) Translatable string changes:
New strings:

  • 'Cannot update "imagetype" for image "%1$s".'
  • 'Create background'
  • 'Create icon'

Removed strings:

  • 'Create image'
  • 'Wrong fields for image.'

kristsk Updated translatable strings list. RESOLVED.

iivs CLOSED.

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 24 ]

(2) adm.images.php:148 This code can be written in 1 line:

	if($imageType == IMAGE_TYPE_ICON) {
		$submitCaption = _('Upload icon');
	}
	else {
		$submitCaption = _('Upload background image');
	}

$submitCaption = ($imageType == IMAGE_TYPE_ICON) ? _('Upload icon') : _('Upload background image');

After this changes variable $submitCaption will be used once so also can be optimized..

kristsk RESOLVED in r44783.
Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 24 ]

(3) administration.general.image.edit.php:46
Incorrent ")" in line

$imageTab->addTab('imageTab', ($this->data['imagetype'] == IMAGE_TYPE_ICON ? _('Icon') : _('Background')), $imageFormList);

must be

$imageTab->addTab('imageTab', ($this->data['imagetype'] == IMAGE_TYPE_ICON) ? _('Icon') : _('Background'), $imageFormList);

kristsk RESOLVED in r44783.
Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 24 ]

(4) Incorrect string, please changes:
_('Can not update "%1$s" for image "%2$s".')
to
_('Cannot update "%1$s" for image "%2$s".')

Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 24 ]

(5) Undefined index in Image API request for query:
{"jsonrpc":"2.0","method":"image.update","params":

{"imageid":205,"imagetype":1}

,"id":0,"auth":"303e0a760eabd231c43eaf916be1ee37"}

Notice: Undefined index: name in /home/zabbix/www/testing-ZBX-8118/frontends/php/api/classes/CImage.php on line 329

kristsk RESOLVED in r44793.

Eduards REOPEN, Empty name if we try to update unexisting image: "Cannot update \"imagetype\" for image \"\"."

{"jsonrpc":"2.0","method":"image.update","params":

{"imageid":9999999999999999,"imagetype":1}

,"id":0,"auth":"303e0a760eabd231c43eaf916be1ee37"}

Also:

  • in this case will be faster to use API::getApiService()->select() to get data from DB. For example:
    $imageName = API::getApiService()->select($this->tableName(), array(
        'filter' => array('imageid' => $image['imageid']),
        'output' => array('name')
    ));
    
  • Please use space between "if" and "(" in CImage.php:344

kristsk RESOLVED in r44900.
Eduards REOPEN as discussed
kristsk RESOLVED in r44944.

Eduards REOPEN little formatting improvements:

  • line 509 require space between "foreach" and "("
  • line 535 !empty() can be removed, just "if ($imageNames) {"
  • line 544 redundant "()"

kristsk RESOLVED in r44968.
Eduards REOPEN

  • line 522 require space between "if" and "("
  • line 544 require tab at beginning of second line of if expression

Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 30 ]

(6) Please resolve conflicts after merging with trunk

kristsk RESOLVED in r45009.

Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 30 ]

Tested

Comment by Krists Krigers (Inactive) [ 2014 Apr 30 ]

Merged and committed to trunk in r45022.

Comment by Pavels Jelisejevs (Inactive) [ 2014 May 06 ]

(7) This needs to be documented in the API changelog.

kristsk RESOLVED.

jelisejev Great, thanks! CLOSED.

Comment by Martins Valkovskis [ 2014 May 07 ]

(8) Documented in general documentation as well:

jelisejev Thanks! CLOSED.

Comment by richlv [ 2014 Nov 01 ]

subissues still open : 1

Generated at Thu Apr 25 00:17:34 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.