def _update_app_recommendations_content(self):
     if self.app_recommendations_content:
         self.app_recommendations_content.remove_all()
     self.spinner_notebook.show_spinner(_(u"Receiving recommendations…"))
     # get the recommendations from the recommender agent
     self.app_recommendations_cat = AppRecommendationsCategory(self.pkgname)
     self.app_recommendations_cat.connect(
         'needs-refresh', self._on_app_recommendations_agent_refresh)
     self.app_recommendations_cat.connect('recommender-agent-error',
                                          self._on_recommender_agent_error)
Exemplo n.º 2
0
class RecommendationsPanelDetails(RecommendationsPanel):
    """
    Panel for use in the details view to display recommendations for a given
    application
    """
    def __init__(self, catview):
        RecommendationsPanel.__init__(self, catview)
        self.set_header_label(_(u"People Also Installed"))
        self.app_recommendations_content = FlowableGrid()
        self.add(self.app_recommendations_content)

    def set_pkgname(self, pkgname):
        self.pkgname = pkgname
        self._update_app_recommendations_content()

    def _update_app_recommendations_content(self):
        if self.app_recommendations_content:
            self.app_recommendations_content.remove_all()
        self.spinner_notebook.show_spinner(_(u"Receiving recommendations…"))
        # get the recommendations from the recommender agent
        self.app_recommendations_cat = AppRecommendationsCategory(self.pkgname)
        self.app_recommendations_cat.connect(
                                    'needs-refresh',
                                    self._on_app_recommendations_agent_refresh)
        self.app_recommendations_cat.connect('recommender-agent-error',
                                             self._on_recommender_agent_error)

    def _on_app_recommendations_agent_refresh(self, cat):
        docs = cat.get_documents(self.catview.db)
        # display the recommendations
        if len(docs) > 0:
            self.catview._add_tiles_to_flowgrid(docs,
                                        self.app_recommendations_content, 3)
            self.show_all()
            self.spinner_notebook.hide_spinner()
        else:
            self._hide_app_recommendations_panel()

    def _on_recommender_agent_error(self, agent, msg):
        LOG.warn("Error while accessing the recommender agent for the "
                 "details view recommendations: %s" % msg)
        # TODO: temporary, instead we will display cached recommendations here
        self._hide_app_recommendations_panel()

    def _hide_app_recommendations_panel(self):
        # and hide the pane
        self.hide()
class RecommendationsPanelDetails(RecommendationsPanel):
    """
    Panel for use in the details view to display recommendations for a given
    application
    """
    def __init__(self, catview):
        RecommendationsPanel.__init__(self, catview)
        self.set_header_label(_(u"People Also Installed"))
        self.app_recommendations_content = FlowableGrid()
        self.add(self.app_recommendations_content)

    def set_pkgname(self, pkgname):
        self.pkgname = pkgname
        self._update_app_recommendations_content()

    def _update_app_recommendations_content(self):
        if self.app_recommendations_content:
            self.app_recommendations_content.remove_all()
        self.spinner_notebook.show_spinner(_(u"Receiving recommendations…"))
        # get the recommendations from the recommender agent
        self.app_recommendations_cat = AppRecommendationsCategory(self.pkgname)
        self.app_recommendations_cat.connect(
            'needs-refresh', self._on_app_recommendations_agent_refresh)
        self.app_recommendations_cat.connect('recommender-agent-error',
                                             self._on_recommender_agent_error)

    def _on_app_recommendations_agent_refresh(self, cat):
        docs = cat.get_documents(self.catview.db)
        # display the recommendations
        if len(docs) > 0:
            self.catview._add_tiles_to_flowgrid(
                docs, self.app_recommendations_content, 3)
            self.show_all()
            self.spinner_notebook.hide_spinner()
        else:
            self._hide_app_recommendations_panel()

    def _on_recommender_agent_error(self, agent, msg):
        LOG.warn("Error while accessing the recommender agent for the "
                 "details view recommendations: %s" % msg)
        # TODO: temporary, instead we will display cached recommendations here
        self._hide_app_recommendations_panel()

    def _hide_app_recommendations_panel(self):
        # and hide the pane
        self.hide()
Exemplo n.º 4
0
 def _update_app_recommendations_content(self):
     if self.app_recommendations_content:
         self.app_recommendations_content.remove_all()
     self.spinner_notebook.show_spinner(_(u"Receiving recommendations…"))
     # get the recommendations from the recommender agent
     self.app_recommendations_cat = AppRecommendationsCategory(self.db, self.pkgname)
     self.app_recommendations_cat.connect("needs-refresh", self._on_app_recommendations_agent_refresh)
     self.app_recommendations_cat.connect("recommender-agent-error", self._on_recommender_agent_error)
Exemplo n.º 5
0
class RecommendationsPanelDetails(RecommendationsPanel):
    """
    Panel for use in the details view to display recommendations for a given
    application
    """
    def __init__(self, db, properties_helper):
        RecommendationsPanel.__init__(self)
        self.db = db
        self.properties_helper = properties_helper
        self.set_header_label(_(u"People Also Installed"))
        self.app_recommendations_content = TileGrid()
        self.app_recommendations_content.connect(
                    "application-activated", self._on_application_activated)
        self.add(self.app_recommendations_content)

    def set_pkgname(self, pkgname):
        self.pkgname = pkgname
        self._update_app_recommendations_content()

    def _update_app_recommendations_content(self):
        if self.app_recommendations_content:
            self.app_recommendations_content.remove_all()
        self.spinner_notebook.show_spinner(_(u"Receiving recommendations…"))
        # get the recommendations from the recommender agent
        self.app_recommendations_cat = AppRecommendationsCategory(
                self.db,
                self.pkgname)
        self.app_recommendations_cat.connect(
                                    'needs-refresh',
                                    self._on_app_recommendations_agent_refresh)
        self.app_recommendations_cat.connect('recommender-agent-error',
                                             self._on_recommender_agent_error)

    def _on_app_recommendations_agent_refresh(self, cat):
        docs = cat.get_documents(self.db)
        # display the recommendations
        if len(docs) > 0:
            self.app_recommendations_content.add_tiles(
                    self.properties_helper,
                    docs,
                    DETAILS_RECOMMENDATIONS_CAROUSEL_LIMIT)
            self.show_all()
            self.spinner_notebook.hide_spinner()
        else:
            self.hide()
class RecommendationsPanelDetails(RecommendationsPanel):
    """
    Panel for use in the details view to display recommendations for a given
    application
    """
    def __init__(self, db, properties_helper):
        RecommendationsPanel.__init__(self)
        self.db = db
        self.properties_helper = properties_helper
        self.set_header_label(_(u"People Also Installed"))
        self.app_recommendations_content = TileGrid()
        self.app_recommendations_content.connect(
                    "application-activated", self._on_application_activated)
        self.add(self.app_recommendations_content)

    def set_pkgname(self, pkgname):
        self.pkgname = pkgname
        self._update_app_recommendations_content()

    def _update_app_recommendations_content(self):
        if self.app_recommendations_content:
            self.app_recommendations_content.remove_all()
        self.spinner_notebook.show_spinner(_(u"Receiving recommendations…"))
        # get the recommendations from the recommender agent
        self.app_recommendations_cat = AppRecommendationsCategory(
                self.db,
                self.pkgname)
        self.app_recommendations_cat.connect(
                                    'needs-refresh',
                                    self._on_app_recommendations_agent_refresh)
        self.app_recommendations_cat.connect('recommender-agent-error',
                                             self._on_recommender_agent_error)

    def _on_app_recommendations_agent_refresh(self, cat):
        docs = cat.get_documents(self.db)
        # display the recommendations
        if len(docs) > 0:
            self.app_recommendations_content.add_tiles(
                    self.properties_helper,
                    docs,
                    DETAILS_RECOMMENDATIONS_CAROUSEL_LIMIT)
            self.show_all()
            self.spinner_notebook.hide_spinner()
        else:
            self.hide()