mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-23 23:02:22 +00:00
Merge pull request #393 from GNS3/adbutler-integration
Adbutler integration, Fixes: #361
This commit is contained in:
commit
3f28256932
@ -180,6 +180,7 @@ import { StartCaptureDialogComponent } from './components/project-map/packet-cap
|
||||
import { SuspendLinkActionComponent } from './components/project-map/context-menu/actions/suspend-link/suspend-link-action.component';
|
||||
import { ResumeLinkActionComponent } from './components/project-map/context-menu/actions/resume-link-action/resume-link-action.component';
|
||||
import { StopCaptureActionComponent } from './components/project-map/context-menu/actions/stop-capture/stop-capture-action.component';
|
||||
import { AdbutlerComponent } from './components/adbutler/adbutler.component';
|
||||
import { ConsoleService } from './services/settings/console.service';
|
||||
import { DefaultConsoleService } from './services/settings/default-console.service';
|
||||
import { NodeCreatedLabelStylesFixer } from './components/project-map/helpers/node-created-label-styles-fixer';
|
||||
@ -297,6 +298,8 @@ if (environment.production) {
|
||||
NameFilter,
|
||||
ListOfSnapshotsComponent,
|
||||
CustomAdaptersComponent,
|
||||
NodesMenuComponent,
|
||||
AdbutlerComponent,
|
||||
ConsoleDeviceActionComponent,
|
||||
ConsoleComponent,
|
||||
NodesMenuComponent
|
||||
|
15
src/app/components/adbutler/adbutler.component.html
Normal file
15
src/app/components/adbutler/adbutler.component.html
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
<table class="butler" style="width: 600px; border: 0px solid #C0C0C0; background-color: #263238" cellSpacing=0 cellPadding=3>
|
||||
<tr><td height=80 style="background-color: #263238" #code>
|
||||
<div id="{{ this.divId }}"></div>
|
||||
|
||||
|
||||
<!-- Begin Ad Code -->
|
||||
|
||||
|
||||
<!-- End Ad Code -->
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
7
src/app/components/adbutler/adbutler.component.scss
Normal file
7
src/app/components/adbutler/adbutler.component.scss
Normal file
@ -0,0 +1,7 @@
|
||||
.butler a {
|
||||
color: #0097a7;
|
||||
}
|
||||
|
||||
.butler {
|
||||
font-size: 14px;
|
||||
}
|
25
src/app/components/adbutler/adbutler.component.spec.ts
Normal file
25
src/app/components/adbutler/adbutler.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AdbutlerComponent } from './adbutler.component';
|
||||
|
||||
describe('AdbutlerComponent', () => {
|
||||
let component: AdbutlerComponent;
|
||||
let fixture: ComponentFixture<AdbutlerComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ AdbutlerComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AdbutlerComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
68
src/app/components/adbutler/adbutler.component.ts
Normal file
68
src/app/components/adbutler/adbutler.component.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import { Component, OnInit, ElementRef, ViewChild, AfterViewInit, ViewEncapsulation, OnDestroy } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-adbutler',
|
||||
templateUrl: './adbutler.component.html',
|
||||
styleUrls: ['./adbutler.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class AdbutlerComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
id: number;
|
||||
setId: number;
|
||||
rnd: number;
|
||||
abkw: string;
|
||||
sparkCounter: number;
|
||||
divId: string;
|
||||
|
||||
@ViewChild('code') code: ElementRef;
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
var loadedTextAds355353 = (window as any).loadedTextAds355353;
|
||||
if(loadedTextAds355353 == null) {
|
||||
(window as any).loadedTextAds355353 = new Array();
|
||||
}
|
||||
|
||||
(window as any).id355353 = 165803;
|
||||
(window as any).setID355353 = 355353;
|
||||
(window as any).rnd = (window as any).rnd || Math.floor(Math.random()*10e6);
|
||||
(window as any).abkw = (window as any).abkw ||'';
|
||||
|
||||
var sparkCounter355353 = (window as any).sparkCounter355353;
|
||||
if(sparkCounter355353 == null) {
|
||||
sparkCounter355353 = 1;
|
||||
}
|
||||
else {
|
||||
sparkCounter355353 = sparkCounter355353 + 1
|
||||
}
|
||||
|
||||
(window as any).sparkCounter355353 = sparkCounter355353;
|
||||
(window as any).loadedTextAds355353[sparkCounter355353] = false;
|
||||
|
||||
this.id = (window as any).id355353;
|
||||
this.divId = "abta355353" + sparkCounter355353;
|
||||
this.setId = (window as any).setID355353;
|
||||
this.abkw = (window as any).abkw;
|
||||
this.rnd = (window as any).rnd;
|
||||
this.sparkCounter = (window as any).sparkCounter355353;
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
const scriptUrl = "https://servedbyadbutler.com/adserve/;ID=" + this.id + ";setID=" + this.setId + ";type=textad;kw=" + this.abkw + ";pid=" + this.rnd + ";layoutID=" + this.sparkCounter;
|
||||
|
||||
const scriptElement = document.createElement('script');
|
||||
scriptElement.src = scriptUrl;
|
||||
scriptElement.type = 'text/javascript';
|
||||
scriptElement.async = true;
|
||||
scriptElement.charset = 'utf-8';
|
||||
this.code.nativeElement.appendChild(scriptElement);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
// start from 0 when switching pages
|
||||
(window as any).sparkCounter355353 = 0;
|
||||
delete (window as any).loadedTextAds355353[this.sparkCounter];
|
||||
}
|
||||
|
||||
}
|
@ -8,13 +8,21 @@
|
||||
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef> Name </mat-header-cell>
|
||||
<mat-cell *matCellDef="let row;">{{ row.name }}</mat-cell>
|
||||
<mat-cell *matCellDef="let row;">
|
||||
<ng-container *ngIf="row.type !== 'adbutler'">
|
||||
{{ row.name }}
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="row.type === 'adbutler'">
|
||||
<app-adbutler></app-adbutler>
|
||||
</ng-container>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="actions">
|
||||
<mat-header-cell *matHeaderCellDef></mat-header-cell>
|
||||
<mat-cell *matCellDef="let row;" style="text-align: right">
|
||||
<app-install-software [software]="row" (installedChanged)="onInstalled($event)"></app-install-software>
|
||||
<app-install-software [software]="row" (installedChanged)="onInstalled($event)" *ngIf="row.type !== 'adbutler'"></app-install-software>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
|
@ -47,7 +47,11 @@ export class InstalledSoftwareDataSource extends DataSource<any> {
|
||||
disconnect() {}
|
||||
|
||||
refresh() {
|
||||
this.installed.next(this.installedSoftwareService.list());
|
||||
let installedSoftware = this.installedSoftwareService.list();
|
||||
installedSoftware.push({
|
||||
type: 'adbutler'
|
||||
});
|
||||
this.installed.next(installedSoftware);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user