Example #1
0
function Rappid() {
    // leaflet
    this.map = null;
    this.latlng = {lat: null, lng: null};
    // route shape and stops go on rappid.routeLayer
    // vehicles go on rappid.vehicles.layer
    this.routeLayer = null;

    // data
    this.vehicles = null;
    this.shape = null;

    // viewmodels
    this.availableRoutes = ko.observableArray();
    this.route = ko.observable();
    this.stops = ko.observableArray();

    // options
    this.includeList = ko.observable(true);
    this.includeMap = ko.observable(true);
    this.includeToggleBtn = ko.computed(function() {
        return !this.includeList() || !this.includeMap();
    }.bind(this));
}
function BaseGalleryViewModel(slides) {
  this.slides = ko.observableArray(slides || []);

  this.totalSlideCount = ko.observable();

  this.currentSlideIndex = ko.observable(0);

  this.currentSlide = ko.computed(function() {
    return this.slides()[this.currentSlideIndex()];
  }, this);

  this.currentSlideNum = ko.computed(function() {
    return this.currentSlideIndex() + 1;
  }, this);
}
    constructor(params) {
        this.activityData = params.activityData;
        this.showLessonNavigation = !!this.activityData; // coerce to boolean
        this.editorPaneTabs = ko.observableArray();

        this.docParams = params.docParams;
        this.vmState = params.vmParams.vmState;
        var compilerParams = params.compilerParams;
        this.compilerStateParams = {
            compileStatus: compilerParams.compileStatus,
            lastGccOutput: compilerParams.lastGccOutput,
            gccErrorCount: compilerParams.gccErrorCount,
            gccWarningCount: compilerParams.gccWarningCount
        };

        var editorParams = params.editorParams;
        var openManPageCallback = this.openManPage.bind(this);
        editorParams.openManPage = openManPageCallback;

        this.initLayout();
        $('body').css('overflow', 'hidden');

        // Prevent accidental backward navigation.
        // The event name is namespaced so that its handler can be safely removed
        // when this component is disposed, as we want backspace to work properly
        // when the user is not in the playground.
        $(window).on('keydown.playground', (e) => {
            var keyCode = {
                backspace: 8
            };

            // allow backspace for inputs
            var focused = $(':focus');
            if (focused.is('input') || focused.is('textarea')) {
                return true;
            }

            if (e.keyCode === keyCode.backspace) {
                e.preventDefault();
            }
        });

        this.createVideoSearchTab();
        this.createEditorTab(editorParams, compilerParams);
        this.createFileBrowserTab();
        this.createManPageSearchTab(openManPageCallback);

    }
Example #4
0
define(function (require) {

    var ko = require('knockout');
    var app = require('durandal/app');
    var ajax = require('pdtracker/ajax');
    var auth = require('pdtracker/auth');
    var globals = require('pdtracker/globals');

    return {
        user: globals.user,
        years: ko.observableArray([]),
        fiscalYear: ko.observable(),

        activate: function () {
            var self = this;
            //return ajax.get('fiscalYears').done(function (years) {
            //    self.years(years);
            //    globals.fiscalYear = self.years.length > 0 ? self.years[0] : undefined;
            //    self.fiscalYear(globals.fiscalYear);
            //    self.fiscalYear.subscribe(function (value) {
            //        globals.fiscalYear = value;
            //        app.trigger('fiscalYear:change', value);
            //    });
            //    return true;
            //});
            globals.fiscalYear = '14';
            return true;
        },

        attached: function () {
            $('#myaccount').click(function () {
                $('#myaccount-dropdown').slideToggle();
                return false;
            });
            $(document).click(function () {
                $('#myaccount-dropdown').slideUp();
            });
            $("#toggle").on("click", function () {
                $("#sidebar").toggleClass("active");
                $("#wrapper").toggleClass("active");
            });
        },

        doSignOut: function () {
            auth.signOut();
        }
    };
});
Example #5
0
	function CohortExpression(data) {
		var self = this;
		var data = data || {};

		
		self.PrimaryCriteria = ko.observable(new PrimaryCriteria(data.PrimaryCriteria));
		self.AdditionalCriteria = ko.observable(data.AdditionalCriteria && new CriteriaGroup(data.AdditionalCriteria));
		self.ConceptSets = ko.observableArray(data.ConceptSets && data.ConceptSets.map(function(d) { return new ConceptSet(d) }));
		self.ExpressionLimit =  { Type: ko.observable(data.ExpressionLimit && data.ExpressionLimit.Type || "All") }
		
		self.ConceptSets.sorted = ko.pureComputed(function() {
			return self.ConceptSets().map(function (item) { return item; }).sort(conceptSetSorter);
		});
	
		
	}
    constructor: function (urls) {
        this.apiListUrl = urls.apiListUrl;
        this.webCreateUrl = urls.webCreateUrl;
        // Set up data storage
        this.tokenData = ko.observableArray();
        this.sortedByName = ko.pureComputed(function () {
            return this.tokenData().sort(function (a,b) {
                var an = a.name().toLowerCase();
                var bn = b.name().toLowerCase();
                return an === bn ? 0 : (an < bn ? -1 : 1);
            });
        }.bind(this));

        // Set up data access client
        this.client = new TokenDataClient(this.apiListUrl);
    },
Example #7
0
    constructor: function(logs, url) {
        this.super.constructor.call(this);
        var self = this;
        self.loading = ko.observable(false);
        self.logs = ko.observableArray(logs);
        self.url = url;

        self.tzname = ko.pureComputed(function() {
            var logs = self.logs();
            if (logs.length) {
                var tz =  moment(logs[0].date.date).format('ZZ');
                return tz;
            }
            return '';
        });
    },
Example #8
0
		viewModel = function() {
			var self = this;
			self.activate = function () {					
				purchase.getAll({limit:5})
					.done(function(response){
						if (response.success) {
							self.purchases(response.purchases);
						}else{
							app.showMessage(response.message);
						}
					});
				shell.navGlobal(true); 
			};
			self.purchases = ko.observableArray();
			self.router = require('plugins/router');
		};
Example #9
0
 self.availableActions = function(scope) {
   let actions = ['SELECT', 'INSERT', 'ALL'];
   const databaseActions = ['CREATE'];
   const tableActions = ['REFRESH', 'ALTER', 'DROP'];
   switch (scope) {
     case 'SERVER':
       actions = actions.concat(databaseActions).concat(tableActions);
       break;
     case 'DATABASE':
       actions = actions.concat(databaseActions);
       break;
     case 'TABLE':
       actions = actions.concat(tableActions);
       break;
   }
   return ko.observableArray(actions.sort());
 };
/**
 * @constructor
 */
function CLoginView()
{
	CAbstractScreenView.call(this, '%ModuleName%');
	
	this.sCustomLogoUrl = Settings.CustomLogoUrl;
	this.sInfoText = Settings.InfoText;
	this.sBottomInfoHtmlText = Settings.BottomInfoHtmlText;
	
	this.login = ko.observable('');
	this.password = ko.observable('');
	
	this.loginFocus = ko.observable(false);
	this.passwordFocus = ko.observable(false);

	this.loading = ko.observable(false);

	this.bUseSignMe = (Settings.LoginSignMeType === Enums.LoginSignMeType.Unuse);
	this.signMe = ko.observable(Enums.LoginSignMeType.DefaultOn === Settings.LoginSignMeType);
	this.signMeFocused = ko.observable(false);

	this.canBeLogin = ko.computed(function () {
		return !this.loading();
	}, this);

	this.signInButtonText = ko.computed(function () {
		return this.loading() ? TextUtils.i18n('COREWEBCLIENT/ACTION_SIGN_IN_IN_PROGRESS') : TextUtils.i18n('COREWEBCLIENT/ACTION_SIGN_IN');
	}, this);

	this.loginCommand = Utils.createCommand(this, this.signIn, this.canBeLogin);

	this.login(Settings.DemoLogin || '');
	this.password(Settings.DemoPassword || '');
	
	this.shake = ko.observable(false).extend({'autoResetToFalse': 800});
	
	this.bRtl = UserSettings.IsRTL;
	this.aLanguages = UserSettings.LanguageList;
	this.currentLanguage = ko.observable(UserSettings.Language);
	this.bAllowChangeLanguage = Settings.AllowChangeLanguage && !App.isMobile();
	this.bUseDropdownLanguagesView = Settings.UseDropdownLanguagesView;

	this.beforeButtonsControllers = ko.observableArray([]);
	App.broadcastEvent('AnonymousUserForm::PopulateBeforeButtonsControllers', { ModuleName: '%ModuleName%', RegisterBeforeButtonsController: this.registerBeforeButtonsController.bind(this) });

	App.broadcastEvent('%ModuleName%::ConstructView::after', {'Name': this.ViewConstructorName, 'View': this});
}
Example #11
0
function createMockFront (frontId, description) {
    var deferreds = {},
        allCollections = {},
        front = {
            front: ko.observable(frontId),
            collections: ko.observableArray(),
            sparklinesOptions: ko.observable({}),
            _collections: {}
        }
    ;

    if (description) {
        var collectionsInFront = applyDescription(front, deferreds, description);
        collectionsInFront.forEach(function (collection) {
            allCollections[collection._key] = collection;
        });
        front.collections(collectionsInFront);
    }

    front._resolveCollection = function (id) {
        var collection = allCollections[id];
        collection.eachArticle(function (article) {
            article.props.webUrl(article._description.article);
        });
        deferreds[id].deferred.resolve();
        mediator.emit('collection:populate', deferreds[id].collection);
    };

    front._load = function (frontId, description) {
        front.front(frontId);
        var collectionsInFront = applyDescription(front, deferreds, description);
        collectionsInFront.forEach(function (collection) {
            allCollections[collection._key] = collection;
        });
        front.collections(collectionsInFront);
    };

    front._addArticle = function (id, article) {
        var collection = allCollections[id];
        appendArticles(collection._items, [article], front, true);
        deferreds[id].deferred = new $.Deferred();
        mediator.emit('collection:populate', collection);
    };

    return front;
}
export default function globalNavigation(node) {
    const routes = ko.observableArray(node.routes),
        navLinks = navigation.navLinks,
        activeLink = navigation.activeLink;

    function walkGetTypes(nodes) {
        return (nodes || [])
            .reduce((types, childNode) => types.concat([childNode.type])
            .concat(walkGetTypes(childNode.children)), []);
    }

    routes().forEach((route) => {
        navigation.addNav(route, (routeInfo) => {
            const name = route.get.replace('{path}', routeInfo.path ? `_${routeInfo.path.replace('/', '_')}` : '');
            dataservice.ajax({ uri: name }, (err, metadata) => {
                if (err) {
                    return;
                }
                const types = _.uniq(walkGetTypes(Array.isArray(metadata) ? metadata : [metadata]))
                    .filter(type =>
                        type && getRegisteredTypes().indexOf(type) === -1
                    );

                // console.log('Missing types:', types);

                layout.content(metadata);
            });
        });
    });

    navigation.init(node.initial || 0);

    routes.subscribe((oldRoutes) => {
        oldRoutes.forEach((routeOptions) => {
            navigation.removeNav(routeOptions.text);
        });
    }, null, 'beforeChange');

    return merge(node, {
        navLinks,
        activeLink,
        dispose: function () {
            routes([]);
        }
    });
}
Example #13
0
define(function (require) {
    var app = require('durandal/app'),
        ko = require('knockout');
    var info = {
        currentContactDetails:ko.observableArray()
    };
    info.addDetails = ko.computed(function(){
        var
            details = viewModel.currentContactDetails()
        ;
        if(info.currentContactDetails().length > 0){
            info.currentContactDetails([]);
        }
        info.currentContactDetails.push(viewModel.currentContactDetails());
    });
    return info;
});
Example #14
0
exports.getOptions = function (field) {
    var options = ko.observableArray([]);

    if (field.type == 'combo-box') {
        base.findAll(field.name, options, {}, function (option) {
            option.optionText = external.getOptionText(field, option);
        });
    }

    options.subscribe(function () {
        setTimeout(function () {
            external.selectCurrentOption(field);
        }, 0);
    });

    return options;
};
Example #15
0
    var Cart = function(){
        var self = this ; // ce hack sent le dev python a plein nez

        self.items = ko.observableArray([]);

        self.add = function(voice){
            console.log("Cart.add+");
            console.log(voice);
            self.items.push(voice);
            console.log("Cart.add-");
        };

        self.remove = function(voice){
            console.log("Cart.remove+");
            self.items.remove(voice);
            console.log("Cart.remove-");
        };

        self.reset = function(){
            console.log("Cart.reset+");
            self.items.removeAll() ;
            console.log("Cart.reset-");
        };

        self.save = function(){
            console.log("Cart.save+");
            console.log(self.items());
            // retrieve all items
            var data = $.map(self.items(), function(item){
                return {
                    name: item.name(),
                    feature: item.feature()
                }
            });

            http.post('/cart/buy/', data).then(function(response){
                    console.log(response);
                    console.log("Cart.save-");
            }).fail(function(r,e){
                console.log("save cart failed+");
                console.log(e);
                console.log("save cart failed-");
            });
        }
    };
Example #16
0
function CommandGroup() {

  this.commands = ko.observableArray();

  this.position = ko.observable(0);  
  this.attachmentOffset = ko.observable(0);
  this.height = ko.observable(0);

  this.target = ko.observable(null);   

  this.commands.subscribe( function(changes) {
    changes.forEach( function(change) {
      //change.index, change.status, change.value
      // So we don't have to pass owner when constructing objects
      if (change.status === 'added') change.value._owner = this;
    }, this);
  }, this, 'arrayChange');  
}
Example #17
0
function LinkViewModel(data, $root) {

    var self = this;

    self.$root = $root;
    $.extend(self, data);

    self.name = ko.observable(data.name);
    self.readonly = 'readonly';
    self.selectText = 'this.setSelectionRange(0, this.value.length);';

    self.dateCreated = new $osf.FormattableDate(data.date_created);
    self.linkUrl = ko.computed(function() {
        return self.$root.nodeUrl() + '?view_only=' + data.key;
    });
    self.nodesList = ko.observableArray(data.nodes);

    self.anonymousDisplay = ko.computed(function() {
        var openTag = '<span>';
        var closeTag = '</span>';
        var text;
        if (data.anonymous) {
            text = 'Yes';
            // Strikethrough if node is public
            if ($root.nodeIsPublic) {
                openTag = '<del>';
                closeTag = '</del>';
            }
        } else{
            text = 'No';
        }
        return [openTag, text, closeTag].join('');
    });

    self.toggle = function(data, event) {
        event.target.select();
    };

    self.toggleExpand = function() {
        self.expanded(!self.expanded());
    };

    self.expanded = ko.observable(false);
}
Example #18
0
var CommitDiff = function(args) {
  this.totalLineDiffs = ko.observable();
  this.commitLineDiffs = ko.observableArray();
  this.showLoadMore = ko.observable();
  this.server = args.server;
  this.sha1 = args.sha1;
  this.repoPath = args.repoPath;
  this.maxNumberOfFilesShown = 50;

  var totalLineDiffs = args.fileLineDiffs.shift();
  if (!totalLineDiffs) {
    this.totalLineDiffs([0, 0, 'total']);
  } else {
    this.totalLineDiffs(totalLineDiffs);
  }

  this.checkShowLoadMore(args.fileLineDiffs.length);
  this.loadFileLineDiffs(args);
};
Example #19
0
function InitViewModel() {
    this.boxScore = {
        gid: ko.observable(-1),
        prevGid: ko.observable(null),
        nextGid: ko.observable(null)
    };
    this.gamesList = {
        abbrev: ko.observable(),
        loading: ko.observable(true), // Needed because this isn't really set until updateGamesList, which could be after first render
        season: ko.observable(),
        games: ko.observableArray([])
    };

    // This computed is used so the box score won't be rendered until after it is fully loaded (due to the throttle). Otherwise, the mapping plugin sometimes sets the gid before the rest of the box score.
    // But because it's throttled, ui.tableClickableRows can't be called directly in uiFirst or uiEvery.
    this.showBoxScore = ko.computed(function () {
        return this.boxScore.gid() >= 0;
    }, this).extend({throttle: 1});
}
function createShoutbox(analytics) {
	var db = firebase.database().ref();

	var shoutbox = {
		items: ko.observableArray([]),
		message: ko.observable(''),
		name: ko.observable(shoutboxName)
			    .extend({rateLimit: {method: "notifyWhenChangesStop", timeout: 300}}),
		onKeyPress: function(data, event) {
			if (event.which !== 13) return true;
			if (shoutbox.message().trim().length === 0 || 
				shoutbox.name().trim().length === 0) return true;

			db.child("shoutbox").push({
				msg: shoutbox.message(),
				name: shoutbox.name(),
				time: firebase.database.ServerValue.TIMESTAMP,
				sessionId: analytics.key
			});

			shoutbox.message('');
		}
	};

	// scroll shoutbox to bottom when items are updated:
	shoutbox.items.subscribe(function() {
		var container = $('.shoutbox-items-container')[0];
		if (!container) return;

		var isScrolledToBottom = container.scrollHeight - container.clientHeight <= container.scrollTop + 1;
		setTimeout(function() {
			if (isScrolledToBottom) 
	    		container.scrollTop = container.scrollHeight - container.clientHeight;
		}, 0);
	});

	shoutbox.name.subscribe(function(name) {		
		localStorage["streamzShoutboxName"] = shoutboxName = name;
	});

	return shoutbox;
}
Example #21
0
module.exports = exports = new (function () {
	var self = this;
	self.link = ko.observable('');
	self.results = ko.observableArray();
	self.add = function () {
		var query = self.link();
		if (query == '') {
			self.results([]);
			return;
		}
		self.link('');
		var id = youtube.parseUrl(query);
		if (id === null) {
			self.lastQuery(query);
			youtube.search(query, _searchResult);
		} else {
			sync.add(id);
		}
	};
	self.lastQuery = ko.observable();
	self.prevToken = ko.observable();
	self.nextToken = ko.observable();
	self.prevDisabled = ko.computed(function () { return self.prevToken() == null; });
	self.nextDisabled = ko.computed(function () { return self.nextToken() == null; });
	self.prev = function () {
		if (self.prevToken()) {
			youtube.searchPage(self.lastQuery(), self.prevToken(), _searchResult);
		}
	};
	self.next = function () {
		if (self.nextToken()) {
			youtube.searchPage(self.lastQuery(), self.nextToken(), _searchResult);
		}
	};

	function _searchResult (err, results) {
		if (err) { alert(JSON.stringify(err)); return; }
		self.prevToken(results.prevToken);
		self.nextToken(results.nextToken);
		self.results(results.items.map(function (result) { return new SearchResultViewModel(result); }));
	}
})();
Example #22
0
var BaseComment = function() {

    var self = this;

    self.abuseOptions = Object.keys(ABUSE_CATEGORIES);

    self._loaded = false;
    self.id = ko.observable();

    self.errorMessage = ko.observable();
    self.editErrorMessage = ko.observable();
    self.replyErrorMessage = ko.observable();

    self.replying = ko.observable(false);
    self.replyContent = ko.observable('');

    self.submittingReply = ko.observable(false);

    self.comments = ko.observableArray();
    self.unreadComments = ko.observable(0);

    self.displayCount = ko.computed(function() {
        if (self.unreadComments() !== 0) {
            return self.unreadComments().toString();
        } else {
            return ' ';
        }
    });

    /* Removes number of unread comments from tab when comments pane is opened  */
    self.removeCount = function() {
        self.unreadComments(0);
    };

    self.replyNotEmpty = ko.computed(function() {
        return notEmpty(self.replyContent());
    });
    self.saveButtonText = ko.computed(function() {
        return self.submittingReply() ? 'Saving' : 'Save';
    });

};
Example #23
0
var BaseSearchViewModel = function (params) {
    // Parse params
    this.dataUrl = params.data;
    this.inputElement = params.inputElement;

    // Observables
    this.items = ko.observableArray();
    this.itemSelected = ko.observable(null);
    this.hasItemSelected = ko.pureComputed(function() {
        return this.itemSelected() !== null;
    }.bind(this));
    this.submitText = ko.observable(params.submitText || 'Submit');
    this.placeholder = params.placeholder || '';

    // Get the data and initialize the component
    this.fetchData().done(
        this.processData.bind(this),
        this.initTypeahead.bind(this)
    );
};
Example #24
0
var CommentListModel = function(userName, canComment, hasChildren) {

    BaseComment.prototype.constructor.call(this);

    var self = this;

    self.$root = self;
    self.MAXLENGTH = MAXLENGTH;

    self.editors = 0;
    self.commented = ko.observable(false);
    self.userName = ko.observable(userName);
    self.canComment = ko.observable(canComment);
    self.hasChildren = ko.observable(hasChildren);
    self.discussion = ko.observableArray();

    self.fetch();
    self.fetchDiscussion();

};
Example #25
0
var mapJStoKO = function(data, options) {
    var settings = $.extend({
        exclude: []   //List of object parameters to exclude
    }, options || {});
    var dataOut = {};

    for (var key in data) {
        // checks for key, if in the exclude list
        if (data.hasOwnProperty(key) && $.inArray(key, settings.exclude) === -1) {
            if(Array.isArray(data[key])) {
                dataOut[key] = ko.observableArray(data[key]);
            } else {
                dataOut[key] = ko.observable(data[key]);
            }
        } else if (data.hasOwnProperty(key)) {
            dataOut[key] = data[key]; //excluded parameters
        }
    }
    return dataOut;
};
Example #26
0
    constructor ({project}) {
        this.project = project;
        this.stages = project.stages;

        // 全作業時間の合計
        this.totalTime = ko.pureComputed(() => {
            const times = this.project.tasks().map(x => x.allWorkTime());
            return _.sum(times);
        });

        this.totalTimeFormat = ko.pureComputed(() => util.dateFormatHM(this.totalTime()));

        // ラベルごとの全作業時間の合計
        this.totalTimeLabels = ko.pureComputed(() => {
            const noneKey = '(none)';
            const res = {};
            res[noneKey] = 0;

            this.project.labels().forEach(label => { res[label.name()] = 0; });

            this.project.tasks().forEach(task => {
                const labels = task.labels();
                const time = task.allWorkTime();
                if (labels.length) {
                    labels.forEach(label => { res[label.name()] += time; });
                } else {
                    res[noneKey] += time;
                }
            });

            return _.map(res, (time, name) => {
                return {name, time, format: util.dateFormatHM(time)};
            });
        }, this);

        // 過去1週間ごと人ごとの作業時間
        // lastTwoWeekWorkTime()[iteration]
        // iteration = {day, dayFormat, users}
        // users[username] = {minutes, format}
        this.lastTwoWeekWorkTime = ko.observableArray([]);
    }
Example #27
0
var BaseComment = function() {

    var self = this;
    self.abuseOptions = Object.keys(ABUSE_CATEGORIES);

    self._loaded = false;
    self.id = ko.observable();
    self.page = ko.observable('node'); // Default

    self.errorMessage = ko.observable();
    self.editErrorMessage = ko.observable();
    self.replyErrorMessage = ko.observable();

    self.replying = ko.observable(false);
    self.replyContent = ko.observable('');

    self.urlForNext = ko.observable();

    self.saveContent = ko.pureComputed(function() {
        return convertMentionHtmlToMarkdown(self.replyContent());
    });

    self.submittingReply = ko.observable(false);

    self.comments = ko.observableArray();

    self.loadingComments = ko.observable(true);

    self.underMaxLength = ko.observable(true);

    self.replyNotEmpty = ko.pureComputed(function() {
        return notEmpty(self.replyContent());
    });
    self.commentButtonText = ko.computed(function() {
        return self.submittingReply() ? 'Commenting' : 'Comment';
    });
    self.validateReply = ko.pureComputed(function() {
        return self.replyNotEmpty() && self.underMaxLength();
    });

};
Example #28
0
var LinksViewModel = function($elm) {

    var self = this;
    self.links = ko.observableArray([]);

    $elm.on('shown.bs.modal', function() {
        if (self.links().length === 0) {
            $.ajax({
                type: 'GET',
                url: nodeApiUrl + 'pointer/',
                dataType: 'json'
            }).done(function(response) {
                self.links(response.pointed);
            }).fail(function() {
                $elm.modal('hide');
                osfHelpers.growl('Error:', 'Could not get links');
            });
        }
    });

};
Example #29
0
  constructor(data) {
    this.id = null
    this.description = ko.observable()

    this.status = ko.observable()
    this.target = ko.observable()
    this.targetChoice = ko.observable()
    this.condition = ko.observable('ALL')
    this.groups = ko.observableArray([])

    this.condition.subscribe((newValue) => {
      if (newValue != 'ALL' && newValue != 'ANY'){
        this.condition('ALL')
      }
    })

    this.groupsLength = ko.pureComputed(() => this.groups().length)
    this.hasMultipleGroups = ko.pureComputed(() => this.groupsLength() > 1)

    this.update(data)
  }
Example #30
0
define(function (require) {
  var http = require('plugins/http'),
      ko = require('knockout'),
      moment = require('moment');
 
  var url = '/allmi';
 
  return {
    incidents: ko.observableArray(),
    activate: function () {
      var that = this;
      if (this.incidents().length > 0) {
        return;
      }
 
      return http.get(url).then(function(response) {
        that.incidents(response);
      });
     }
   };
});