Ejemplo n.º 1
0
  def testLinks(self):
    """Make sure all the links are pointed to the correct paths."""
    sidebar = Sidebar(self.driver)

    home_link = sidebar.GetLink(sidebar.HOME_LINK)
    self.assertEquals(PATHS['landing_page_path'],
                      home_link.get_attribute('data-href'))

    users_link = sidebar.GetLink(sidebar.USERS_LINK)
    self.assertEquals(PATHS['user_page_path'],
                      users_link.get_attribute('data-href'))

    proxy_servers_link = sidebar.GetLink(sidebar.PROXY_SERVERS_LINK)
    self.assertEquals(PATHS['proxy_server_list'],
                      proxy_servers_link.get_attribute('data-href'))

    setup_link = sidebar.GetLink(sidebar.SETUP_LINK)
    self.assertEquals(PATHS['setup_oauth_path'],
                      setup_link.get_attribute('data-href'))

    sync_notifications_link = sidebar.GetLink(sidebar.SYNC_NOTIFICATIONS_LINK)
    self.assertEquals(PATHS['sync_top_level_path'],
                      sync_notifications_link.get_attribute('data-href'))

    logout_link = sidebar.GetLink(sidebar.LOGOUT_LINK)
    self.assertEquals(PATHS['logout'], logout_link.get_attribute('data-href'))
Ejemplo n.º 2
0
    def __init__(self):
        Gtk.Window.__init__(self)
        self.connect("destroy", self.on_quit)
        self.set_default_size(1000, 600)
        self.load_css()

        header_bar = Gtk.HeaderBar()
        header_bar.set_show_close_button(True)
        header_bar.props.title = "TVTracker"

        search_button = Gtk.ToggleButton()
        search_icon = Gtk.Image.new_from_icon_name("edit-find-symbolic", 4)

        search_button.add(search_icon)
        header_bar.pack_start(search_button)
        self.set_titlebar(header_bar)

        self.store = Store()

        box = Gtk.Box(Gtk.Orientation.HORIZONTAL)

        self.sidebar = Sidebar(self.store, search_button)
        self.sidebar.connect("notify::selected-show",
                             self.on_navigation_change)

        separator = Gtk.Separator()
        self.show_info = ShowInfo(self.store)
        self.show_info.connect("subscription_changed",
                               self.on_subscription_change)

        box.pack_start(self.sidebar, False, False, 0)
        box.pack_start(separator, False, False, 0)
        box.pack_start(self.show_info, True, True, 0)
        self.add(box)
Ejemplo n.º 3
0
    def __init__(self, buf):
        self.edit_only = buf.worksheet.edit_only

        if not self.edit_only:
            buf.worksheet.sig_chunk_inserted.connect( self.on_chunk_inserted )
            buf.worksheet.sig_chunk_changed.connect( self.on_chunk_changed )
            buf.worksheet.sig_chunk_status_changed.connect( self.on_chunk_status_changed )
            buf.worksheet.sig_chunk_deleted.connect( self.on_chunk_deleted )
            buf.worksheet.sig_state.connect( self.on_notify_state )

            # Track changes to update completion
            buf.connect_after('insert-text', self.on_after_insert_text)
            buf.connect_after('delete-range', self.on_after_delete_range)
            buf.connect_after('end-user-action', self.on_after_end_user_action)

            self.__inserted_in_user_action = False
            self.__deleted_in_user_action = False

        if not self.edit_only:
            self.sidebar = Sidebar()
        else:
            self.sidebar = None

        buf.connect('add-custom-result', self.on_add_custom_result)
        buf.connect('add-sidebar-results', self.on_add_sidebar_results)
        buf.connect('remove-sidebar-results', self.on_remove_sidebar_results)
        buf.connect('pair-location-changed', self.on_pair_location_changed)
            
        gtk.TextView.__init__(self, buf)
        if not self.edit_only:
            self.set_border_window_size(gtk.TEXT_WINDOW_LEFT, LEFT_MARGIN_WIDTH)
        self.set_left_margin(2)

        # Attach a "behavior object" to the view which, by ugly hacks, makes it
        # do simply and reasonable things for cut-and-paste and DND
        sanitize_textview_ipc.sanitize_view(self)

        self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)

        self.__completion_popup = CompletionPopup(self)
        self.__doc_popup = DocPopup()
        self.__mouse_over_object = None
        self.__mouse_over_timeout = None

        self.__mouse_over_start = buf.create_mark(None, buf.get_start_iter(), True)

        self.__arg_highlight_start = None
        self.__arg_highlight_end = None
        buf.connect('mark-set', self.on_mark_set)

        self.__cursor_chunk = None
        self.__scroll_to_result = False
        self.__scroll_to = buf.create_mark(None, buf.get_start_iter(), True)
        self.__scroll_idle = None

        self.__update_sidebar_positions_idle = 0
        self.__pixels_below_buffer = 0
        self.__last_chunk = None

        self.connect('destroy', self.on_destroy)
Ejemplo n.º 4
0
def build():
    ########sizes
    mergins = 20
    win_size = (800, 700)
    top_size = (win_size[0] - 2 * mergins, 30)
    side_size = (100, win_size[1] - top_size[1] - 2 * mergins)
    word_size = (win_size[0] - mergins * 2 - side_size[0], 80)

    #####coordinates
    top_cord = (mergins, mergins)
    side_cord = (mergins, mergins + top_size[1])
    word_cord = (side_size[0] + mergins, mergins + top_size[1])
    #####initializing
    pygame.init()
    screen = pygame.display.set_mode(win_size)
    #####
    buttons = [
        Button(text="Quit"),
        Button(text="Setup"),
        Button(text="Depth")
    ]
    side_bar = Sidebar(side_cord,
                       w=side_size[0],
                       h=side_size[1],
                       buttons=buttons)
    #####
    top_bar = topbar.topBar(top_size, pos=top_cord)
    #####
    word_bar = topbar.word(word_size, "word", pos=word_cord)
    clock = pygame.time.Clock()

    #####
    exit = False
    while not exit:
        e = pygame.event.wait()
        if e.type == pygame.QUIT:
            exit = True

        cntnr = pygame.Surface(
            (win_size[0] - 2 * mergins + 4, win_size[1] - 2 * mergins + 4))
        ####
        import random
        r = random.randint(23, 150)
        g = random.randint(23, 150)
        b = random.randint(23, 150)
        ####
        cntnr.fill((r, g, b))
        side_surf = side_bar.draw_buttons()
        screen.blit(cntnr, (mergins - 2, mergins - 2))
        screen.blit(top_bar, top_cord)
        screen.blit(side_surf, side_cord)
        screen.blit(word_bar, word_cord)
        pygame.display.update()
        clock.tick(40)

    pygame.quit()
Ejemplo n.º 5
0
  async def create_html(resource: str) -> str:
    template_uri = HTML_PATH_MAPPINGS[resource]
    main_template_task = asyncio.create_task(fetch_file_txt(file=template_uri, metric=MAIN_SITE_METRIC, from_disk=True))
    sidebar_task = asyncio.create_task(Sidebar(template_uri=os.environ['SIDEBAR_URI']).get())
    main_injections = ASSET_REPLACEMENTS
    main_template = await main_template_task
    main_html = inject(main_template, main_injections)
    sidebar_html = await sidebar_task

    html = main_html.replace('{SIDEBAR_ITEMS}', sidebar_html)

    return html
Ejemplo n.º 6
0
	def __init__(self, image, master=None ):
		super().__init__(master)

		self.master = master	
		self.imagePath = image
		self.resize = True

		self.canvas_config()
		self.master.width = self.width
		self.master.height = self.height

		sidebar = Sidebar(self.master, self.canvas)
		self.keybinds()
Ejemplo n.º 7
0
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        self.heading = tk.Label(self,
                                text="Products",
                                background="lightgrey",
                                pady="5")
        self.heading.pack(side="top", fill="x")
        self.sidebar = Sidebar(self, "Products")
        self.sidebar.pack(side="left", fill="y")
        self.main = tk.Frame(master=self)
        self.productsList = createListFrame(self.main, "Products",
                                            productModule.getAllProducts(),
                                            "No Products", "Change Product",
                                            self.changeProduct, [])

        self.productAdd = tk.Frame(master=self.main, padx=30, pady=100)
        self.productAddInit()
        self.switchMain("Product List")
Ejemplo n.º 8
0
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        self.heading = tk.Label(self,
                                text="Invoices",
                                background="lightgrey",
                                pady="5")
        self.heading.pack(side="top", fill="x")
        self.sidebar = Sidebar(self, "Invoices")
        self.sidebar.pack(side="left", fill="y")
        self.main = tk.Frame(master=self)
        self.invoicesList = tk.Frame()
        self.updateList("unpaid")

        self.invoiceAdd = tk.Frame(master=self.main, padx=30, pady=30)
        self.invoiceAddInit()
        self.products = {}
        self.productList = tk.Frame(master=self.main, padx=30, pady=30)
        self.invoiceProductList()
        self.switchMain("Current Invoices")
Ejemplo n.º 9
0
    def initUI(self):
        self.setWindowTitle('Chess')
        self.resize(700, 500)

        layout = QHBoxLayout()

        playingFiled = Board()
        playingFiled.setObjectName("boardPlayer")
        playingFiled.createBord()
        sidebar = Sidebar()

        layout.addWidget(playingFiled,
                         3)  # Takes 3 times more space than sidebar
        layout.addWidget(sidebar, 1)

        self.setCentralWidget(QWidget())
        self.centralWidget().setLayout(layout)

        playingFiled.playerChanged.connect(sidebar.TimePanel.boardSays)
        self.show()
Ejemplo n.º 10
0
    def __init__(self):
        QPlainTextEdit.__init__(self)
        self.position_margin = QFontMetricsF(
            self.document().defaultFont()).width("#") * 80
        # Margin line
        self._margin = False
        # Sidebar
        self.sidebar = Sidebar(self)
        # Highlight current line
        self._color_current_line = QColor('lightblue')
        self._alpha_current_line = self._color_current_line.setAlpha(50)
        # Connection
        self.connect(self, SIGNAL("blockCountChanged(int)"),
                     self.sidebar.update_area_width)
        self.connect(self, SIGNAL("updateRequest(const QRect&, int)"),
                     self.sidebar.update_area)
        self.connect(self, SIGNAL("cursorPositionChanged()"),
                     self._highlight_current_line)

        self._highlight_current_line()
Ejemplo n.º 11
0
    def __init__(self, s):
        self.board_ = Board(s.boardsize_)

        self.robots_ = []
        for i in range(s.robots_):
            self.robots_.append(
                Robot(COLORS[i], rd(s.boardsize_), rd(s.boardsize_)))
        Robot.validate_positions(self.board_, self.robots_)

        self.target_ = Target(s.boardsize_, self.board_, self.robots_)

        if (s.test_rounds_ > 0):
            self.test_rounds_ = s.test_rounds_
        else:
            self.test_rounds_ = 0

        self.players_ = s.assign_players()

        self.graphics_ = GraphicalBoard(s.boardsize_)
        self.sidebar_ = Sidebar(self.graphics_, self.players_)
        self.games_to_win_ = 7
Ejemplo n.º 12
0
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        self.heading = tk.Label(self,
                                text="Clients",
                                background="lightgrey",
                                pady="5")
        self.heading.pack(side="top", fill="x")
        self.sidebar = Sidebar(self, "Clients")
        self.sidebar.pack(side="left", fill="y")
        self.main = tk.Frame(master=self)

        self.clientList = createListFrame(self.main, "Clients",
                                          clientModule.get_all_clients(),
                                          "No Clients", "See Invoices",
                                          self.clientInvoiceView, [])

        self.clientAdd = tk.Frame(master=self.main, padx=30, pady=100)
        self.clientAddInit()

        self.clientView = tk.Frame(master=self.main)

        self.switchMain("Client List")
    def __init__(self):
        wx.Frame.__init__(self, None, title='OpenVPN Connector')

        self.CreateStatusBar()
        #Create multi-panel UI
        self.mainpanel = wx.Panel(self)
        mainsizer = wx.BoxSizer(wx.VERTICAL)
        splitter = wx.SplitterWindow(self.mainpanel)  #horizontal
        subsplitter = wx.SplitterWindow(splitter)  #vertical
        self.subsplitter = subsplitter
        # top_sizer = wx.BoxSizer(wx.HORIZONTAL)
        # top_panel = wx.Panel(subsplitter)

        self.sidebar = Sidebar(subsplitter)
        sidebarMenu = [("Configs", Configs), ("Command Flags", Flags),
                       ("Preferences", Preferences)]

        self.subpanels = {}
        for name, pnl in sidebarMenu:
            panel = pnl(self.subsplitter)
            panel.Hide()
            # top_sizer.Add(panel, 2, wx.ALL|wx.EXPAND, 2)
            self.subpanels[name] = panel
        self.subpanels["Configs"].Show()
        # self.currentpanel = self.subpanels["Configs"]
        # top_panelthe.SetSizer(top_sizer)

        #the bottom_sizer contains buttons and controls
        bottom_sizer = wx.BoxSizer(wx.HORIZONTAL)
        bottom_panel = wx.Panel(splitter)

        txt = Output(bottom_panel)

        control_grid = wx.GridSizer(cols=3)
        for label in [
                "Clear", "Export", "Reconnect", "Disconnect", "Force Reconnect"
        ]:
            btn = wx.Button(bottom_panel, label=label)
            btn.Bind(wx.EVT_BUTTON, self.OnButton)
            control_grid.Add(btn, 0, wx.ALL | wx.EXPAND, 2)
        # self.text = wx.StaticText(bottom_panel,label="Connection: None")
        # bottom_sizer.Add(self.text, 5, wx.ALL|wx.EXPAND, 2)

        bottom_sizer.Add(txt, 2, wx.ALL | wx.EXPAND, 2)
        bottom_sizer.Add(control_grid, 1, wx.ALL | wx.EXPAND, 2)
        bottom_panel.SetSizer(bottom_sizer)

        # mainsizer.Add(top_panel, 3, wx.ALL|wx.EXPAND, 0)
        # mainsizer.Add(bottom_panel, 1, wx.ALL|wx.EXPAND, 0)

        subsplitter.SplitVertically(self.sidebar, self.subpanels["Configs"])
        subsplitter.SetSashGravity(0.3)
        splitter.SplitHorizontally(subsplitter, bottom_panel)
        splitter.SetSashGravity(0.7)

        # mainsizer.Add(subsplitter, 1, wx.ALL|wx.EXPAND, 0)
        mainsizer.Add(splitter, 1, wx.ALL | wx.EXPAND, 5)
        self.mainsizer = mainsizer
        self.mainpanel.SetSizer(mainsizer)
        self.mainsizer.Fit(self)
        self.SetMinSize(self.GetBestSize())
        self.Show()

        # if reconnect == "1":
        # self.on.Disable()
        # if lastconnection != "0":
        # print("connecting to last used connection")
        # SubCall(lastconnection)
        # else:
        # self.off.Disable()

        #pub-sub
        pub.subscribe(self.DoConnect, "DoConnect")
        pub.subscribe(self.PubSubChangeMainPanel, "PubSubChangeMainPanel")

        #Timers
        self.log_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnLogTimer, self.log_timer)
        self.log_read = 0
Ejemplo n.º 14
0
  def __init__(self,screen,backend = {}):
    self.screen = screen;
    self.screen_lock = thread.allocate()
    self.draw_skeleton = True
    self.video_display = False
    self.dispInfo = pygame.display.Info()
    self.skeleton_to_depth_image = nui.SkeletonEngine.skeleton_to_depth_image
    self.control_words = ['pause','run','quit','repeat',"train",'test']
    self.paused = False;
    self.skeletons = None
    self.DEPTH_WINSIZE = 320,240
    self.VIDEO_WINSIZE = 640,480
    self.skeletal_map = []
    self.state = self.SETUP;
    self.mode = self.TRAINING;
    self.backend = backend;
    self.wordlist = CircularArray(backend['words'])
    self.word = "None"
    self.test_word = self.wordlist.roll()
    self.backend_wait = True;
    self.show_depth = False;
    ####
    if self.video_display:
      size = self.dispInfo.current_w-self.VIDEO_WINSIZE[0];
    else:
      size = self.dispInfo.current_w-self.DEPTH_WINSIZE[0];
    size = size + 100
    #self.clock_image = resize((size,size), ou_img="ui/images/_clock.gif");
    self.sent_data = False;
    self.use_speech = True;
    self.repeat = False
    self.camera_surf = pygame.Surface(self.DEPTH_WINSIZE)
    
    
    ##########
    self.counter = self.READY_COUNTER;
    self.action = Text(self.screen,w=100, h=50,pos=(485,0),text=self.test_word[0],color=THECOLORS['white']);
    self.count = Text(self.screen,w=100, h=100,pos=(485,55),text=str(self.counter),color=THECOLORS['white']);

    ####general state display paramters
    self.mergin_side = 20;
    self.mergin_top = 20;
    ###top bar
    self.top_bar_size = (self.dispInfo.current_w-2*self.mergin_side,70);
    self.topbar_pos = (self.mergin_side,self.mergin_side)
    self.topbar = bars.topBar(self.top_bar_size,pos=self.topbar_pos);
    ###side bar
    self.side_bar_w = 100;
    self.side_bar_h = self.dispInfo.current_h-self.mergin_top*2-self.top_bar_size[1];
    self.side_bar_pos = (self.mergin_side,self.top_bar_size[1]+self.mergin_top);
    ###word bar
    w = self.dispInfo.current_w-self.side_bar_w-2*self.mergin_side
    self.word_bar_size = (w,70);
    self.word_bar_pos = (self.mergin_side+self.side_bar_w,self.mergin_side+self.top_bar_size[1])
    
    ###camera feedback pos
    self.camera_feed_pos = (self.mergin_side+self.side_bar_w,self.word_bar_pos[1]+self.word_bar_size[1]);
    ####SETUP display parameters
    self.train_button_pos = (100,100);
    self.train_button = Button(pos=self.train_button_pos,text="TRAINING");
    #++++++++++
    self.user_button_pos = (100,210);
    #++++++++
    self.depth_button = Button(text="DEPTH")
    #++++++
    self.user_button = Button(pos=self.user_button_pos,text="USER");
    self.setup_sidebar = Sidebar(self.side_bar_pos,w=self.side_bar_w,h=self.side_bar_h,buttons=[self.train_button,self.user_button,self.depth_button])
    self.setup_sidebar_surf = self.setup_sidebar.draw_buttons()

    ###Text input
    self.text_in_h = 40;
    self.text_in_w = 100;
    self.text_in_pos = (self.camera_feed_pos[0]+self.DEPTH_WINSIZE[0]+10,self.camera_feed_pos[1])
    self.text_input = InputBox(self.text_in_pos[0], self.text_in_pos[1], self.text_in_w, self.text_in_h)
    ####READY display parameters
    self.quit_button = Button(text="QUIT");
    #++++++++++
    self.setup_button = Button(text="SETUP");
    #++++++
    self.puase_button = Button(text="PAUSE");
    #++++++

    self.sidar_bar = Sidebar(self.side_bar_pos,w=self.side_bar_w,h=self.side_bar_h,buttons=[self.quit_button,self.puase_button,self.setup_button,self.depth_button])
    self.sidebar_surf = self.sidar_bar.draw_buttons()
    #++++++
    #self.clock_pos = (self.camera_feed_pos[0]+self.DEPTH_WINSIZE[0]+10,self.camera_feed_pos[1]+self.text_in_h)
    self.clock_pos = (self.camera_feed_pos[0]+self.DEPTH_WINSIZE[0]+70,self.camera_feed_pos[1])
    self.clock = Clock(size=self.DEPTH_WINSIZE[1] + 30);
    ####RECODRING display parameters 
    

    ####FEEDBACK parameters
    self.feedback_bar_pos=(self.word_bar_pos[0], self.camera_feed_pos[1]+self.DEPTH_WINSIZE[1]+10);
    self.feedback_bar_size = self.word_bar_size;


    
   
    self.speech_thread = SpeechTrigger(self);
    self.listen = False;
    ###
    self.ctl_word_size = 40;
    self.ctl_pose = self.camera_feed_pos[0],self.camera_feed_pos[1]+self.DEPTH_WINSIZE[1]+30
    self.ctl_size = self.word_bar_size[0],300
    self.clt_words=ControlWords(self.WORDS,font_size=self.ctl_word_size,pose=self.ctl_pose,size=self.ctl_size)
    self.setup_clt_words=ControlWords(self.SETUP_WORDS,font_size=self.ctl_word_size,pose=self.ctl_pose,size=self.ctl_size)
    self.ctl_surf = self.clt_words.show()
    self.setup_ctl_surf=self.setup_clt_words.show()

    ### Feedback bars
    self.congrats_bar = bars.congrats(self.feedback_bar_size,pos = self.feedback_bar_pos);
    self.no_data_bar = bars.noData(self.feedback_bar_size,pos = self.feedback_bar_pos);
    self.processing_bar = bars.processing(self.feedback_bar_size,pos = self.feedback_bar_pos)
    self.gogo_bar = bars.gogo(size=(self.clock.size, self.clock.size),pos=self.clock_pos);
    self.correct_word_pos = (self.feedback_bar_pos[0],(self.feedback_bar_pos[1]+self.feedback_bar_size[1]))
    ####Test words
    self.train_bars = mappers.trainer_vocab_display_mapper(self);
    self.test_bars = mappers.test__vocab_display_mapper(self);
    self.sorry_bar_mapper = mappers.sorry_bar_mapper(self);
    self.correct_word_bar = mappers.correct__word_display_mapper(self);
Ejemplo n.º 15
0
    def __init__(self, params, **kw):

        super(ViewForm, self).__init__(**kw)

        # save reference of params dictionary in requeste
        cherrypy.request.terp_params = params
        cherrypy.request.terp_fields = []

        editable = params.editable
        readonly = params.readonly

        if editable is None:
            editable = True

        if readonly is None:
            readonly = False

        self.screen = Screen(prefix='',
                             hastoolbar=True,
                             editable=editable,
                             readonly=readonly,
                             selectable=params.selectable or 2)

        self.sidebar = Sidebar(self.screen.model,
                               self.screen.toolbar,
                               self.screen.id,
                               self.screen.view_type,
                               context=self.screen.context)

        self.is_dashboard = getattr(cherrypy.request, '_terp_dashboard', False)

        self.search = None

        if params.view_type in ('tree', 'graph'):
            self.search = Search(model=params.model,
                                 domain=params.domain,
                                 context=params.context,
                                 values=params.search_data or {})

        if params.view_type == 'tree':
            self.screen.id = False

        if 'form' not in self.screen.view_mode:
            self.screen.widget.show_links = 0
            self.screen.widget.link = 0
            self.screen.editable = False
            self.screen.widget.editable = False

        # get the correct view title
        if params.context:
            self.screen.string = params.context.get('_terp_view_name',
                                                    self.screen.string)
        self.screen.string = self.screen.string

        # get the actual pager data
        self.limit = self.screen.limit
        self.offset = self.screen.offset
        self.count = self.screen.count

        self.search_domain = params.search_domain
        self.search_data = params.search_data

        if params.hidden_fields:
            self.hidden_fields = params.hidden_fields
    def __init__(self, params, **kw):

        super(ViewForm, self).__init__(**kw)

        # save reference of params dictionary in requeste
        cherrypy.request.terp_params = params
        cherrypy.request.terp_fields = []
        self.notebook_tab = params.notebook_tab or 0
        self.context_menu = params.get('context_menu')
        editable = params.editable
        readonly = params.readonly

        if editable is None:
            editable = True

        if readonly is None:
            readonly = False

        self.is_dashboard = getattr(cherrypy.request, '_terp_dashboard', False)

        self.search = None
        search_param = params.search_domain or []
        params_domain = params.domain or []
        for element in params_domain:
            if element not in search_param:
                if not isinstance(element, tuple):
                    search_param.append(element)
                else:
                    key, op, value = element
                    search_param.append((key, op, value))

        cherrypy.request.custom_search_domain = []
        cherrypy.request.custom_filter_domain = []

        if params.view_type in ('tree', 'graph'):
            search_view_id = False
            if params and '_terp_search_view' in params:
                if not params.search_view and params.context:
                    search_view_id = params.context.get('search_view')

            self.search = Search(source=params.source,
                                 model=params.model,
                                 domain=search_param,
                                 context=params.context,
                                 values=params.search_data or {},
                                 filter_domain=params.filter_domain or [],
                                 search_view=params.search_view,
                                 group_by_ctx=params.group_by_ctx or [],
                                 **{
                                     'clear': params.get('_terp_clear'),
                                     'search_view_id': search_view_id
                                 })

            cherrypy.request.custom_search_domain = self.search.listof_domain or []
            cherrypy.request.custom_filter_domain = self.search.custom_filter_domain or []
            params.search_domain = self.search.listof_domain
            params.filter_domain = self.search.custom_filter_domain
            params.group_by_ctx = self.search.groupby

        self.screen = Screen(prefix='',
                             hastoolbar=True,
                             hassubmenu=True,
                             editable=editable,
                             readonly=readonly,
                             selectable=params.selectable or 2)

        if self.screen.widget and self.screen.view_type in ['form', 'tree']:
            self.logs = Logs()

        if self.screen.widget and hasattr(self.screen.widget, 'sidebar'):
            self.sidebar = self.screen.widget.sidebar
        else:
            if params.target != 'new' and not self.screen.is_dashboard and not self.screen.is_wizard and (
                    len(params.view_mode) > 1 or 'tree' in params.view_mode):
                self.sidebar = Sidebar(self.screen.model,
                                       self.screen.submenu,
                                       self.screen.toolbar,
                                       self.screen.id,
                                       self.screen.view_type,
                                       context=self.screen.context)

        if params.view_type == 'tree':
            self.screen.id = False

        if 'form' not in self.screen.view_mode and not isinstance(
                self.screen.widget, ListGroup):
            self.screen.widget.link = 0
            self.screen.editable = False
            self.screen.widget.editable = False

        # get the correct view title
        if params.context:
            self.screen.string = params.context.get('_terp_view_name',
                                                    self.screen.string)
        self.screen.string = self.screen.string

        # get the actual pager data
        self.limit = self.screen.limit
        self.offset = self.screen.offset
        self.count = self.screen.count

        self.search_domain = params.search_domain
        self.search_data = params.search_data
        self.filter_domain = params.filter_domain or []

        if params.hidden_fields:
            self.hidden_fields = params.hidden_fields
Ejemplo n.º 17
0
    def __init__(self, view, model, res_id=False, domain=[], context={}, action=None, fields=None):
        super(ViewTree, self).__init__(name='view_tree', action=action)

        self.model = view['model']
        self.domain2 = domain or []
        self.context = context or {}
        self.domain = []
        
        fields_info = dict(fields)

        self.field_parent = view.get("field_parent") or None

        if self.field_parent:
            self.domain = domain

        self.view = view
        self.view_id = view['view_id']

        proxy = rpc.RPCProxy(self.model)

        ctx = dict(self.context,
                   **rpc.session.context)
                
        dom = xml.dom.minidom.parseString(view['arch'].encode('utf-8'))

        root = dom.childNodes[0]
        attrs = node_attributes(root)
        self.string = attrs.get('string', 'Unknown')
        self.toolbar = attrs.get('toolbar', False)

        ids = []
        id = res_id
        
        colors = {}
        for color_spec in attrs.get('colors', '').split(';'):
            if color_spec:
                colour, test = color_spec.split(':')
                colors[colour] = test
                
        if self.toolbar:
            ids = proxy.search(self.domain2, 0, 0, 0, ctx)
            self.toolbar = proxy.read(ids, ['name', 'icon'], ctx)

            if not id and ids:
                id = ids[0]

            if id:
                ids = proxy.read([id], [self.field_parent], ctx)[0][self.field_parent]
        elif not ids:
            ids = proxy.search(domain, 0, 0, 0, ctx)

        self.headers = []
        self.parse(root, fields)

        self.tree = treegrid.TreeGrid(name="tree_%d" % (id),
                                      model=self.model,
                                      headers=self.headers,
                                      url=url("/openerp/tree/data"),
                                      ids=ids,
                                      domain=self.domain,
                                      context=self.context,
                                      field_parent=self.field_parent,
                                      onselection="onSelection",
                                      fields_info=fields_info,
                                      colors=colors)
        self.id = id
        self.ids = ids

        toolbar = {}
        for item, value in view.get('toolbar', {}).items():
            if value: toolbar[item] = value
        if toolbar:
            self.sidebar = Sidebar(self.model, None, toolbar, context=self.context)

        # get the correct view title
        self.string = self.context.get('_terp_view_name', self.string) or self.string
Ejemplo n.º 18
0
import dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html

from navbar import Navbar
from sidebar import Sidebar
from dashboard import Dashboard

nav = Navbar()
side = Sidebar()
dashboard = Dashboard()

body = dbc.Container(
    [
        dbc.Row([
                    dbc.Col(html.Div(side), lg=2),
                    dbc.Col(html.Div(dashboard)),
        ])
    ],
    fluid=True
)


def Homepage():
    layout = html.Div([
    nav,
    body
    ])
    return layout