Merge branch 'master' into RebeccaBranch

RebeccaBranch
David Tookey 5 years ago
commit 5c2ea9844d

@ -10,6 +10,7 @@ let tsSource = ts.createProject('tsconfig.json')
function clean(cb) { function clean(cb) {
del(['build/*']); del(['build/*']);
del(['out/*']);
cb(); cb();
} }
@ -45,6 +46,10 @@ function validateConfigSources(cb) {
cb(); cb();
} }
let deploy = () => {
};
function conf() { function conf() {
return src(['src/assets/**/*', '!src/assets/**/*.scss'], {base: 'src/assets'}) return src(['src/assets/**/*', '!src/assets/**/*.scss'], {base: 'src/assets'})
.pipe(dest('build/assets/')); .pipe(dest('build/assets/'));
@ -112,7 +117,6 @@ let validationRules = {
"description": stringLengthRule "description": stringLengthRule
} }
} }
} }
@ -124,3 +128,4 @@ exports.tests = series(validateConfigSources, conf, style, scss, root, pkg, type
exports.runFast = series(validateConfigSources, conf, style, scss, root, pkg) exports.runFast = series(validateConfigSources, conf, style, scss, root, pkg)
exports.deploy = series(clean, validateConfigSources, conf, style, scss, root, pkg, typescript, dependencies, deploy);

40
package-lock.json generated

@ -871,9 +871,9 @@
} }
}, },
"base64-js": { "base64-js": {
"version": "1.3.1", "version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"dev": true "dev": true
}, },
"bcrypt-pbkdf": { "bcrypt-pbkdf": {
@ -4879,9 +4879,9 @@
} }
}, },
"y18n": { "y18n": {
"version": "4.0.0", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true "dev": true
}, },
"yargs": { "yargs": {
@ -5394,9 +5394,9 @@
} }
}, },
"y18n": { "y18n": {
"version": "4.0.0", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true "dev": true
}, },
"yargs": { "yargs": {
@ -5864,14 +5864,14 @@
} }
}, },
"plist": { "plist": {
"version": "3.0.1", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.1.tgz", "resolved": "https://registry.npmjs.org/plist/-/plist-3.0.2.tgz",
"integrity": "sha512-GpgvHHocGRyQm74b6FWEZZVRroHKE1I0/BTjAmySaohK+cUn+hZpbqXkc3KWgW3gQYkqcQej35FohcT0FRlkRQ==", "integrity": "sha512-MSrkwZBdQ6YapHy87/8hDU8MnIcyxBKjeF+McXnr5A9MtffPewTs7G3hlpodT5TacyfIyFTaJEhh3GGcmasTgQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"base64-js": "^1.2.3", "base64-js": "^1.5.1",
"xmlbuilder": "^9.0.7", "xmlbuilder": "^9.0.7",
"xmldom": "0.1.x" "xmldom": "^0.5.0"
} }
}, },
"plugin-error": { "plugin-error": {
@ -6461,9 +6461,9 @@
} }
}, },
"y18n": { "y18n": {
"version": "4.0.0", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true "dev": true
}, },
"yargs": { "yargs": {
@ -7690,9 +7690,9 @@
"dev": true "dev": true
}, },
"xmldom": { "xmldom": {
"version": "0.1.31", "version": "0.5.0",
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz", "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.5.0.tgz",
"integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ==", "integrity": "sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA==",
"dev": true "dev": true
}, },
"xtend": { "xtend": {

@ -16,10 +16,10 @@
"start-fast": "gulp runFast && electron ./build --debug", "start-fast": "gulp runFast && electron ./build --debug",
"dev": "npm run build && electron ./build --debug", "dev": "npm run build && electron ./build --debug",
"package": "npm-run-all package:*", "package": "npm-run-all package:*",
"package:mac": "electron-packager ./build --overwrite --platform=darwin --arch=x64 --out=out --icon=assets/images/app.icns --osx-sign.identity='Developer ID Application: GitHub' --extend-info=assets/mac/info.plist", "package:mac": "electron-packager ./build --overwrite --platform=darwin --arch=x64 --out=out --icon=src/assets/images/icon.ico --osx-sign.identity='Developer ID Application: GitHub' --extend-info=assets/mac/info.plist",
"package:win32": "electron-packager ./build --overwrite --platform=win32 --arch=ia32 --out=out --icon=assets/images/app.ico", "package:win32": "electron-packager ./build --overwrite --platform=win32 --arch=ia32 --out=out --icon=src/assets/images/icon.ico",
"package:win64": "electron-packager ./build --overwrite --platform=win32 --arch=x64 --out=out --icon=assets/images/app.ico", "package:win64": "electron-packager ./build --overwrite --platform=win32 --arch=x64 --out=out --icon=src/assets/images/icon.ico",
"package:linux": "electron-packager ./build --overwrite --platform=linux --arch=x64 --out=out", "package:linux": "electron-packager ./build --overwrite --platform=linux --arch=x64 --out=out --icon=src/assets/images/icon.ico",
"package:installer": "node ./script/installer.js", "package:installer": "node ./script/installer.js",
"release": "node ./script/release.js", "release": "node ./script/release.js",
"prepack": "check-for-leaks", "prepack": "check-for-leaks",

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -2,19 +2,54 @@ require('update-electron-app')({
logger: require('electron-log') logger: require('electron-log')
}) })
const updateCheckInterval = 1000 * 60
const path = require('path') const path = require('path')
const {app, BrowserWindow} = require('electron') const {app, BrowserWindow, autoUpdater} = require('electron')
const server = 'https://update.jdsconsulting.net'
const url = `${server}/update/${process.platform}/${app.getVersion()}`
autoUpdater.setFeedURL({url})
autoUpdater.checkForUpdates();
setInterval(() => {
console.log("Checking for update...");
autoUpdater.checkForUpdates();
}, updateCheckInterval)
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
console.log("Handling updates...")
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Application Update',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version has been downloaded. Restart the application to apply the updates.'
}
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) autoUpdater.quitAndInstall()
})
})
autoUpdater.on('error', message => {
console.error('There was a problem updating the application')
console.error(message)
})
const debug = /--debug/.test(process.argv[2]) const debug = /--debug/.test(process.argv[2])
if (process.mas) app.setName('JDSfaulkner Portal') if (process.mas) app.setName('JDS Consulting Portal')
let mainWindow = null let mainWindow = null
function initialize () { function initialize() {
makeSingleInstance() makeSingleInstance()
function createWindow () { function createWindow() {
const windowOptions = { const windowOptions = {
width: 1080, width: 1080,
minWidth: 769, minWidth: 769,
@ -69,7 +104,7 @@ function initialize () {
// //
// Returns true if the current version of the app should quit instead of // Returns true if the current version of the app should quit instead of
// launching. // launching.
function makeSingleInstance () { function makeSingleInstance() {
if (process.mas) return if (process.mas) return
app.requestSingleInstanceLock() app.requestSingleInstanceLock()

@ -1,5 +1,6 @@
let path = require('path') let path = require('path')
let fs = require('fs'); let fs = require('fs');
let os = require('os');
const shell = require('electron').shell; const shell = require('electron').shell;
let fileExtensionToImage: object; let fileExtensionToImage: object;
@ -59,6 +60,7 @@ export module FileUtils {
export function getPathToView(templateName: string): string { export function getPathToView(templateName: string): string {
return path.join(getPathToAssets(), "views", templateName + ".mustache") return path.join(getPathToAssets(), "views", templateName + ".mustache")
} }
export function getPathToPage(pageName: string): string { export function getPathToPage(pageName: string): string {
return path.join(getPathToAssets(), "pages", pageName) return path.join(getPathToAssets(), "pages", pageName)
} }
@ -95,6 +97,34 @@ export module FileUtils {
fs.mkdirSync(dirPath); fs.mkdirSync(dirPath);
} }
} }
export function showFileInDir(resourcePath: string) {
let localFile = copyFileToUserDocuments(resourcePath);
shell.showItemInFolder(localFile);
}
/**
* @param resourcePath pathlike of system resource
* @private
* @returns pathlike of local user resource
*/
function copyFileToUserDocuments(resourcePath: string): string {
let fileName = path.basename(resourcePath);
let userFilePath = getPathToUserDocumentDir(fileName);
if(!fs.existsSync(userFilePath)){
fs.copyFileSync(resourcePath, userFilePath);
}
return userFilePath;
}
function getPathToUserDocumentDir(fileName: string): string {
let homeDir = os.homedir();
let parent = path.join(homeDir, "Documents", "Employee Resources");
if(!fs.existsSync(parent)){
fs.mkdirSync(parent);
}
return path.join(parent, fileName);
}
} }
@ -114,27 +144,24 @@ export class DocumentDirectory {
private static walkCards(d: DirectoryNode): Map<string, object[]> { private static walkCards(d: DirectoryNode): Map<string, object[]> {
let cardsByCategory = new Map<string, object[]>(); let cardsByCategory = new Map<string, object[]>();
for (let i = 0, l = d.children.length; i < l; i++) { for (let child of d.children) {
let child = d.children[i];
if (child instanceof DirectoryNode) { if (child instanceof DirectoryNode) {
let dir = child as DirectoryNode; let dir = child as DirectoryNode;
if (dir.containsDirectory()) { if (dir.containsDirectory()) {
let childDirectories = dir.getDirectories(); let childDirectories = dir.getDirectories();
for (let j = 0, k = childDirectories.length; j < k; j++) { for (let dir of childDirectories) {
let dir = childDirectories[j];
let subCards = DocumentDirectory.walkCards(dir); let subCards = DocumentDirectory.walkCards(dir);
this.mergeMaps(cardsByCategory, subCards); this.mergeMaps(cardsByCategory, subCards);
} }
} }
let sCards = dir.getDocuments(); let sCards = dir.getDocuments();
let category = dir.getCategory(); let category = dir.getCategory();
for (let sCard in sCards) { for (let sCard of sCards) {
let scrd = sCards[sCard];
let cards = cardsByCategory.get(category); let cards = cardsByCategory.get(category);
if (cards === undefined || cards === null) { if (cards === undefined || cards === null) {
cards = []; cards = [];
} }
cards.push(scrd.toCard()); cards.push(sCard.toCard());
cardsByCategory.set(category, cards); cardsByCategory.set(category, cards);
} }
} else { } else {
@ -153,8 +180,7 @@ export class DocumentDirectory {
private static mergeMaps(a: Map<string, Object[]>, b: Map<string, Object[]>) { private static mergeMaps(a: Map<string, Object[]>, b: Map<string, Object[]>) {
let keys = Object.keys(b); let keys = Object.keys(b);
for (let z in keys) { for (let key of keys) {
let key = keys[z];
let sa = a.get(key) let sa = a.get(key)
if (sa === undefined || sa === null) { if (sa === undefined || sa === null) {
sa = []; sa = [];
@ -192,8 +218,7 @@ export class FileNode {
private static getImagePathFromDocumentName(name: string): string { private static getImagePathFromDocumentName(name: string): string {
let ext = FileUtils.getFileExtension(name); let ext = FileUtils.getFileExtension(name);
let thumbnail = Configurator.getFileExtensionToImageMap()[ext]; return Configurator.getFileExtensionToImageMap()[ext];
return thumbnail;
} }
open() { open() {
@ -213,12 +238,12 @@ export class FileNode {
"imagePath": imageName, "imagePath": imageName,
"urlText": this.filePath, "urlText": this.filePath,
"altText": "", "altText": "",
"fileCard": true "fileCard": true,
"open": this.open
} }
let altKeys = Object.keys(altProps); let altKeys = Object.keys(altProps);
for (let kidx in altKeys) { for (let key of altKeys) {
let key = altKeys[kidx];
cardObj[key] = altProps[key] cardObj[key] = altProps[key]
} }
@ -251,9 +276,9 @@ export class DirectoryNode extends FileNode {
let stats = fs.lstatSync(filePath); let stats = fs.lstatSync(filePath);
if (stats.isDirectory()) { if (stats.isDirectory()) {
let contents = fs.readdirSync(filePath); let contents = fs.readdirSync(filePath);
for (let i = 0, l = contents.length; i < l; i++) { for (let fileName of contents) {
if (path.extname(contents[i]) === ".json") continue; if (path.extname(fileName) === ".json") continue;
let childPath = path.join(filePath, contents[i]); let childPath = path.join(filePath, fileName);
let childStats = fs.lstatSync(childPath); let childStats = fs.lstatSync(childPath);
if (childStats.isDirectory()) { if (childStats.isDirectory()) {
this.children.push(new DirectoryNode(childPath, this)); this.children.push(new DirectoryNode(childPath, this));
@ -282,8 +307,7 @@ export class DirectoryNode extends FileNode {
} }
containsDirectory(): Boolean { containsDirectory(): Boolean {
for (let i = 0, l = this.children.length; i < l; i++) { for (let child of this.children) {
let child = this.children[i];
if (child instanceof DirectoryNode) return true; if (child instanceof DirectoryNode) return true;
} }
return false return false

@ -14,7 +14,7 @@ function register() {
search(term); search(term);
} }
}else{ } else {
let term = searchBar.val().toString(); let term = searchBar.val().toString();
if (!term || 0 === term.length) { if (!term || 0 === term.length) {
reset() reset()
@ -23,7 +23,7 @@ function register() {
}); });
searchButton.on("click", ()=>{ searchButton.on("click", () => {
let term = searchBar.val().toString(); let term = searchBar.val().toString();
if (!term || 0 === term.length) { if (!term || 0 === term.length) {
reset() reset()
@ -33,7 +33,7 @@ function register() {
}) })
} }
function reset(){ function reset() {
buildUiFromConfig("resources-landing-page.json"); buildUiFromConfig("resources-landing-page.json");
} }
@ -47,7 +47,7 @@ function search(term: string) {
expandAllContainers(); expandAllContainers();
} }
function copyMissingKeys(webCards: object, fileCards: Map<string, object>){ function copyMissingKeys(webCards: object, fileCards: Map<string, object>) {
let elementConfig = Configurator.loadAppConfig("resources-landing-page.json"); let elementConfig = Configurator.loadAppConfig("resources-landing-page.json");
let containerKeys = Object.keys(elementConfig); let containerKeys = Object.keys(elementConfig);
for (let containerKey of containerKeys) { for (let containerKey of containerKeys) {
@ -127,8 +127,14 @@ function addToFileMap(map: Map<string, object>, categoryKey: string, card) {
function cardContainsTerm(term: string, card: object): boolean { function cardContainsTerm(term: string, card: object): boolean {
let titleContains = card["title"].toLowerCase().includes(term.toLowerCase()); let titleContains = card["title"].toLowerCase().includes(term.toLowerCase());
let descriptionContains = card["description"].toLowerCase().includes(term.toLowerCase()); let descriptionContains = card["description"].toLowerCase().includes(term.toLowerCase());
let keywordContains = false;
if (card["keywords"]) {
keywordContains = card["keywords"].toLowerCase().includes(term.toLowerCase());
}
//todo: add keywords //todo: add keywords
return titleContains || descriptionContains; return titleContains || descriptionContains || keywordContains;
} }
function highlightCardTerm(term: string, card: object): object { function highlightCardTerm(term: string, card: object): object {
@ -143,9 +149,9 @@ function escapeRegExp(term: string): string {
return term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string return term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
} }
function expandAllContainers(){ function expandAllContainers() {
let containers = $('[id$="collapser"]') let containers = $('[id$="collapser"]')
for(let container of containers){ for (let container of containers) {
container.click() container.click()
} }

@ -37,15 +37,19 @@ export function buildFileCard(elem: JQuery<HTMLElement>, obj, append: boolean =
elem.html(content) elem.html(content)
} }
if (model["show"] !== undefined) {
$(`#${id}`).on("click", () => { $(`#${id}`).on("click", () => {
shell.showItemInFolder(model.resourcePath) FileUtils.showFileInDir(model.resourcePath);
}); });
} else {
$(`#${id}`).on("click", () => { // if (model["show"] !== undefined) {
shell.openItem(model.resourcePath) // $(`#${id}`).on("click", () => {
}); // shell.showItemInFolder(model.resourcePath)
} // });
// } else {
// $(`#${id}`).on("click", () => {
// shell.openItem(model.resourcePath)
// });
// }
}); });
} }

Loading…
Cancel
Save