diff --git a/chatto/src/main/javascript/ts/src/main.ts b/chatto/src/main/javascript/ts/src/main.ts index a0f722e..bd99907 100644 --- a/chatto/src/main/javascript/ts/src/main.ts +++ b/chatto/src/main/javascript/ts/src/main.ts @@ -1,6 +1,6 @@ import { Builder } from "builder-pattern"; import * as Handlebars from "handlebars"; -import * as log from 'loglevel'; +import * as log from "loglevel"; import { ChatController } from "./controller/ChatController"; import { UserController } from "./controller/UserController"; import { ChatModel } from "./model/ChatModel"; @@ -20,89 +20,94 @@ import { UserViewDeps } from "./view/UserViewDeps"; import { ActiveUserViewModel } from "./viewmodel/ActiveUserViewModel"; import moment = require("moment"); -log.setLevel("TRACE"); +// log.setLevel("TRACE"); -const usersListElement = document.getElementById('contacts-box'); -const userSearchButton = document.getElementById('user-search'); -const userSearchInputElement = document.getElementById('user-search-term') as HTMLInputElement; -const userSearchCancelButton = document.getElementById('user-search-cancel'); -const chatArea = document.getElementById('chat-area-new'); +const usersListElement = document.getElementById("contacts-box"); +const userSearchButton = document.getElementById("user-search"); +const userSearchInputElement = document.getElementById( + "user-search-term" +) as HTMLInputElement; +const userSearchCancelButton = document.getElementById("user-search-cancel"); +const chatArea = document.getElementById("chat-area-new"); - -const activeUserSearchService: SearchService = new FuseSearchService(["userName"]); +const activeUserSearchService: SearchService = new FuseSearchService( + ["userName"] +); const ns: NotificationService = new AlertifyNotificationService(); const encryptionService = EncryptionServiceFactory.getEncryptionService(); - - const chatModelHelper = new ChatModelHelper(encryptionService, ns); const chatModel = new ChatModel(chatModelHelper); const userModel = new UserModel(ns); const cvDeps: ChatViewDeps = { - chatModel: chatModel, - // @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'. - messageContainer: chatArea, - messageSendTemplate: TemplateFactory.getTemplate('msg_container_send_template'), - messageReceiveTemplate: TemplateFactory.getTemplate('msg_container_template'), - markdownService: new MarkDownItMarkDownService, - encryptionService: encryptionService, - notificationService: ns, - userModel: userModel -} + chatModel: chatModel, + // @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'. + messageContainer: chatArea, + messageSendTemplate: TemplateFactory.getTemplate( + "msg_container_send_template" + ), + messageReceiveTemplate: TemplateFactory.getTemplate("msg_container_template"), + markdownService: new MarkDownItMarkDownService(), + encryptionService: encryptionService, + notificationService: ns, + userModel: userModel, +}; const chatView = new ChatView(cvDeps); chatModel.attach(chatView); const chatController = new ChatController(chatModel, chatView); - - - const uvDeps: UserViewDeps = { - model: userModel, - chatModel: chatModel, - // @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'. - usersListElement: usersListElement, - userSearchInputElement: userSearchInputElement, - // @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'. - userSearchButton: userSearchButton, - // @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'. - userSearchCancelButton: userSearchCancelButton, - searchService: activeUserSearchService, - userContactOnlineTemplate: TemplateFactory.getTemplate('user-contact-online-template'), - userContactOfflineTemplate: TemplateFactory.getTemplate('user-contact-offline-template'), - notificationService: ns -} + model: userModel, + chatModel: chatModel, + // @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'. + usersListElement: usersListElement, + userSearchInputElement: userSearchInputElement, + // @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'. + userSearchButton: userSearchButton, + // @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'. + userSearchCancelButton: userSearchCancelButton, + searchService: activeUserSearchService, + userContactOnlineTemplate: TemplateFactory.getTemplate( + "user-contact-online-template" + ), + userContactOfflineTemplate: TemplateFactory.getTemplate( + "user-contact-offline-template" + ), + notificationService: ns, +}; const userView = new UserView(uvDeps); userModel.attach(userView); const userController = new UserController(userModel, userView); userController.getActiveUsers(); // @ts-ignore -Handlebars.registerHelper('moment', require('helper-moment')); -Handlebars.registerHelper('avatar', function () { - return '
'; +Handlebars.registerHelper("moment", require("helper-moment")); +Handlebars.registerHelper("avatar", function () { + return '
'; +}); +Handlebars.registerHelper("fromNow", function (date: string) { + if (date == null) return ": Never"; + return moment(date).fromNow(); +}); +Handlebars.registerHelper("msgDateFormat", function (date: string) { + return moment(date).calendar(moment.now(), { + lastWeek: "DD/MM/YY hh:mm A", + sameElse: "DD/MM/YY hh:mm A", + }); }); -Handlebars.registerHelper('fromNow', function (date: string) { - if (date == null) - return ": Never" - return moment(date).fromNow(); -}) -Handlebars.registerHelper('msgDateFormat', function (date: string) { - return moment(date).calendar(moment.now(), { lastWeek: "DD/MM/YY hh:mm A", sameElse: "DD/MM/YY hh:mm A" }) -}) -Handlebars.registerHelper('lockIcon', function (unlocked: boolean) { - switch (unlocked) { - case true: { return ''; } - default: { return ''; } +Handlebars.registerHelper("lockIcon", function (unlocked: boolean) { + switch (unlocked) { + case true: { + return ''; } -}) - - - + default: { + return ''; + } + } +}); ns.success("Welcome"); // ns.errorWithDelay("Hmm very long error notif", 10); - const test = Builder().build(); - diff --git a/chatto/src/main/resources/application-prod.properties b/chatto/src/main/resources/application-prod.properties index 49f3744..ce43b11 100644 --- a/chatto/src/main/resources/application-prod.properties +++ b/chatto/src/main/resources/application-prod.properties @@ -5,4 +5,5 @@ logging.level.org.hibernate.SQL=INFO logging.level.org.hibernate.type.descriptor.sql.BasicBinder=INFO spring.http.log-request-details=false logging.level.org.springframework.cache = INFO -chat-bundle=bundle.min.js \ No newline at end of file +chat-bundle=bundle.min.js +chatto.frontend.log-level=INFO \ No newline at end of file diff --git a/chatto/src/main/resources/application.properties b/chatto/src/main/resources/application.properties index 3b8bd77..5fc75bf 100644 --- a/chatto/src/main/resources/application.properties +++ b/chatto/src/main/resources/application.properties @@ -20,6 +20,7 @@ logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE spring.jackson.serialization.write-dates-as-timestamps=false spring.cache.jcache.config=classpath:ehcache.xml logging.level.org.springframework.cache=DEBUG -chatto.token.timeout-duration=1 +chatto.token.timeout-duration=30 chat-bundle=bundle.js -# spring.devtools.add-properties=false \ No newline at end of file +# spring.devtools.add-properties=false +chatto.frontend.log-level=TRACE \ No newline at end of file diff --git a/chatto/src/main/resources/templates/fragments/head.html b/chatto/src/main/resources/templates/fragments/head.html index 430488d..e3bd1dc 100644 --- a/chatto/src/main/resources/templates/fragments/head.html +++ b/chatto/src/main/resources/templates/fragments/head.html @@ -11,7 +11,7 @@ - + @@ -40,10 +40,14 @@ - + + Layout Generic Title