Ejemplo n.º 1
0
def insert(request):
    data = yield from request.post()

    node_id = yield from storage.get_storage().insert(
        data.get('text', None),
        data.get('parent', None)
    )

    node = yield from storage.get_storage().get_node(node_id)

    return json_response(node)
Ejemplo n.º 2
0
def init(loop):
    app = web.Application(middlewares=[
        session_middleware(EncryptedCookieStorage(conf.SECRET)),
        auth.auth_middleware,
    ])
    aiohttp_jinja2.setup(
        app,
        context_processors=[context.static,
                            aiohttp_jinja2.request_processor],
        loader=jinja2.FileSystemLoader(conf.relative('templates'))
    )

    yield from get_storage().init_storage()

    if conf.DEBUG:
        app.router.add_static(conf.STATIC_URL, conf.STATIC_PATH)

    for _ in urls.urls:
        url, view, methods = (_ + (['GET', ], ))[:3]
        for method in methods:
            app.router.add_route(method, url, view)

    srv = yield from loop.create_server(
        app.make_handler(),
        '127.0.0.1', 8080
    )
    print("Server started at http://127.0.0.1:8080")
    return srv
Ejemplo n.º 3
0
def subtree(request):
    node = request.GET.get('node')
    items = yield from storage.get_storage().subtree(node)
    return json_response(items)
Ejemplo n.º 4
0
def search(request):
    query = request.GET.get('query', None)
    items = yield from storage.get_storage().search(query)
    return json_response(items)
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        super(AddVolume, self).__init__(parent)

        self.storage = get_storage()

        self.main_layout = QVBoxLayout(self)

        #--- main form
        form = QGridLayout()

        self.edit_path = QLineEdit()
        self.btn_select_path = QPushButton(icons.get_icon(icons.I_OPEN_FOLDER),
                                           "")
        self.btn_select_path.clicked.connect(self.__show_select_dir)

        self.edit_vname = QLineEdit()

        self.edit_icon = QComboBox()
        for vtype in VOLUME_TYPE:
            self.edit_icon.addItem(icons.get_volume_icon(vtype), vtype)

        self.edit_description = QTextEdit()
        self.edit_description.setMaximumHeight(100)
        self.edit_progress = QProgressBar()

        row = 0
        form.addWidget(QLabel("Каталог: "), row, 0, Qt.AlignRight)
        form.addWidget(self.edit_path, row, 1)
        form.addWidget(self.btn_select_path, row, 2)

        row += 1
        form.addWidget(QLabel("Название тома: "), row, 0, Qt.AlignRight)
        form.addWidget(self.edit_vname, row, 1, 1, 2)

        row += 1
        form.addWidget(QLabel("Иконка: "), row, 0, Qt.AlignRight)
        form.addWidget(self.edit_icon, row, 1, 1, 2)

        row += 1
        form.addWidget(QLabel("Описание: "), row, 0,
                       Qt.AlignRight | Qt.AlignTop)
        form.addWidget(self.edit_description, row, 1, 1, 2)

        #--- controls
        controls = QHBoxLayout()

        self.btn_quit = QPushButton(icons.get_icon(icons.I_EXIT), "Закрыть")
        self.btn_quit.clicked.connect(self.close)

        self.btn_start = QPushButton(icons.get_icon(icons.I_START), "Запуск")
        self.btn_start.clicked.connect(self.start_action)

        self.label_error = QLabel()

        controls.addWidget(self.btn_start)
        controls.addStretch()
        controls.addWidget(self.btn_quit)

        #--- make layout
        self.main_layout.addLayout(form)
        self.main_layout.addSpacing(20)
        self.main_layout.addWidget(self.edit_progress)
        self.main_layout.addSpacing(20)
        self.main_layout.addWidget(self.label_error)
        self.main_layout.addStretch()
        self.main_layout.addLayout(controls)
Ejemplo n.º 6
0
    def __init__(self, parent, *args, **kwargs):
        super(FList, self).__init__(parent, *args, **kwargs)

        self.nav_bar = NavBar(self)
        self.nav_bar.pack(side="top", fill="x")
        self.nav_bar.set_cb_go(self.__go_history)
        self.nav_bar.set_cb_root(self.__go_root)
        self.nav_bar.cb_show_info = self.__show_info

        self.__sort_dir = False

        # tree_frame = ttk.Frame(self)
        # tree_frame.pack(side="bottom", expand=True, fill="both")

        columns = (
            'size',
            # 'rights', "owner", "group",
            "ctime",
            # "description",
            # "atime", "mtime"
        )
        self.__tree = ttk.Treeview(self,
                                   show="tree headings",
                                   selectmode='browse',
                                   columns=columns)
        # self.__tree.heading("size", text="Размер", command=lambda c="size": self.__sort(c))
        self.__tree.heading("size", text="Размер")
        # self.__tree.heading("rights", text="Права")
        # self.__tree.heading("owner", text="Владелец")
        # self.__tree.heading("group", text="Группа")
        self.__tree.heading("ctime", text="Создание")
        # self.__tree.heading("description", text="Описание")
        # self.__tree.heading("atime", text="Доступ")
        # self.__tree.heading("mtime", text="Модификация")
        self.__tree.heading('#0', text='Название')

        self.__tree.column("#0", minwidth=200, width=200)
        self.__tree.column("size", minwidth=90, width=90)
        # self.__tree.column("rights", minwidth=40, width=50)
        # self.__tree.column("owner", minwidth=80, width=80)
        # self.__tree.column("group", minwidth=80, width=80)
        self.__tree.column("ctime", minwidth=200, width=200)
        # self.__tree.column("description", minwidth=200, width=200, stretch=False)
        # self.__tree.column("atime", minwidth=90, width=90)
        # self.__tree.column("mtime", minwidth=100, width=100)

        # for c in columns:
        # 	self.__tree.heading(c, text=c, command=lambda c=c: self.__sort(c))

        # #--- horizontal scroll
        # xsb = ttk.Scrollbar(self, orient="horizontal", command= self.__tree.xview)
        # self.__tree['xscroll'] = xsb.set
        # xsb.pack(side="bottom", expand=False, fill="x")

        self.__tree.pack(side="left", expand=True, fill="both")

        #--- vertical scroll
        ysb = ttk.Scrollbar(self, orient="vertical", command=self.__tree.yview)
        self.__tree['yscroll'] = ysb.set
        ysb.pack(side="right", expand=False, fill="y", anchor="e")

        self.__tree.column("#0", width=300)
        self.__tree.tag_bind("simple", "<<TreeviewSelect>>", self.__select_row)
        self.__tree.bind("<Double-1>", self.__open_row)
        # self.__tree.tag_bind("simple", "<<TreeviewOpen>>", self.__open_row)
        self.__tree.bind("<Button-3>", self.__make_cmenu)

        self.cmenu = tkinter.Menu(self, tearoff=0)
        self.cmenu.add_command(label="Свойства",
                               command=self.__show_info,
                               image=ticons.ticon(ticons.INFO),
                               compound="left")
        # self.cmenu.add_command(label="Экспорт", command=self.__show_export, image=ticons.ticon(ticons.I_EXPORT), compound="left")
        self.cmenu.add_command(label="Удалить",
                               command=self.__show_remove,
                               image=ticons.ticon(ticons.TRASH),
                               compound="left")
        # self.cmenu.add_command(label="Изменить", command=self.__show_edit, image=self.__icon_menu_edit, compound="left")

        #--- хранилище
        self.storage = get_storage()

        #--- тек. объекты тома и папки
        self.current_vnode = None
        self.current_fnode = None

        self.modal_about = None

        #--- карта загруженных нод для поиска при событиях от дерева
        self.litems = {}

        # dbus.eon(dbus.SHOW_REMOVE_FTREE_OK, self.__on_ftree_removed)

        #--- signals
        self.signal_file_selected = Signal()  # up signal(FNode)
Ejemplo n.º 7
0
    def __init__(self, vnode, master=None, *args, **kwargs):
        super(AboutVolume, self).__init__(master, *args, **kwargs)
        self.title("Свойства тома")

        self.maxsize(450, 350)
        self.minsize(450, 350)

        self.vnode = vnode
        self.vtype = None
        self.storage = get_storage()

        self.main_frame = ttk.Frame(self, padding=10)
        self.main_frame.pack(expand=True, fill="both", side="top")

        edit_frame = ttk.Frame(self.main_frame)
        edit_frame.pack(fill="x", side="top", padx=10, pady=10)

        row = 0
        ttk.Label(edit_frame, text="Название тома: ").grid(row=row,
                                                           column=0,
                                                           sticky="e",
                                                           pady=2,
                                                           padx=5)
        self.volume_name_entry = tkinter.Entry(edit_frame,
                                               width=30,
                                               justify="left")
        self.volume_name_entry.grid(row=row,
                                    column=1,
                                    sticky="w",
                                    pady=2,
                                    padx=5)

        row += 1
        ttk.Label(edit_frame, text="Иконка: ").grid(row=row,
                                                    column=0,
                                                    sticky="e",
                                                    pady=2,
                                                    padx=5)

        frame_icon = ttk.Frame(edit_frame)
        frame_icon.grid(row=row, column=1, sticky="w", pady=2, padx=5)

        self.volume_type_box = ttk.Combobox(frame_icon,
                                            values=VOLUME_TYPE,
                                            state='readonly')
        self.volume_type_box.pack(side="left")
        self.volume_type_box.bind('<<ComboboxSelected>>',
                                  self.__update_volume_vtype)

        self.__label_vtype_icon = ttk.Label(frame_icon, text="icon")
        self.__label_vtype_icon.pack(side="left", padx=10)
        self.__vtype_icon = None

        row += 1
        ttk.Label(edit_frame, text="Создание").grid(row=row,
                                                    column=0,
                                                    sticky="e",
                                                    pady=2,
                                                    padx=5)
        self.__label_created = ttk.Label(edit_frame)
        self.__label_created.grid(row=row,
                                  column=1,
                                  sticky="w",
                                  pady=2,
                                  padx=5)

        row += 1
        ttk.Label(edit_frame, text="Обновление").grid(row=row,
                                                      column=0,
                                                      sticky="e",
                                                      pady=2,
                                                      padx=5)
        self.__label_updated = ttk.Label(edit_frame)
        self.__label_updated.grid(row=row,
                                  column=1,
                                  sticky="w",
                                  pady=2,
                                  padx=5)

        row += 1
        ttk.Label(edit_frame, text="Путь").grid(row=row,
                                                column=0,
                                                sticky="e",
                                                pady=2,
                                                padx=5)
        self.__label_path = ttk.Label(edit_frame)
        self.__label_path.grid(row=row, column=1, sticky="w", pady=2, padx=5)

        row += 1
        ttk.Label(edit_frame, text="Кол-во элементов").grid(row=row,
                                                            column=0,
                                                            sticky="e",
                                                            pady=2,
                                                            padx=5)
        self.__label_elements_count = ttk.Label(edit_frame)
        self.__label_elements_count.grid(row=row,
                                         column=1,
                                         sticky="w",
                                         pady=2,
                                         padx=5)

        #--- edit description field
        frame_description = ttk.Frame(self.main_frame, padding=5)
        frame_description.pack(side="top", expand=True, fill="both")

        ttk.Label(frame_description, text="описание").pack(fill="x",
                                                           side="top")
        self.description = tkinter.Text(frame_description, height=6, width=20)
        self.description.pack(side="left", fill="both", expand=True)

        #- vertical scroll
        ysb = ttk.Scrollbar(frame_description,
                            orient="vertical",
                            command=self.description.yview)
        self.description['yscroll'] = ysb.set
        ysb.pack(side="right", expand=False, fill="y")

        # self.description = tkinter.Text(self.main_frame, height=6, width=20)
        # self.description.pack(side="top", fill="both", expand=True)

        #--- controls
        controls_frame = ttk.Frame(self.main_frame)
        controls_frame.pack(fill="both", side="bottom", padx=5, pady=5)

        ttk.Button(controls_frame,
                   text="Сохранить",
                   command=self.__do_save,
                   image=ticons.ticon(ticons.SAVE),
                   compound="left").pack(side="left")
        ttk.Button(controls_frame,
                   text="Закрыть(Ctrl+w)",
                   command=self.destroy,
                   image=ticons.ticon(ticons.CLOSE),
                   compound="left").pack(side="right")

        self.bind_all("<Control-w>", lambda e: self.destroy())

        self.__init_data()
Ejemplo n.º 8
0
    def __init__(self, master=None, *args, **kwargs):
        super(AboutBase, self).__init__(master, *args, **kwargs)
        self.title("Свойства базы")

        self.maxsize(450, 350)
        self.minsize(450, 350)

        self.storage = get_storage()

        self.main_frame = ttk.Frame(self, padding=10)
        self.main_frame.pack(expand=True, fill="both")

        #--- main info grid
        self.grid = ttk.Frame(self.main_frame)
        self.grid.pack(side="top", expand=True, fill="x")

        self.__current_row = 0
        self.label_path = self.__append_kv_row("путь")
        self.label_size = self.__append_kv_row("размер")
        self.label_version = self.__append_kv_row("версия")
        self.label_created = self.__append_kv_row("создание")
        self.label_updated = self.__append_kv_row("обновление")

        #--- edit description field
        frame_description = ttk.Frame(self.main_frame, padding=5)
        frame_description.pack(side="top", expand=True, fill="both")

        ttk.Label(frame_description, text="описание").pack(fill="x",
                                                           side="top")
        self.description = tkinter.Text(frame_description, height=6, width=20)
        self.description.pack(side="left", fill="both", expand=True)

        #- vertical scroll
        ysb = ttk.Scrollbar(frame_description,
                            orient="vertical",
                            command=self.description.yview)
        self.description['yscroll'] = ysb.set
        ysb.pack(side="right", expand=False, fill="y")

        #--- controls
        controls_frame = ttk.Frame(self.main_frame)
        controls_frame.pack(fill="both", side="bottom", padx=5, pady=5)

        ttk.Button(controls_frame,
                   text="Закрыть(Ctrl+w)",
                   command=self.destroy,
                   image=ticons.ticon(ticons.CLOSE),
                   compound="left").pack(side="right")

        ttk.Button(controls_frame,
                   text="Сохранить",
                   command=self.__do_save,
                   image=ticons.ticon(ticons.SAVE),
                   compound="left").pack(side="left")
        ttk.Button(controls_frame,
                   text="Уплотнить",
                   command=self.do_vacuum,
                   image=ticons.ticon(ticons.I_BOOKMARK),
                   compound="left").pack(side="left")

        self.bind_all("<Control-w>", lambda e: self.destroy())

        #--- start
        self.__load()