hide peers
This commit is contained in:
parent
ad2d763fbb
commit
dad9b53b54
4 changed files with 114 additions and 5 deletions
|
@ -368,6 +368,7 @@
|
||||||
"showFilters": true,
|
"showFilters": true,
|
||||||
"showIconInfo": true,
|
"showIconInfo": true,
|
||||||
"showInfo": true,
|
"showInfo": true,
|
||||||
|
"showPeers": true,
|
||||||
"showSection": {
|
"showSection": {
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"received": true,
|
"received": true,
|
||||||
|
|
78
oml/annotation/models.py
Normal file
78
oml/annotation/models.py
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from datetime import datetime
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
from sqlalchemy.orm import load_only
|
||||||
|
import ox
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from changelog import add_record
|
||||||
|
from db import MutableDict
|
||||||
|
import db
|
||||||
|
import json_pickler
|
||||||
|
import settings
|
||||||
|
import state
|
||||||
|
import utils
|
||||||
|
import media
|
||||||
|
from websocket import trigger_event
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Annotation(db.Model):
|
||||||
|
__tablename__ = 'annotation'
|
||||||
|
|
||||||
|
_id = sa.Column(sa.Integer(), primary_key=True)
|
||||||
|
id = sa.Column(sa.String(43))
|
||||||
|
created = sa.Column(sa.DateTime())
|
||||||
|
modified = sa.Column(sa.DateTime())
|
||||||
|
|
||||||
|
user = sa.orm.relationship('User', backref=sa.orm.backref('annotations', lazy='dynamic'))
|
||||||
|
item = sa.orm.relationship('Item', backref=sa.orm.backref('items', lazy='dynamic'))
|
||||||
|
data = sa.Column(MutableDict.as_mutable(sa.PickleType(pickler=json_pickler)))
|
||||||
|
|
||||||
|
def __init__(self, item_id, user_id, data):
|
||||||
|
self.created = datetime.utcnow()
|
||||||
|
self.modified = datetime.utcnow()
|
||||||
|
self.item_id = item_id
|
||||||
|
self.user_id = user_id
|
||||||
|
self.data = data
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create(cls, **kwargs):
|
||||||
|
a = cls(**kwargs)
|
||||||
|
state.db.session.add(a)
|
||||||
|
state.db.session.commit()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get(cls, user, item_id, annotation_id):
|
||||||
|
for a in cls.query.filter_by(item_id=item_id, user=user, _id=annotation_id):
|
||||||
|
if a.data.get('id') == annotation_id:
|
||||||
|
return a
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_by_item(cls, user, item_id):
|
||||||
|
annotations = []
|
||||||
|
for a in cls.query.filter_by(item_id=item_id):
|
||||||
|
annotations.append(a.json())
|
||||||
|
return annotations
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
_id = self.data.get('id')
|
||||||
|
if _id:
|
||||||
|
self._id = _id
|
||||||
|
state.db.session.add(self)
|
||||||
|
state.db.session.commit()
|
||||||
|
|
||||||
|
def json(self):
|
||||||
|
data = self.data.copy()
|
||||||
|
data['created'] = self.created
|
||||||
|
data['modified'] = self.modified
|
||||||
|
data['user'] = self.user_id
|
||||||
|
data['_id'] = ox.toAZ(self.id)
|
||||||
|
return data
|
||||||
|
|
|
@ -20,6 +20,9 @@ oml.ui.folders = function() {
|
||||||
oml_showfolder: function() {
|
oml_showfolder: function() {
|
||||||
oml.resizeListFolders();
|
oml.resizeListFolders();
|
||||||
},
|
},
|
||||||
|
oml_showpeers: function() {
|
||||||
|
that.updateElement();
|
||||||
|
},
|
||||||
oml_showinfo: function() {
|
oml_showinfo: function() {
|
||||||
oml.resizeListFolders();
|
oml.resizeListFolders();
|
||||||
}
|
}
|
||||||
|
@ -48,9 +51,15 @@ oml.ui.folders = function() {
|
||||||
|
|
||||||
function getUsersAndLists(callback) {
|
function getUsersAndLists(callback) {
|
||||||
oml.getUsers(function(users_) {
|
oml.getUsers(function(users_) {
|
||||||
|
if (ui.showPeers) {
|
||||||
users = users_.filter(function(user) {
|
users = users_.filter(function(user) {
|
||||||
return user.id == oml.user.id || user.peered;
|
return user.id == oml.user.id || user.peered;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
users = users_.filter(function(user) {
|
||||||
|
return user.id == oml.user.id;
|
||||||
|
});
|
||||||
|
}
|
||||||
oml.getLists(function(lists) {
|
oml.getLists(function(lists) {
|
||||||
callback(users, lists);
|
callback(users, lists);
|
||||||
});
|
});
|
||||||
|
|
|
@ -214,6 +214,12 @@ oml.ui.mainMenu = function() {
|
||||||
title: Ox._((ui.showSidebar ? 'Hide' : 'Show') + ' Sidebar'),
|
title: Ox._((ui.showSidebar ? 'Hide' : 'Show') + ' Sidebar'),
|
||||||
keyboard: 'shift s'
|
keyboard: 'shift s'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'showpeers',
|
||||||
|
title: Ox._((ui.showPeers ? 'Hide' : 'Show') + ' Peers'),
|
||||||
|
keyboard: 'shift p',
|
||||||
|
disabled: !ui.showSidebar
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'showinfo',
|
id: 'showinfo',
|
||||||
title: Ox._((ui.showInfo ? 'Hide' : 'Show') + ' Info'),
|
title: Ox._((ui.showInfo ? 'Hide' : 'Show') + ' Info'),
|
||||||
|
@ -539,6 +545,8 @@ oml.ui.mainMenu = function() {
|
||||||
oml.history.clear();
|
oml.history.clear();
|
||||||
} else if (id == 'showsidebar') {
|
} else if (id == 'showsidebar') {
|
||||||
oml.UI.set({showSidebar: !ui.showSidebar});
|
oml.UI.set({showSidebar: !ui.showSidebar});
|
||||||
|
} else if (id == 'showpeers') {
|
||||||
|
oml.UI.set({showPeers: !ui.showPeers});
|
||||||
} else if (id == 'showinfo') {
|
} else if (id == 'showinfo') {
|
||||||
oml.UI.set({showInfo: !ui.showInfo});
|
oml.UI.set({showInfo: !ui.showInfo});
|
||||||
} else if (id == 'showfilters') {
|
} else if (id == 'showfilters') {
|
||||||
|
@ -636,12 +644,16 @@ oml.ui.mainMenu = function() {
|
||||||
that[action]('viewMenu_iconsSubmenu_extension');
|
that[action]('viewMenu_iconsSubmenu_extension');
|
||||||
that[action]('viewMenu_iconsSubmenu_size');
|
that[action]('viewMenu_iconsSubmenu_size');
|
||||||
},
|
},
|
||||||
|
oml_showpeers: function(data) {
|
||||||
|
that.setItemTitle('showpeers', Ox._((data.value ? 'Hide' : 'Show') + ' Peers'));
|
||||||
|
},
|
||||||
oml_showinfo: function(data) {
|
oml_showinfo: function(data) {
|
||||||
that.setItemTitle('showinfo', Ox._((data.value ? 'Hide' : 'Show') + ' Info'));
|
that.setItemTitle('showinfo', Ox._((data.value ? 'Hide' : 'Show') + ' Info'));
|
||||||
},
|
},
|
||||||
oml_showsidebar: function(data) {
|
oml_showsidebar: function(data) {
|
||||||
that.setItemTitle('showsidebar', Ox._((data.value ? 'Hide' : 'Show') + ' Sidebar'));
|
that.setItemTitle('showsidebar', Ox._((data.value ? 'Hide' : 'Show') + ' Sidebar'));
|
||||||
that[data.value ? 'enableItem' : 'disableItem']('showinfo');
|
that[data.value ? 'enableItem' : 'disableItem']('showinfo');
|
||||||
|
that[data.value ? 'enableItem' : 'disableItem']('showpeers');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
Ox.Event.bind({
|
Ox.Event.bind({
|
||||||
|
@ -726,8 +738,17 @@ oml.ui.mainMenu = function() {
|
||||||
key_shift_f: function() {
|
key_shift_f: function() {
|
||||||
!ui.item && oml.UI.set({showFilters: !ui.showFilters});
|
!ui.item && oml.UI.set({showFilters: !ui.showFilters});
|
||||||
},
|
},
|
||||||
key_shift_i: function() {
|
key_shift_p: function(event, name, target) {
|
||||||
|
// FIXME: event triggers twice
|
||||||
|
if (target.hasClass('OxFocus')) {
|
||||||
|
ui.showSidebar && oml.UI.set({showPeers: !ui.showPeers});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
key_shift_i: function(event, name, target) {
|
||||||
|
// FIXME: event triggers twice
|
||||||
|
if (target.hasClass('OxFocus')) {
|
||||||
ui.showSidebar && oml.UI.set({showInfo: !ui.showInfo});
|
ui.showSidebar && oml.UI.set({showInfo: !ui.showInfo});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
key_shift_s: function() {
|
key_shift_s: function() {
|
||||||
oml.UI.set({showSidebar: !ui.showSidebar});
|
oml.UI.set({showSidebar: !ui.showSidebar});
|
||||||
|
|
Loading…
Reference in a new issue