diff --git a/package.json b/package.json index 24882f1..009252d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "T-Rec", - "version": "1.0.2", + "version": "1.1.0", "description": "T-Rec time tracker is built for speed and live work item update in youtrack system.", "homepage": "", "author": { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 125af3f..9cb7f3a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -38,6 +38,7 @@ import { ToasterService } from './services/toaster.service'; import { ToolbarComponent } from './components/toolbar/toolbar.component'; import { SwitchAccountComponent } from './components/accounts/switch-account/switch-account.component' import { MenuService } from './services/menu.service'; +import { Nl2brPipe } from 'app/pipes/nl2br.pipe'; import { LoadingSpinnerComponent } from './components/loading-spinner/loading-spinner.component'; import { ToasterComponent } from './components/toaster/toaster.component'; @@ -49,6 +50,7 @@ import { ToasterComponent } from './components/toaster/toaster.component'; RecordsComponent, BoardsChoiceComponent, SecondsToTimePipe, + Nl2brPipe, AddAccountComponent, EditAccountComponent, EditBoardComponent, diff --git a/src/app/components/accounts/edit-account/edit-account.component.html b/src/app/components/accounts/edit-account/edit-account.component.html index fa64a81..1b5145c 100644 --- a/src/app/components/accounts/edit-account/edit-account.component.html +++ b/src/app/components/accounts/edit-account/edit-account.component.html @@ -4,6 +4,14 @@
+
+ +
+ PUBLISHED: {{version.published_at | date:"dd-MM-yyyy"}} +

+ Download new version +
+
@@ -41,7 +49,6 @@ REMOVE ACCOUNT -
diff --git a/src/app/components/accounts/edit-account/edit-account.component.scss b/src/app/components/accounts/edit-account/edit-account.component.scss index 7748a00..bd0e3b2 100644 --- a/src/app/components/accounts/edit-account/edit-account.component.scss +++ b/src/app/components/accounts/edit-account/edit-account.component.scss @@ -1,6 +1,9 @@ @import "../../../theme/colors.scss"; .container { + .new { + color: $major !important + } margin-top: 60px; width: 100%; height: 100%; @@ -46,7 +49,7 @@ font-size: 12px; font-weight: 400; letter-spacing: 1px; - cursor: default; + cursor: default; } .edit-account__form { margin-bottom: 30px; @@ -177,6 +180,22 @@ line-height: 18px; color: $white; } + .edit-account__info { + margin: 16px 0 32px; + font-family: 'Montserrat', sans-serif; + font-size: 12px; + line-height: 18px; + color: $white; + a { + cursor: pointer; + text-decoration: underline; + color: $white; + &:hover { + color: $white; + text-decoration: none; + } + } + } .edit-account__actions { margin-bottom: 50px; .edit-account__remove { diff --git a/src/app/components/accounts/edit-account/edit-account.component.ts b/src/app/components/accounts/edit-account/edit-account.component.ts index b402e95..356c9a9 100644 --- a/src/app/components/accounts/edit-account/edit-account.component.ts +++ b/src/app/components/accounts/edit-account/edit-account.component.ts @@ -7,6 +7,9 @@ import { Router, ActivatedRoute } from '@angular/router'; import { RemoteAccount } from 'app/models/RemoteAccount'; import { AccountService } from '../../../services/account.service' import { ToasterService } from '../../../services/toaster.service' +import { versions } from '../../../../environments/versions' +import { shell } from 'electron'; + @Component({ selector: 'app-edit-account', @@ -18,6 +21,9 @@ export class EditAccountComponent implements OnInit { public agiles: any public toasterText: string public modalText: string + public isNew = false; + public version = {name:'', published_at:'', body:''}; + constructor( public databaseService: DatabaseService, public activatedRoute: ActivatedRoute, @@ -31,6 +37,12 @@ export class EditAccountComponent implements OnInit { ngOnInit() { this.getCurrentAccount() this.getAllAgiles() + this.api.getVersionInfo().then(data => { + this.version = data; + if (data.tag_name != undefined && data.tag_name.replace("v","") !== versions.version){ + this.isNew = true + } + }) } async getCurrentAccount() { @@ -53,6 +65,10 @@ export class EditAccountComponent implements OnInit { ) } + public async openInBrowser(url : string){ + shell.openExternal(url); + } + editNameOrUrl(account) { this.databaseService.editAccount(account).then(data => { this.toasterService.success('Account updated!') diff --git a/src/app/components/workspace/boards/boards.component.html b/src/app/components/workspace/boards/boards.component.html index 62cd0b1..a327c78 100644 --- a/src/app/components/workspace/boards/boards.component.html +++ b/src/app/components/workspace/boards/boards.component.html @@ -2,7 +2,7 @@
-

{{ agile.name }}

+

{{ agile.name }}

diff --git a/src/app/components/workspace/workspace.component.html b/src/app/components/workspace/workspace.component.html index 31bd04e..8085448 100644 --- a/src/app/components/workspace/workspace.component.html +++ b/src/app/components/workspace/workspace.component.html @@ -5,7 +5,7 @@
  • Records
  • diff --git a/src/app/components/workspace/workspace.component.scss b/src/app/components/workspace/workspace.component.scss index 47416a6..87a51cb 100644 --- a/src/app/components/workspace/workspace.component.scss +++ b/src/app/components/workspace/workspace.component.scss @@ -55,6 +55,12 @@ color: $custom-red; } } + .trec-icon-settings.warning { + color: $major; + &:hover { + color: $custom-red; + } + } } } .content { diff --git a/src/app/components/workspace/workspace.component.ts b/src/app/components/workspace/workspace.component.ts index 26c540d..2450b79 100644 --- a/src/app/components/workspace/workspace.component.ts +++ b/src/app/components/workspace/workspace.component.ts @@ -7,6 +7,7 @@ import { DatabaseService } from '../../services/database.service' import { ApiService } from '../../services/api.service' import { SecondsToTimePipe } from '../../pipes/seconds-to-time.pipe' import { ToasterService } from '../../services/toaster.service' +import { versions } from '../../../environments/versions' import { Router } from '@angular/router'; import { WorkItemData } from 'app/models/RemoteAccount'; @@ -30,6 +31,7 @@ export class WorkspaceComponent implements OnDestroy, OnInit { public hideHints: number secondsToTimePipe = new SecondsToTimePipe() public dbVariables: object + public differentVersion = false; constructor( public timerService: TimerService, @@ -38,7 +40,9 @@ export class WorkspaceComponent implements OnDestroy, OnInit { public api: ApiService, public router: Router, public toasterService: ToasterService - ) { } + ) { + this.checkVersion() + } ngOnInit() { this.subscribeNotificationTime() @@ -52,7 +56,15 @@ export class WorkspaceComponent implements OnDestroy, OnInit { this.alive = false } - subscribeNotificationTime() { + private checkVersion(){ + this.api.getVersionInfo().then(data => { + if (data.tag_name != undefined && data.tag_name.replace("v","") !== versions.version){ + this.differentVersion = true + } + }) + } + + private subscribeNotificationTime() { this.dataService.currentNotificationTime.takeWhile(() => this.alive).subscribe(data => { this.notificationTime = data if (this.notificationTime != undefined) { @@ -61,7 +73,7 @@ export class WorkspaceComponent implements OnDestroy, OnInit { }) } - subscribeIssueTime() { + private subscribeIssueTime() { this.dataService.currentIssueTime.takeWhile(() => this.alive).subscribe(data => { let issueTime = data["currentTime"] if (issueTime % 60 === 0) { @@ -76,7 +88,7 @@ export class WorkspaceComponent implements OnDestroy, OnInit { }) } - subscribeUnstoppedItem() { + private subscribeUnstoppedItem() { this.dataService.currentUnstoppedItem.takeWhile(() => this.alive).subscribe(data => { this.unstoppedItem = data if (Object.keys(this.unstoppedItem).length != 0) { diff --git a/src/app/pipes/nl2br.pipe.ts b/src/app/pipes/nl2br.pipe.ts new file mode 100644 index 0000000..dc0a12c --- /dev/null +++ b/src/app/pipes/nl2br.pipe.ts @@ -0,0 +1,11 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'nl2br' +}) +export class Nl2brPipe implements PipeTransform { + transform(str): any { + return str.split("\n").join("
    "); + } + +} diff --git a/src/app/services/api.service.ts b/src/app/services/api.service.ts index 83dea46..d18c5ea 100644 --- a/src/app/services/api.service.ts +++ b/src/app/services/api.service.ts @@ -4,9 +4,7 @@ import 'rxjs/add/operator/map'; import { HttpService } from '../services/http.service' import { AccountService } from './account.service' import { RemoteAccount, UserData, IssueDetails, WorkItemData } from 'app/models/RemoteAccount'; -import { error } from 'util'; -import { reject } from 'q'; -import { resolve } from 'dns'; + @Injectable() export class ApiService { @@ -27,7 +25,7 @@ export class ApiService { return; } - getAllProjects = () => { + public getAllProjects = () => { return new Promise(resolve => { this.UseAccount().then(() => { this.http.get('/rest/admin/project') @@ -41,6 +39,16 @@ export class ApiService { }); } + public getVersionInfo(): Promise { + return new Promise((resolve, reject) => { + this.http.getRawUrl("https://api.github.com/repos/kleder/timetracker/releases/latest") + .map(res => res.json()) + .subscribe(data => { + resolve(data); + }, err => reject(err)) + }) + } + private encodeQueryData(data) { let ret = []; for (let d in data) @@ -48,7 +56,7 @@ export class ApiService { return ret.join('&'); } - executeCommand(id: string, command: any) { + public executeCommand(id: string, command: any) { return new Promise((resolve, reject) => { let options = new RequestOptions(); options.headers = new Headers(); @@ -59,7 +67,7 @@ export class ApiService { }); } - createIssueOnBoard(data, BoardName, state) { + public createIssueOnBoard(data, BoardName, state) { let id = ""; return new Promise((resolve, reject) => { this.UseAccount().then(() => { @@ -76,7 +84,7 @@ export class ApiService { .then(() => {this.executeCommand(id, {'command': 'State ' + state})} ) } - getAllAgiles = () => { + public getAllAgiles = () => { return new Promise(resolve => { this.UseAccount().then(() => { this.http.get('/rest/admin/agile') @@ -90,7 +98,7 @@ export class ApiService { }); } - getIssuesByProject = (id) => { + public getIssuesByProject = (id) => { return new Promise(resolve => { this.UseAccount().then(() => { this.http.get('/rest/issue/byproject/' + id + '?filter=for%3A+me') @@ -102,7 +110,7 @@ export class ApiService { }) } - getIssuesByAgile = (agileName) => { + public getIssuesByAgile = (agileName) => { return new Promise(resolve => { this.UseAccount().then(() => { this.http.get('/rest/issue?filter=for:me+Board+' + agileName + ':+{Current+sprint}+%23Unresolved') @@ -114,7 +122,7 @@ export class ApiService { }) } - getIssue = (issueId) => { + public getIssue = (issueId) => { return new Promise(resolve => { this.UseAccount().then(() => { this.http.get('/rest/issue/' + issueId + '?wikifyDescription=true') @@ -126,7 +134,7 @@ export class ApiService { }) } - getSprintInfo = (agile) => { + public getSprintInfo = (agile) => { let query = agile.url.split("/youtrack")[1] return new Promise(resolve => { this.UseAccount().then(() => { @@ -139,7 +147,7 @@ export class ApiService { }) } - createNewWorkItem = (data: WorkItemData) => { + public createNewWorkItem = (data: WorkItemData) => { let newItem = { date: data.date, duration: Math.round(data.duration / 60), @@ -158,7 +166,7 @@ export class ApiService { }) } - getWorkItem = (issueId) => { + public getWorkItem = (issueId) => { return new Promise(resolve => { this.UseAccount().then(() => { this.http.get('/rest/issue/' + issueId + '/timetracking/workitem') @@ -170,7 +178,7 @@ export class ApiService { }) } - getTimetrackingWorkTypes = (projectId) => { + public getTimetrackingWorkTypes = (projectId) => { return new Promise(resolve => { this.UseAccount().then(() => { this.http.get('/rest/admin/project/' + projectId + '/timetracking/worktype') @@ -182,7 +190,7 @@ export class ApiService { }) } - getCurrentUser(remoteAccount: RemoteAccount) { + public getCurrentUser(remoteAccount: RemoteAccount) { this.UseAccount(remoteAccount) this.http.UseAccount(remoteAccount) return new Promise((resolve, reject) => { diff --git a/src/app/services/http.service.ts b/src/app/services/http.service.ts index 950b099..31da9cb 100644 --- a/src/app/services/http.service.ts +++ b/src/app/services/http.service.ts @@ -25,6 +25,10 @@ export class HttpService extends Http { super(backend, defaultOptions) } + public getRawUrl(url: string){ + return super.get(url); + } + public UseAccount(remoteAccount : RemoteAccount) { this.remoteAccount = remoteAccount; }