Skip to content

Commit

Permalink
add: log items remove button
Browse files Browse the repository at this point in the history
  • Loading branch information
Maigo Erit committed Oct 12, 2017
1 parent f5b9040 commit bae66c5
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 163 deletions.
68 changes: 37 additions & 31 deletions client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import './style/_themes/blue-theme.scss';
import './style/app.scss';
import 'material-design-iconic-font/dist/css/material-design-iconic-font.css';
import 'font-awesome/css/font-awesome.css';
import "aurelia-dialog/styles/output.css";
import 'aurelia-dialog/styles/output.css';
import 'typeface-berkshire-swash';
import { Router } from "aurelia-router";
import { EventAggregator } from "aurelia-event-aggregator";


import { Router } from 'aurelia-router';
import { EventAggregator } from 'aurelia-event-aggregator';

const remote = (<any>window).nodeRequire('electron').remote;

Expand All @@ -31,45 +29,49 @@ let logger = LogManager.getLogger('InitMain');
export async function configure(aurelia: Aurelia) {
aurelia.use
.standardConfiguration()
.feature(PLATFORM.moduleName("resources/index"))
.feature(PLATFORM.moduleName('resources/index'))
.plugin(PLATFORM.moduleName('aurelia-dialog'))
.plugin(PLATFORM.moduleName('aurelia-i18n'), (instance) => {
.plugin(PLATFORM.moduleName('au-table'))
.plugin(PLATFORM.moduleName('aurelia-i18n'), instance => {
// register backend plugin
instance.i18next.use(Backend);

function loadLocales(url, options, callback, data) {
try {
let waitForLocale = require('bundle-loader!./locales/en/' + url + '.json');
waitForLocale((locale) => {
let waitForLocale = require('bundle-loader!./locales/en/' +
url +
'.json');
waitForLocale(locale => {
callback(locale, { status: '200' });
});
} catch (e) {
logger.error(e);
callback(null, { status: '404' });
}

}

return instance.setup({
backend: {
loadPath: '{{ns}}',
parse: (data) => data,
ajax: loadLocales
},
lng: 'en',
attributes: ['t', 'i18n'],
fallbackLng: 'en',
debug: false,
ns: ['translation', 'validation', 'field', 'messages', 'nav'],
defaultNS: 'translation'
}).then(() => {
const router = aurelia.container.get(Router);
const events = aurelia.container.get(EventAggregator);
router.transformTitle = title => instance.tr(title);
events.subscribe('i18n:locale:changed', () => {
router.updateTitle();
return instance
.setup({
backend: {
loadPath: '{{ns}}',
parse: data => data,
ajax: loadLocales,
},
lng: 'en',
attributes: ['t', 'i18n'],
fallbackLng: 'en',
debug: false,
ns: ['translation', 'validation', 'field', 'messages', 'nav'],
defaultNS: 'translation',
})
.then(() => {
const router = aurelia.container.get(Router);
const events = aurelia.container.get(EventAggregator);
router.transformTitle = title => instance.tr(title);
events.subscribe('i18n:locale:changed', () => {
router.updateTitle();
});
});
});
})
.plugin(PLATFORM.moduleName('aurelia-validation'))
.plugin(PLATFORM.moduleName('au-table'));
Expand All @@ -79,8 +81,12 @@ export async function configure(aurelia: Aurelia) {
// }

const window = remote.getCurrentWindow();
const isMenubarWin = (window.id == 2);
const isMenubarWin = window.id == 2;

await aurelia.start();
await aurelia.setRoot((isMenubarWin) ? PLATFORM.moduleName('app-menubar') : PLATFORM.moduleName('app'));
await aurelia.setRoot(
isMenubarWin
? PLATFORM.moduleName('app-menubar')
: PLATFORM.moduleName('app'),
);
}
7 changes: 5 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@types/jest": "^20.0.6",
"@types/lodash": "^4.14.72",
"@types/webpack": "^3.0.7",
"au-table": "^0.1.12",
"au-table": "^0.1.13",
"aurelia-animator-css": "1.0.2",
"aurelia-bootstrapper": "2.1.1",
"aurelia-dialog": "^1.0.0-rc.1.0.3",
Expand Down Expand Up @@ -94,7 +94,10 @@
"babel",
"<rootDir>/node_modules/source-map-support"
],
"moduleFileExtensions": ["ts", "js"],
"moduleFileExtensions": [
"ts",
"js"
],
"setupTestFrameworkScriptFile": "<rootDir>/util/jest-setup.js",
"transform": {
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
Expand Down
115 changes: 59 additions & 56 deletions client/services/track-item-service.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,71 @@
import { autoinject } from "aurelia-framework";
import * as moment from "moment";
import { SettingsService } from "./settings-service";
import { autoinject } from 'aurelia-framework';
import * as moment from 'moment';
import { SettingsService } from './settings-service';

const remote = (<any>window).nodeRequire('electron').remote;
let ipcRenderer: any = (<any>window).nodeRequire('electron').ipcRenderer;

@autoinject
export class TrackItemService {
private service: any;
private service: any;

constructor(private settingsService: SettingsService) {
this.service = remote.getGlobal('TrackItemService');
}
constructor(private settingsService: SettingsService) {
this.service = remote.getGlobal('TrackItemService');
}

/* findAllItems(from, to, taskName, searchStr, paging) {
/* findAllItems(from, to, taskName, searchStr, paging) {
return this.service.findAllFromDay(from, to, taskName, searchStr, paging);
}*/

findAllDayItems(from, to, taskName): Promise<any> {
return this.service.findAllDayItems(from, to, taskName);
}

findAllFromDay(from: Date, type: string): Promise<any> {
return this.service.findAllFromDay(from, type);
}

findFirstLogItems(): Promise<any> {
return this.service.findFirstLogItems();
}

createItem(trackItem): Promise<any> {
return this.service.createTrackItem(trackItem);
}

updateItem(trackItem): Promise<any> {
return this.service.updateItem(trackItem);
}

deleteById(trackItemId) {
return this.service.deleteById(trackItemId);
}

startNewLogItem(oldItem: any) {
console.log("startNewLogItem");

let newItem: any = {};
newItem.app = oldItem.app || "WORK";
newItem.taskName = "LogTrackItem";
newItem.color = oldItem.color;
newItem.title = oldItem.title;
newItem.beginDate = moment().toDate();
newItem.endDate = moment().add(60, 'seconds').toDate();

ipcRenderer.send('start-new-log-item', newItem);

}

stopRunningLogItem(runningLogItemId) {
console.log("stopRunningLogItem", runningLogItemId);
ipcRenderer.send('end-running-log-item');
}

updateColorForApp(appName, color) {
return this.service.updateColorForApp(appName, color);
}

findAllDayItems(from, to, taskName): Promise<any> {
return this.service.findAllDayItems(from, to, taskName);
}

findAllFromDay(from: Date, type: string): Promise<any> {
return this.service.findAllFromDay(from, type);
}

findFirstLogItems(): Promise<any> {
return this.service.findFirstLogItems();
}

createItem(trackItem): Promise<any> {
return this.service.createTrackItem(trackItem);
}

updateItem(trackItem): Promise<any> {
return this.service.updateItem(trackItem);
}

deleteById(trackItemId) {
return this.service.deleteById(trackItemId);
}
deleteByIds(trackItemId) {
return this.service.deleteByIds(trackItemId);
}

startNewLogItem(oldItem: any) {
console.log('startNewLogItem');

let newItem: any = {};
newItem.app = oldItem.app || 'WORK';
newItem.taskName = 'LogTrackItem';
newItem.color = oldItem.color;
newItem.title = oldItem.title;
newItem.beginDate = moment().toDate();
newItem.endDate = moment()
.add(60, 'seconds')
.toDate();

ipcRenderer.send('start-new-log-item', newItem);
}

stopRunningLogItem(runningLogItemId) {
console.log('stopRunningLogItem', runningLogItemId);
ipcRenderer.send('end-running-log-item');
}

updateColorForApp(appName, color) {
return this.service.updateColorForApp(appName, color);
}
}
20 changes: 14 additions & 6 deletions client/summary/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="row">
<div class="col col-md-auto">
<button type="button" class="btn btn-secondary" click.delegate="list()">
<i class="fa fa-refresh"></i>
<i class="fa fa-refresh"></i>
</button>
</div>
<div class="col col-md-auto">
Expand All @@ -15,12 +15,16 @@
<div class="col col-md-auto">
<bootstrap-datepicker placeholder="To" dateobj.bind="searchMaxDate"></bootstrap-datepicker>
</div>

<div class="col col-md-auto">
<button type="button" class="btn btn-danger-outline btn btn-no-border" click.delegate="deleteTrackItems()">
<i class="fa fa-trash-o"></i>
</button>
</div>
</div>

<table class="table table-striped">
<table class="table table-striped" aurelia-table="data.bind: trackItems; display-data.bind: $displayData">
<thead>
<tr>
<th></th>
<th>App</th>
<th>Title</th>
<th>Begin</th>
Expand All @@ -29,7 +33,10 @@
</tr>
</thead>
<tbody>
<tr repeat.for="trackItem of trackItems">
<tr repeat.for="trackItem of $displayData" aut-select="row.bind: trackItem; mode: multiple; selected-class: bg-warning" select.delegate="rowSelected($event)">
<td>
<input type="checkbox" checked.bind="trackItem.$isSelected" />
</td>
<td>${trackItem.app}</td>
<td>${trackItem.title}</td>
<td>${trackItem.beginDate | toDate | df: { year: '2-digit', month: '2-digit', day: '2-digit', hour: '2-digit', minute:
Expand All @@ -42,7 +49,8 @@
<tfoot>
<tr>
<td></td>
<td><strong>Total: </strong>${trackItemsTotal | msToDuration}
<td>
<strong>Total: </strong>${trackItemsTotal | msToDuration}
</td>
<td colspan="6"></td>
</tr>
Expand Down
Loading

0 comments on commit bae66c5

Please sign in to comment.