Commit 1bf37d71 authored by Adarsh's avatar Adarsh

user tokens added to fiel and home

parent 88d8797e
...@@ -2,6 +2,7 @@ import {Injectable} from '@angular/core'; ...@@ -2,6 +2,7 @@ import {Injectable} from '@angular/core';
import {File} from './file'; import {File} from './file';
import {Observable, of} from 'rxjs'; import {Observable, of} from 'rxjs';
import {HttpClient} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import { User } from './user';
@Injectable({ @Injectable({
...@@ -11,6 +12,7 @@ export class FileService { ...@@ -11,6 +12,7 @@ export class FileService {
saveUrl = 'http://localhost/sfcode/backend/filesave.php'; saveUrl = 'http://localhost/sfcode/backend/filesave.php';
uploadUrl = 'http://localhost/sfcode/backend/fileupload.php'; uploadUrl = 'http://localhost/sfcode/backend/fileupload.php';
filelistUrl = 'http://localhost/sfcode/backend/list_files.php'
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
} }
...@@ -18,7 +20,6 @@ export class FileService { ...@@ -18,7 +20,6 @@ export class FileService {
getFiles(): Observable<File[]> { getFiles(): Observable<File[]> {
const ret: File[] = []; const ret: File[] = [];
const arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
for (const item of arr) { for (const item of arr) {
......
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {File} from '../file'; import {File} from '../file';
import {FileService} from '../file.service'; import {FileService} from '../file.service';
import { ApiService } from '../api.service';
import { User } from '../user';
@Component({ @Component({
selector: 'app-file', selector: 'app-file',
...@@ -9,17 +11,19 @@ import {FileService} from '../file.service'; ...@@ -9,17 +11,19 @@ import {FileService} from '../file.service';
}) })
export class FileComponent implements OnInit { export class FileComponent implements OnInit {
user: User;
files: File[]; files: File[];
// File upload variables
shortLink = ''; shortLink = '';
loading = false; // Flag variable loading = false;
fileToUpload: File = null; fileToUpload: File = null;
uploadPopupActive = false; uploadPopupActive = false;
constructor(private fileService: FileService) { constructor(private fileService: FileService,
private dataService: ApiService ) {
} }
ngOnInit(): void { ngOnInit(): void {
this.user = JSON.parse(this.dataService.getToken());
this.getFiles(); this.getFiles();
} }
......
...@@ -12,7 +12,6 @@ import { User } from '../user'; ...@@ -12,7 +12,6 @@ import { User } from '../user';
export class HomeComponent implements OnInit { export class HomeComponent implements OnInit {
user: User; user: User;
loggedIn: boolean;
problems: Problem[]; problems: Problem[];
constructor(private dataService: ApiService, constructor(private dataService: ApiService,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment