Add lens, category, color and year search filters

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer
2019-12-28 23:06:44 +01:00
parent 8e8642cb08
commit a66d0887bd
8 changed files with 152 additions and 81 deletions

View File

@@ -59,7 +59,6 @@ seashore:
threshold: 0.3 threshold: 0.3
categories: categories:
- beach - beach
- coast
- water - water
lakeside: lakeside:
@@ -104,9 +103,7 @@ fashion:
label: portrait label: portrait
threshold: 0.1 threshold: 0.1
categories: categories:
- fashion - people
- person
- face
poncho: poncho:
see: fashion see: fashion
@@ -274,10 +271,8 @@ stingray:
threshold: 0.2 threshold: 0.2
categories: categories:
- water - water
- sea
- fish - fish
- animal - animal
- ray
cock: cock:
threshold: 0.2 threshold: 0.2
@@ -731,7 +726,6 @@ wombat:
jellyfish: jellyfish:
categories: categories:
- water - water
- sea
- animal - animal
- fish - fish
@@ -1480,20 +1474,17 @@ starfish:
threshold: 0.5 threshold: 0.5
categories: categories:
- water - water
- sea
- animal - animal
- fish - fish
sea urchin: sea urchin:
categories: categories:
- water - water
- sea
- animal - animal
sea cucumber: sea cucumber:
categories: categories:
- water - water
- sea
- animal - animal
rabbit: rabbit:
@@ -1789,7 +1780,6 @@ fish:
threshold: 0.2 threshold: 0.2
categories: categories:
- water - water
- sea
- animal - animal
barracouta: barracouta:
@@ -1903,7 +1893,7 @@ barbershop:
barn: barn:
cateories: cateories:
- building - architecture
bassoon: bassoon:
label: entertainment label: entertainment
@@ -1926,7 +1916,6 @@ bathtub:
beacon: beacon:
categories: categories:
- building
- tower - tower
- architecture - architecture
@@ -1945,7 +1934,6 @@ beer glass:
bell cote: bell cote:
label: church label: church
categories: categories:
- building
- architecture - architecture
bicycle-built-for-two: bicycle-built-for-two:
@@ -1956,13 +1944,12 @@ bicycle-built-for-two:
birdhouse: birdhouse:
categories: categories:
- building - bird
- house - outdoor
boathouse: boathouse:
categories: categories:
- building - architecture
- house
- water - water
bobsled: bobsled:
@@ -2030,9 +2017,7 @@ car wheel:
castle: castle:
categories: categories:
- building - historic
- old
- architecture
catamaran: catamaran:
categories: categories:
@@ -2169,7 +2154,6 @@ disk brake:
dock: dock:
categories: categories:
- water - water
- sea
dogsled: dogsled:
categories: categories:
@@ -2389,7 +2373,6 @@ library:
lifeboat: lifeboat:
categories: categories:
- water - water
- sea
- boat - boat
lighter: lighter:
@@ -2457,13 +2440,11 @@ microwave:
minibus: minibus:
label: bus label: bus
categories: categories:
- van
- vehicle - vehicle
minivan: minivan:
label: van label: van
categories: categories:
- car
- vehicle - vehicle
mixing bowl: mixing bowl:
@@ -2511,7 +2492,6 @@ moving van:
label: van label: van
categories: categories:
- vehicle - vehicle
- bus
notebook: notebook:
label: computer label: computer
@@ -2548,7 +2528,6 @@ paddle:
paddlewheel: paddlewheel:
categories: categories:
- water - water
- sea
padlock: padlock:
label: tool label: tool
@@ -2565,7 +2544,7 @@ paintbrush:
palace: palace:
label: historic architecture label: historic architecture
categories: categories:
- building - historic
panpipe: panpipe:
label: goods label: goods
@@ -2657,7 +2636,6 @@ police van:
label: van label: van
categories: categories:
- vehicle - vehicle
- bus
pool table: pool table:
categories: categories:
@@ -2699,8 +2677,6 @@ punching bag:
recreational vehicle: recreational vehicle:
label: camper label: camper
categories: categories:
- bus
- van
- vehicle - vehicle
reflex camera: reflex camera:
@@ -2806,7 +2782,6 @@ snorkel:
categories: categories:
- swimming - swimming
- water - water
- sea
snowmobile: snowmobile:
categories: categories:
@@ -2841,7 +2816,6 @@ spatula:
speedboat: speedboat:
categories: categories:
- water - water
- sea
- boat - boat
sports car: sports car:
@@ -2885,7 +2859,6 @@ studio couch:
submarine: submarine:
categories: categories:
- water - water
- sea
- boat - boat
suspension bridge: suspension bridge:
@@ -2939,7 +2912,6 @@ trimaran:
categories: categories:
- boat - boat
- water - water
- sea
triumphal arch: triumphal arch:
categories: categories:
@@ -2949,7 +2921,6 @@ triumphal arch:
trolleybus: trolleybus:
label: bus label: bus
categories: categories:
- van
- vehicle - vehicle
trombone: trombone:
@@ -3022,10 +2993,8 @@ wreck:
yawl: yawl:
categories: categories:
- ship
- boat - boat
- water - water
- sea
- vehicle - vehicle
yurt: yurt:
@@ -3347,7 +3316,6 @@ tile roof:
label: building label: building
categories: categories:
- architecture - architecture
- house
croquet ball: croquet ball:
label: pumpkin label: pumpkin
@@ -3463,8 +3431,6 @@ band aid:
portrait: portrait:
label: portrait label: portrait
categories: categories:
- person
- face
- people - people
oxygen mask: oxygen mask:
@@ -3480,8 +3446,6 @@ heritage:
label: portrait label: portrait
categories: categories:
- people - people
- person
- face
safety pin: safety pin:
priority: -1 priority: -1
@@ -3500,10 +3464,7 @@ vestment:
bassinet: bassinet:
label: baby label: baby
categories: categories:
- person - people
- child
- portrait
- face
patio: patio:
label: building label: building

View File

@@ -54,18 +54,18 @@
item-value="code" item-value="code"
item-text="name" item-text="name"
v-model="filter.country" v-model="filter.country"
:items="options.countries"> :items="countryOptions">
</v-select> </v-select>
</v-flex> </v-flex>
<v-flex xs12 sm6 md3 pa-2 class="p-camera-select"> <v-flex xs12 sm6 md3 pa-2 class="p-camera-select">
<v-select @change="dropdownChange" <v-select @change="dropdownChange"
:label="labels.camera" :label="labels.year"
flat solo hide-details flat solo hide-details
color="secondary-dark" color="secondary-dark"
item-value="ID" item-value="year"
item-text="CameraModel" item-text="label"
v-model="filter.camera" v-model="filter.year"
:items="options.cameras"> :items="yearOptions">
</v-select> </v-select>
</v-flex> </v-flex>
<v-flex xs12 sm6 md3 pa-2 class="p-view-select"> <v-flex xs12 sm6 md3 pa-2 class="p-view-select">
@@ -87,7 +87,51 @@
:items="options.sorting"> :items="options.sorting">
</v-select> </v-select>
</v-flex> </v-flex>
<v-flex xs6 pa-2 class="p-time-after"> <v-flex xs12 sm6 md3 pa-2 class="p-camera-select">
<v-select @change="dropdownChange"
:label="labels.camera"
flat solo hide-details
color="secondary-dark"
item-value="ID"
item-text="CameraModel"
v-model="filter.camera"
:items="cameraOptions">
</v-select>
</v-flex>
<v-flex xs12 sm6 md3 pa-2 class="p-camera-select">
<v-select @change="dropdownChange"
:label="labels.lens"
flat solo hide-details
color="secondary-dark"
item-value="ID"
item-text="LensModel"
v-model="filter.lens"
:items="lensOptions">
</v-select>
</v-flex>
<v-flex xs12 sm6 md3 pa-2 class="p-camera-select">
<v-select @change="dropdownChange"
:label="labels.color"
flat solo hide-details
color="secondary-dark"
item-value="name"
item-text="label"
v-model="filter.color"
:items="colorOptions">
</v-select>
</v-flex>
<v-flex xs12 sm6 md3 pa-2 class="p-camera-select">
<v-select @change="dropdownChange"
:label="labels.category"
flat solo hide-details
color="secondary-dark"
item-value="LabelName"
item-text="Title"
v-model="filter.label"
:items="categoryOptions">
</v-select>
</v-flex>
<!-- v-flex xs6 pa-2 class="p-time-after">
<v-menu v-model="showAfterPicker" <v-menu v-model="showAfterPicker"
:close-on-content-click="false" :close-on-content-click="false"
:nudge-right="40" :nudge-right="40"
@@ -136,7 +180,7 @@
@input="datepickerChange"> @input="datepickerChange">
</v-date-picker> </v-date-picker>
</v-menu> </v-menu>
</v-flex> </v-flex -->
</v-layout> </v-layout>
</v-card-text> </v-card-text>
</v-card> </v-card>
@@ -152,42 +196,69 @@
filterChange: Function, filterChange: Function,
}, },
data() { data() {
const cameras = [{ID: 0, CameraModel: this.$gettext('All Cameras')}].concat(this.$config.getValue('cameras'));
const countries = [{
code: '',
name: this.$gettext('All Countries')
}].concat(this.$config.getValue('countries'));
return { return {
config: this.$config.values,
searchExpanded: false, searchExpanded: false,
all: {
countries: [{ code: "", name: this.$gettext("All Countries")}],
cameras: [{ID: 0, CameraModel: this.$gettext("All Cameras")}],
lenses: [{ID: 0, LensModel: "All Lenses"}],
colors: [{label: "All Colors", name: ""}],
categories: [{LabelName: "", Title: this.$gettext("All Categories")}],
},
options: { options: {
'views': [ 'views': [
// {value: 'tiles', text: this.$gettext('Tiles')},
{value: 'mosaic', text: this.$gettext('Mosaic')}, {value: 'mosaic', text: this.$gettext('Mosaic')},
{value: 'details', text: this.$gettext('Details')}, {value: 'details', text: this.$gettext('Details')},
{value: 'list', text: this.$gettext('List')}, {value: 'list', text: this.$gettext('List')},
], ],
'countries': countries,
'cameras': cameras,
'sorting': [ 'sorting': [
{value: 'imported', text: this.$gettext('Recently imported')}, {value: 'imported', text: this.$gettext('Recently imported')},
{value: 'newest', text: this.$gettext('Newest first')}, {value: 'newest', text: this.$gettext('Newest first')},
{value: 'oldest', text: this.$gettext('Oldest first')}, {value: 'oldest', text: this.$gettext('Oldest first')},
], ],
}, },
showAfterPicker: false, // showAfterPicker: false,
showBeforePicker: false, // showBeforePicker: false,
labels: { labels: {
search: this.$gettext("Search"), search: this.$gettext("Search"),
view: this.$gettext("View"), view: this.$gettext("View"),
country: this.$gettext("Country"), country: this.$gettext("Country"),
camera: this.$gettext("Camera"), camera: this.$gettext("Camera"),
lens: this.$gettext("Lens"),
year: this.$gettext("Year"),
color: this.$gettext("Color"),
category: this.$gettext("Category"),
sort: this.$gettext("Sort By"), sort: this.$gettext("Sort By"),
before: this.$gettext("Taken before"), before: this.$gettext("Taken before"),
after: this.$gettext("Taken after"), after: this.$gettext("Taken after"),
}, },
}; };
}, },
computed: {
countryOptions() {
return this.all.countries.concat(this.config.countries);
},
cameraOptions() {
return this.all.cameras.concat(this.config.cameras);
},
lensOptions() {
return this.all.lenses.concat(this.config.lenses);
},
colorOptions() {
return this.all.colors.concat(this.config.colors);
},
categoryOptions() {
return this.all.categories.concat(this.config.categories);
},
yearOptions() {
let result = [{"year": 0, "label": "All Years"}];
for (let i = 0; i < this.config.years.length; i++) {
result.push({"year": this.config.years[i], "label": this.config.years[i].toString()});
}
return result;
},
},
methods: { methods: {
dropdownChange() { dropdownChange() {
this.filterChange(); this.filterChange();
@@ -196,16 +267,12 @@
this.searchExpanded = false; this.searchExpanded = false;
} }
}, },
datepickerChange() { /*datepickerChange() {
this.showAfterPicker = false; this.showAfterPicker = false;
this.showBeforePicker = false; this.showBeforePicker = false;
this.dropdownChange(); this.dropdownChange();
}, },
setView(name) {
this.settings.view = name;
this.filterChange();
},
clearBefore() { clearBefore() {
this.filter.before = ''; this.filter.before = '';
this.datepickerChange(); this.datepickerChange();
@@ -213,11 +280,16 @@
clearAfter() { clearAfter() {
this.filter.after = ''; this.filter.after = '';
this.datepickerChange(); this.datepickerChange();
},
*/
setView(name) {
this.settings.view = name;
this.filterChange();
}, },
clearQuery() { clearQuery() {
this.filter.q = ''; this.filter.q = '';
this.filterChange(); this.filterChange();
}, },
} },
}; };
</script> </script>

View File

@@ -50,8 +50,14 @@
this.filter.q = query['q'] ? query['q'] : ''; this.filter.q = query['q'] ? query['q'] : '';
this.filter.camera = query['camera'] ? parseInt(query['camera']) : 0; this.filter.camera = query['camera'] ? parseInt(query['camera']) : 0;
this.filter.country = query['country'] ? query['country'] : ''; this.filter.country = query['country'] ? query['country'] : '';
this.filter.before = query['before'] ? query['before'] : ''; this.filter.lens = query['lens'] ? parseInt(query['lens']) : 0;
this.filter.after = query['after'] ? query['after'] : ''; this.filter.year = query['year'] ? parseInt(query['year']) : 0;
this.filter.color = query['color'] ? query['color'] : '';
this.filter.label = query['label'] ? query['label'] : '';
// this.filter.before = query['before'] ? query['before'] : '';
// this.filter.after = query['after'] ? query['after'] : '';
this.settings.view = this.viewType(); this.settings.view = this.viewType();
this.lastFilter = {}; this.lastFilter = {};
this.routeName = this.$route.name; this.routeName = this.$route.name;
@@ -64,11 +70,28 @@
const order = query['order'] ? query['order'] : 'imported'; const order = query['order'] ? query['order'] : 'imported';
const camera = query['camera'] ? parseInt(query['camera']) : 0; const camera = query['camera'] ? parseInt(query['camera']) : 0;
const q = query['q'] ? query['q'] : ''; const q = query['q'] ? query['q'] : '';
const before = query['before'] ? query['before'] : '';
const after = query['after'] ? query['after'] : ''; // const before = query['before'] ? query['before'] : '';
// const after = query['after'] ? query['after'] : '';
const country = query['country'] ? query['country'] : ''; const country = query['country'] ? query['country'] : '';
const lens = query['lens'] ? parseInt(query['lens']) : 0;
const year = query['year'] ? parseInt(query['year']) : 0;
const color = query['color'] ? query['color'] : '';
const label = query['label'] ? query['label'] : '';
const view = this.viewType(); const view = this.viewType();
const filter = {country: country, camera: camera, order: order, q: q, before: before, after: after}; const filter = {
country: country,
camera: camera,
lens: lens,
label: label,
year: year,
color: color,
order: order,
q: q,
/* before: before,
after: after, */
};
const settings = {view: view}; const settings = {view: view};
return { return {

View File

@@ -61,17 +61,17 @@ var All = Colors{
Cyan, Cyan,
Blue, Blue,
Purple, Purple,
Brown,
White, White,
Grey, Grey,
Black, Black,
Brown,
} }
var Names = map[Color]string{ var Names = map[Color]string{
Black: "dark", // 0 Black: "dark", // 0
Brown: "brown", // 1 Brown: "brown", // 1
Grey: "grey", // 2 Grey: "grey", // 2
White: "bright", // 3 White: "white", // 3
Purple: "purple", // 4 Purple: "purple", // 4
Gold: "gold", // 5 Gold: "gold", // 5
Blue: "blue", // 6 Blue: "blue", // 6

View File

@@ -652,7 +652,7 @@ func (c *Config) ClientConfig() ClientConfig {
Limit(20).Order("album_name"). Limit(20).Order("album_name").
Find(&albums) Find(&albums)
var years []string var years []int
db.Table("photos"). db.Table("photos").
Order("photo_year DESC"). Order("photo_year DESC").

View File

@@ -35,8 +35,11 @@ type PhotoSearch struct {
Album string `form:"album"` Album string `form:"album"`
Label string `form:"label"` Label string `form:"label"`
Country string `form:"country"` Country string `form:"country"`
Year uint `form:"year"`
Month uint `form:"month"`
Color string `form:"color"` Color string `form:"color"`
Camera int `form:"camera"` Camera int `form:"camera"`
Lens int `form:"lens"`
Before time.Time `form:"before" time_format:"2006-01-02"` Before time.Time `form:"before" time_format:"2006-01-02"`
After time.Time `form:"after" time_format:"2006-01-02"` After time.Time `form:"after" time_format:"2006-01-02"`
Favorites bool `form:"favorites"` Favorites bool `form:"favorites"`

View File

@@ -233,9 +233,9 @@ func TestTensorFlow_BestLabels(t *testing.T) {
result := tensorFlow.bestLabels(p) result := tensorFlow.bestLabels(p)
assert.Equal(t, "chicken", result[0].Name) assert.Equal(t, "chicken", result[0].Name)
assert.Equal(t, "bird", result[0].Categories[0]) assert.Equal(t, "bird", result[0].Categories[0])
assert.Equal(t, "animal", result[1].Categories[1])
assert.Equal(t, "image", result[0].Source) assert.Equal(t, "image", result[0].Source)
assert.Equal(t, "fish", result[1].Name) assert.Equal(t, "fish", result[1].Name)
assert.Equal(t, "animal", result[1].Categories[2])
assert.Equal(t, "image", result[1].Source) assert.Equal(t, "image", result[1].Source)
t.Log(result) t.Log(result)
}) })

View File

@@ -193,6 +193,18 @@ func (s *Repo) Photos(f form.PhotoSearch) (results []PhotoResult, err error) {
q = q.Where("photos.camera_id = ?", f.Camera) q = q.Where("photos.camera_id = ?", f.Camera)
} }
if f.Lens > 0 {
q = q.Where("photos.lens_id = ?", f.Lens)
}
if f.Year > 0 {
q = q.Where("photos.photo_year = ?", f.Year)
}
if f.Month > 0 {
q = q.Where("photos.photo_month = ?", f.Month)
}
if f.Color != "" { if f.Color != "" {
q = q.Where("files.file_main_color = ?", strings.ToLower(f.Color)) q = q.Where("files.file_main_color = ?", strings.ToLower(f.Color))
} }