diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index d68e95f..690daa3 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -1,9 +1,11 @@ +import { EditSlaveComponent } from './pages/edit-slave/edit-slave.component'; import { PasswordComponent } from './pages/password/password.component'; import { AuthGuard } from './services/auth-guard.service'; import { DomainsComponent } from './pages/domains/domains.component'; import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { LoginComponent } from './pages/login/login.component'; +import { EditAuthComponent } from './pages/edit-auth/edit-auth.component'; const routes: Routes = [ { @@ -25,6 +27,14 @@ const routes: Routes = [ path: 'domains', component: DomainsComponent }, + { + path: 'domains/slave/:domainId', + component: EditSlaveComponent + }, + { + path: 'domains/auth/:domainId', + component: EditAuthComponent + }, { path: 'password', component: PasswordComponent diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index b617f9a..3e0e278 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -25,6 +25,7 @@ import { SessionOperation } from './operations/session.operation'; import { DomainsComponent } from './pages/domains/domains.component'; import { PasswordComponent } from './pages/password/password.component'; import { EditSlaveComponent } from './pages/edit-slave/edit-slave.component'; +import { EditAuthComponent } from './pages/edit-auth/edit-auth.component'; @NgModule({ declarations: [ @@ -42,7 +43,8 @@ import { EditSlaveComponent } from './pages/edit-slave/edit-slave.component'; PasswordComponent, PagingComponent, PagesizeComponent, - EditSlaveComponent + EditSlaveComponent, + EditAuthComponent ], imports: [ BrowserModule, diff --git a/frontend/src/app/operations/domains.operations.ts b/frontend/src/app/operations/domains.operations.ts index 5765782..c6b3bbf 100644 --- a/frontend/src/app/operations/domains.operations.ts +++ b/frontend/src/app/operations/domains.operations.ts @@ -10,12 +10,15 @@ export class DomainsOperation { constructor(private http: HttpService, private gs: StateService) { } - public async getList(page?: number, pageSize?: number, query?: string, sort?: Array): Promise> { + public async getList(page?: number, pageSize?: number, query?: string, + sort?: Array | string, type?: string): Promise> { try { return new ListApitype(await this.http.get('/domains', { page: page, pagesize: pageSize, - query: query + query: query, + sort: sort, + type: type })); } catch (e) { console.error(e); diff --git a/frontend/src/app/pages/domains/domains.component.html b/frontend/src/app/pages/domains/domains.component.html index 583408a..5e6b3d4 100644 --- a/frontend/src/app/pages/domains/domains.component.html +++ b/frontend/src/app/pages/domains/domains.component.html @@ -5,11 +5,34 @@ - - - - - + + + + + @@ -25,6 +48,7 @@
IDNameTypeRecords + ID + + +
+ Name + + +
+
+
+ Name + + +
+
+ Records + +
+ \ No newline at end of file diff --git a/frontend/src/app/pages/domains/domains.component.ts b/frontend/src/app/pages/domains/domains.component.ts index ca0304d..e15b7b8 100644 --- a/frontend/src/app/pages/domains/domains.component.ts +++ b/frontend/src/app/pages/domains/domains.component.ts @@ -1,3 +1,4 @@ +import { SortEventDatatype } from './../../datatypes/sort-event.datatype'; import { ModalOptionsDatatype } from './../../datatypes/modal-options.datatype'; import { ModalService } from './../../services/modal.service'; import { StateService } from './../../services/state.service'; @@ -5,6 +6,10 @@ import { DomainApitype } from './../../apitypes/Domain.apitype'; import { PagingApitype } from './../../apitypes/Paging.apitype'; import { DomainsOperation } from './../../operations/domains.operations'; import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { FormControl } from '@angular/forms'; + +import 'rxjs/add/operator/debounceTime'; @Component({ selector: 'app-domains', @@ -18,14 +23,30 @@ export class DomainsComponent implements OnInit { public domainList: DomainApitype[] = []; - constructor(private domains: DomainsOperation, public gs: StateService, private modal: ModalService) { } + public sortField = ''; + public sortOrder = 'asc'; + + public searchInput: FormControl; + public typeFilter: FormControl; + + constructor(private domains: DomainsOperation, public gs: StateService, private modal: ModalService, private router: Router) { } public ngOnInit() { + this.searchInput = new FormControl(''); + this.searchInput.valueChanges.debounceTime(500).subscribe(() => this.loadData()); + + this.typeFilter = new FormControl(''); + this.typeFilter.valueChanges.subscribe(() => this.loadData()); + this.loadData(); } public async loadData() { - const res = await this.domains.getList(this.pageRequested, this.gs.pageSize); + const sortStr = this.sortField !== '' ? this.sortField + '-' + this.sortOrder : null; + const searchStr = this.searchInput.value !== '' ? this.searchInput.value : null; + const typeFilter = this.typeFilter.value !== '' ? this.typeFilter.value : null; + + const res = await this.domains.getList(this.pageRequested, this.gs.pageSize, searchStr, sortStr, typeFilter); this.pagingInfo = res.paging; this.domainList = res.results; @@ -60,6 +81,22 @@ export class DomainsComponent implements OnInit { } public async onDomainClick(domain: DomainApitype) { - alert(domain.id); + if (domain.type === 'SLAVE') { + this.router.navigate(['/domains/slave/', domain.id.toString()]); + } else if (domain.type === 'MASTER' || domain.type === 'NATIVE') { + this.router.navigate(['/domains/auth/', domain.id.toString()]); + } + } + + public async onSortEvent(sortEvent: SortEventDatatype) { + if (sortEvent.order === 0) { + this.sortField = ''; + this.sortOrder = 'asc'; + } else { + this.sortField = sortEvent.field; + this.sortOrder = sortEvent.order === 1 ? 'asc' : 'desc'; + } + + await this.loadData(); } } diff --git a/frontend/src/app/pages/edit-auth/edit-auth.component.html b/frontend/src/app/pages/edit-auth/edit-auth.component.html new file mode 100644 index 0000000..372e765 --- /dev/null +++ b/frontend/src/app/pages/edit-auth/edit-auth.component.html @@ -0,0 +1,3 @@ +

+ edit-auth works! +

\ No newline at end of file diff --git a/frontend/src/app/pages/edit-auth/edit-auth.component.scss b/frontend/src/app/pages/edit-auth/edit-auth.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/app/pages/edit-auth/edit-auth.component.ts b/frontend/src/app/pages/edit-auth/edit-auth.component.ts new file mode 100644 index 0000000..8819dcb --- /dev/null +++ b/frontend/src/app/pages/edit-auth/edit-auth.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-edit-auth', + templateUrl: './edit-auth.component.html', + styleUrls: ['./edit-auth.component.scss'] +}) +export class EditAuthComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/frontend/src/app/pages/edit-slave/edit-slave.component.html b/frontend/src/app/pages/edit-slave/edit-slave.component.html new file mode 100644 index 0000000..b2db57e --- /dev/null +++ b/frontend/src/app/pages/edit-slave/edit-slave.component.html @@ -0,0 +1,3 @@ +

+ edit-slave works! +

\ No newline at end of file diff --git a/frontend/src/app/pages/edit-slave/edit-slave.component.scss b/frontend/src/app/pages/edit-slave/edit-slave.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/app/pages/edit-slave/edit-slave.component.ts b/frontend/src/app/pages/edit-slave/edit-slave.component.ts new file mode 100644 index 0000000..01ae251 --- /dev/null +++ b/frontend/src/app/pages/edit-slave/edit-slave.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-edit-slave', + templateUrl: './edit-slave.component.html', + styleUrls: ['./edit-slave.component.scss'] +}) +export class EditSlaveComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/frontend/src/app/partials/sort/sort.component.html b/frontend/src/app/partials/sort/sort.component.html index df0d28b..620c231 100644 --- a/frontend/src/app/partials/sort/sort.component.html +++ b/frontend/src/app/partials/sort/sort.component.html @@ -1,3 +1,3 @@ - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/frontend/src/app/partials/sort/sort.component.ts b/frontend/src/app/partials/sort/sort.component.ts index fa16183..46a4cdb 100644 --- a/frontend/src/app/partials/sort/sort.component.ts +++ b/frontend/src/app/partials/sort/sort.component.ts @@ -12,6 +12,9 @@ export class SortComponent { @Output() sort = new EventEmitter(); @Input() field: string; + + @Input() activeFields: Array | string = null; + public order = 0; constructor() { } @@ -53,4 +56,19 @@ export class SortComponent { })); } + /** + * Determines if field is active + */ + public isActive() { + if (this.activeFields === null) { + return false; + } else { + if (this.activeFields instanceof Array) { + return this.activeFields.includes(this.field); + } else { + return this.activeFields === this.field; + } + } + } + } diff --git a/frontend/src/styles.scss b/frontend/src/styles.scss index 30404c4..f9bbcc8 100644 --- a/frontend/src/styles.scss +++ b/frontend/src/styles.scss @@ -58,3 +58,9 @@ $fa-font-path: "~font-awesome/fonts"; .cursor-pointer { cursor: pointer; } + +/* Remove glow from inputs */ +.no-shadow { + box-shadow: none!important; + border-color: #CCC!important; +} diff --git a/utils/pre-commit.hook b/utils/pre-commit.hook index d161c95..3bdcfc7 100755 --- a/utils/pre-commit.hook +++ b/utils/pre-commit.hook @@ -8,11 +8,20 @@ then fi cd .. +cd frontend +if ! npm run build +then + echo "Frontend build failed" + exit 2 +fi +rm -rf dist/ +cd .. + cd backend/src if ! composer run-script lint then echo "Backend lint failed" - exit 2 + exit 3 fi cd ../.. @@ -20,7 +29,7 @@ cd backend/test if ! ./test.sh all then echo "Backend test failed" - exit 3 + exit 4 fi cd ../..