delete environment.prod.ts;

use environment.ts for location + port;
This commit is contained in:
Marco Zeisler 2021-05-04 19:36:25 +02:00
parent 42edbdd195
commit 065922b279
6 changed files with 38 additions and 60 deletions

View File

@ -1,7 +1,7 @@
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {FormGroup, FormBuilder, AbstractControl} from '@angular/forms';
import {FileInput, FileValidator} from 'ngx-material-file-input';
import {FormGroup, FormBuilder} from '@angular/forms';
import {FileValidator} from 'ngx-material-file-input';
import {HttpClient} from '@angular/common/http';
import {environment} from '../../../../environments/environment';
import {throwError} from 'rxjs';
@ -28,8 +28,6 @@ export class EditierenComponent implements OnInit {
keywords: String;
readonly maxSize = 10240;
private currentLocation = environment.location;
constructor(private route: ActivatedRoute,
private formBuilder: FormBuilder,
private http: HttpClient,
@ -55,7 +53,7 @@ export class EditierenComponent implements OnInit {
}
public loadFeed(id) {
this.http.get('http://127.0.0.1:8000/feeds/' + id + '/').subscribe(
this.http.get('http://' + environment.location + ':' + environment.port + '/feeds/' + id + '/').subscribe(
(data: any) => {
this.url = data.url;
this.active = data.active;
@ -88,7 +86,7 @@ export class EditierenComponent implements OnInit {
form.append('icon', feedData.icon._files['0']);
}
if (this.id == null) {
this.http.post('http://127.0.0.1:8000/feeds/', form).subscribe(
this.http.post('http://' + environment.location + ':' + environment.port + '/feeds/', form).subscribe(
() => {
this._snackbar.open('Feed erfolgreich gespeichert!', 'Schließen', {duration: 3000});
},
@ -99,7 +97,7 @@ export class EditierenComponent implements OnInit {
}
);
} else {
this.http.put('http://127.0.0.1:8000/feeds/' + this.id + '/', form).subscribe(
this.http.put('http://' + environment.location + ':' + environment.port + '/feeds/' + this.id + '/', form).subscribe(
() => {
this._snackbar.open('Feed erfolgreich gespeichert!', 'Schließen', {duration: 3000});
},
@ -114,7 +112,7 @@ export class EditierenComponent implements OnInit {
public errorDialog() {
const dialogRef = this._dialog.open(DialogComponent, {
this._dialog.open(DialogComponent, {
data: {
title: 'Serverfehler',
body: 'Fehler beim Aufruf des Servers',

View File

@ -8,6 +8,7 @@ import {FeedService} from '../../services/feed.service';
import {ActivatedRoute} from '@angular/router';
import {DialogComponent} from '../dialog/dialog.component';
import {MatDialog} from '@angular/material/dialog';
import {environment} from '../../../environments/environment';
@Component({
selector: 'app-einstellungen',
@ -34,7 +35,7 @@ export class EinstellungenComponent implements OnInit {
}
deleteFeed(id: number) {
this.http.delete('http://127.0.0.1:8000/feeds/' + id + '/').subscribe(
this.http.delete('http://' + environment.location + ':' + environment.port + '/feeds/' + id + '/').subscribe(
() => {
this._snackbar.open('Feed erfolgreich gelöscht!', 'Schließen', {duration: 3000});
this.feeds = this.feeds.filter(feed => feed.id !== id);
@ -69,7 +70,7 @@ export class EinstellungenComponent implements OnInit {
public errorDialog() {
const dialogRef = this._dialog.open(DialogComponent, {
this._dialog.open(DialogComponent, {
data: {
title: 'Serverfehler',
body: 'Fehler beim Aufruf des Servers',

View File

@ -1,11 +1,12 @@
import {Component, OnInit} from '@angular/core';
import {AuthService} from '../../services/auth.service';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {HttpClient} from '@angular/common/http';
import {FeedService} from '../../services/feed.service';
import {IFeed} from '../../interfaces/feed.interface';
import {Observable} from 'rxjs';
import {Tweet} from "../../interfaces/interface";
import {SnackbarService} from "../../services/snackbar.service";
import {Tweet} from '../../interfaces/interface';
import {SnackbarService} from '../../services/snackbar.service';
import {environment} from '../../../environments/environment';
@Component({
@ -34,8 +35,8 @@ export class TweetsComponent implements OnInit {
ngOnInit(): void {
this.fillTweets()
console.log(this.tweets)
this.fillTweets();
console.log(this.tweets);
}
@ -43,17 +44,19 @@ export class TweetsComponent implements OnInit {
console.log(this.tweets);
this.http.get<Tweet[]>('http://127.0.0.1:8000/getMoreTweets/'+this.tweets[this.tweets.length-1].tweet_id+'/').subscribe(data => {
console.log(data)
this.http.get<Tweet[]>(
'http://' + environment.location + ':' + environment.port + '/getMoreTweets/' + this.tweets[this.tweets.length - 1].tweet_id + '/'
).subscribe(data => {
console.log(data);
if(data.length == 0){
this._snackbarService.show("Keine weiteren Tweets vorhanden","Schließen");
if (data.length === 0) {
this._snackbarService.show('Keine weiteren Tweets vorhanden', 'Schließen');
}
for(let tweet of data){
let position = tweet.text.search(": http");
tweet.text = tweet.text.substring(0,position);
for (const tweet of data) {
const position = tweet.text.search(': http');
tweet.text = tweet.text.substring(0, position);
this.tweets.push(tweet);
}
}
@ -61,18 +64,18 @@ export class TweetsComponent implements OnInit {
}
fillTweets(){
fillTweets() {
this.http.get<Tweet[]>('http://127.0.0.1:8000/getSixTweets/').subscribe(data => {
console.log(data)
for(let tweet of data){
let position = tweet.text.search(": http");
tweet.text = tweet.text.substring(0,position);
this.tweets.push(tweet);
}
this.http.get<Tweet[]>('http://' + environment.location + ':' + environment.port + '/getSixTweets/').subscribe(data => {
console.log(data);
for (const tweet of data) {
const position = tweet.text.search(': http');
tweet.text = tweet.text.substring(0, position);
this.tweets.push(tweet);
}
}
);
}
}
}

View File

@ -3,12 +3,13 @@ import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {IFeed} from '../interfaces/feed.interface';
import {delay} from 'rxjs/operators';
import {environment} from '../../environments/environment';
@Injectable({
providedIn: 'root'
})
export class FeedService {
private url = 'http://localhost:8000/feeds/';
private url = 'http://' + environment.location + ':' + environment.port + '/feeds/';
constructor(private http: HttpClient) {}

View File

@ -1,10 +0,0 @@
import {NgxLoggerLevel} from 'ngx-logger';
export const environment = {
title: 'Bsp 4 Gruppe 4',
production: true,
location: window.location.hostname,
port: 8000,
ws_url_root: 'ws://' + window.location.hostname + ':' + window.location.port + '/',
log_level: NgxLoggerLevel.WARN,
};

View File

@ -1,25 +1,10 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
import {NgxLoggerLevel} from 'ngx-logger';
export const environment = {
title: 'Bsp 4 Gruppe 4',
openid_endpoint: 'https://waecm-sso.inso.tuwien.ac.at/auth/realms/waecm/protocol/openid-connect',
production: false,
location: 'http://localhost:4200',
production: true,
location: window.location.hostname,
port: 8000,
ws_location: 'ws://127.0.0.1',
ws_port: 8000,
log_level: NgxLoggerLevel.DEBUG,
log_level: NgxLoggerLevel.WARN,
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.