diff --git a/src/assets/conf/file-extensions.json b/src/assets/conf/file-extensions.json index 4e7a0a2..819b309 100644 --- a/src/assets/conf/file-extensions.json +++ b/src/assets/conf/file-extensions.json @@ -1,3 +1,6 @@ { - ".pdf": "pdf-icon.svg" + ".pdf": "pdf-icon-100x100.png", + ".eps": "image-eps-icon.png", + ".png": "image-png-icon.png", + ".docx": "word-icon-100x100.png" } \ No newline at end of file diff --git a/src/assets/conf/resources-landing-page.json b/src/assets/conf/resources-landing-page.json index a65a801..73630a9 100644 --- a/src/assets/conf/resources-landing-page.json +++ b/src/assets/conf/resources-landing-page.json @@ -1,8 +1,9 @@ { "grid-container": { - - - + "Resources": { + "description": "Top level resources", + "cards": [] + }, "Human Resources": { "description": "Policies, recruitment, onboarding, benefits and compensation", "cards": [ @@ -71,8 +72,6 @@ } ] }, - - "Marketing": { "description": "Client-facing media, publications, public relations and advertising", "cards": [ @@ -141,8 +140,6 @@ } ] }, - - "Productivity": { "description": "Basic work tools, e-mail, calendar, document applications and cloud storage", "cards": [ @@ -176,8 +173,6 @@ } ] }, - - "Training": { "description": "Career growth, skills development, online courses, manuals and references", "cards": [ @@ -220,13 +215,11 @@ "title": "Deltek University", "description": "Increase your Deltek knowledge with courses designed to teach you how to use Deltek solutions.", "imagePath": "deltek-logo-black.png", - "urlText":"https://www.deltek.com/en/support/deltek-university", - "altText": "Deltek logo" + "urlText": "https://www.deltek.com/en/support/deltek-university", + "altText": "Deltek logo" } ] }, - - "Workflow": { "description": "Project management, task assignment and status, client information, invoicing and reports", "cards": [ diff --git a/src/assets/resources/coming-soon.pdf.json b/src/assets/resources/coming-soon.pdf.json index 6a3ae3e..48aa54d 100644 --- a/src/assets/resources/coming-soon.pdf.json +++ b/src/assets/resources/coming-soon.pdf.json @@ -1,5 +1,4 @@ { "description": "Coming soon pdf", - "imagePath": "../resources/coming-soon.pdf", "show": true } \ No newline at end of file diff --git a/src/assets/resources/marketing/JDS_faulkner_Logo.eps.json b/src/assets/resources/marketing/JDS_faulkner_Logo.eps.json new file mode 100644 index 0000000..763657c --- /dev/null +++ b/src/assets/resources/marketing/JDS_faulkner_Logo.eps.json @@ -0,0 +1,5 @@ +{ + "title": "JDSfaulkner Logo - EPS", + "description": "Do you need to present the logo in your work? Here's an eps format to use in collateral and merchandise.", + "show": true +} \ No newline at end of file diff --git a/src/ts_source/fileutils.ts b/src/ts_source/fileutils.ts index 6a1c547..8a30a7b 100644 --- a/src/ts_source/fileutils.ts +++ b/src/ts_source/fileutils.ts @@ -1,5 +1,3 @@ - - let path = require('path') let fs = require('fs'); const shell = require('electron').shell; @@ -107,7 +105,7 @@ export class DocumentDirectory { root: DirectoryNode; - getCards(): object { + getCards(): Map { return DocumentDirectory.walkCards(this.root); } @@ -189,6 +187,12 @@ export class FileNode { return props } + private static getImagePathFromDocumentName(name: string): string { + let ext = FileUtils.getFileExtension(name); + let thumbnail = Configurator.getFileExtensionToImageMap()[ext]; + return thumbnail; + } + open() { shell.openItem(this.filePath); } @@ -198,11 +202,12 @@ export class FileNode { } toCard(): object { - let altProps = FileNode.loadAltProps(this.filePath) + let altProps = FileNode.loadAltProps(this.filePath); + let imageName = FileNode.getImagePathFromDocumentName(this.filePath); let cardObj = { "title": this.getTitle(), "description": "", - "imagePath": "", + "imagePath": imageName, "urlText": this.filePath, "altText": "", "fileCard": true @@ -244,6 +249,7 @@ export class DirectoryNode extends FileNode { if (stats.isDirectory()) { let contents = fs.readdirSync(filePath); for (let i = 0, l = contents.length; i < l; i++) { + if (path.extname(contents[i]) === ".json") continue; let childPath = path.join(filePath, contents[i]); let childStats = fs.lstatSync(childPath); if (childStats.isDirectory()) { diff --git a/src/ts_source/viewFactory.ts b/src/ts_source/viewFactory.ts index e0aa143..cb8cbdc 100644 --- a/src/ts_source/viewFactory.ts +++ b/src/ts_source/viewFactory.ts @@ -1,5 +1,6 @@ -import {Configurator, FileUtils} from './fileutils' +import {Configurator, DocumentDirectory, FileUtils} from './fileutils' import {loadTemplate, loadTemplateSingle} from "./templates" +import * as path from "path"; const shell = require('electron').shell; @@ -18,29 +19,43 @@ export class CardModel { } } -export function buildFileCard(filePath: string, elem: Element, append: boolean = false, $: any = require('jquery')) { - // let model = new CardModel(getImagePathFromDocumentName(filePath), fileNameToPrettyString(filePath)); - // loadTemplateSingle("file-card.mustache", model, (content: string, id: string) => { - // let snip = $(content); - // let container = $("#" + elem.id); - // - // if (append) { - // container.append(snip); - // } else { - // container.empty().append(snip); - // } - // setTimeout(() => { - // $(`#${id}`).on("click", () => { - // launchDocument(filePath); - // }); - // }, 1); //for some reason we have to let the dom breathe before it will let us do this? - // }); +export function buildFileCard(elem: JQuery, obj, append: boolean = false, $: any = require('jquery')) { + console.log(obj); + let model = new CardModel( + obj["title"], + obj["description"], + FileUtils.getPathToImage(obj["imagePath"]), + obj["urlText"] + ); + model["show"] = obj["show"]; + + loadTemplateSingle("web-card.mustache", model, (content: string, id: string) => { + if (append) { + elem.append(content); + } else { + elem.html(content) + } + + if (model["show"] !== undefined) { + $(`#${id}`).on("click", () => { + console.log("showing") + shell.showItemInFolder(model.resourcePath) + }); + } else { + $(`#${id}`).on("click", () => { + console.log("opening") + shell.openItem(model.resourcePath) + }); + } + }); } export function buildWebCardsFromConfig(configName: string) { let elementConfig = Configurator.loadAppConfig(configName); let $ = require('jquery') let containers = Object.keys(elementConfig); + let directoryPath = path.join(__dirname, "../assets/resources"); + let fileCards = new DocumentDirectory(directoryPath).getCards(); for (let i = 0, l = containers.length; i < l; i++) { let containerName = containers[i]; @@ -48,11 +63,15 @@ export function buildWebCardsFromConfig(configName: string) { let containerElem = $(`#${containerName}`); let containerCategories = Object.keys(containerObject); + containerCategories.push("Resources"); for (let j = 0, m = containerCategories.length; j < m; j++) { let categoryMetaObjectKey = containerCategories[j]; let categoryMetaObject = containerObject[categoryMetaObjectKey]; + let contentList = categoryMetaObject["cards"];//should be array of objects to render + let files = fileCards.get(categoryMetaObjectKey); + let categoryDescription = categoryMetaObject["description"]; let categoryKey = categoryMetaObjectKey.replace(/[\s,]/ig, '-').toLowerCase(); let categoryObject = { @@ -84,10 +103,17 @@ export function buildWebCardsFromConfig(configName: string) { } }); + for (let j in files) { + let file = files[j]; + buildFileCard(view, file, true, $) + } + for (let j = 0, m = contentList.length; j < m; j++) { let content = contentList[j]; buildWebCard(view, content, true, $); } + + } } @@ -128,12 +154,6 @@ function fileNameToPrettyString(fileName: string): string { return buffer.join(''); } -function getImagePathFromDocumentName(name: string): string { - let ext = FileUtils.getFileExtension(name); - let thumbnail = Configurator.getFileExtensionToImageMap()[ext]; - return FileUtils.getPathToImage(thumbnail); -} - function launchDocument(filename: string) { let fullPath = FileUtils.getPathToDocument(filename); shell.openItem(fullPath);