mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-29 02:11:28 -06:00
SEARCH-273
- Added new library - New attachments implementation
This commit is contained in:
parent
f72e0b7db6
commit
718459c201
@ -42,6 +42,10 @@
|
||||
<label for="query">Query:</label><input id="query" size=60>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<label for="has">Has:</label><input id="has">
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<label for="offset">Offset:</label><input id="offset" type="number" value="0" size=5>
|
||||
<label for="limit">Limit:</label><input id="limit" type="number" value="25" size=5>
|
||||
@ -99,7 +103,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var search = new ssf.Search("7078106230763", "7078106230763");
|
||||
var search = new ssf.Search("7078106230763", "k2rbHBd5CgU3/PKLFUKUYkmuhCiL2Gw2bnsD7MdaZrU=");
|
||||
var buttonEl = document.getElementById('search');
|
||||
var merge = document.getElementById('merge');
|
||||
var buttonIndex = document.getElementById('index');
|
||||
@ -117,6 +121,7 @@
|
||||
var realTimeIndexing = document.getElementById('realTimeIndexing');
|
||||
var batchNumber = document.getElementById('batchNumber');
|
||||
var timestamp = document.getElementById('getLatestMessageTimestamp');
|
||||
var has = document.getElementById('has');
|
||||
|
||||
|
||||
buttonIndex.addEventListener('click', function () {
|
||||
@ -146,7 +151,8 @@
|
||||
if (threadIdEl.value && threadIdEl.value !== "" && threadIdEl.value.replace(/ /g, "").length > 0) {
|
||||
threadIdObj = JSON.parse(threadIdEl.value);
|
||||
}
|
||||
search.searchQuery(queryEl.value, senderIdObj, threadIdObj, null, startDate, endDate, limitEl.value, offsetEl.value, 0).then(function (result) {
|
||||
let _has = has.value || null;
|
||||
search.searchQuery(queryEl.value, senderIdObj, threadIdObj, _has, startDate, endDate, limitEl.value, offsetEl.value, 0).then(function (result) {
|
||||
if (result.messages.length < 1) {
|
||||
resultsEl.innerHTML = "No results found"
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ class Search {
|
||||
* @param {String} query
|
||||
* @param {Array} senderIds
|
||||
* @param {Array} threadIds
|
||||
* @param {String} attachments
|
||||
* @param {String} fileType
|
||||
* @param {String} startDate
|
||||
* @param {String} endDate
|
||||
* @param {Number} limit
|
||||
@ -227,7 +227,7 @@ class Search {
|
||||
* @param {Number} sortOrder
|
||||
* @returns {Promise}
|
||||
*/
|
||||
searchQuery(query, senderIds, threadIds, attachments, startDate,
|
||||
searchQuery(query, senderIds, threadIds, fileType, startDate,
|
||||
endDate, limit, offset, sortOrder) {
|
||||
|
||||
let _limit = limit;
|
||||
@ -245,7 +245,7 @@ class Search {
|
||||
return;
|
||||
}
|
||||
|
||||
let q = Search.constructQuery(query, senderIds, threadIds);
|
||||
let q = Search.constructQuery(query, senderIds, threadIds, fileType);
|
||||
|
||||
if (q === undefined) {
|
||||
reject(new Error('Search query error'));
|
||||
@ -282,6 +282,7 @@ class Search {
|
||||
try {
|
||||
let ret = returnedResult.readCString();
|
||||
resolve(JSON.parse(ret));
|
||||
console.log(JSON.parse(ret));
|
||||
} finally {
|
||||
libSymphonySearch.symSEFreeResult(returnedResult);
|
||||
}
|
||||
@ -326,9 +327,10 @@ class Search {
|
||||
* @param {String} searchQuery
|
||||
* @param {Array} senderId
|
||||
* @param {Array} threadId
|
||||
* @param fileType
|
||||
* @returns {string}
|
||||
*/
|
||||
static constructQuery(searchQuery, senderId, threadId) {
|
||||
static constructQuery(searchQuery, senderId, threadId, fileType) {
|
||||
|
||||
let query = "";
|
||||
if(searchQuery !== undefined) {
|
||||
@ -346,16 +348,41 @@ class Search {
|
||||
hashCashTagQuery += ")";
|
||||
}
|
||||
|
||||
let hasAttachments = false;
|
||||
let additionalAttachmentQuery = "";
|
||||
if(fileType) {
|
||||
hasAttachments = true;
|
||||
if(fileType === "attachment") {
|
||||
additionalAttachmentQuery = "(hasfiles:true)";
|
||||
} else {
|
||||
additionalAttachmentQuery = "(filetype:(" + fileType +"))";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (query.length > 0 ) {
|
||||
q = "(text:(" + query + ")" + hashCashTagQuery + ")";
|
||||
q = "((text:(" + query + "))" + hashCashTagQuery ;
|
||||
if(hasAttachments) {
|
||||
q += " OR (filename:(" + query + "))" ;
|
||||
}
|
||||
q = q + ")";
|
||||
}
|
||||
|
||||
q = Search.appendFilterQuery(q, "senderId", senderId);
|
||||
q = Search.appendFilterQuery(q, "threadId", threadId);
|
||||
|
||||
if(q === "") {
|
||||
q = undefined; //will be handled in the search function
|
||||
if(hasAttachments) {
|
||||
q = additionalAttachmentQuery;
|
||||
} else {
|
||||
q = undefined; //will be handled in the search function
|
||||
}
|
||||
} else {
|
||||
if(hasAttachments){
|
||||
q = q + " AND " + additionalAttachmentQuery
|
||||
}
|
||||
}
|
||||
console.log(q);
|
||||
return q;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -11,7 +11,7 @@
|
||||
"demo-mac": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/demo/index.html",
|
||||
"search-win": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file:///demo/search.html",
|
||||
"search-mac": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/demo/search.html",
|
||||
"unpacked-mac": "npm run prebuild && npm run test && build --mac --dir",
|
||||
"unpacked-mac": "npm run prebuild && build --mac --dir",
|
||||
"packed-mac": "npm run unpacked-mac && packagesbuild -v installer/mac/symphony-mac-packager.pkgproj",
|
||||
"unpacked-win": "npm run prebuild && npm run test && build --win --x64 --dir",
|
||||
"unpacked-win-x86": "npm run prebuild && npm run test && build --win --ia32 --dir",
|
||||
|
Loading…
Reference in New Issue
Block a user