Skip to main content
1-Visitor
July 19, 2019
Solved

Browse the image from c drive and apply as style definition to selected mashup in a combo

  • July 19, 2019
  • 4 replies
  • 1417 views

Hi,

I have a UI in which I have a combo box having 19 mashup names and a browse widget in which I wanted to browse the image from pc and once I selected the image, when I click on apply button I want the selected image to be set as mashup background style for selected mashup from combo.

 

The basic idea is to make the background of mashup as configurable.

 

Please give some idea on how I can achieve this.

 

Thanks,

Shalini V.

Best answer by Constantine
Hello,

You need to create a thing “UploadsRepository”, with thing template “FileRepository”. It will correspond to a simple folder with the same name under your /ThingworxStorage/repositories. See more details in ThingWorx help, I can’t find the right link from the phone. You can use a predefined “SystemRepository” thing just as well, but it’s probably a somewhat cleaner approach to create a separate thing for that (like this you’ll be able to better configure access rights eventually).

/ Constantine

4 replies

18-Opal
July 21, 2019

Hello,

 

Just my five cents. You can replace MediaEntity content with uploaded content programmatically:

 

var newContent = Things["UploadsRepository"].LoadImage({ path: uploadedPath });
Resources["EntityServices"].UpdateMediaEntity({
 name: 'YourMediaEntityName',
 content: newContent
});

 

But to see the changes the user will have to refresh the page (e.g. CTRL+F5) or wait for quite some time, since ThingWorx caches style definitions.

 

You can probably use MediaEntity's Dynamic Content capability. Unfortunately I've never worked with it myself, so I cannot provide any details on that.

 

/ Constantine

1-Visitor
July 23, 2019

Hi @Constantine ,

Thanks for your response. 

I have a doubt, should I create a thing in which I should be writing a service LoadImage?

Things["UploadsRepository"].LoadImage({ path: uploadedPath });

Could you please clarify this alone?

 

Regards,

Shalini V.

18-Opal
July 23, 2019
Hello,

You need to create a thing “UploadsRepository”, with thing template “FileRepository”. It will correspond to a simple folder with the same name under your /ThingworxStorage/repositories. See more details in ThingWorx help, I can’t find the right link from the phone. You can use a predefined “SystemRepository” thing just as well, but it’s probably a somewhat cleaner approach to create a separate thing for that (like this you’ll be able to better configure access rights eventually).

/ Constantine