Skip to content

Commit

Permalink
Use 'image' as key, not 'images'
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Jun 15, 2014
1 parent 6185ddf commit 81ac72e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ def search(self, query, onlyTypes, fields, searchGroup, ownedBy, date=None):
d1 = datetime.datetime.strptime(p[0]+" 00:00:00", "%Y-%m-%d %H:%M:%S")

def doSearch(searchType):
""" E.g. searchType is 'images' """
objType = searchType[0:-1] # remove 's'
obj_list = list(self.conn.searchObjects([objType], query, created, fields=fields, searchGroup=searchGroup, ownedBy=ownedBy))
""" E.g. searchType is 'image' """
obj_list = list(self.conn.searchObjects([searchType], query, created, fields=fields, searchGroup=searchGroup, ownedBy=ownedBy))

obj_ids = [o.id for o in obj_list]
im_annotation_counter = self.conn.getCollectionCount(objType.title(), "annotationLinks", obj_ids)
im_annotation_counter = self.conn.getCollectionCount(searchType.title(), "annotationLinks", obj_ids)

im_list_with_counters = []
for o in obj_list:
Expand All @@ -99,7 +98,7 @@ def doSearch(searchType):

for dt in onlyTypes:
dt = str(dt)
if dt in ['projects', 'datasets', 'images', 'screens', 'plates']:
if dt in ['project', 'dataset', 'image', 'screen', 'plate']:
self.containers[dt] = doSearch(dt)
resultCount += len(self.containers[dt])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@
beforeSubmit: function(fields) {

// check we have some search query...
var $query = $("input[name='query']");
if ($query.val().length <= 0) {
var $query = $("input[name='query']"),
q = $.trim($query.val());
if (q.length <= 0) {
alert("Search must contains some text.");
return false;
} else if ($query.val().length <= 1 && $query.val().indexOf("*") < 1) {
} else if (q.length <= 1 && q.indexOf("*") < 1) {
alert("Wildcard searches (*) must contain more than a single wildcard.");
return false;
}
Expand Down Expand Up @@ -206,26 +207,29 @@ <h2>{% trans "General Search" %}</h2>
<label id="criteria">Search for:</label>

<ul class="criteria">
<li><input type="checkbox" name="datatype" value="images" CHECKED />{% trans "Images" %}</li>
<li><input type="checkbox" name="datatype" value="datasets" CHECKED />{% trans "Datasets" %}</li>
<li><input type="checkbox" name="datatype" value="projects" CHECKED />{% trans "Projects" %}</li>
<li><input type="checkbox" name="datatype" value="plates" CHECKED />{% trans "Plates" %}</li>
<li><input type="checkbox" name="datatype" value="screens" CHECKED />{% trans "Screens" %}</li>
<li><input type="checkbox" name="datatype" value="image" CHECKED />{% trans "Images" %}</li>
<li><input type="checkbox" name="datatype" value="dataset" CHECKED />{% trans "Datasets" %}</li>
<li><input type="checkbox" name="datatype" value="project" CHECKED />{% trans "Projects" %}</li>
<li><input type="checkbox" name="datatype" value="plate" CHECKED />{% trans "Plates" %}</li>
<li><input type="checkbox" name="datatype" value="screen" CHECKED />{% trans "Screens" %}</li>
</ul>

<hr>

<label>Using Fields:</label>
<label style="white-space:nowrap;">
Fields:
<span class="searching_info" title="Search by specified fields.<br>If none chosen, we search across all fields">
<img src="{% static "webgateway/img/help16.png" %}" />
</span>
</label>

<ul class="criteria">
<li><input type="checkbox" name="field" value="name" CHECKED />{% trans "Name" %}</li>
<li><input type="checkbox" name="field" value="description" CHECKED />{% trans "Description" %}</li>
<li>
<input type="checkbox" name="field" value="all" CHECKED />{% trans "All" %}
<span class="searching_info"
title="All fields: Includes file attachments, tags, comments, owner etc">
<img src="{% static "webgateway/img/help16.png" %}" />
</span>
<li><input type="checkbox" name="field" value="name" />{% trans "Name" %}</li>
<li><input type="checkbox" name="field" value="description" />{% trans "Description" %}</li>
<li style="white-space:nowrap;">
<input type="checkbox" name="field" value="annotation" />{% trans "Attachments" %}<span class="searching_info" title="Includes file attachments, tags, comments etc">
<img src="{% static "webgateway/img/help16.png" %}" />
</span>
</li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</tr>
{% endwith %}
{% endfor %}
{% for c in manager.containers.projects %}
{% for c in manager.containers.project %}
<tr id="project-{{ c.id }}" class="{{ c.getPermsCss }}">
<td class="image">
<img id="{{ c.id }}" src="{% static "webgateway/img/folder16.png" %}" alt="project" title="{{ c.name }}"/>
Expand All @@ -112,7 +112,7 @@
</a></td>
</tr>
{% endfor %}
{% for c in manager.containers.screens %}
{% for c in manager.containers.screen %}
<tr id="screen-{{ c.id }}" class="{{ c.getPermsCss }}">
<td class="image">
<img id="{{ c.id }}" src="{% static "webclient/image/folder_screen32.png" %}" alt="screen" title="{{ c.name }}"/>
Expand All @@ -124,7 +124,7 @@
</a></td>
</tr>
{% endfor %}
{% for c in manager.containers.datasets %}
{% for c in manager.containers.dataset %}
<tr id="dataset-{{ c.id }}" class="{{ c.getPermsCss }}">
<td class="image">
<img id="{{ c.id }}" src="{% static "webgateway/img/folder_image16.png" %}" alt="dataset" title="{{ c.name }}"/>
Expand All @@ -136,7 +136,7 @@
</a></td>
</tr>
{% endfor %}
{% for c in manager.containers.plates %}
{% for c in manager.containers.plate %}
<tr id="plate-{{ c.id }}" class="{{ c.getPermsCss }}">
<td class="image">
<img id="{{ c.id }}" src="{% static "webclient/image/folder_plate32.png" %}" alt="plate" title="{{ c.name }}"/>
Expand All @@ -148,7 +148,7 @@
</a></td>
</tr>
{% endfor %}
{% for c in manager.containers.images %}
{% for c in manager.containers.image %}
<tr id="image-{{ c.id }}" class="{{ c.getPermsCss }}">
<td class="image">
<img class="search_thumb" id="{{ c.id }}" src="{% url 'render_thumbnail_resize' 96 c.id %}" alt="image" title="{{ c.name }}"/>
Expand Down
3 changes: 1 addition & 2 deletions components/tools/OmeroWeb/omeroweb/webclient/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,15 +574,14 @@ def load_searching(request, form=None, conn=None, **kwargs):

# by default, if user has not specified any types:
if len(onlyTypes) == 0:
onlyTypes = ['images']
onlyTypes = ['image']

# search is carried out and results are stored in manager.containers.images etc.
manager.search(query_search, onlyTypes, fields, searchGroup, ownedBy, date)

try:
searchById = long(query_search)
for t in onlyTypes:
t = t[0:-1] # remove 's'
if t in ('project', 'dataset', 'image', 'screen', 'plate'):
obj = conn.getObject(t, searchById)
if obj is not None:
Expand Down

0 comments on commit 81ac72e

Please sign in to comment.