Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
021b7085
Commit
021b7085
authored
Apr 10, 2015
by
Klaus Wölfel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web_jabber_client: Add jio based chat history
per default it useses indexeddb storage
parent
748c295d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
214 additions
and
21 deletions
+214
-21
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_jabberclient_html.xml
...eItem/web_page_module/jabber_gadget_jabberclient_html.xml
+15
-4
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_jabberclient_js.xml
...ateItem/web_page_module/jabber_gadget_jabberclient_js.xml
+199
-17
No files found.
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_jabberclient_html.xml
View file @
021b7085
...
@@ -63,6 +63,12 @@
...
@@ -63,6 +63,12 @@
</tuple>
</tuple>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<item>
<key>
<string>
content_md5
</string>
</key>
<key>
<string>
content_md5
</string>
</key>
<value>
<value>
...
@@ -202,6 +208,8 @@
...
@@ -202,6 +208,8 @@
</script>
\n
</script>
\n
\n
\n
<script
class=
"message-template"
type=
"text/x-handlebars-template"
><li
data-theme=
"{{theme}}"
style=
"{{style}}"
><pre
style=
"white-space: pre-wrap;"
>
{{text}}
</pre></li></script>
\n
<script
class=
"message-template"
type=
"text/x-handlebars-template"
><li
data-theme=
"{{theme}}"
style=
"{{style}}"
><pre
style=
"white-space: pre-wrap;"
>
{{text}}
</pre></li></script>
\n
\n
<script
class=
"history-template"
type=
"text/x-handlebars-template"
><pre
style=
"white-space: pre-wrap;"
>
{{text}}
</pre></script>
\n
\n
\n
<script
class=
"header-template"
type=
"text/x-handlebars-template"
>
\n
<script
class=
"header-template"
type=
"text/x-handlebars-template"
>
\n
{{#if left_url}}\n
{{#if left_url}}\n
...
@@ -222,6 +230,9 @@
...
@@ -222,6 +230,9 @@
<div
data-role=
"header"
data-position=
"fixed"
class=
"gadget-header"
data-theme=
"b"
>
\n
<div
data-role=
"header"
data-position=
"fixed"
class=
"gadget-header"
data-theme=
"b"
>
\n
<h1></h1>
\n
<h1></h1>
\n
</div>
\n
</div>
\n
<div
data-gadget-url=
"gadget_jio.html"
\n
data-gadget-scope=
"jio_gadget"
\n
data-gadget-sandbox=
"public"
></div>
\n
\n
\n
<div
role=
"main"
class=
"ui-content gadget-content"
></div>
\n
<div
role=
"main"
class=
"ui-content gadget-content"
></div>
\n
</div>
\n
</div>
\n
...
@@ -357,7 +368,7 @@
...
@@ -357,7 +368,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
actor
</string>
</key>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
<value>
<string>
klaus.woelfel
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
comment
</string>
</key>
<key>
<string>
comment
</string>
</key>
...
@@ -371,7 +382,7 @@
...
@@ -371,7 +382,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
39.33990.61359.38570
</string>
</value>
<value>
<string>
9
42.1666.29972.41045
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -389,8 +400,8 @@
...
@@ -389,8 +400,8 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
14
18720455.63
</float>
<float>
14
27926413.61
</float>
<string>
GMT
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
</object>
</object>
...
...
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_jabberclient_js.xml
View file @
021b7085
...
@@ -63,6 +63,14 @@
...
@@ -63,6 +63,14 @@
</tuple>
</tuple>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
contributor/person_module/1
</string>
</tuple>
</value>
</item>
<item>
<item>
<key>
<string>
content_md5
</string>
</key>
<key>
<string>
content_md5
</string>
</key>
<value>
<value>
...
@@ -103,6 +111,7 @@
...
@@ -103,6 +111,7 @@
/*globals window, document, RSVP, rJS, Handlebars, promiseEventListener,\n
/*globals window, document, RSVP, rJS, Handlebars, promiseEventListener,\n
loopEventListener, jQuery*/\n
loopEventListener, jQuery*/\n
/*jslint indent: 2*/\n
(function (window, document, RSVP, rJS, Handlebars, promiseEventListener,\n
(function (window, document, RSVP, rJS, Handlebars, promiseEventListener,\n
loopEventListener, $) {\n
loopEventListener, $) {\n
"use strict";\n
"use strict";\n
...
@@ -115,10 +124,16 @@
...
@@ -115,10 +124,16 @@
var PAGE_CONTACT = "contact",\n
var PAGE_CONTACT = "contact",\n
PAGE_CONNECTION = "connect",\n
PAGE_CONNECTION = "connect",\n
PAGE_DIALOG = "dialog",\n
PAGE_DIALOG = "dialog",\n
PAGE_HISTORY = "history",\n
PAGE_NEW_CONTACT = "subscribe",\n
PAGE_NEW_CONTACT = "subscribe",\n
DEFAULT_PAGE = PAGE_CONTACT,\n
DEFAULT_PAGE = PAGE_CONTACT,\n
CONNECTION_GADGET_URL = "./gadget_jabberconnection.html",\n
CONNECTION_GADGET_URL = "./gadget_jabberconnection.html",\n
CONNECTION_GADGET_SCOPE = "connection";\n
CONNECTION_GADGET_SCOPE = "connection",\n
ATTACHMENT_ID = "enclosure",\n
JIO_STORAGE_TYPE = "indexeddb",\n
DAV_URL = "",\n
DAV_USER = "",\n
DAV_PASSWORD = "";\n
\n
\n
function compareContact(a, b) {\n
function compareContact(a, b) {\n
var result;\n
var result;\n
...
@@ -149,6 +164,125 @@
...
@@ -149,6 +164,125 @@
);\n
);\n
}\n
}\n
}\n
}\n
\n
//////////////////////////////////////////\n
// History Support with Jio\n
//////////////////////////////////////////\n
function createJio_indexeddb(gadget) {\n
return gadget.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.createJio({\n
type: "indexeddb",\n
database: "jabberclient"\n
});\n
});\n
}\n
\n
function createJio_local(gadget) {\n
return gadget.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.createJio({\n
type: "query",\n
sub_storage: {\n
type: "document",\n
document_id: "/",\n
sub_storage: { type: "local" }\n
}\n
});\n
});\n
}\n
\n
function createJio_dav(gadget) {\n
return gadget.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
return jio_gadget.createJio({\n
type: "drivetojiomapping",\n
sub_storage: {\n
type: "dav",\n
url: DAV_URL,\n
basic_login: btoa(DAV_USER + ":" + DAV_PASSWORD)\n
}\n
});\n
});\n
}\n
\n
function createJio(gadget) {\n
switch (JIO_STORAGE_TYPE) {\n
case "indexeddb":\n
return createJio_indexeddb(gadget);\n
case "local":\n
return createJio_local(gadget);\n
case "dav":\n
return createJio_dav(gadget);\n
}\n
}\n
\n
function zfill(s, size) {\n
s = String(s);\n
while (s.length < size) {\n
s = "0" + s;\n
}\n
return s;\n
}\n
\n
function getLogString(text, is_incomming) {\n
var prefix,\n
date = new Date(),\n
timestamp = date.getFullYear() + "-" +\n
zfill(date.getMonth(), 2) + "-" +\n
zfill(date.getDate(), 2) + " " +\n
date.toTimeString();\n
if (is_incomming) {\n
prefix = \'<\';\n
} else {\n
prefix = \'>
\';\n
}\n
return "[" + timestamp + "] " + prefix + " " + text + "\\n";\n
}\n
\n
function getStorageIdFromJid(gadget, jid) {\n
return gadget.props.my_jid + \'-\' + jid;\n
}\n
\n
function loadHistory(gadget, jid) {\n
var jio;\n
return gadget.getDeclaredGadget("jio_gadget")\n
.push(function (jio_gadget) {\n
jio = jio_gadget;\n
return jio.getAttachment(getStorageIdFromJid(gadget, jid), ATTACHMENT_ID);\n
})\n
.push(function (attachment) {\n
return jIO.util.readBlobAsText(attachment);\n
})\n
.push(\n
function (e) {\n
return {\n
\'history\': e.target.result,\n
\'jio\': jio\n
};\n
},\n
function (error) {\n
var my_message = "Cannot find ";\n
if ((error instanceof Error)
&&
\n
(error.message.substring(0, my_message.length) === my_message)) {\n
return {\n
\'history\': \'\',\n
\'jio\': jio\n
};\n
}\n
throw error;\n
}\n
);\n
}\n
\n
function addLog(gadget, jid, text, is_incomming) {\n
return loadHistory(gadget, jid)\n
.push(function (result) {\n
var id = getStorageIdFromJid(gadget, jid),\n
new_history = result.history + getLogString(text, is_incomming);\n
return result.jio.putAttachment(id, ATTACHMENT_ID, new_history);\n
});\n
}\n
\n
\n
//////////////////////////////////////////\n
//////////////////////////////////////////\n
// Page rendering\n
// Page rendering\n
...
@@ -234,6 +368,8 @@
...
@@ -234,6 +368,8 @@
document.querySelector(".ui-last-child").scrollIntoView();\n
document.querySelector(".ui-last-child").scrollIntoView();\n
}\n
}\n
\n
\n
return RSVP.all([\n
function () {\n
if ((gadget.props.options !== undefined)
&&
\n
if ((gadget.props.options !== undefined)
&&
\n
(gadget.props.options.page === PAGE_CONTACT)) {\n
(gadget.props.options.page === PAGE_CONTACT)) {\n
return gadget.getDeclaredGadget(CONNECTION_GADGET_SCOPE)\n
return gadget.getDeclaredGadget(CONNECTION_GADGET_SCOPE)\n
...
@@ -241,20 +377,56 @@
...
@@ -241,20 +377,56 @@
return renderContactPage(gadget, connection_gadget);\n
return renderContactPage(gadget, connection_gadget);\n
});\n
});\n
}\n
}\n
}(),\n
addLog(gadget, jid, text, is_incoming)\n
]);\n
}\n
\n
function renderHistoryPage(gadget) {\n
var jid,\n
dialog_url;\n
return RSVP.Queue()\n
.push(function () {\n
jid = gadget.props.options.jid;\n
return gadget.aq_pleasePublishMyState({page: PAGE_DIALOG, jid: jid});\n
})\n
.push(function (dialog) {\n
dialog_url = dialog;\n
return loadHistory(gadget, jid);\n
})\n
.push(function (result) {\n
gadget.props.header_element.innerHTML = gadget.props.header_template({\n
left_url: dialog_url,\n
left_title: "Back",\n
title: "History of " + jid\n
});\n
gadget.props.content_element.innerHTML = gadget.props.history_template({\n
text: result.history\n
});\n
$(gadget.props.element).trigger("create");\n
});\n
}\n
}\n
\n
\n
function renderDialogPage(gadget, connection_gadget) {\n
function renderDialogPage(gadget, connection_gadget) {\n
var jid,\n
contact_url;\n
return RSVP.Queue()\n
return RSVP.Queue()\n
.push(function () {\n
.push(function () {\n
return gadget.aq_pleasePublishMyState({page: PAGE_CONTACT});\n
return gadget.aq_pleasePublishMyState({page: PAGE_CONTACT});\n
})\n
})\n
.push(function (contact_url) {\n
.push(function (contact) {\n
var jid = gadget.props.options.jid,\n
jid = gadget.props.options.jid;\n
last_child;\n
contact_url = contact;\n
return gadget.aq_pleasePublishMyState({page: PAGE_HISTORY, jid: jid});\n
})\n
.push(function (history_url) {\n
var last_child;\n
gadget.props.header_element.innerHTML = gadget.props.header_template({\n
gadget.props.header_element.innerHTML = gadget.props.header_template({\n
left_url: contact_url,\n
left_url: contact_url,\n
left_title: "Back",\n
left_title: "Back",\n
title: jid\n
title: jid,\n
right_url: history_url,\n
right_title: "History"\n
});\n
});\n
gadget.props.content_element.innerHTML =\n
gadget.props.content_element.innerHTML =\n
gadget.props.dialog_template({});\n
gadget.props.dialog_template({});\n
...
@@ -292,6 +464,7 @@
...
@@ -292,6 +464,7 @@
function renderConnectPage(gadget) {\n
function renderConnectPage(gadget) {\n
// Always flush the contact list\n
// Always flush the contact list\n
gadget.props.contact_dict = {};\n
gadget.props.contact_dict = {};\n
gadget.props.my_jid = \'\';\n
// Always kill the previous connection gadget to ensure disconnection\n
// Always kill the previous connection gadget to ensure disconnection\n
gadget.props.connection_element.innerHTML = "";\n
gadget.props.connection_element.innerHTML = "";\n
return gadget.dropGadget(CONNECTION_GADGET_SCOPE)\n
return gadget.dropGadget(CONNECTION_GADGET_SCOPE)\n
...
@@ -334,6 +507,7 @@
...
@@ -334,6 +507,7 @@
.push(function (result_list) {\n
.push(function (result_list) {\n
var connection_gadget = result_list[0],\n
var connection_gadget = result_list[0],\n
submit_event = result_list[1];\n
submit_event = result_list[1];\n
gadget.props.my_jid = submit_event.target[1].value;\n
return connection_gadget.connect(\n
return connection_gadget.connect(\n
submit_event.target[0].value,\n
submit_event.target[0].value,\n
submit_event.target[1].value,\n
submit_event.target[1].value,\n
...
@@ -400,6 +574,9 @@
...
@@ -400,6 +574,9 @@
g.props.dialog_template = Handlebars.compile(\n
g.props.dialog_template = Handlebars.compile(\n
document.querySelector(".dialog-template").innerHTML\n
document.querySelector(".dialog-template").innerHTML\n
);\n
);\n
g.props.history_template = Handlebars.compile(\n
document.querySelector(".history-template").innerHTML\n
);\n
g.props.message_template = Handlebars.compile(\n
g.props.message_template = Handlebars.compile(\n
document.querySelector(".message-template").innerHTML\n
document.querySelector(".message-template").innerHTML\n
);\n
);\n
...
@@ -408,6 +585,10 @@
...
@@ -408,6 +585,10 @@
);\n
);\n
});\n
});\n
})\n
})\n
// Configure jIO storage\n
.ready(function (g) {\n
return createJio(g);\n
})\n
\n
\n
//////////////////////////////////////////\n
//////////////////////////////////////////\n
// Connection information\n
// Connection information\n
...
@@ -488,8 +669,7 @@
...
@@ -488,8 +669,7 @@
if (!document.hasFocus()) {\n
if (!document.hasFocus()) {\n
// Only notify when page has no focused.\n
// Only notify when page has no focused.\n
// It simplifies a lot notification status\n
// It simplifies a lot notification status\n
$("#favicon").attr("href", \n
$("#favicon").attr("href", "data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEREAAAAAAAAREQAAAAAAABERAAAAAAAAEREAAAAAAAAAAAAAAAAAABERAAAAAAAAEREAAAAAAAAREQAAAAAAABERAAAAAAAAEREAAAAAAAAREQAAAAAAABERAAAAAAAAEREAAAAAAAAREQAAAAAAABERAAAAAAAAEREAAAD8PwAA/D8AAPw/AAD8PwAA//8AAPw/AAD8PwAA/D8AAPw/AAD8PwAA/D8AAPw/AAD8PwAA/D8AAPw/AAD8PwAA");\n
"data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEREAAAAAAAAREQAAAAAAABERAAAAAAAAEREAAAAAAAAAAAAAAAAAABERAAAAAAAAEREAAAAAAAAREQAAAAAAABERAAAAAAAAEREAAAAAAAAREQAAAAAAABERAAAAAAAAEREAAAAAAAAREQAAAAAAABERAAAAAAAAEREAAAD8PwAA/D8AAPw/AAD8PwAA//8AAPw/AAD8PwAA/D8AAPw/AAD8PwAA/D8AAPw/AAD8PwAA/D8AAPw/AAD8PwAA");\n
}\n
}\n
return updateConversation(this, argument_list[0],\n
return updateConversation(this, argument_list[0],\n
argument_list[2], true);\n
argument_list[2], true);\n
...
@@ -535,6 +715,8 @@
...
@@ -535,6 +715,8 @@
method = renderNewContactPage;\n
method = renderNewContactPage;\n
} else if (options.page === PAGE_DIALOG) {\n
} else if (options.page === PAGE_DIALOG) {\n
method = renderDialogPage;\n
method = renderDialogPage;\n
} else if (options.page === PAGE_HISTORY) {\n
method = renderHistoryPage;\n
} else {\n
} else {\n
throw new Error("not implemented page " + options.page);\n
throw new Error("not implemented page " + options.page);\n
}\n
}\n
...
@@ -683,7 +865,7 @@
...
@@ -683,7 +865,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
actor
</string>
</key>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
<value>
<string>
klaus.woelfel
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
comment
</string>
</key>
<key>
<string>
comment
</string>
</key>
...
@@ -697,7 +879,7 @@
...
@@ -697,7 +879,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
39.42421.62935.47718
</string>
</value>
<value>
<string>
9
42.15802.51997.34560
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -715,8 +897,8 @@
...
@@ -715,8 +897,8 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
14
18722252.34
</float>
<float>
14
28662162.99
</float>
<string>
GMT
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
</object>
</object>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment