Exemplo n.º 1
0
 def step2_new(self, app, action, **params):
     owner = splunk.auth.getCurrentUser()['name']
     saved_search = SavedSearch.get(params.get('id'))
     dashboard = Dashboard(app, owner, None)
     dashboard.metadata.sharing = 'app'
     dashboards = Dashboard.filter_by_can_write_simple_xml(app)
     template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards, 
                          dashboard_action=None, panel_type='event', panel_title=None)
     return self.render_template('dashboardwizard/step2.html', template_args)
Exemplo n.º 2
0
 def step2_new(self, app, action, **params):
     owner = splunk.auth.getCurrentUser()['name']
     saved_search = SavedSearch.get(params.get('id'))
     dashboard = Dashboard(app, owner, None)
     dashboard.metadata.sharing = 'app'
     dashboards = Dashboard.filter_by_can_write_simple_xml(app)
     template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards, 
                          dashboard_action=None, panel_type='event', panel_title=None)
     return self.render_template('dashboardwizard/step2.html', template_args)
Exemplo n.º 3
0
 def step2_edit(self, app, action, **params):
     owner = splunk.auth.getCurrentUser()['name']
     saved_search = SavedSearch.get(params.get('id'))
     dashboard = Dashboard.get(params.get('dashboard_id'))
     dashboard_action = params.get('dashboard_action')
     if dashboard_action=='new':
         dashboard.delete()
     dashboards = Dashboard.filter_by_can_write_simple_xml()
     template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards, 
                          dashboard_action=dashboard_action)
     return self.render_template('dashboardwizard/step2.html', template_args)
Exemplo n.º 4
0
 def step2_edit(self, app, action, **params):
     owner = splunk.auth.getCurrentUser()['name']
     saved_search = SavedSearch.get(params.get('id'))
     dashboard = Dashboard.get(params.get('dashboard_id'))
     dashboard_action = params.get('dashboard_action')
     if dashboard_action=='new':
         dashboard.delete()
     dashboards = Dashboard.filter_by_can_write_simple_xml()
     template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards, 
                          dashboard_action=dashboard_action)
     return self.render_template('dashboardwizard/step2.html', template_args)
Exemplo n.º 5
0
    def step2_create(self, app, step, action, **params):
        # saved search models
        saved_search = SavedSearch.get(params.get('id'))
        # dashboard model
        dashboard_action = params.get('dashboard.action')
        owner = splunk.auth.getCurrentUser()['name']
        if dashboard_action=='get':
            try:
                dashboard = Dashboard.get(params.get('dashboard.id'))
            except:
                dashboard = Dashboard(app, owner, None)
                dashboard.errors = [_('Please choose an existing dashboard.')]
        else:
            dashboard_name = params.get('dashboard.name', '')
            try:
                dashboard_name.encode('ascii')
            except:
                date = str(splunk.util.dt2epoch(datetime.datetime.now())).replace('.', '_')
                dashboard_name = '%s_%s' % (splunk.auth.getCurrentUser()['name'], date)
            dashboard = Dashboard(app, owner, dashboard_name)
            dashboard.label = params.get('dashboard.label')
            dashboard.metadata.sharing = params.get('sharing', 'user')

        if not dashboard.errors and saved_search.passive_save() and dashboard.passive_save():
            # update saved search only on save success
            if dashboard.metadata.sharing=='app':
                try:
                    saved_search.share_app()
                except Exception:
                    saved_search.errors = [_('Search %s cannot be shared because it already exists. Try using another search name in the previous step.') % saved_search.name ]
            else:
                try:
                    saved_search.unshare()
                except Exception:
                    saved_search.errors = [_('Search %s cannot be private because it already exists. Try using another search name in the previous step.') % saved_search.name]
            if not saved_search.errors:
                raise cherrypy.HTTPRedirect(self.make_url(['dashboardwizard', app, 'step3'], _qs=dict(search_id=saved_search.id, dashboard_id=dashboard.id, dashboard_action=dashboard_action)), 303)
        dashboards = Dashboard.filter_by_can_write_simple_xml()
        template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards, dashboard_action=dashboard_action)
        return self.render_template('dashboardwizard/step2.html', template_args)
Exemplo n.º 6
0
    def step2_create(self, app, step, action, **params):
        # saved search models
        saved_search = SavedSearch.get(params.get('id'))
        # dashboard model
        dashboard_action = params.get('dashboard.action')
        owner = splunk.auth.getCurrentUser()['name']
        if dashboard_action=='get':
            try:
                dashboard = Dashboard.get(params.get('dashboard.id'))
            except:
                dashboard = Dashboard(app, owner, None)
                dashboard.errors = [_('Please choose an existing dashboard.')]
        else:
            dashboard_name = params.get('dashboard.name', '')
            try:
                dashboard_name.encode('ascii')
            except:
                date = str(splunk.util.dt2epoch(datetime.datetime.now())).replace('.', '_')
                dashboard_name = '%s_%s' % (splunk.auth.getCurrentUser()['name'], date)
            dashboard = Dashboard(app, owner, dashboard_name)
            dashboard.label = params.get('dashboard.label')
            dashboard.metadata.sharing = params.get('sharing', 'user')

        if not dashboard.errors and saved_search.passive_save() and dashboard.passive_save():
            # update saved search only on save success
            if dashboard.metadata.sharing=='app':
                try:
                    saved_search.share_app()
                except Exception:
                    saved_search.errors = [_('Search %s cannot be shared because it already exists. Try using another search name in the previous step.') % saved_search.name ]
            else:
                try:
                    saved_search.unshare()
                except Exception:
                    saved_search.errors = [_('Search %s cannot be private because it already exists. Try using another search name in the previous step.') % saved_search.name]
            if not saved_search.errors:
                raise cherrypy.HTTPRedirect(self.make_url(['dashboardwizard', app, 'step3'], _qs=dict(search_id=saved_search.id, dashboard_id=dashboard.id, dashboard_action=dashboard_action)), 303)
        dashboards = Dashboard.filter_by_can_write_simple_xml()
        template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards, dashboard_action=dashboard_action)
        return self.render_template('dashboardwizard/step2.html', template_args)