Projekt

Obecné

Profil

« Předchozí | Další » 

Revize e0a53a48

Přidáno uživatelem Martin Matas před téměř 6 roky(ů)

Laoding data from IMiGEr REST API, timeline design adjustment (refs #7464)

Zobrazit rozdíly:

sources/imiger-core/src/main/webapp/timeline/css/styles.css
450 450
  position: fixed;
451 451
  top: 0;
452 452
  left: 0;
453
  right: 400px;
453
  right: 0;
454 454
  overflow-x: hidden;
455 455
  overflow-y: hidden;
456 456
  bottom: 0;
sources/imiger-core/src/main/webapp/timeline/data/BandsDistribution.js
1 1
define([ 
2
    'cz/kajda/timeline/render/BandItemRenderer', 
3
    'cz/kajda/timeline/render/SplitBandItemRenderer',
4
    'cz/kajda/timeline/render/DumbbellItemRenderer'
2
    'cz/kajda/timeline/render/BandItemRenderer',
5 3
],
6 4

  
7
function(BandItemRenderer, SplitBandItemRenderer, DumbbellItemRenderer){
5
function(BandItemRenderer){
8 6

  
9
    var BandsDistribution = new Class("BandsDistribution", {
7
    return new Class("BandsDistribution", {
10 8
    
11
    _constructor : function() {
12
    },
13
    bands : [
14
          {
15
               id: "place",
16
               label: "Místa",
17
               itemRenderer: new BandItemRenderer("#7DD968"),
18
               color: "#f5f5f5"
19
          },
20
           {
21
               id: "person",
22
               label: "Lidé",
23
               itemRenderer: new BandItemRenderer("#FFB182"),
24
               color: "#fafafa"
25
           },
26
        //    {
27
        //        id: "event",
28
        //        label: "Události",
29
        //        itemRenderer: new BandItemRenderer("#F2BC53"),
30
        //        color: "#f5f5f5"
31
        //    },
32
        //    {
33
        //        id: "item",
34
        //        label: "Objekty",
35
        //        itemRenderer: new BandItemRenderer("#78B4FF"),
36
        //        color: "#fafafa"
37
        //    },
38
           /* FIALA */
9
        _constructor : function() {},
10
        bands : [
11
            {
12
                id: "person",
13
                label: "Lidé",
14
                itemRenderer: new BandItemRenderer("#FFB182"),
15
                color: "#fafafa"
16
            },
17
            {
18
                id: "item",
19
                label: "Objekty",
20
                itemRenderer: new BandItemRenderer("#78B4FF"),
21
                color: "#fafafa"
22
            }
23
        ]
39 24

  
40
           /* Funcki verze */
41
           // {
42
           //     id: "split-event",
43
           //     label: "Rozdeleni",
44
           //     types: [
45
           //         {"split-event":"SplitBandItemRenderer"}
46
           //     ],
47
           //     itemRenderer: new SplitBandItemRenderer("#03f945"),
48
           //     color: "#fafafa"
49
           // },
50
           // {
51
           //     id: "dumbbell-entity",
52
           //     label: "Cinka",
53
           //     itemRenderer: new DumbbellItemRenderer("#03f945"),
54
           //     color: "#fafafa"
55

  
56
           // }
57
           /** Testovaci verze */
58
        //    {
59
        //        id: "Rozdeleni",
60
        //        label: "Rozdeleni",
61
        //        types: [
62
        //             {
63
        //                 id: "split-event", 
64
        //                 itemRenderer: new SplitBandItemRenderer("#03f945")
65
        //             },
66
        //             {
67
        //                 id: "dumbbell-entity", 
68
        //                 itemRenderer: new DumbbellItemRenderer("#03f945")
69
        //             }
70
        //                ],
71
        //        // itemRenderer: new SplitBandItemRenderer("#03f945"),
72
        //        // color: "#fafafa"
73
        //    },
74
        /** SJEDNOCENI VSECH */
75
           {
76
               id: "Sjednoceny pruh",
77
               label: "Sjednoceni",
78
               types: [
79
                   {
80
                         id: "event",
81
                         itemRenderer: new BandItemRenderer("#F2BC53"),
82
                         color: "#f5f5f5"
83
                    },
84
                    {
85
                         id: "item",
86
                         itemRenderer: new BandItemRenderer("#78B4FF"),
87
                         color: "#fafafa"
88
                    },
89
                    {
90
                         id: "split-event", 
91
                         itemRenderer: new SplitBandItemRenderer("#03f945")
92
                    },
93
                    {
94
                         id: "dumbbell-entity", 
95
                         itemRenderer: new DumbbellItemRenderer("#03f945")
96
                    }
97
               ]
98
           }
99

  
100
           
101
       ],    
102 25
    });
103
    return BandsDistribution;
26

  
104 27
});
sources/imiger-core/src/main/webapp/timeline/data/questions.js
1
/**
2
 * @author Michal Fiala
3
 * @version 1.0
4
 */
5
define([],function(){
6
    return{
7
        questions : [
8
            {
9
                "text" : "Kdo byl prvni kral?",
10
                "answer" : "Karel"
11
            },
12
            {
13
                "text" : "Kdo je Karel?",
14
                "answer" : "Karel"
15
            },
16
            // {
17
            //     "text" : "Kdo byl prvni Přemyslovec?",
18
            //     "answer" : "Bořivoj I."
19
            // },
20
            // {
21
            //     "text" : "Kdo byl první z dynastie Mojmírovců?",
22
            //     "answer" : "Mojmír I."
23
            // },
24
        ]
25
    }
26
});
sources/imiger-core/src/main/webapp/timeline/index.html
26 26
                <div class="timeline-pane">
27 27
                    <div id="timeline" tabindex="0"></div>
28 28
                </div>
29
          
30
                <div role="tabpanel" class="sidebar" id="sidebar">
31
                    <ul class="nav nav-pills tab-list" role="tablist">
32
                        <li role="presentation" class="active"><a role="tab" data-toggle="tab" href="#home">Záznamy</a></li>
33
                        <li role="presentation"><a role="tab" data-toggle="tab" href="#widgeting">Rozhraní widgetu</a></li>
34
                        <li role="presentation"><a role="tab" data-toggle="tab" href="#testing">Test widgetu</a></li>
35
                    </ul>
36
                    <div class="tab-content">
37
                        <div role="tabpanel" class="tab-pane active" id="home">
38
                            <div id="item_detail_pane" class="hidden">
39
                                <div id="item_image">
40
                                    <div class="helper"><img alt="náhled"></div>
41
                                </div>
42
                                <div class="padded">
43
                                    <h1 id="item_title"></h1>
44
                                    <p class="small" id="item_timerange"></p>
45
                                    <p class="small" id="item_description"></p>
46
                                    <h4>Související</h4>
47
                                </div>
48
                                <table id="item_relations" class="table table-condensed small table-striped">
49
                                </table>
50
                            </div>
51
                            <div id="item_search">
52
                                <div class="row">
53
                                <div class="text-center col-xs-8 col-xs-offset-2">
54
                                    <p>Zadejte část názvu hledaného záznamu</p>
55
                                    <input type="search" id="item_search_term" class="form-control input-sm">
56
                                    <div class="text-center text-muted padded-top">nebo</div>
57
                                    <p class="padded-top text-center">klepněte na některý ze záznamů v ose a zobrazte jeho detail.</p>
58
                                </div>
59
                                </div>
60
                                <div class="padded-top">
61
                                    <table id="item_search_result" class="table table-condensed small table-striped">
62
                                        <tr>
63
                                            <td><em>Žádné nálezy...</em></td>
64
                                        </tr>
65
                                    </table>
66
                                </div>
67
                            </div>
68
                        </div>
69
                        <div role="tabpanel" class="tab-pane" id="widgeting">
70
                            <div class="padded">
71
                                <h1>Rozhraní widgetu</h1>
72
                            </div>
73
                            <table class="table small table-condensed table-striped">
74
                                <tr>
75
                                    <td><strong>středový čas</strong></td>
76
                                    <td class="text-right" id="center_time_td">?</td>
77
                                </tr>
78
                                <tr>
79
                                    <td><strong>rozsah průhledu</strong></td>
80
                                    <td class="text-right" id="viewport_range_td">?<div>?</div></td>
81
                                </tr>
82
                                <tr>
83
                                    <td><strong>úroveň přiblížení</strong></td>
84
                                    <td class="text-right" id="zoom_level_td">?<div>?</div></td>
85
                                </tr>
86
                                <tr>
87
                                    <td><strong>vybraný záznam</strong></td>
88
                                    <td class="text-right"><div style="white-space: nowrap; text-overflow: ellipsis; overflow: hidden" id="focused_entity_td"><em>žádný</em></div></td>
89
                                </tr>
90
                            </table>
91
                            <div class="padded">
92
                                <div>
93
                                    <div class="btn-group btn-group-justified">
94
                                        <a class="btn btn-default" id="zoomin_btn">Přiblížit</a>
95
                                        <a class="btn btn-default" id="zoomout_btn">Oddálit</a>
96
                                    </div>
97
                                    <div class="btn-group btn-group-justified">
98
                                        <a class="btn btn-default" id="slideLeft_btn">Posun vzad</a>
99
                                        <a class="btn btn-default" id="slideRight_btn">Posun vpřed</a>
100
                                    </div>
101
                                    <div class="btn-group btn-group-justified">
102
                                        <a class="btn btn-default" id="jump_ad_btn">Přejít na počátek letopočtu</a>
103
                                    </div>
104
                                    <div class="form-group">
105
                                        <div class="checkbox">
106
                                            <label for="bandLabels_chb">
107
                                                <input type="checkbox" checked id="bandLabels_chb">Zobrazit popisky pásů
108
                                            </label>
109
                                        </div>
110
                                        <div class="checkbox">
111
                                            <label for="zoombar_chb">
112
                                                <input type="checkbox" checked id="zoombar_chb">Zobrazit zoom panel
113
                                            </label>
114
                                        </div>
115
                                        <div class="checkbox">
116
                                            <label for="timepointer_chb">
117
                                                <input type="checkbox" checked id="timepointer_chb">Zobrazit ukazatel středového času
118
                                            </label>
119
                                        </div>
120
                                        <div class="checkbox">
121
                                            <label for="popover_chb">
122
                                                <input type="checkbox" checked id="popover_chb">Zobrazovat náhledy záznamů a vztahů
123
                                            </label>
124
                                        </div>
125
                                        <div class="checkbox">
126
                                            <label for="guidelines_chb">
127
                                                <input type="checkbox" checked id="guidelines_chb">Zobrazovat vodící linky záznamů
128
                                            </label>
129
                                        </div>
130
                                        <div class="checkbox">
131
                                            <label for="relations_chb">
132
                                                <input type="checkbox" checked id="relations_chb">Zobrazovat vztahy mezi záznamy
133
                                            </label>
134
                                        </div>
135
                                    </div>
136
                                </div>
137
                            </div>
138
                        </div>
139
                        <div role="tabpanel" class="tab-pane" id="testing">
140
                            <!-- FIALA Test tool  -->
141
                            <div class="padded" id="testing_content">
142
                                <div style="display: none;"> 
143
                                    <h2 id="question_label">Otázka</h2>
144
                                    <h4 id="questions_done_label"> 1/10</h4>
145
                                    <div id="answer_fgroup_label" class="form-group">
146
                                        <label for="answer">Odpověď</label>
147
                                        <input type="text" class="form-control" id="answer_text">
148
                                    </div>
149
                                </div>
150
                                <div style="display: none;" class="btn-group btn-group-justified">
151
                                    <a class="btn btn-default" id="confirm_btn">Potvrdit</a>
152
                                </div>
153
                                <div class="btn-group btn-group-justified">
154
                                    <a class="btn btn-default" id="start_test_btn">Začít test</a>
155
                                </div>
156
                            </div>
157
                            <div class="padded" style="display: none; color: red;" id="wrong_anser_content">
158
                                <h2>Špatná odpověď</h2>
159
                            </div>
160
                            
161
                        </div>
162
                    </div>
163
                </div>
164 29
            </div>
165 30
        </div>
166 31
  </body>
sources/imiger-core/src/main/webapp/timeline/js/auxiliary/App.js
8 8
    'cz/kajda/common/Observable',
9 9
    'cz/kajda/data/Entity',
10 10
    'cz/kajda/data/Relation',
11
    'auxiliary/RandSource',
12
    'auxiliary/StaticSource',
11
    'auxiliary/RestSource',
13 12
    'momentjs',
14 13
    'auxiliary/QuestionTool',
15 14
],
16
function(DataWizard, Observable, Entity, Relation, RandSource, StaticSource, moment, QuestionTool) {
15
function(DataWizard, Observable, Entity, Relation, RestSource, moment, QuestionTool) {
17 16
    
18 17
/**
19 18
 * Demo application support for the widget.
......
48 47
     *  @author Michal Fiala
49 48
     */
50 49
    _questionTool : null,
51
    
52
    
53
    /**
54
     * Launch data wizard that invokes REST request to obtain data.
55
	 * @param {String} url REST service url
56
     */
57
    startDataWizard : function(url) {
58
        new DataWizard(url, new Closure(this, this._sourceReady));
59
    },
50

  
60 51
    
61 52
    /**
62 53
     * Creates data source using static JSON object 
63 54
     */
64 55
    createSource : function() {
65
        this._source = new StaticSource(Entity, Relation);
66
        this._source.addListener("dataLoaded", new Closure(this, this._sourceReady));
67
        this._source.loadData();
68
    },
69
    
70
    /**
71
     * Creates data source generating data randomly.
72
     * @param {Object} conf
73
     */
74
    createRandSource : function(conf) {
75
        this._source = new RandSource(conf, Entity, Relation);
76
        this._source.setTimeRange(moment.utc("-002000-01-01T00:00:00"), moment.utc("2000-12-31T23:59:00"));
56
        this._source = new RestSource(Entity, Relation, "http://localhost:8080/imiger/", null);
77 57
        this._source.addListener("dataLoaded", new Closure(this, this._sourceReady));
78 58
        this._source.loadData();
79 59
    },
sources/imiger-core/src/main/webapp/timeline/js/auxiliary/RestSource.js
68 68
        /** @see cz.kajda.data.AbstractDataSource#loadData */
69 69
        loadData : function(callback) {
70 70
            var mapClosure = new Closure(this, this._map);
71
            this._client.post("importances", {
72
                "query" : {
73
                    "from" : this._timeRange.start.utc().format(),
74
                    "to" : this._timeRange.end.format(),
75
                    "nodeImportance" : this._entityPriors,
76
                    "edgeImportance" : this._relationPriors,
77
                    "properties" : {}
78
                }
79
            }, new Closure(this, function(data) {
80
                this._map(data);
71
            this._client.get("api/load-graph-data", new Closure(this, function(data) {
72
                var json = JSON.parse(data.graph_json);
73
                var graph = this._convertGraph(json);
74
                this._map(graph);
81 75
                this._fireEvent("dataLoaded", this);
82 76
            }));
83 77
        },
84 78

  
79
        _convertGraph : function(data) {
80
            var archetypes = data.vertexArchetypes;
81
            var nodes = new Array(data.vertices.length), edges = new Array(data.edges.length);
82

  
83
            for(var i = 0; i < data.vertices.length; i++) {
84
                var v = data.vertices[i];
85
                var prop = {
86
                    startPrecision: "none",
87
                    endPrecision: "none"
88
                };
89
                var archetype = archetypes[v.archetype].name.toLowerCase();
90
                if (archetype !== 'person') {
91
                    archetype = 'item';
92
                }
93
                var node = {
94
                    id: v.id, 
95
                    name: v.name, 
96
                    description: v.text,
97
                    stereotype: archetype,
98
                    properties: prop,
99
                    begin: v.attributes[1][1],
100
                    end: typeof v.attributes[2] === 'undefined' ? null : v.attributes[2][1]
101
                }
102
                nodes[i] = node;
103
            }
104

  
105
            for(var i = 0; i < data.edges.length; i++) {
106
                var e = data.edges[i];
107
                var edge = {
108
                    id: e.id, 
109
                    name: e.text, 
110
                    from: e.from,
111
                    stereotype: "relationship",
112
                    to: e.to
113
                }
114
                edges[i] = edge;
115
            }
116

  
117
            return {
118
                nodes: nodes,
119
                edges: edges
120
            }
121
        },
122

  
85 123
        /** @see cz.kajda.data.AbstractDataSource#_map */
86 124
        _map : function(data) {
87 125
            var entities = new Collection(),
sources/imiger-core/src/main/webapp/timeline/js/auxiliary/StaticSource.js
1
/**
2
 * @author Bc. Michal Kacerovský
3
 * @version 1.0
4
 */
5

  
6
define([
7
    'cz/kajda/data/AbstractDataSource',
8
    'cz/kajda/data/Collection',
9
    '../../data/data',
10
    /** FIALA */
11
    'cz/kajda/data/SubEntity'
12
],
13
function(AbstractDataSource, Collection, __data, SubEntity) {
14
    
15

  
16
/**
17
 * Data source used for test purpose.
18
 * gets data from a JSON variable.
19
 */
20
var StaticSource = new Class("StaticSource", {
21
   
22
    _extends : AbstractDataSource,
23

  
24
    /**
25
     * @constructor
26
     * @param {Class} T_entity object that entities should be mapped to
27
     * @param {Class} T_relation object that relations should be mapped to
28
     */
29
    _constructor: function(T_entity, T_relation) {
30
        AbstractDataSource.call(this, T_entity, T_relation);
31
    },
32
    /**
33
     * @author Michal Fiala
34
     * All mapped entities
35
     */
36
    _allMappedEntities : null,
37

  
38
    //<editor-fold defaultstate="collapsed" desc="overridden">
39

  
40
        /** @see cz.kajda.data.AbstractDataSource#loadData */
41
        loadData : function() {
42
            this._map(__data);
43
            this._fireEvent("dataLoaded", this);
44
        },
45

  
46
        /** 
47
         * @see cz.kajda.data.AbstractDataSource#_map 
48
         * @author Bc. Michal Kacerovský
49
         * @author Michal Fiala
50
         */
51
        _map : function(data) {
52
            // All entities (Entity for BandItem)
53
            var entities = new Collection(),
54
                relations = new Collection();
55
            // All mapped entities (Entity and SubEntity)
56
            var allMappedEntities = new Collection();    
57
            // Map all entities 
58
            for(var i = 0; i < data.nodes.length; i++)
59
                this._createEntity(data.nodes[i], entities, allMappedEntities);
60

  
61
            // Map relations
62
            for(var i = 0; i < data.edges.length; i++) {
63
                var edge = data.edges[i],
64
                    edgeObj = new this._objectMapping.relation(edge); // mapped object
65
                // Find relation and add relation in all entities include SubEntity
66
                if(!allMappedEntities.get(edge.from).hasRelation(edgeObj.getId()))
67
                    allMappedEntities.get(edge.from).addRelation(edge.id);
68
                if(!allMappedEntities.get(edge.to).hasRelation(edgeObj.getId()))
69
                    allMappedEntities.get(edge.to).addRelation(edge.id);
70
                
71
                relations.add(edgeObj);
72
            }
73
            this._allMappedEntities = allMappedEntities;
74
            this._entities = entities;
75
            this._relations = relations;
76
        },
77
        /**
78
         * @author Michal Fiala
79
         * @author Bc. Michal Kacerovský
80
         * Create Entity and adds it in Collections       
81
         * Create SubEntities of Entity and adds it in Collection
82
         * @param {JSON} dataNode
83
         * @param {Collection} entities contain only Entity
84
         * @param {Collection} allMappedEntities contain Entity and SubEntity
85
         */
86
        _createEntity : function(dataNode, entities, allMappedEntities)
87
        {
88
            var entity = new this._objectMapping.entity(dataNode);
89
            
90
            entities.add(entity);
91
            allMappedEntities.add(entity);
92
            // Has SubEntities
93
            if(dataNode.subItems)
94
                for(var i =0; i < dataNode.subItems.length; i++)
95
                {
96
                    // Create SubEntity
97
                    var subEntity = new SubEntity(dataNode.subItems[i], entity);
98
                    // Add SubEntity in Entity
99
                    entity.addSubEntity(subEntity);
100
                    // Add in all mapped entities
101
                    allMappedEntities.add(subEntity);
102
                }
103
        },
104
        
105
        /**
106
         * @author Michal Fiala
107
         * Returns all mapped entities
108
         */
109
        getAllMappedEntities : function()
110
        {
111
            return this._allMappedEntities;
112
        },
113
    //</editor-fold>
114
    
115
});
116
    
117
return StaticSource;
118
});
119

  
sources/imiger-core/src/main/webapp/timeline/js/cz/kajda/timeline/Timeline.js
501 501

  
502 502
            _handleIMiGErClick : function(e) {
503 503
                var entity = this.getEntities().get(e.detail);
504
                    bandItem = this._bandGroup.getBand("Sjednoceny pruh").getBandItem(entity.getId());
504
                    bandItem = this._bandGroup.getBand("person").getBandItem(entity.getId());
505 505
                
506 506
                this.focusItem(bandItem.getEntity(), false);
507 507
                this._fireEvent("itemClick", entity);
sources/imiger-core/src/main/webapp/timeline/js/main.js
136 136
    
137 137
    // creates static data source using JSON
138 138
    app.createSource();
139
    var event = $.Event( "imigerClick" );
140
    event.detail = 34;
141
    $(document).trigger( event );
139
    /*var event = $.Event( "imigerClick" );
140
    event.detail = 66;
141
    $(document).trigger( event );*/
142 142
    // creates data source using REST server request
143 143
    //app.startDataWizard("http://localhost:8080/timeline-rest/");
144 144
    
sources/imiger-core/src/main/webapp/timeline/less/styles.less
104 104
    position: fixed;
105 105
    top: 0;
106 106
    left: 0;
107
    right: 400px;
107
    right: 0;
108 108
    overflow-x: hidden;
109 109
    overflow-y: hidden;
110 110
    bottom: 0;

Také k dispozici: Unified diff