Skip to content

Commit

Permalink
Merge pull request #15 from mechero/1_0_2
Browse files Browse the repository at this point in the history
#14 Ability to enter the Quboo server URL
  • Loading branch information
mechero authored Oct 31, 2018
2 parents fbe2fdf + 65e2817 commit 7717929
Show file tree
Hide file tree
Showing 38 changed files with 173 additions and 342 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BACKEND_VERSION=1.0.1
UI_VERSION=1.0.1
BACKEND_VERSION=1.0.2
UI_VERSION=1.0.2
8 changes: 8 additions & 0 deletions sonar-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<forkCount>0</forkCount>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
7 changes: 5 additions & 2 deletions web-client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {FooterComponent} from "./footer/footer.component";
import {FooterService} from "./footer/footer.service";
import {AngularFontAwesomeModule} from "angular-font-awesome";
import {RetrieverService} from "./retriever/retriever.service";
import {ServerUrlComponent} from "./settings/server-url.component";
import {ServerUrlService} from "./settings/server-url.service";

@NgModule({
declarations: [
Expand All @@ -23,7 +25,8 @@ import {RetrieverService} from "./retriever/retriever.service";
TeamsComponent,
OrganizerComponent,
SettingsComponent,
FooterComponent
FooterComponent,
ServerUrlComponent
],
imports: [
BrowserModule,
Expand All @@ -32,7 +35,7 @@ import {RetrieverService} from "./retriever/retriever.service";
AppRoutingModule,
AngularFontAwesomeModule
],
providers: [TeamsService, MemberService, FooterService, RetrieverService],
providers: [TeamsService, MemberService, FooterService, RetrieverService, ServerUrlService],
bootstrap: [AppComponent]
})
export class AppModule {
Expand Down
8 changes: 0 additions & 8 deletions web-client/src/app/common/Badge.js

This file was deleted.

10 changes: 0 additions & 10 deletions web-client/src/app/common/Badge.js.map

This file was deleted.

8 changes: 0 additions & 8 deletions web-client/src/app/common/StatsRow.js

This file was deleted.

10 changes: 0 additions & 10 deletions web-client/src/app/common/StatsRow.js.map

This file was deleted.

6 changes: 3 additions & 3 deletions web-client/src/app/footer/footer.service.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {Injectable} from '@angular/core';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {environment} from "../../environments/environment";
import {Code} from "./Code";
import {getStoredServerUrl} from "../settings/Settings";


@Injectable()
export class FooterService {

private codeUrl = environment.serverUrl + '/code';
private codeUrl = '/code';

constructor(private http: HttpClient) {
}

getCode(): Promise<Code> {
return this.http.get(this.codeUrl)
return this.http.get(getStoredServerUrl() + this.codeUrl)
.toPromise()
.then(response => response as Code)
.catch(this.handleError);
Expand Down
8 changes: 0 additions & 8 deletions web-client/src/app/members/Member.js

This file was deleted.

10 changes: 0 additions & 10 deletions web-client/src/app/members/Member.js.map

This file was deleted.

45 changes: 0 additions & 45 deletions web-client/src/app/members/member.service.js

This file was deleted.

10 changes: 0 additions & 10 deletions web-client/src/app/members/member.service.js.map

This file was deleted.

20 changes: 10 additions & 10 deletions web-client/src/app/members/member.service.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
import {Injectable} from '@angular/core';
import {StatsRow} from '../common/StatsRow';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {environment} from "../../environments/environment";
import {User} from "./User";
import {MessageResponse} from "../common/MessageResponse";
import {getStoredServerUrl} from "../settings/Settings";


@Injectable()
export class MemberService {

private memberStatsUrl = environment.serverUrl + '/stats/users';
private usersUrl = environment.serverUrl + '/users';
private memberStatsUrl = '/stats/users';
private usersUrl = '/users';

constructor(private http: HttpClient) {
}

getMemberStats(): Promise<StatsRow[]> {
return this.http.get(this.memberStatsUrl)
return this.http.get(getStoredServerUrl() + this.memberStatsUrl)
.toPromise()
.then(response => response as StatsRow[])
.catch(this.handleError);
}

getUsers(): Promise<User[]> {
return this.http.get(this.usersUrl + '?assigned')
return this.http.get(getStoredServerUrl() + this.usersUrl + '?assigned')
.toPromise()
.then(response => response as User[])
.catch(this.handleError);
}

getUnassignedUsers(): Promise<User[]> {
return this.http.get(this.usersUrl + '?unassigned')
return this.http.get(getStoredServerUrl() + this.usersUrl + '?unassigned')
.toPromise()
.then(response => response as User[])
.catch(this.handleError);
}

deleteUnassignedUsers(): Promise<MessageResponse> {
return this.http.delete(this.usersUrl + '?unassigned')
return this.http.delete(getStoredServerUrl() + this.usersUrl + '?unassigned')
.toPromise()
.then(response => response as MessageResponse)
.catch(this.handleError);
}

updateUser(user: User) {
return this.http.put(this.usersUrl + '/' + user.id, user)
return this.http.put(getStoredServerUrl() + this.usersUrl + '/' + user.id, user)
.toPromise()
.then(response => response as User)
.catch(this.handleError);
}

removeAllStats(): Promise<MessageResponse> {
return this.http.delete(this.memberStatsUrl)
return this.http.delete(getStoredServerUrl() + this.memberStatsUrl)
.toPromise()
.then(response => response as MessageResponse)
.catch(this.handleError);
}

private handleError(error: any): Promise<any> {
console.error('An error occurred accessing ' + environment.serverUrl, error);
console.error('An error occurred accessing the server', error);
if (error instanceof HttpErrorResponse) {
console.error("Response status: " + error.status + " | Message: " + error.message);
}
Expand Down
47 changes: 0 additions & 47 deletions web-client/src/app/members/members.component.js

This file was deleted.

10 changes: 0 additions & 10 deletions web-client/src/app/members/members.component.js.map

This file was deleted.

10 changes: 6 additions & 4 deletions web-client/src/app/members/members.component.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
import {Component} from '@angular/core';
import {OnInit} from '@angular/core';
import {User} from './Member';
import {User} from './User';
import {MemberService} from './member.service';
import {StatsRow} from '../common/StatsRow';
import {ServerUrlService} from "../settings/server-url.service";

@Component({
moduleId: module.id,
selector: 'members',
templateUrl: 'members.component.html'
})
export class MembersComponent implements OnInit {

ngOnInit(): void {
setInterval(() => this.getMembers(), 20 * 1000);
setInterval(() => this.getMembers(), 2 * 60 * 1000);
this.getMembers();
this.serverUrlService.change.subscribe(ignore => this.getMembers());
}

memberStats: StatsRow[];
selectedMember: User;

constructor(private memberService: MemberService) {
constructor(private memberService: MemberService, private serverUrlService: ServerUrlService) {
}

onSelect(member: User): void {
this.selectedMember = member;
}

getMembers(): void {
console.log('get members');
this.memberService.getMemberStats().then(memberStats => this.memberStats = memberStats);
}

Expand Down
6 changes: 3 additions & 3 deletions web-client/src/app/retriever/retriever.service.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {Injectable} from '@angular/core';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {environment} from "../../environments/environment";
import {getStoredServerUrl} from "../settings/Settings";

@Injectable()
export class RetrieverService {

private forceRetrievalUrl = environment.serverUrl + '/retriever/now';
private forceRetrievalUrl = '/retriever/now';

constructor(private http: HttpClient) {
}

forceRetrieval(): Promise<String> {
return this.http.post(this.forceRetrievalUrl, {})
return this.http.post(getStoredServerUrl() + this.forceRetrievalUrl, {})
.toPromise()
.catch(this.handleError);
}
Expand Down
17 changes: 17 additions & 0 deletions web-client/src/app/settings/Settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const SERVER_URL_KEY = 'QUBOO_SERVER_URL';

export function getStoredServerUrl() : string {
return localStorage.getItem(SERVER_URL_KEY);
}

export function isServerUrlStored() : boolean {
return localStorage.getItem(SERVER_URL_KEY) !== null;
}

export function defaultServerUrl(): string {
return window.location.protocol + '//' + window.location.hostname + ':8080';
}

export function saveServerUrl(url: string) {
localStorage.setItem(SERVER_URL_KEY, url);
}
Loading

0 comments on commit 7717929

Please sign in to comment.