Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit 8199923

Browse files
lumburovskalinaJWittmeyer
and
JWittmeyer
authored
Update logic start (#47)
* Update logic start * Modal for version overview and added navigation to modal for steps update * Renamed checked version to remote version and added tabs for OS * Steps for update added * Added new fields for checking updates * Sorted array,align left and scrollable modal body * Added tooltips for tabs on how to update * Request called only once * Improvements on query for has updates and tooltip green on steps * Added statis variable for calling function only once * Modal sizes fixed * Icons alignment and data-tip changed to Version overview * Returned untentionally removed tooltip * Removed commented code * Dropdown for models on smaller sizes Co-authored-by: JWittmeyer <jens.wittmeyer@onetask.ai>
1 parent d60a629 commit 8199923

File tree

7 files changed

+348
-8
lines changed

7 files changed

+348
-8
lines changed

src/app/base/components/sidebar-pm/sidebar-pm.component.html

Lines changed: 199 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,16 @@
192192
</button>
193193
</div>
194194
<div class="flex-shrink-0 flex py-6 justify-center">
195-
<a data-tip="Changelog" target="_blank" rel="noopener noreferrer"
196-
class="z-50 tooltip tooltip-right cursor-pointer select-none text-white"
197-
href="https://docs.kern.ai/changelog">v1.1.1</a>
195+
<label data-tip="Version overview" for="version-overview" (click)="requestVersionOverview()"
196+
class="z-50 tooltip tooltip-right cursor-pointer select-none text-white flex items-center">v1.1.1
197+
<svg *ngIf="hasUpdates" xmlns="http://www.w3.org/2000/svg" data-tip="Newer version available"
198+
class="icon icon-tabler icon-tabler-alert-circle inline-block text-yellow-700 tooltip tooltip-right align-top ml-1 mt-px" width="16" height="16" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
199+
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
200+
<circle cx="12" cy="12" r="9"></circle>
201+
<line x1="12" y1="8" x2="12" y2="12"></line>
202+
<line x1="12" y1="16" x2="12.01" y2="16"></line>
203+
</svg>
204+
</label>
198205
</div>
199206
</div>
200207
</div>
@@ -206,4 +213,193 @@
206213
<path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16" />
207214
</svg>
208215
</div>
216+
</div>
217+
218+
<input #versionOverviewModal type="checkbox" id="version-overview" class="modal-toggle">
219+
<div class="modal">
220+
<div class="modal-box text-black bg-white justify-center modal-configuration text-center">
221+
<div class="inline-block justify-center text-lg leading-6 text-gray-900 font-medium">
222+
Version overview
223+
224+
<a class="text-green-800 text-base font-medium ml-3" href="https://docs.kern.ai/changelog" target="_blank">
225+
<span class="leading-5">Changelog</span>
226+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 inline-block" fill="none"
227+
viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
228+
<path stroke-linecap="round" stroke-linejoin="round"
229+
d="M13 7l5 5m0 0l-5 5m5-5H6" />
230+
</svg>
231+
</a>
232+
</div>
233+
234+
<div class="inline-block min-w-full align-middle mt-3" *ngIf="versionOverview">
235+
<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg scrollable-size">
236+
<table class="min-w-full divide-y divide-gray-300">
237+
<thead class="bg-gray-50">
238+
<tr>
239+
<th scope="col"
240+
class="px-3 py-2 text-left text-xs font-medium uppercase tracking-wide text-gray-500">
241+
Service</th>
242+
<th scope="col"
243+
class="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
244+
Installed version</th>
245+
<th scope="col"
246+
class="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
247+
Remote version</th>
248+
<th scope="col"
249+
class="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
250+
Last checked</th>
251+
<th scope="col"
252+
class="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
253+
Link</th>
254+
</tr>
255+
</thead>
256+
<tbody class="divide-y divide-gray-200">
257+
<tr *ngFor="let service of versionOverview">
258+
<td class="text-left px-3 py-2 text-sm text-gray-500">
259+
{{service.service}}
260+
</td>
261+
<td class="text-center px-3 py-2 text-sm text-gray-500">
262+
{{service.installedVersion}}
263+
</td>
264+
<td class="text-center px-3 py-2 text-sm text-gray-500">
265+
<div class="flex flex-row items-center justify-center">
266+
<div class="mr-2">{{service.remoteVersion}}</div>
267+
<div *ngIf="service.remoteHasNewer" class="tooltip tooltip-right" data-tip="Newer version available">
268+
<svg xmlns="http://www.w3.org/2000/svg"
269+
class="icon icon-tabler icon-tabler-alert-circle inline-block text-yellow-700 align-top" width="20" height="20" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
270+
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
271+
<circle cx="12" cy="12" r="9"></circle>
272+
<line x1="12" y1="8" x2="12" y2="12"></line>
273+
<line x1="12" y1="16" x2="12.01" y2="16"></line>
274+
</svg></div>
275+
</div>
276+
</td>
277+
<td class="text-center px-3 py-2 text-sm text-gray-500">
278+
{{service.parseDate}}
279+
</td>
280+
<td class="text-center px-3 py-2 text-sm text-gray-500">
281+
<a [href]="service.link" target="_blank" class="h4 w-4 m-auto block"
282+
style="padding:0px"><svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 m-auto"
283+
fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
284+
<path stroke-linecap="round" stroke-linejoin="round"
285+
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
286+
</svg></a>
287+
</td>
288+
</tr>
289+
</tbody>
290+
</table>
291+
</div>
292+
</div>
293+
294+
<kern-loading *ngIf="versionOverview == null" color="yellow" class="mt-3"></kern-loading>
295+
296+
<div class="modal-action">
297+
<label (click)="howToUpdate()" *ngIf="!isManaged"
298+
class="mr-2 bg-green-100 text-green-700 border border-green-400 text-xs font-semibold px-4 py-2 rounded-md cursor-pointer hover:bg-green-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500">How to update</label>
299+
<label for="version-overview"
300+
class="bg-white text-gray-700 text-xs font-semibold mr-4 px-4 py-2 rounded border border-gray-300 cursor-pointer hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 inline-block">Close</label>
301+
</div>
302+
</div>
303+
</div>
304+
305+
<input #stepsUpdate type="checkbox" id="steps-update" class="modal-toggle">
306+
<div class="modal">
307+
<div class="modal-box text-black bg-white justify-center modal-sizes">
308+
<div class="text-center justify-center text-lg leading-6 text-gray-900 font-medium">
309+
How to update
310+
</div>
311+
312+
<div class="flex border-b-2 border-b-gray-200 max-w-full text-center overflow-visible">
313+
<div (click)="toggleTabs(0)"
314+
[ngClass]="openTab == 0 ? 'text-indigo-700 border-bottom' : 'text-gray-500' "
315+
class="text-sm leading-5 font-medium mr-10 cursor-help py-3">
316+
<span class="tooltip tooltip-bottom tooltip-margin border-dotted" data-tip="Linux/Mac">Bash users</span>
317+
</div>
318+
<div (click)="toggleTabs(1)"
319+
[ngClass]="openTab == 1 ? 'text-indigo-700 border-bottom' : 'text-gray-500' "
320+
class="text-sm leading-5 font-medium mr-10 cursor-help py-3">
321+
<span class="tooltip tooltip-bottom border-dotted" data-tip="Installed refinery with pip">CLI users</span>
322+
</div>
323+
<div (click)="toggleTabs(2)"
324+
[ngClass]="openTab == 2 ? 'text-indigo-700 border-bottom' : 'text-gray-500' "
325+
class="text-sm leading-5 font-medium mr-10 cursor-help py-3">
326+
<span class="tooltip tooltip-bottom border-dotted" data-tip="Windows terminal">cmd</span>
327+
</div>
328+
<div (click)="toggleTabs(3)"
329+
[ngClass]="openTab == 3 ? 'text-indigo-700 border-bottom' : 'text-gray-500' "
330+
class="text-sm leading-5 font-medium mr-10 cursor-help py-3">
331+
<span class="tooltip tooltip-bottom border-dotted" data-tip="Windows from File Explorer">Executing from explorer</span>
332+
</div>
333+
</div>
334+
335+
<div class="mt-3 px-5 h-40">
336+
<ng-container [ngSwitch]="openTab">
337+
<ng-template [ngSwitchCase]="0">
338+
<ol class="font-dmMono">
339+
<li>Open a Terminal</li>
340+
<li>Change to refinery directory (using cd) -
341+
<span class="bg-gray-200 text-red-700 rounded-md p-1 whitespace-nowrap">$ cd /path/to/refinery</span>
342+
</li>
343+
<li>Run the update script -
344+
<span class="bg-gray-200 text-red-700 rounded-md p-1 whitespace-nowrap">$
345+
<span class="cursor-pointer tooltip tooltip-top" data-tip="Click to copy" (click)="copyToClipboard('./update')">./update</span>
346+
</span>
347+
</li>
348+
</ol>
349+
</ng-template>
350+
<ng-template [ngSwitchCase]="1">
351+
<ol class="font-dmMono">
352+
<li>Open a Terminal</li>
353+
<li>Change to refinery directory
354+
<ol class="list-letters px-8">
355+
<li>Linux/Mac -
356+
<span class="bg-gray-200 text-red-700 rounded-md p-1 whitespace-nowrap">$ cd path/to/refinery</span>
357+
</li>
358+
<li>Windows -
359+
<span class="bg-gray-200 text-red-700 rounded-md p-1 whitespace-nowrap">cd path\to\refinery</span>
360+
</li>
361+
</ol>
362+
</li>
363+
<li>
364+
Run the CLI update command
365+
<span class="bg-gray-200 text-red-700 rounded-md p-1 whitespace-nowrap">$
366+
<span class="cursor-pointer tooltip tooltip-top" data-tip="Click to copy" (click)="copyToClipboard('refinery update')">refinery update</span>
367+
</span>
368+
</li>
369+
</ol>
370+
</ng-template>
371+
<ng-template [ngSwitchCase]="2">
372+
<ol class="font-dmMono">
373+
<li>Open a Terminal</li>
374+
<li>Change to refinery directory
375+
<span class="bg-gray-200 text-red-700 rounded-md p-1 whitespace-nowrap">cd path\to\refinery</span>
376+
</li>
377+
<li>Run the update script -
378+
<span class="bg-gray-200 text-red-700 rounded-md p-1 whitespace-nowrap">
379+
<span class="cursor-pointer tooltip tooltip-top" data-tip="Click to copy" (click)="copyToClipboard('update.bat')">update.bat</span>
380+
</span>
381+
</li>
382+
</ol>
383+
</ng-template>
384+
<ng-template [ngSwitchCase]="3">
385+
<ol class="font-dmMono">
386+
<li>Open the File Explorer</li>
387+
<li>Navigate to the refinery directory</li>
388+
<li>Launch the update script by double-clicking
389+
<span class="bg-gray-200 text-red-700 rounded-md p-1 whitespace-nowrap">
390+
<span class="cursor-pointer tooltip tooltip-top" data-tip="Click to copy" (click)="copyToClipboard('update.bat')">update.bat</span>
391+
</span>
392+
</li>
393+
</ol>
394+
</ng-template>
395+
</ng-container>
396+
</div>
397+
398+
<div class="modal-action">
399+
<label (click)="back()"
400+
class="bg-white text-gray-700 text-xs font-semibold mr-2 px-4 py-2 rounded border border-gray-300 cursor-pointer hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 inline-block">Go back</label>
401+
<label for="steps-update"
402+
class="bg-white text-gray-700 text-xs font-semibold mr-4 px-4 py-2 rounded border border-gray-300 cursor-pointer hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 inline-block">Close</label>
403+
</div>
404+
</div>
209405
</div>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
11
.overflow-initial {
22
overflow: initial;
33
}
4+
5+
.border-bottom {
6+
border-bottom: 1px solid #4F46E5;
7+
}
8+
9+
ol {
10+
list-style: decimal;
11+
li {
12+
margin-top: 8px;
13+
}
14+
}
15+
16+
ol.list-letters {
17+
list-style-type: lower-alpha !important;
18+
}
19+
20+
.scrollable-size {
21+
max-height: calc(100vh - 230px);
22+
overflow-y: auto;
23+
}
24+
25+
.tooltip-margin::before {
26+
margin-left: 8px;
27+
}
28+
29+
.border-dotted {
30+
border-bottom: 2px dotted #22c55e;
31+
}
32+
33+
.modal-sizes {
34+
min-width: 750px;
35+
}
36+
37+
@media (max-width: 1024px) {
38+
.modal-sizes {
39+
min-width: 400px;
40+
}
41+
}

src/app/base/components/sidebar-pm/sidebar-pm.component.ts

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ import {
55
transition,
66
trigger,
77
} from '@angular/animations';
8-
import { Component, Inject, EventEmitter, OnInit, Output, Input, HostListener } from '@angular/core';
8+
import { Component, Inject, EventEmitter, OnInit, Output, Input, HostListener, ViewChild, ElementRef } from '@angular/core';
99
import { ActivatedRoute } from '@angular/router';
10-
import { Observable, Subscription } from 'rxjs';
11-
import { tap } from 'rxjs/operators';
10+
import { Observable, Subscription, timer } from 'rxjs';
11+
import { first, tap } from 'rxjs/operators';
1212
import { AuthApiService } from '../../services/auth-api.service';
1313
import { OrganizationApolloService } from '../../services/organization/organization-apollo.service';
1414
import { RouteService } from '../../services/route.service';
1515
import { DOCUMENT } from '@angular/common';
1616
import { ProjectApolloService } from '../../services/project/project-apollo.service';
17+
import { ConfigApolloService } from '../../services/config/config-apollo.service';
18+
import { dateAsUTCDate } from 'src/app/util/helper-functions';
19+
import { ConfigManager } from '../../services/config-service';
20+
import { ConfigService } from 'aws-sdk';
1721

1822

1923
@Component({
@@ -60,13 +64,21 @@ export class SidebarPmComponent implements OnInit {
6064
isFullscreen: boolean = false;
6165
@Output() firstName = new EventEmitter<Observable<any>>();
6266
toggleClass = 'ft-maximize';
67+
versionOverview: any[] = [];
68+
@ViewChild('versionOverviewModal', { read: ElementRef }) versionOverviewModal: ElementRef;
69+
@ViewChild('stepsUpdate', { read: ElementRef }) stepsUpdate: ElementRef;
70+
openTab: number = 0;
71+
isManaged: boolean = true;
72+
hasUpdates: boolean;
73+
private static initialConfigRequest: boolean = false;
6374

6475
constructor(
6576
private organizationService: OrganizationApolloService,
6677
private routeService: RouteService,
6778
private activatedRoute: ActivatedRoute,
6879
private auth: AuthApiService,
6980
private projectApolloService: ProjectApolloService,
81+
private configService: ConfigApolloService,
7082
@Inject(DOCUMENT) private document: any
7183
) { }
7284

@@ -89,6 +101,30 @@ export class SidebarPmComponent implements OnInit {
89101
})
90102
)
91103
.subscribe());
104+
105+
if(!SidebarPmComponent.initialConfigRequest) {
106+
this.requestVersionOverview();
107+
SidebarPmComponent.initialConfigRequest = true;
108+
}
109+
this.checkIfManagedVersion();
110+
}
111+
112+
requestVersionOverview() {
113+
this.versionOverview = null;
114+
this.configService
115+
.getVersionOverview()
116+
.pipe(first())
117+
.subscribe((versionOverview) => {
118+
this.versionOverview = versionOverview;
119+
this.versionOverview.forEach((version)=> {
120+
version.parseDate = this.parseUTC(version.lastChecked);
121+
});
122+
this.versionOverview.sort((a, b) => a.service.localeCompare(b.service));
123+
this.configService
124+
.hasUpdates()
125+
.pipe(first())
126+
.subscribe((hasUpdates) => this.hasUpdates = hasUpdates);
127+
});
92128
}
93129

94130
onDestroy() {
@@ -161,4 +197,35 @@ export class SidebarPmComponent implements OnInit {
161197

162198
}
163199
}
200+
201+
parseUTC(utc: string) {
202+
const utcDate = dateAsUTCDate(new Date(utc));
203+
return utcDate.toLocaleString();
204+
}
205+
206+
howToUpdate() {
207+
this.versionOverviewModal.nativeElement.checked = false;
208+
this.stepsUpdate.nativeElement.checked = true;
209+
}
210+
211+
back() {
212+
this.stepsUpdate.nativeElement.checked = false;
213+
this.versionOverviewModal.nativeElement.checked = true;
214+
}
215+
216+
toggleTabs(index: number) {
217+
this.openTab = index;
218+
}
219+
220+
copyToClipboard(textToCopy) {
221+
navigator.clipboard.writeText(textToCopy);
222+
}
223+
224+
checkIfManagedVersion() {
225+
if (!ConfigManager.isInit()) {
226+
timer(250).subscribe(() => this.checkIfManagedVersion());
227+
return;
228+
}
229+
this.isManaged = ConfigManager.getIsManaged();
230+
}
164231
}

src/app/base/services/config/config-apollo.service.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,22 @@ export class ConfigApolloService {
6060
.pipe(map((result) => JSON.parse(result['data']['getBlackWhiteDemo'])));
6161
}
6262

63+
getVersionOverview() {
64+
return this.apollo
65+
.query({
66+
query: queries.GET_VERSION_OVERVIEW,
67+
fetchPolicy: 'no-cache',
68+
})
69+
.pipe(map((result) => result['data']['versionOverview']));
70+
}
71+
72+
hasUpdates() {
73+
return this.apollo
74+
.query({
75+
query: queries.GET_HAS_UPDATES,
76+
fetchPolicy: 'no-cache',
77+
})
78+
.pipe(map((result) => result['data']['hasUpdates']));
79+
}
80+
6381
}

0 commit comments

Comments
 (0)