Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
Jira integration fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Cucer committed Feb 22, 2018
1 parent 918bf30 commit da572d7
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ npm run publish
- [x] Add Redmine Integration
- [x] Add deep Redmine Integration
- [x] Archive old data
- [ ] Add Jira Integration
- [x] Add Jira Integration
- [ ] Add deep Jira Integration
- [ ] Build for multiple platforms (Linux/Win)
- [ ] Add tests
Expand Down
32 changes: 29 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "titime",
"productName": "TiTime - Keeping the time for you",
"version": "1.3.6",
"version": "1.4.1",
"description": "Tool for Instant Time Tracking",
"main": "src/index.js",
"scripts": {
Expand Down
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ if (Env.isDebug()) {
const createProviderSyncCommand = (providerName, createProvider) => async (...args) => {
const provider = createProvider(...args);

if (!cron.exists('jira')) {
if (!cron.exists(providerName)) {
cron.add(
'jira',
providerName,
registry.config().get('remoteSyncCron'),
() => provider.synchronize().then(() => provider.report(registry.config().get('minLogTime'))),
() => provider.synchronize()
.then(() => provider.report(registry.config().get('minLogTime'))),
true,
);
}
Expand All @@ -79,7 +80,7 @@ registry
}
})
.register('synchronizeRedmine', createProviderSyncCommand(
'jira',
'redmine',
(host, apiKey) => new RedmineProvider(db, { host, apiKey }),
))
.register('synchronizeJira', createProviderSyncCommand(
Expand Down
2 changes: 1 addition & 1 deletion src/remote/redmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export default class RedmineProvider extends AbstractProvider {
timeSegmentValid(lastReportTime, segment) { // eslint-disable-line class-methods-use-this
if (!lastReportTime) {
return true;
} else if (moment.unix(segment.start).isSameOrAfter(moment.unix(lastReportTime))) {
} else if (moment.unix(segment.end).isSameOrAfter(moment.unix(lastReportTime))) {
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions src/remote/rest/client/rest-client.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

import axios from 'axios';
import invariant from '../../../invariant';
import AnonProvider from '../auth/anon-provider';
Expand Down
36 changes: 19 additions & 17 deletions src/view/component/app.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<template>
<md-app>
<md-app-toolbar class="md-primary md-layout control-offset">
<div class="md-layout-item heading-item">
<md-button @click="tracking = true" :disabled="tracking || !project" :class="[ 'md-raised', { 'md-accent': !tracking } ]">
<md-icon>alarm_add</md-icon>
Start
</md-button>
</div>
<div class="md-layout-item heading-item">
{{ timer }}
</div>
<div class="md-layout-item heading-item">
<md-button @click="tracking = false" :disabled="!tracking || !project" :class="[ 'md-raised', { 'md-accent': tracking } ]">
<md-icon>alarm_off</md-icon>
Stop
</md-button>
<md-app md-waterfall md-mode="fixed">
<md-app-toolbar class="md-primary md-dense">
<div class="md-toolbar-row">
<div class="md-layout-item heading-item">
<md-button @click="tracking = true" :disabled="tracking || !project" :class="[ 'md-raised', { 'md-accent': !tracking } ]">
<md-icon>alarm_add</md-icon>
Start
</md-button>
</div>
<div class="md-layout-item heading-item">
{{ timer }}
</div>
<div class="md-layout-item heading-item">
<md-button @click="tracking = false" :disabled="!tracking || !project" :class="[ 'md-raised', { 'md-accent': tracking } ]">
<md-icon>alarm_off</md-icon>
Stop
</md-button>
</div>
</div>
</md-app-toolbar>

Expand Down Expand Up @@ -57,7 +59,7 @@ if (!String.prototype.padStart) {
export default {
name: 'app',
components: {
Projects
Projects,
},
data () {
return {
Expand Down
45 changes: 24 additions & 21 deletions src/view/component/projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

<md-dialog-actions>
<md-button class="md-raised" @click="jiraDialog = false">Close</md-button>
<md-button class="md-raised md-accent" @click="syncJira(); jiraDialog = false">Synchronize</md-button>
<md-button class="md-raised md-accent" :disabled="!canSyncJira()" @click="syncJira(); jiraDialog = false">Synchronize</md-button>
</md-dialog-actions>
</md-dialog>

Expand Down Expand Up @@ -181,11 +181,15 @@ export default {
this.refresh();
this.syncRedmine(true);
this.syncJira(true);
},
methods: {
canSyncRedmine () {
return this.redmineHost && this.redmineApiKey;
},
canSyncJira () {
return this.jiraHost && this.jiraUsername && this.jiraPassword;
},
async syncRedmine (readConfig = false) {
if (readConfig) {
this.redmineHost = this.$registry.config().get(REDMINE.HOST);
Expand Down Expand Up @@ -216,39 +220,38 @@ export default {
}
}
},
// TODO: make separate component for synchronization
async syncJira (readConfig = false) {
if (readConfig) {
this.jiraHost = this.$registry.config().get(JIRA.HOST);
this.jiraUsername = this.$registry.config().get(JIRA.USERNAME);
this.jiraPassword = this.$registry.config().get(JIRA.PASSWORD);
}
this.$registry.get('logger').info('Trigger Jira synchronization');
if (this.canSyncJira()) {
this.$registry.get('logger').info('Trigger Jira synchronization');
this.$registry.config().set(this.jiraHost, JIRA.HOST);
this.$registry.config().set(this.jiraUsername, JIRA.USERNAME);
this.$registry.config().set(this.jiraPassword, JIRA.PASSWORD);
this.$registry.config().set(this.jiraHost, JIRA.HOST);
this.$registry.config().set(this.jiraUsername, JIRA.USERNAME);
this.$registry.config().set(this.jiraPassword, JIRA.PASSWORD);
try {
await this.$registry.get('synchronizeJira')(this.jiraHost, this.jiraUsername, this.jiraPassword);
this.refresh();
try {
await this.$registry.get('synchronizeJira')(this.jiraHost, this.jiraUsername, this.jiraPassword);
this.refresh();
this.$registry.get('notify')(
'TiTime - Jira Integration.',
`We've successfully synchronized w/ Jira (${ this.jiraHost }).`
);
} catch (error) {
this.$registry.get('logger').error(error.message);
this.$registry.get('notify')(
'TiTime - Jira Integration.',
`We've successfully synchronized w/ Jira (${ this.jiraHost }).`
);
} catch (error) {
this.$registry.get('logger').error(error.message);
this.$registry.get('notify')(
'TiTime - Jira Integration.',
`Failed to synchronized w/ Jira (${ this.jiraHost }). Error: ${ error.message }`
);
this.$registry.get('notify')(
'TiTime - Jira Integration.',
`Failed to synchronized w/ Jira (${ this.jiraHost }). Error: ${ error.message }`
);
}
}
},
validUrl (val) {
return validUrl.isUri(val);
},
Expand Down
4 changes: 0 additions & 4 deletions src/view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
.md-content.new-project {
margin: 30px;
}

/* .control-offset {
padding-top: 30px;
} */
</style>
</head>
<body>
Expand Down

0 comments on commit da572d7

Please sign in to comment.