Beispiel #1
0
    def saveConfig(self, conf):
        targets = [target.specYaml for target in self.targetentity_set.all()]

        if not conf:
            conf = {'layout': 'grid',
                    'ncols': 2,
                    'template': 'material',
                    'theme': 'default',
                    'title': 'Nouveau DashBoard'
                    }

        spec = SpecYamlCreator(config=conf,targets=targets)
        self.config = spec.to_yaml()
Beispiel #2
0
    def saveSpec(self):
        views = self.get_spec()['views']
        filters = self.get_spec()['filters']
        source = self.get_spec()['source']
        title = self.get_spec()['title']
        name = self.get_spec()['name']
        p = {'name': name, 'title': title, 'source': source}
        if len(views) > 0:
            if views[0]:
                p['views'] = views
        if len(filters) > 0:
            if filters[0]:
                p['filters'] = filters

        spec = SpecYamlCreator(**p)
        self.specYaml = spec.to_yaml()
Beispiel #3
0
    def specUpdate(self):
        if self.transformTypeSelector:
            transform_type = self.transformTypeSelector.transform_type
            if hasattr(self, 'panelWidgets'):
                self.transformTypeParameters = {
                    p.name: getattr(self, p.name)
                    for p in self.panelWidgets
                }
                self.transformTypeParameters['type'] = transform_type

        self.config = {
            'title': self.lumenDashboard.title,
            'layout': self.lumenDashboard.layout,
            'ncols': self.lumenDashboard.ncols,
            'template': self.lumenDashboard.template,
            'theme': self.lumenDashboard.theme
        }

        viewParameters = {'type': 'table', 'pagination': 'remote'}

        target_param = [{
            'title': 'Nouveau',
            'views': [viewParameters],
            'filters': []
        }]

        sources_param = {
            'sources': [{
                "new": {
                    'type': 'file',
                    'files': ['new.csv']
                }
            }]
        }

        if hasattr(self, 'transformTypeParameters') and hasattr(self, 'src'):
            target_param[0]['source'] = self.src.name
            # todo ajouter des filtres pour la préparation de la donnée
            #target_param[0]['filters'] = [{'field': str(list(self.schema.keys())[0]) ,'type': 'widget'}]

            viewParameters['table'] = self.src.name
            viewParameters['transforms'] = [{**self.transformTypeParameters}]

            sources_param = {
                self.src.name: {
                    'type': 'intake',
                    'shared': True,
                    'cache_dir': "cache",
                    'catalog': yaml.load(self.src.__repr__())
                }
            }

        else:
            viewParameters['source'] = 'new'

        return SpecYamlCreator(config=self.config,
                               targets=target_param,
                               sources=sources_param)
Beispiel #4
0
    def specUpdate(self):
        filter_type = self.filterTypeSelector.filter_type
        self.filterTypeParameters = {p.name: getattr(self, p.name) for p in self.panelWidgets}

        self.filterTypeParameters['type'] = filter_type

        self.config = {
            'title': self.lumenDashboard.title,
            'layout': self.lumenDashboard.layout,
            'ncols': self.lumenDashboard.ncols,
            'template': self.lumenDashboard.template,
            'theme': self.lumenDashboard.theme}

        target_param = [t for t in self.lumenDashboard.dashBoard._spec['targets'] if t['name'] == self.target.name][0]

        target_param['filters'] = [{**self.filterTypeParameters}]


        return SpecYamlCreator(config=self.config, targets=[target_param])
Beispiel #5
0
    def specUpdate(self):
        view_type = self.viewTypeSelector.view_type
        self.viewTypeParameters = {
            p.name: getattr(self, p.name)
            for p in self.panelWidgets
        }

        self.config = {
            'title': self.lumenDashboard.title,
            'layout': self.lumenDashboard.layout,
            'ncols': self.lumenDashboard.ncols,
            'template': self.lumenDashboard.template,
            'theme': self.lumenDashboard.theme
        }

        if self.viewTypeParameters:
            viewParameters = {
                'type':
                view_type,
                'table':
                self.src.name,
                'name':
                self.viewTypeParameters.get(
                    'label', self.viewTypeParameters.get('title', '')),
                **self.viewTypeParameters,
            }

            transforms = [{**self.transforms}] if self.transforms else []
            viewParameters['transforms'] = transforms

            target_param = [{
                'title': 'Nouveau',
                "source": {
                    'type': 'intake',
                    'uri': self.src.cat.path
                },
                'views': [viewParameters],
                'filters': []
            }]

        return SpecYamlCreator(config=self.config, targets=target_param)
Beispiel #6
0
 def createFakeYaml(self):
     path = BASE_DIR + '/vizApps/services/intake/'
     config = {
         'title': "Nouveau DashBoard",
         'layout': "grid",
         'ncols': 2,
         'template': 'material',
         'theme': 'dark'
     }
     targets = [
         {
             'title': 'Nouvelle Source',
             "source": {
                 'type': 'intake',
                 'filename': os.path.join(path, 'catalog.yml')
             },
             'views': [],
             'filters': []
         },
     ]
     specObj = SpecYamlCreator(config=config, targets=targets)
     return specObj
Beispiel #7
0
    def specUpdate(self):
        title = '-'
        if self.transformTypeSelector:
            if self.transformTypeSelector.transform_type != 'No':
                transform_type = self.transformTypeSelector.transform_type
                if hasattr(self, 'panelWidgets'):
                    self.transformTypeParameters = {
                        p.name: getattr(self, p.name)
                        for p in self.panelWidgets
                    }
                    self.transformTypeParameters['type'] = transform_type
                    self.transformTypeParameters['width_policy'] = 'max'
                    title = transform_type
            else:
                self.transformTypeParameters = dict()

        self.config = {
            'title': self.lumenDashboard.title,
            'layout': self.lumenDashboard.layout,
            'ncols': self.lumenDashboard.ncols,
            'template': self.lumenDashboard.template,
            'theme': self.lumenDashboard.theme
        }

        viewParameters = {
            'type': 'table',
            'pagination': 'remote',
            'page_size': 15,
            'layout': 'fit_columns'
        }

        target_param = [{
            'title': title,
            'width_policy': 'max',
            'views': [viewParameters],
            'filters': []
        }]

        sources_param = {
            'sources': [{
                "new": {
                    'type': 'file',
                    'files': ['new.csv']
                }
            }]
        }

        if hasattr(self, 'transformTypeParameters') and hasattr(self, 'src'):
            target_param[0]['source'] = self.src.name
            # todo ajouter des filtres pour la préparation de la donnée
            viewParameters['table'] = self.src.name
            viewParameters['transforms'] = [{
                **self.transformTypeParameters
            }] if len(self.transformTypeParameters) >= 1 else []

            sources_param = {
                self.src.name: {
                    'type': 'intake',
                    'shared': True,
                    'cache_dir': "cache",
                    'catalog': yaml.load(self.src.__repr__())
                }
            }

        else:
            viewParameters['source'] = 'new'

        return SpecYamlCreator(config=self.config,
                               targets=target_param,
                               sources=sources_param)