Exemplo n.º 1
0
 def ui(self):
     layout = QVBoxLayout(self)
     layout.setAlignment(Qt.AlignTop)
     # Product List
     pdsWidget = ProductList(self.products, show_status=True)
     layout.addWidget(pdsWidget)
     return layout
Exemplo n.º 2
0
    def ui(self):
        scroll = QScrollArea()
        scroll.setStyleSheet("background: #fafafa;")
        layout = QVBoxLayout(self)
        layout.setAlignment(Qt.AlignHCenter | Qt.AlignTop)

        width = 720

        path = abs_path('icons/banner 2.png')
        banner = Banner(
            path,
            width=width,
            height=155,
            title="PDASH",
            subtitle=
            "Parallel Distributed Architecture for Data Storage and Sharing")
        banner.setObjectName('banner')

        layout.addWidget(banner)

        # add market title
        layout.addSpacing(15)
        layout.addWidget(Builder().text("Market Products").style(
            "font-size:24px;color:#333333;").build())

        layout.addSpacing(15)
        self.loading = Loading(text='Loading')
        layout.addWidget(self.loading)

        # Product List
        pdsWidget = ProductList(self.products, scroll=False)
        pdsWidget.setObjectName('products_list')
        pdsWidget.setMinimumWidth(width)
        pdsWidget.setMaximumWidth(width)

        layout.addWidget(pdsWidget)
        layout.addStretch(1)
        scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll.setWidgetResizable(True)
        wid = QWidget()
        wid.setLayout(layout)
        wid.setContentsMargins(0, 0, 0, 0)
        scroll.setWidget(wid)

        _layout = QVBoxLayout()
        _layout.setAlignment(Qt.AlignTop)
        _layout.addWidget(scroll)
        # add spacing with bottom
        _layout.addSpacing(30)
        wid.setStyleSheet("""
        """)
        return _layout
Exemplo n.º 3
0
 def ui(self):
     layout = QVBoxLayout(self)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QQuickWidget(self)
     widget.setContentsMargins(0, 0, 0, 0)
     widget.rootContext().setContextProperty('self', self.obj)
     widget.setSource(QtCore.QUrl(self.qml))
     layout.addWidget(widget)
     pdsWidget = ProductList(self.products)
     layout.addWidget(pdsWidget)
     return layout
Exemplo n.º 4
0
    def ui(self):
        layout = QVBoxLayout(self)
        layout.setAlignment(Qt.AlignHCenter | Qt.AlignTop)

        width = 750

        path = abs_path('icons/banner 2.png')
        banner = Banner(
            path,
            width=720,
            height=155,
            title="PDASH",
            subtitle=
            "Parallel Distributed Architecture for Data Storage and Sharing")
        banner.setObjectName('banner')
        wrapper_banner = QWidget()
        wrapper_banner.setContentsMargins(0, 0, 0, 0)
        wrapper_layout = QHBoxLayout()
        wrapper_layout.addWidget(banner)
        wrapper_layout.setContentsMargins(0, 0, 0, 0)
        wrapper_banner.setLayout(wrapper_layout)

        wrapper_banner.setMinimumWidth(width)
        wrapper_banner.setMaximumWidth(width)

        layout.addWidget(wrapper_banner)
        layout.addSpacing(15)
        self.loading = Loading(text='Loading')
        layout.addWidget(self.loading)

        # Product List
        pdsWidget = ProductList(self.products)
        pdsWidget.setObjectName('products_list')
        pdsWidget.setMinimumWidth(width)
        pdsWidget.setMaximumWidth(width)
        layout.addWidget(pdsWidget)
        self.setStyleSheet("""
            QWidget#banner {
                
            }
            QScrollArea#market_page {
            }
            QWidget#products_list {
                width: 720;
            }
        """)
        return layout
Exemplo n.º 5
0
    def ui(self):
        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        widget = QQuickWidget(self)
        widget.setContentsMargins(0, 0, 0, 0)
        widget.rootContext().setContextProperty('self', self.obj)
        widget.setSource(QtCore.QUrl(self.qml))
        layout.addWidget(widget)
        pdsWidget = ProductList(self.products)

        width = 750
        pdsWidget.setMinimumWidth(width)
        pdsWidget.setMaximumWidth(width)

        product_layout = QHBoxLayout(self)
        product_layout.setContentsMargins(0, 0, 0, 0)
        product_layout.addSpacing(30)
        product_layout.addWidget(pdsWidget)
        product_layout.addStretch(1)

        layout.addLayout(product_layout)
        layout.addStretch(1)
        return layout
Exemplo n.º 6
0
    def ui(self, vLayout):
        def buildTable():
            header = {
                'headers': ['Name', 'Location', 'Size', 'Status'],
                'width': [282, 170, 170, 54]
            }
            data = fs.get_file_by_data_type()
            self.table_data.value = data

            def buildProductClickListener(product_id):
                def listener(event):
                    app.router.redirectTo('publish_product',
                                          product_id=product_id)

                return listener

            def itemHandler(data):
                items = []
                items.append(data.name)
                items.append(data.remote_type)
                items.append(str(sizeof_fmt(data.size)))
                status = data.is_published
                wid = QLabel('Published')
                if not status:
                    wid.setText('Publish as product')
                    wid.setStyleSheet("QLabel{color: #006bcf;}")
                    Binder.click(wid, buildProductClickListener(data.id))
                items.append(wid)
                return items

            table = Table(self,
                          header,
                          self.table_data,
                          itemHandler,
                          sort=None)
            table.setObjectName('my_table')
            table.setFixedWidth(800)
            return table

        table = buildTable()
        self.table = table
        self.buildTable = buildTable

        def buildStreamTable():
            def right_menu(row):
                self.menu = QMenu(self.stream_table)
                show_id = QAction('Stream ID', self)

                def open():
                    uri = self.stream_data.value[row].remote_uri
                    name = self.stream_data.value[row].name
                    if uri:
                        try:
                            uri = json.loads(uri)
                            ws_url = uri.get('ws_url')
                            dlg = StreamUploadedDialog(data_name=name,
                                                       stream_id=ws_url)
                            dlg.show()
                        except Exception as e:
                            logger.debug(uri)
                            logger.error(e)

                show_id.triggered.connect(lambda: open())
                self.menu.addAction(show_id)
                self.menu.popup(QCursor.pos())
                self.menu.setStyleSheet("""
                    QMenu::item::selected {
                        color: #666;
                    }
                """)

            header = {
                'headers': ['Name', 'Location', 'Status'],
                'width': [327, 295, 54]
            }
            data = fs.get_file_by_data_type('stream')
            self.stream_data.value = data

            def buildProductClickListener(product_id):
                def listener(event):
                    app.router.redirectTo('publish_product',
                                          product_id=product_id,
                                          type_='stream')

                return listener

            def itemHandler(data):
                items = []
                items.append(data.name)
                items.append(data.remote_type)
                status = data.is_published
                wid = QLabel('Published')
                if not status:
                    wid.setText('Publish as product')
                    wid.setStyleSheet("QLabel{color: #006bcf;}")
                    Binder.click(wid, buildProductClickListener(data.id))
                items.append(wid)
                return items

            table = Table(self,
                          header,
                          self.stream_data,
                          itemHandler,
                          sort=None)
            table.setObjectName('my_table')
            table.setFixedWidth(800)

            def record_check(item):
                right_menu(item.row())

            table.itemClicked.connect(record_check)
            return table

        stream_table = buildStreamTable()
        self.stream_table = stream_table
        self.buildStreamTable = buildStreamTable

        self.addH(
            Button.Builder(width=150, height=30).style('primary').name(
                'btn').text('Upload Batch Data').click(
                    self.onClickUpload).build(), 6)
        self.addH(
            Button.Builder(
                width=180,
                height=30).name('btn').text('Upload Streaming Data').click(
                    self.onClickStreamUpload).build())
        self.add(space=10)

        # Line
        self.add(Line(wid=1, color="#dadada"), 20)

        # My Product
        self.add(Builder().text('My Product').name('label_hint').build())

        # Product List
        pdsWidget = ProductList(self.products, scroll=False)
        width = 750
        height = 200
        pdsWidget.setMinimumWidth(width)
        pdsWidget.setMaximumWidth(width)
        self.addH(pdsWidget, align=Qt.AlignTop | Qt.AlignHCenter)

        # Batch Data
        self.add(Builder().text('Batch Data').name('label_hint').build())
        self.add(table)

        if len(self.table_data.value) == 0:
            # No Data
            self.add(Builder().text('0 Batch Data!').name('no_data').build())

        # Stream Data
        self.add(Builder().text('Streaming Data').name('label_hint').build())
        self.add(stream_table)

        if len(self.stream_data.value) == 0:
            # No Data
            self.add(
                Builder().text('0 Streaming Data!').name('no_data').build())
        vLayout.addSpacing(100)
        vLayout.addStretch(1)
        return vLayout