chore: remove obsolete dart related files

This commit is contained in:
Igor Minar
2016-09-02 11:45:13 -07:00
committed by Martin Probst
parent 6f4b6edfea
commit 2371d22d49
24 changed files with 0 additions and 1015 deletions

View File

@ -1,59 +0,0 @@
library scroll_app;
import 'dart:async';
import 'dart:html';
import 'package:angular/angular.dart';
import 'package:angular2/src/testing/benchmark_util.dart';
@Component(
selector: 'scroll-app',
template: '''
<div>
<div style="display: flex">
<scroll-area scroll-top="scrollTop"></scroll-area>
</div>
<div ng-if="scrollAreas.length > 0">
<p>Following tables are only here to add weight to the UI:</p>
<scroll-area ng-repeat="scrollArea in scrollAreas"></scroll-area>
</div>
</div>
''')
class App implements ShadowRootAware {
final VmTurnZone ngZone;
List<int> scrollAreas;
int scrollTop = 0;
int iterationCount;
int scrollIncrement;
App(this.ngZone) {
int appSize = getIntParameter('appSize');
iterationCount = getIntParameter('iterationCount');
scrollIncrement = getIntParameter('scrollIncrement');
appSize = appSize > 1 ? appSize - 1 : 0; // draw at least one table
scrollAreas = new List.generate(appSize, (i) => i);
}
@override
void onShadowRoot(ShadowRoot shadowRoot) {
bindAction('#run-btn', () {
runBenchmark();
});
bindAction('#reset-btn', () {
scrollTop = 0;
});
}
void runBenchmark() {
int n = iterationCount;
scheduleScroll() {
new Future(() {
scrollTop += scrollIncrement;
n--;
if (n > 0) {
scheduleScroll();
}
});
}
scheduleScroll();
}
}

View File

@ -1,128 +0,0 @@
library cells;
import 'package:angular/angular.dart';
import 'common.dart';
@Component(
selector: 'company-name',
template: '''
<div style="width: {{width}}">{{company.name}}</div>
''',
map: const {'company': '=>company', 'cell-width': '=>width',})
class CompanyNameComponent {
String width;
Company company;
}
@Component(
selector: 'opportunity-name',
template: '''
<div style="width: {{width}}">{{opportunity.name}}</div>
''',
map: const {'opportunity': '=>opportunity', 'cell-width': '=>width',})
class OpportunityNameComponent {
String width;
Opportunity opportunity;
}
@Component(
selector: 'offering-name',
template: '''
<div style="width: {{width}}">{{offering.name}}</div>
''',
map: const {'offering': '=>offering', 'cell-width': '=>width',})
class OfferingNameComponent {
String width;
Offering offering;
}
class Stage {
String name;
bool isDisabled;
Map style;
Function apply;
String get styleString => style != null
? style.keys.map((prop) => '$prop: ${style[prop]}').join(';')
: '';
}
@Component(
selector: 'stage-buttons',
template: '''
<div style="width: {{width}}">
<button ng-repeat="stage in stages"
ng-disabled="stage.isDisabled"
style="{{stage.styleString}}"
ng-click="setStage(stage)">
{{stage.name}}
</button>
</div>
''',
map: const {'offering': '=>offering', 'cell-width': '=>width',})
class StageButtonsComponent {
Offering _offering;
List<Stage> stages;
String width;
Offering get offering => _offering;
set offering(Offering offering) {
_offering = offering;
_computeStageButtons();
}
setStage(Stage stage) {
_offering.status = stage.name;
_computeStageButtons();
}
_computeStageButtons() {
bool disabled = true;
stages = STATUS_LIST.map((String status) {
bool isCurrent = offering.status == status;
var stage = new Stage();
stage
..name = status
..isDisabled = disabled
..style = {
'background-color': disabled ? '#DDD' : isCurrent ? '#DDF' : '#FDD'
};
if (isCurrent) {
disabled = false;
}
return stage;
}).toList();
}
}
@Component(
selector: 'account-cell',
template: '''
<div style="width: {{width}}">
<a href="/account/{{account.accountId}}">
{{account.accountId}}
</a>
</div>
''',
map: const {'account': '=>account', 'cell-width': '=>width',})
class AccountCellComponent {
Account account;
String width;
}
@Component(
selector: 'formatted-cell',
template: '''<div style="width: {{width}}">{{formattedValue}}</div>''',
map: const {'value': '=>value', 'cell-width': '=>width',})
class FormattedCellComponent {
String formattedValue;
String width;
set value(dynamic value) {
if (value is DateTime) {
formattedValue = '${value.month}/${value.day}/${value.year}';
} else {
formattedValue = value.toString();
}
}
}

View File

@ -1,205 +0,0 @@
library common.stuff;
import 'dart:async';
import 'dart:collection';
import 'package:observe/observe.dart';
const ITEMS = 1000;
const ITEM_HEIGHT = 40;
const VISIBLE_ITEMS = 17;
const HEIGHT = ITEMS * ITEM_HEIGHT;
const VIEW_PORT_HEIGHT = ITEM_HEIGHT * VISIBLE_ITEMS;
const COMPANY_NAME_WIDTH = 100;
const OPPORTUNITY_NAME_WIDTH = 100;
const OFFERING_NAME_WIDTH = 100;
const ACCOUNT_CELL_WIDTH = 50;
const BASE_POINTS_WIDTH = 50;
const KICKER_POINTS_WIDTH = 50;
const STAGE_BUTTONS_WIDTH = 220;
const BUNDLES_WIDTH = 120;
const DUE_DATE_WIDTH = 100;
const END_DATE_WIDTH = 100;
const AAT_STATUS_WIDTH = 100;
const ROW_WIDTH = COMPANY_NAME_WIDTH +
OPPORTUNITY_NAME_WIDTH +
OFFERING_NAME_WIDTH +
ACCOUNT_CELL_WIDTH +
BASE_POINTS_WIDTH +
KICKER_POINTS_WIDTH +
STAGE_BUTTONS_WIDTH +
BUNDLES_WIDTH +
DUE_DATE_WIDTH +
END_DATE_WIDTH +
AAT_STATUS_WIDTH;
const STATUS_LIST = const ['Planned', 'Pitched', 'Won', 'Lost'];
const AAT_STATUS_LIST = const ['Active', 'Passive', 'Abandoned'];
// Imitate Streamy entities.
class RawEntity extends Object
with MapMixin<String, dynamic>
implements ObservableMap<String, dynamic> {
ObservableMap _data = new ObservableMap();
@override
Iterable<String> get keys => _data.keys;
@override
void clear() {
_data.clear();
}
@override
operator [](String key) {
if (!key.contains('.')) {
return _data[key];
}
var pieces = key.split('.');
var last = pieces.removeLast();
var target = _resolve(pieces, this);
if (target == null) {
return null;
}
return target[last];
}
@override
operator []=(String key, value) {
if (!key.contains('.')) {
_data[key] = value;
return;
}
var pieces = key.split('.');
var last = pieces.removeLast();
var target = _resolve(pieces, this);
target[last] = value;
}
@override
remove(String key) {
if (!key.contains('.')) {
return _data.remove(key);
}
var pieces = key.split('.');
var last = pieces.removeLast();
var target = _resolve(pieces, this);
return target.remove(last);
}
_resolve(List<String> pieces, start) {
var cur = start;
for (var i = 0; i < pieces.length; i++) {
cur = cur[pieces[i]];
if (cur == null) {
return null;
}
}
return cur;
}
@override
Stream<List<ChangeRecord>> get changes => _data.changes;
@override
bool get hasObservers => _data.hasObservers;
@override
bool deliverChanges() => _data.deliverChanges();
@override
notifyPropertyChange(Symbol field, Object oldValue, Object newValue) =>
_data.notifyPropertyChange(field, oldValue, newValue);
@override
void notifyChange(ChangeRecord record) {
_data.notifyChange(record);
}
@override
void observed() {
_data.observed();
}
@override
void unobserved() {
_data.observed();
}
}
class Company extends RawEntity {
String get name => this['name'];
set name(String val) {
this['name'] = val;
}
}
class Offering extends RawEntity {
String get name => this['name'];
set name(String val) {
this['name'] = val;
}
Company get company => this['company'];
set company(Company val) {
this['company'] = val;
}
Opportunity get opportunity => this['opportunity'];
set opportunity(Opportunity val) {
this['opportunity'] = val;
}
Account get account => this['account'];
set account(Account val) {
this['account'] = val;
}
int get basePoints => this['basePoints'];
set basePoints(int val) {
this['basePoints'] = val;
}
int get kickerPoints => this['kickerPoints'];
set kickerPoints(int val) {
this['kickerPoints'] = val;
}
String get status => this['status'];
set status(String val) {
this['status'] = val;
}
String get bundles => this['bundles'];
set bundles(String val) {
this['bundles'] = val;
}
DateTime get dueDate => this['dueDate'];
set dueDate(DateTime val) {
this['dueDate'] = val;
}
DateTime get endDate => this['endDate'];
set endDate(DateTime val) {
this['endDate'] = val;
}
String get aatStatus => this['aatStatus'];
set aatStatus(String val) {
this['aatStatus'] = val;
}
}
class Opportunity extends RawEntity {
String get name => this['name'];
set name(String val) {
this['name'] = val;
}
}
class Account extends RawEntity {
int get accountId => this['accountId'];
set accountId(int val) {
this['accountId'] = val;
}
}

View File

@ -1,28 +0,0 @@
library naive_infinite_scroll;
import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';
import 'app.dart';
import 'scroll_area.dart';
import 'scroll_item.dart';
import 'cells.dart';
class MyAppModule extends Module {
MyAppModule() {
bind(ResourceResolverConfig,
toValue: new ResourceResolverConfig.resolveRelativeUrls(false));
bind(App);
bind(ScrollAreaComponent);
bind(ScrollItemComponent);
bind(CompanyNameComponent);
bind(OpportunityNameComponent);
bind(OfferingNameComponent);
bind(AccountCellComponent);
bind(StageButtonsComponent);
bind(FormattedCellComponent);
}
}
void main() {
applicationFactory().addModule(new MyAppModule()).run();
}

View File

@ -1,69 +0,0 @@
library random_data;
import 'common.dart';
List<Offering> generateOfferings(int count) =>
new List.generate(count, generateOffering);
Offering generateOffering(int seed) {
final res = new Offering();
res.name = generateName(seed++);
res.company = generateCompany(seed++);
res.opportunity = generateOpportunity(seed++);
res.account = generateAccount(seed++);
res.basePoints = seed % 10;
res.kickerPoints = seed % 4;
res.status = STATUS_LIST[seed % STATUS_LIST.length];
res.bundles = randomString(seed++);
res.dueDate = randomDate(seed++);
res.endDate = randomDate(seed++, minDate: res.dueDate);
res.aatStatus = AAT_STATUS_LIST[seed % AAT_STATUS_LIST.length];
return res;
}
Company generateCompany(int seed) {
return new Company()..name = generateName(seed);
}
Opportunity generateOpportunity(int seed) {
return new Opportunity()..name = generateName(seed);
}
Account generateAccount(int seed) {
return new Account()..accountId = seed;
}
String generateName(int seed) {
const names = const [
'Foo',
'Bar',
'Baz',
'Qux',
'Quux',
'Garply',
'Waldo',
'Fred',
'Plugh',
'Xyzzy',
'Thud',
'Cruft',
'Stuff'
];
return names[seed % names.length];
}
DateTime randomDate(int seed, {DateTime minDate}) {
if (minDate == null) {
minDate = new DateTime.now();
}
const offsets = const [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
return minDate.add(new Duration(days: offsets[seed % offsets.length]));
}
String randomString(int seed) {
return new String.fromCharCodes(new List.generate(
const [5, 7, 9, 11, 13][seed % 5],
(i) =>
'a'.codeUnitAt(0) + const [0, 1, 2, 3, 4, 5, 6, 7, 8][seed % 9] + i));
}

View File

@ -1,57 +0,0 @@
library scroll_area;
import 'dart:html';
import 'dart:math' as math;
import 'package:angular/angular.dart';
import 'common.dart';
import 'random_data.dart';
@Component(
selector: 'scroll-area',
templateUrl: 'scroll_area.html',
map: const {'scroll-top': '=>scrollTop',})
class ScrollAreaComponent implements ShadowRootAware {
Element scrollDiv;
List<Offering> _fullList;
List<Offering> visibleItems = [];
// Init empty maps and populate later. There seems to be a bug in Angular
// that makes it choke on pre-populated style maps.
final Map paddingStyle = {};
final Map innerStyle = {};
final Map scrollDivStyle = {};
ScrollAreaComponent() {
_fullList = generateOfferings(ITEMS);
}
@override
void onShadowRoot(ShadowRoot shadowRoot) {
scrollDiv = shadowRoot.querySelector('#scrollDiv');
onScroll();
scrollDivStyle.addAll({
'height': '${VIEW_PORT_HEIGHT}px',
'width': '1000px',
'border': '1px solid #000',
'overflow': 'scroll',
});
innerStyle['width'] = '${ROW_WIDTH}px';
}
set scrollTop(int value) {
if (value == null || scrollDiv == null) return;
scrollDiv.scrollTop = value;
}
void onScroll() {
int scrollY = scrollDiv.scrollTop;
int iStart = scrollY == 0 ? 0 : (scrollY / ITEM_HEIGHT).floor();
int iEnd = math.min(iStart + VISIBLE_ITEMS + 1, _fullList.length);
int padding = iStart * ITEM_HEIGHT;
innerStyle['height'] = '${HEIGHT - padding}px';
paddingStyle['height'] = '${padding}px';
visibleItems
..clear()
..addAll(_fullList.getRange(iStart, iEnd));
}
}

View File

@ -1,39 +0,0 @@
library scroll_item;
import 'package:angular/angular.dart';
import 'common.dart';
@Component(
selector: 'scroll-item',
templateUrl: 'scroll_item.html',
map: const {'offering': '=>offering',})
class ScrollItemComponent implements ShadowRootAware {
Offering offering;
// Init empty maps and populate later. There seems to be a bug in Angular
// that makes it choke on pre-populated style maps.
Map itemStyle = {};
@override
void onShadowRoot(_) {
itemStyle.addAll({
'height': '${ITEM_HEIGHT}px',
'line-height': '${ITEM_HEIGHT}px',
'font-size': '18px',
'display': 'flex',
'justify-content': 'space-between',
});
}
get companyNameWidth => '${COMPANY_NAME_WIDTH}px';
get opportunityNameWidth => '${OPPORTUNITY_NAME_WIDTH}px';
get offeringNameWidth => '${OFFERING_NAME_WIDTH}px';
get accountCellWidth => '${ACCOUNT_CELL_WIDTH}px';
get basePointsWidth => '${BASE_POINTS_WIDTH}px';
get kickerPointsWidth => '${KICKER_POINTS_WIDTH}px';
get stageButtonsWidth => '${STAGE_BUTTONS_WIDTH}px';
get bundlesWidth => '${BUNDLES_WIDTH}px';
get dueDateWidth => '${DUE_DATE_WIDTH}px';
get endDateWidth => '${END_DATE_WIDTH}px';
get aatStatusWidth => '${AAT_STATUS_WIDTH}px';
}