Proof-of-concept for import and index from Web UI
This commit is contained in:
parent
f57eea8d76
commit
3ee3946011
|
@ -1,19 +1,25 @@
|
|||
<template>
|
||||
<div class="p-tab p-tab-import">
|
||||
<v-form ref="form" class="p-photo-import" lazy-validation @submit.prevent="submit" dense>
|
||||
<input type="file" ref="upload" multiple @change.stop="upload()" class="d-none">
|
||||
|
||||
<v-container fluid>
|
||||
<h3 class="subheading">Only available using the command-line interface at the moment</h3>
|
||||
<p class="body-1 mt-2">
|
||||
Issues labeled <a href="https://github.com/photoprism/photoprism/labels/help%20wanted">help
|
||||
wanted</a> /
|
||||
<a href="https://github.com/photoprism/photoprism/labels/easy">easy</a> can be good (first)
|
||||
contributions.
|
||||
Our <a href="https://github.com/photoprism/photoprism/wiki">Developer Guide</a> contains all
|
||||
information
|
||||
necessary to get you started.
|
||||
<p class="subheading">
|
||||
<span v-if="busy">Importing files from directory...</span>
|
||||
<span v-else-if="completed">Done.</span>
|
||||
<span v-else>Press button to import photos from directory...</span>
|
||||
</p>
|
||||
|
||||
<v-progress-linear color="blue-grey" :value="completed" :indeterminate="busy"></v-progress-linear>
|
||||
|
||||
<v-btn
|
||||
:disabled="busy"
|
||||
color="blue-grey"
|
||||
class="white--text ml-0"
|
||||
depressed
|
||||
@click.stop="startImport()"
|
||||
>
|
||||
Import
|
||||
<v-icon right dark>create_new_folder</v-icon>
|
||||
</v-btn>
|
||||
</v-container>
|
||||
</v-form>
|
||||
</div>
|
||||
|
@ -27,9 +33,34 @@
|
|||
name: 'p-tab-import',
|
||||
data() {
|
||||
return {
|
||||
started: false,
|
||||
busy: false,
|
||||
completed: 0,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
console.log("SUBMIT");
|
||||
},
|
||||
startImport() {
|
||||
this.started = Date.now();
|
||||
this.busy = true;
|
||||
this.completed = 0;
|
||||
|
||||
this.$alert.info("Importing photos...");
|
||||
|
||||
const ctx = this;
|
||||
|
||||
axios.post('/api/v1/import').then(function () {
|
||||
Event.publish("alert.success", "Import complete");
|
||||
ctx.busy = false;
|
||||
ctx.completed = 100;
|
||||
}).catch(function () {
|
||||
Event.publish("alert.error", "Import failed");
|
||||
ctx.busy = false;
|
||||
ctx.completed = 0;
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1,19 +1,25 @@
|
|||
<template>
|
||||
<div class="p-tab p-tab-index">
|
||||
<v-form ref="form" class="p-photo-index" lazy-validation @submit.prevent="submit" dense>
|
||||
<input type="file" ref="upload" multiple @change.stop="upload()" class="d-none">
|
||||
|
||||
<v-container fluid>
|
||||
<h3 class="subheading">Only available using the command-line interface at the moment</h3>
|
||||
<p class="body-1 mt-2">
|
||||
Issues labeled <a href="https://github.com/photoprism/photoprism/labels/help%20wanted">help
|
||||
wanted</a> /
|
||||
<a href="https://github.com/photoprism/photoprism/labels/easy">easy</a> can be good (first)
|
||||
contributions.
|
||||
Our <a href="https://github.com/photoprism/photoprism/wiki">Developer Guide</a> contains all
|
||||
information
|
||||
necessary to get you started.
|
||||
<p class="subheading">
|
||||
<span v-if="busy">Re-indexing existing files and photos...</span>
|
||||
<span v-else-if="completed">Done.</span>
|
||||
<span v-else>Press button to re-index existing files and photos...</span>
|
||||
</p>
|
||||
|
||||
<v-progress-linear color="blue-grey" :value="completed" :indeterminate="busy"></v-progress-linear>
|
||||
|
||||
<v-btn
|
||||
:disabled="busy"
|
||||
color="blue-grey"
|
||||
class="white--text ml-0"
|
||||
depressed
|
||||
@click.stop="startIndexing()"
|
||||
>
|
||||
Index
|
||||
<v-icon right dark>update</v-icon>
|
||||
</v-btn>
|
||||
</v-container>
|
||||
</v-form>
|
||||
</div>
|
||||
|
@ -27,9 +33,34 @@
|
|||
name: 'p-tab-index',
|
||||
data() {
|
||||
return {
|
||||
started: false,
|
||||
busy: false,
|
||||
completed: 0,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
console.log("SUBMIT");
|
||||
},
|
||||
startIndexing() {
|
||||
this.started = Date.now();
|
||||
this.busy = true;
|
||||
this.completed = 0;
|
||||
|
||||
this.$alert.info("Indexing photos...");
|
||||
|
||||
const ctx = this;
|
||||
|
||||
axios.post('/api/v1/index').then(function () {
|
||||
Event.publish("alert.success", "Indexing complete");
|
||||
ctx.busy = false;
|
||||
ctx.completed = 100;
|
||||
}).catch(function () {
|
||||
Event.publish("alert.error", "Indexing failed");
|
||||
ctx.busy = false;
|
||||
ctx.completed = 0;
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,9 +19,7 @@ func initImporter(conf *config.Config) {
|
|||
return
|
||||
}
|
||||
|
||||
tensorFlow := photoprism.NewTensorFlow(conf)
|
||||
|
||||
indexer := photoprism.NewIndexer(conf, tensorFlow)
|
||||
initIndexer(conf)
|
||||
|
||||
converter := photoprism.NewConverter(conf)
|
||||
|
||||
|
|
43
internal/api/index.go
Normal file
43
internal/api/index.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/config"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/photoprism/photoprism/internal/photoprism"
|
||||
)
|
||||
|
||||
var indexer *photoprism.Indexer
|
||||
|
||||
func initIndexer(conf *config.Config) {
|
||||
if indexer != nil {
|
||||
return
|
||||
}
|
||||
|
||||
tensorFlow := photoprism.NewTensorFlow(conf)
|
||||
|
||||
indexer = photoprism.NewIndexer(conf, tensorFlow)
|
||||
}
|
||||
|
||||
// POST /api/v1/index
|
||||
func Index(router *gin.RouterGroup, conf *config.Config) {
|
||||
router.POST("/index", func(c *gin.Context) {
|
||||
start := time.Now()
|
||||
path := conf.OriginalsPath()
|
||||
|
||||
log.Infof("indexing photos in %s", path)
|
||||
|
||||
initIndexer(conf)
|
||||
|
||||
indexer.IndexAll()
|
||||
|
||||
elapsed := time.Since(start)
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": fmt.Sprintf("indexing completed in %s", elapsed)})
|
||||
})
|
||||
}
|
|
@ -32,6 +32,7 @@ func registerRoutes(router *gin.Engine, conf *config.Config) {
|
|||
|
||||
api.Upload(v1, conf)
|
||||
api.Import(v1, conf)
|
||||
api.Index(v1, conf)
|
||||
|
||||
api.BatchPhotosDelete(v1, conf)
|
||||
api.BatchPhotosPrivate(v1, conf)
|
||||
|
|
Loading…
Reference in a new issue