Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
Flutter App for Memri
Commits
fc645b4f
Commit
fc645b4f
authored
2 years ago
by
Erfan Jazeb Nikoo
Browse files
Options
Download
Plain Diff
Merge branch 'refactor-app-show' into 'dev'
Refactor app show See merge request
!406
parents
2c08bcfa
38ba8e3e
Pipeline
#10264
passed with stages
in 6 minutes and 25 seconds
Changes
12
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
assets/schema.json
+12
-0
assets/schema.json
docs/app_data_stuctures.md
+10
-0
docs/app_data_stuctures.md
lib/configs/routes/route_handler.dart
+1
-1
lib/configs/routes/route_handler.dart
lib/core/models/item.dart
+8
-0
lib/core/models/item.dart
lib/core/services/graph_service.dart
+51
-10
lib/core/services/graph_service.dart
lib/providers/data_app_provider.dart
+78
-107
lib/providers/data_app_provider.dart
lib/screens/workspace/apps/apps_configure_screen.dart
+25
-39
lib/screens/workspace/apps/apps_configure_screen.dart
lib/screens/workspace/apps/apps_feed_screen.dart
+5
-1
lib/screens/workspace/apps/apps_feed_screen.dart
lib/screens/workspace/projects/projects_app_preview_screen.dart
+5
-6
...reens/workspace/projects/projects_app_preview_screen.dart
lib/widgets/data_app/data_app.dart
+15
-12
lib/widgets/data_app/data_app.dart
lib/widgets/data_app/data_app_settings.dart
+2
-4
lib/widgets/data_app/data_app_settings.dart
pubspec.yaml
+1
-1
pubspec.yaml
with
213 additions
and
181 deletions
+213
-181
assets/schema.json
+
12
-
0
View file @
fc645b4f
...
...
@@ -2117,6 +2117,18 @@
"targetType"
:
"CVUStoredDefinition"
,
"edgeName"
:
"view"
},
{
"type"
:
"ItemEdgeSchema"
,
"sourceType"
:
"Plugin"
,
"targetType"
:
"Project"
,
"edgeName"
:
"project"
},
{
"type"
:
"ItemEdgeSchema"
,
"sourceType"
:
"Plugin"
,
"targetType"
:
"PluginRun"
,
"edgeName"
:
"run"
},
{
"type"
:
"ItemEdgeSchema"
,
"sourceType"
:
"PluginRun"
,
...
...
This diff is collapsed.
Click to expand it.
docs/app_data_stuctures.md
+
10
-
0
View file @
fc645b4f
```
plantuml
Project --|> Dataset : dataset
Project --|> Plugin : plugin
Plugin --|> PluginRun : pluginRun
Dataset --|> LabellingTask : labellingTask
Dataset --|> DatasetEntry : entry
Dataset --|> ItemPropertySchema : feature
...
...
@@ -12,6 +14,14 @@ class DatasetEntry {
id: String
}
class Plugin {
id: String
}
class PluginRun {
id: String
}
class ItemPropertySchema {
propertyName: String
valueType: String
...
...
This diff is collapsed.
Click to expand it.
lib/configs/routes/route_handler.dart
+
1
-
1
View file @
fc645b4f
...
...
@@ -84,7 +84,7 @@ var appsScreenHandler = Handler(handlerFunc: (_, __) => AppsScreen());
var
appsConfigureScreenHandler
=
Handler
(
handlerFunc:
(
_
,
Map
<
String
,
List
<
String
>>
params
)
=
>
AppsConfigureScreen
(
tab:
params
[
'tab'
]
?.
first
??
''
,
i
d:
params
[
'id'
]
?.
first
??
''
));
tab:
params
[
'tab'
]
?.
first
??
''
,
pluginI
d:
params
[
'id'
]
?.
first
??
''
));
var
appsInboxScreenHandler
=
Handler
(
handlerFunc:
(
_
,
Map
<
String
,
List
<
String
>>
params
)
=
>
...
...
This diff is collapsed.
Click to expand it.
lib/core/models/item.dart
+
8
-
0
View file @
fc645b4f
...
...
@@ -54,6 +54,14 @@ class Item {
}
}
void
copyPropertiesFrom
(
Item
other
,
List
<
String
>
properties
)
{
other
.
properties
.
forEach
((
key
,
value
)
{
if
(
properties
.
contains
(
key
))
{
this
.
properties
[
key
]
=
value
;
}
});
}
Edge
addEdge
(
String
edgeName
,
Item
item
)
{
initEdge
(
edgeName
);
edges
[
edgeName
]
!.
targets
.
add
(
item
);
...
...
This diff is collapsed.
Click to expand it.
lib/core/services/graph_service.dart
+
51
-
10
View file @
fc645b4f
...
...
@@ -191,8 +191,8 @@ query {
return
result
;
}
Future
<
List
<
Item
>>
LoadItems
(
int
amount
,
String
type
,
List
<
String
>
properties
)
async
{
Future
<
List
<
Item
>>
Load
Project
Items
(
String
memriProjectId
,
int
amount
,
List
<
String
>
properties
)
async
{
String
sorter
=
''
;
if
(
properties
.
contains
(
'dateSent'
))
{
sorter
=
'order_desc: dateSent,'
;
...
...
@@ -201,18 +201,27 @@ query {
}
List
<
Item
>
res
=
await
getResultAsItemList
(
query:
'''
query {
$type
(
$sorter
, filter: {deleted: {eq: 0}}) {
${properties.join('\n')}
isMock
Project(filter: {id: {eq: "
$memriProjectId
"}}) {
dataset{
id
entry {
data(
$sorter
, filter: {deleted: {eq: 0}}) {
${properties.join('\n')}
isMock
}
}
}
}
}
'''
);
List
<
Item
>
entries
=
res
[
0
]
.
edgeItem
(
'dataset'
)
!.
getEdgeTargets
(
'entry'
)
!
;
List
<
Item
>
resItems
=
entries
.
map
((
e
)
=
>
e
.
edgeItem
(
'data'
)
!
)
.
toList
();
//ugly hack to make sure we can filter and limit
res
=
re
s
.
where
((
x
)
=
>
x
.
get
(
'isMock'
)
!=
true
)
.
toList
();
if
(
res
.
length
>
amount
)
{
res
=
re
s
.
sublist
(
0
,
amount
);
res
Items
=
resItem
s
.
where
((
x
)
=
>
x
.
get
(
'isMock'
)
!=
true
)
.
toList
();
if
(
res
Items
.
length
>
amount
)
{
res
Items
=
resItem
s
.
sublist
(
0
,
amount
);
}
return
res
;
return
res
Items
;
}
Future
<
List
<
Item
>>
loadAppContent
(
...
...
@@ -235,7 +244,11 @@ query {
}
List
<
Item
>
result
=
await
getResultAsItemList
(
query:
'''
query {
$dataType
(
$sorter
filter: {sourceProject: {eq: "
$pluginId
"}}) {
$dataType
(
$sorter
filter: {and: [
{sourceProject: {eq: "
$pluginId
"}},
{deleted: {eq: 0}}
]}
) {
${properties.join('\n')}
sourceProject
label {
...
...
@@ -365,4 +378,32 @@ query {
'''
);
return
result
.
firstOrNull
;
}
Future
<
Item
?
>
getProjectFromPlugin
({
required
id
})
async
{
List
<
Item
>
result
=
await
getResultAsItemList
(
query:
'''
query {
Plugin(filter: {id: {eq: "
$id
"}}) {
id
project {
id
dataSource
}
}
}
'''
);
return
result
.
firstOrNull
?.
edgeItem
(
'project'
);
}
Future
<
List
<
Item
>>
getPluginRunsForPlugin
(
String
pluginId
)
async
{
List
<
Item
>
result
=
await
getResultAsItemList
(
query:
'''
query {
Plugin(filter: {id: {eq: "
$pluginId
"}}, order_desc: dateCreated) {
run {
id
}
}
}
'''
);
return
result
.
firstOrNull
!.
getEdgeTargets
(
'run'
)
!
;
}
}
This diff is collapsed.
Click to expand it.
lib/providers/data_app_provider.dart
+
78
-
107
View file @
fc645b4f
...
...
@@ -85,6 +85,24 @@ class DataAppProvider with ChangeNotifier {
String
?
currentDataType
;
String
?
currentDataSource
;
Item
?
_currentMemriProject
;
Item
?
currentPlugin
;
Item
?
get
currentMemriProject
{
return
_currentMemriProject
;
}
set
currentMemriProject
(
Item
?
item
)
{
if
(
item
!=
null
)
{
_currentMemriProject
=
item
;
currentDataSource
=
_currentMemriProject
?.
get
(
'dataSource'
);
currentDataType
=
source2type
[
currentDataSource
]
!
;
}
}
String
?
get
currentMemriProjectId
{
return
_currentMemriProject
?.
get
(
'id'
);
}
String
getFeedPostDate
(
int
feedIndex
)
=
>
DateTimeHelper
()
.
getDateString
(
feed
[
feedIndex
]
.
get
(
'postDate'
));
...
...
@@ -109,8 +127,7 @@ class DataAppProvider with ChangeNotifier {
currentAppState
=
AppState
.
deploying
;
currentRunLog
=
null
;
currentGitProjectId
=
null
;
currentPluginItems
=
[];
runningPlugins
=
{};
currentDataAppItems
=
[];
//Inbox
chatStream
=
null
;
...
...
@@ -147,7 +164,7 @@ class DataAppProvider with ChangeNotifier {
AppListState
appListState
=
AppListState
.
fetching
;
String
?
currentRunLog
;
int
?
currentGitProjectId
;
List
<
Item
>
current
Plugin
Items
=
[];
List
<
Item
>
current
DataApp
Items
=
[];
setDataAppState
(
AppState
state
)
async
{
// first show the logs are loading
...
...
@@ -163,19 +180,19 @@ class DataAppProvider with ChangeNotifier {
notifyListeners
();
}
handlePublishApp
(
BuildContext
context
,
String
projectName
,
String
dataSource
)
{
handlePublishApp
(
BuildContext
context
,
Item
project
,
String
dataSource
)
{
// TODO delete previous app with name + gitProjectId
createPluginItem
(
project
Name
);
create
AndConnect
PluginItem
(
project
);
RouteNavigator
.
navigateTo
(
context:
context
,
route:
Routes
.
apps
);
}
handleRerunApp
(
Item
project
)
{
runIndexerPluginFromGit
(
project:
project
,
changeState:
false
);
}
//
handleRerunApp(Item project) {
//
runIndexerPluginFromGit(project: project, changeState: false);
//
}
createPluginItem
(
String
projectName
)
async
{
createAndConnectPluginItem
(
project
)
async
{
String
projectName
=
project
.
get
(
'name'
)
!
;
// Create data app from current gitlab id
var
metadata
=
await
getMetadata
(
currentGitProjectId
!
);
var
plugin
=
Item
(
type:
'Plugin'
);
...
...
@@ -194,17 +211,16 @@ class DataAppProvider with ChangeNotifier {
// plugin.properties['dataType'] = 'Text';
plugin
.
properties
[
'pluginType'
]
=
'dataApp'
;
plugin
.
properties
[
'dataType'
]
=
currentDataType
;
plugin
.
setIdIfNotExists
();
Edge
edge
=
Edge
(
name:
'project'
,
source
:
plugin
,
target:
project
)
;
await
_podService
.
createItem
(
item:
plugin
);
await
createMockItems
(
128
,
plugin
.
id
);
// await _podService.createItem(item: plugin);
await
_podService
.
bulkAction
(
createItems:
[
plugin
],
createEdges:
[
edge
]);
dataApps
.
add
(
plugin
);
AppLogger
.
debug
(
'Created plugin:
$projectName
'
);
}
setCurrentDataTypesFromProject
(
Item
project
)
{
currentDataSource
=
project
.
get
(
'dataSource'
);
currentDataType
=
source2type
[
currentDataSource
]
!
;
}
runIndexerPluginFromGit
(
{
required
Item
project
,
bool
changeState
=
true
})
async
{
currentPluginRun
=
null
;
...
...
@@ -213,9 +229,9 @@ class DataAppProvider with ChangeNotifier {
if
(
dataSource
==
null
)
{
debugPrint
(
'Could not run plugin, git project id not set'
);
}
else
{
current
Plugin
Items
=
await
createMockItems
(
10
,
dataSource
);
current
DataApp
Items
=
await
createMockItems
(
10
,
dataSource
);
debugPrint
(
'
${current
Plugin
Items.length}
mock items available'
);
debugPrint
(
'
${current
DataApp
Items.length}
mock items available'
);
var
pluginRun
=
await
createPluginRunFromGit
(
currentGitProjectId
!
,
currentDataType
!
);
...
...
@@ -260,16 +276,16 @@ class DataAppProvider with ChangeNotifier {
if
(
changeState
)
{
currentAppState
=
AppState
.
showApp
;
}
current
Plugin
Items
=
current
DataApp
Items
=
await
loadAppContent
(
'_preview-
$currentGitProjectId
'
,
dataType
);
for
(
var
item
in
current
Plugin
Items
)
{
for
(
var
item
in
current
DataApp
Items
)
{
if
(
item
.
edgeItem
(
'label'
)
!=
null
)
{
AppLogger
.
debug
(
item
.
edgeItem
(
'label'
)
!.
get
(
'value'
));
}
}
notifyListeners
();
AppLogger
.
debug
(
'Run done'
);
AppLogger
.
debug
(
'app message:
${current
Plugin
Items.length}
'
);
AppLogger
.
debug
(
'app message:
${current
DataApp
Items.length}
'
);
AppLogger
.
debug
(
'has log:
${currentRunLog != null}
'
);
}
else
if
(
getCurrentRunStatus
()
==
'started'
)
{
if
(
changeState
)
{
...
...
@@ -317,20 +333,8 @@ class DataAppProvider with ChangeNotifier {
return
pluginRun
;
}
// Stream<String?> pluginRunLogStream(String runId, {int maxTime=100}) async* {
// int time = 0;
// while (!["error", "done"].contains(getCurrentRunStatus()) && time < maxTime) {
// yield await getCurrentRunLog();
// await Future.delayed(Duration(seconds: 1));
// time = time + 1;
// }
// }
Future
<
String
?
>
getRunLog
(
Item
run
)
async
{
if
(
currentPluginRun
!=
null
)
{
return
await
_podService
.
getLogsForPluginRun
(
run
.
get
(
'id'
));
}
return
null
;
return
await
_podService
.
getLogsForPluginRun
(
run
.
get
(
'id'
));
}
bool
pluginIsNotRunning
()
{
...
...
@@ -362,8 +366,8 @@ class DataAppProvider with ChangeNotifier {
// AppLogger.debug(existingMockItems);
int
amountToCreate
=
max
((
amount
-
existingMockItems
.
length
),
0
);
var
items
=
await
_graphService
.
LoadItems
(
amountToCreate
,
currentDataType
!
,
fields
);
var
items
=
await
_graphService
.
LoadProjectItems
(
currentMemriProjectId
!
,
amountToCreate
,
fields
);
List
<
Item
>
newItems
=
[];
for
(
var
item
in
items
)
{
Map
<
String
,
dynamic
>
fieldValues
=
{};
...
...
@@ -432,7 +436,6 @@ class DataAppProvider with ChangeNotifier {
*/
// pluginId: runningPlugin
Map
<
String
,
RunningPlugin
>
runningPlugins
=
{};
List
<
Item
>
dataApps
=
[];
fetchDataApps
()
async
{
...
...
@@ -440,68 +443,56 @@ class DataAppProvider with ChangeNotifier {
dataApps
=
await
_graphService
.
fetchDataApps
()
.
whenComplete
(
_handleAppListFetched
);
getRunningPlugins
();
notifyListeners
();
}
handleOpenDataApp
(
BuildContext
context
,
Item
plugin
,
AppState
appState
)
async
{
var
pluginId
=
plugin
.
get
(
'id'
);
if
(
!
runningPlugins
.
containsKey
(
pluginId
))
{
await
runDataAppPlugin
(
plugin
);
}
else
{
AppLogger
.
debug
(
'Already running'
);
}
RouteNavigator
.
navigateTo
(
route:
Routes
.
appConfigure
,
context:
context
,
param:
{
'id'
:
pluginId
,
'tab'
:
appState
.
toUrlString
()});
}
runDataAppPlugin
(
Item
plugin
)
async
{
AppLogger
.
debug
(
'Creating pluginRun:
${plugin.get("name")}
'
);
Item
newPluginRunItemFromPlugin
(
Item
plugin
)
{
Item
pluginRun
=
Item
(
type:
'PluginRun'
);
plugin
.
properties
.
forEach
((
key
,
value
)
{
if
(
_runProperties
.
contains
(
key
))
{
pluginRun
.
properties
[
key
]
=
value
;
}
});
pluginRun
.
copyPropertiesFrom
(
plugin
,
_runProperties
);
pluginRun
.
setIdIfNotExists
();
pluginRun
.
properties
[
'targetItemId'
]
=
pluginRun
.
get
(
'id'
)
;
pluginRun
.
properties
[
'targetItemId'
]
=
pluginRun
.
id
;
Map
<
String
,
dynamic
>
config
=
{
'isMock'
:
true
};
String
?
dataType
=
plugin
.
get
(
'dataType'
);
if
(
dataType
!=
null
)
{
config
[
'item_type'
]
=
dataType
;
}
pluginRun
.
properties
[
'config'
]
=
jsonEncode
(
config
);
return
pluginRun
;
}
currentDataType
=
plugin
.
get
(
'dataType'
);
await
createMockItems
(
128
,
plugin
.
get
(
'id'
));
_podService
.
createItem
(
item:
pluginRun
);
runDataAppPlugin
(
Item
plugin
)
async
{
AppLogger
.
debug
(
'Creating pluginRun:
${plugin.get("name")}
'
);
Item
pluginRun
=
newPluginRunItemFromPlugin
(
plugin
);
Edge
edge
=
Edge
(
source
:
plugin
,
target:
pluginRun
,
name:
'run'
)
;
_podService
.
bulkAction
(
createItems:
[
pluginRun
],
createEdges:
[
edge
]);
currentMemriProject
=
await
_graphService
.
getProjectFromPlugin
(
id:
plugin
.
id
);
AppLogger
.
debug
(
"created PluginRun
${pluginRun.get("id")}
"
);
_
createRunningPlugin
(
plugin
,
pluginRun
);
_
setupCurrentPluginListener
(
plugin
,
pluginRun
);
}
_createRunningPlugin
(
Item
plugin
,
Item
pluginRun
)
{
var
runningPlugin
=
RunningPlugin
(
plugin:
plugin
,
pluginRun:
pluginRun
);
runningPlugins
[
plugin
.
get
(
'id'
)]
=
runningPlugin
;
runningPlugin
.
pluginRunStream
=
_pluginRunStream
(
pluginRun
.
get
(
'id'
));
// AppLogger.debug(runningPlugin.pluginRunStream.toString());
runningPlugin
.
pluginRunSubscription
=
runningPlugin
.
pluginRunStream
!.
listen
((
run
)
async
{
runningPlugin
.
pluginRun
=
run
;
if
(
runningPlugin
.
isDone
())
{
_setupCurrentPluginListener
(
Item
plugin
,
Item
pluginRun
)
{
var
stream
=
_pluginRunStream
(
pluginRun
.
id
);
StreamSubscription
<
Item
>
?
pluginRunSubscription
;
pluginRunSubscription
=
stream
.
listen
((
run
)
async
{
String
?
status
=
run
.
get
(
'status'
);
AppLogger
.
debug
(
'status:
$status
'
);
if
(
runIsDone
(
status
))
{
AppLogger
.
debug
(
'Run done'
);
runningPlugin
.
runLog
=
await
getRunLog
(
runningPlugin
.
pluginRun
);
// Stop plugin
runningPlugin
.
stopStream
();
runningPlugins
.
remove
(
runningPlugin
.
plugin
.
get
(
'id'
));
pluginRunSubscription
?.
cancel
();
}
currentRunLog
=
await
getRunLog
(
pluginRun
);
notifyListeners
();
});
...
...
@@ -526,7 +517,7 @@ class DataAppProvider with ChangeNotifier {
_handleAppListFetching
()
{
appListState
=
AppListState
.
fetching
;
notifyListeners
();
//
notifyListeners();
}
_handleAppListFetched
()
{
...
...
@@ -534,32 +525,6 @@ class DataAppProvider with ChangeNotifier {
notifyListeners
();
}
setAppState
(
RunningPlugin
?
runningPlugin
,
AppState
state
)
{
if
(
runningPlugin
!=
null
)
{
runningPlugin
.
appState
=
state
;
notifyListeners
();
}
}
void
getRunningPlugins
()
{
// TODO get all running data apps from the pod to initialize apps screen
}
updateRunningPlugin
(
String
pluginId
)
{
if
(
dataApps
.
isNotEmpty
)
{
for
(
Item
dataApp
in
dataApps
)
{
if
(
dataApp
.
get
(
'id'
)
==
pluginId
)
{
if
(
!
runningPlugins
.
containsKey
(
pluginId
))
{
runDataAppPlugin
(
dataApp
);
}
}
break
;
}
}
}
RunningPlugin
?
getRunningPlugin
(
String
pluginId
)
=
>
runningPlugins
[
pluginId
];
/// Inbox
int
selectedChannel
=
-
1
;
List
<
Item
>
chats
=
[];
...
...
@@ -815,7 +780,7 @@ class DataAppProvider with ChangeNotifier {
}
}
Future
<
String
>
getTypeForPlugin
Run
(
String
id
)
async
{
Future
<
String
>
get
Data
TypeForPlugin
(
String
id
)
async
{
String
?
res
=
(
await
_podService
.
getItem
(
id:
id
))
?.
get
(
'dataType'
);
if
(
res
==
null
)
{
throw
Exception
(
'no plugin found for id'
);
...
...
@@ -851,18 +816,18 @@ class DataAppProvider with ChangeNotifier {
void
getFeed
()
async
{
feedStreamSubscription
=
gqlStreamTwitterFeed
()
.
listen
((
res
)
{
feed
=
res
;
setTwitterImages
(
feed
);
setTwitterImages
();
notifyListeners
();
});
}
void
setTwitterImages
(
List
<
Item
>
tweets
)
async
{
for
(
var
item
in
tweets
)
{
void
setTwitterImages
()
async
{
for
(
var
item
in
feed
)
{
var
itemID
=
item
.
get
(
'id'
);
if
(
tweetImageProviders
[
itemID
]
!=
null
)
continue
;
String
?
fileID
=
item
.
edgeItem
(
'author'
)
!
.
edgeItem
(
'profilePicture'
)
.
edgeItem
(
'author'
)
?
.
edgeItem
(
'profilePicture'
)
?.
edgeItem
(
'file'
)
?.
get
(
'sha256'
)
?.
toString
();
...
...
@@ -882,7 +847,7 @@ class DataAppProvider with ChangeNotifier {
if
(
dataSource
==
null
)
{
debugPrint
(
'Could not load initial items, no gitlab id set'
);
}
else
{
current
Plugin
Items
=
await
loadAppContent
(
dataSource
,
currentDataType
!
);
current
DataApp
Items
=
await
loadAppContent
(
dataSource
,
currentDataType
!
);
}
}
...
...
@@ -890,4 +855,10 @@ class DataAppProvider with ChangeNotifier {
currentPluginRun
=
await
_graphService
.
getPluginRunsWithContainerImage
(
containerImage
);
}
Future
<
List
<
Item
>>
getPluginRunsForPlugin
(
String
pluginId
)
async
=
>
await
_graphService
.
getPluginRunsForPlugin
(
pluginId
);
Future
<
Item
?
>
getPlugin
(
String
pluginId
)
async
=
>
await
_podService
.
getItem
(
id:
pluginId
);
}
This diff is collapsed.
Click to expand it.
lib/screens/workspace/apps/apps_configure_screen.dart
+
25
-
39
View file @
fc645b4f
import
'package:flutter/material.dart'
;
import
'package:memri/core/models/item.dart'
;
import
'package:memri/core/models/running_plugin.dart'
;
import
'package:memri/providers/data_app_provider.dart'
;
import
'package:memri/providers/navigation_provider.dart'
;
import
'package:memri/utilities/helpers/app_helper.dart'
;
import
'package:memri/widgets/data_app/data_app.dart'
;
import
'package:memri/widgets/data_app/data_app_error.dart'
;
import
'package:memri/widgets/data_app/data_app_logs.dart'
;
import
'package:memri/widgets/data_app/data_app_settings.dart'
;
import
'package:memri/widgets/loading_indicator.dart'
;
...
...
@@ -13,11 +13,12 @@ import 'package:memri/widgets/scaffold/workspace_scaffold.dart';
import
'package:provider/provider.dart'
;
class
AppsConfigureScreen
extends
StatefulWidget
{
const
AppsConfigureScreen
({
Key
?
key
,
required
this
.
tab
,
required
this
.
id
})
const
AppsConfigureScreen
(
{
Key
?
key
,
required
this
.
tab
,
required
this
.
pluginId
})
:
super
(
key:
key
);
final
String
tab
;
final
String
i
d
;
final
String
pluginI
d
;
@override
State
<
AppsConfigureScreen
>
createState
()
=
>
_AppsConfigureScreenState
();
...
...
@@ -33,52 +34,44 @@ class _AppsConfigureScreenState extends State<AppsConfigureScreen> {
late
List
<
TabItem
>
tabs
=
[
TabItem
(
name:
runningPlugin
?.
plugin
.
get
(
'name'
)
??
'Data App'
,
onTap:
()
=
>
_dataAppProvider
.
setAppState
(
runningPlugin
,
AppState
.
showApp
)),
onTap:
()
=
>
_dataAppProvider
.
setDataAppState
(
AppState
.
showApp
)),
TabItem
(
name:
'Settings'
,
onTap:
()
=
>
_dataAppProvider
.
setAppState
(
runningPlugin
,
AppState
.
showSettings
)),
onTap:
()
=
>
_dataAppProvider
.
setDataAppState
(
AppState
.
showSettings
)),
TabItem
(
name:
'Logs'
,
onTap:
()
=
>
_dataAppProvider
.
setAppState
(
runningPlugin
,
AppState
.
showLogs
)),
onTap:
()
=
>
_dataAppProvider
.
setDataAppState
(
AppState
.
showLogs
)),
];
@override
void
initState
()
{
runningPlugin
=
_dataAppProvider
.
getRunningPlugin
(
widget
.
id
);
initState
()
{
if
(
widget
.
tab
==
AppState
.
showSettings
.
toUrlString
())
{
runningPlugin
?.
a
ppState
=
AppState
.
showSettings
;
_dataAppProvider
.
currentA
ppState
=
AppState
.
showSettings
;
_navProvider
.
setSelectedTabIndex
(
1
);
}
else
if
(
widget
.
tab
==
AppState
.
showLogs
.
toUrlString
())
{
runningPlugin
?.
a
ppState
=
AppState
.
showLogs
;
_dataAppProvider
.
currentA
ppState
=
AppState
.
showLogs
;
_navProvider
.
setSelectedTabIndex
(
2
);
}
else
{
runningPlugin
?.
a
ppState
=
AppState
.
showApp
;
_dataAppProvider
.
currentA
ppState
=
AppState
.
showApp
;
_navProvider
.
setSelectedTabIndex
(
0
);
}
_setup
();
super
.
initState
();
}
void
_updateTabs
()
{
if
(
widget
.
tab
==
AppState
.
showSettings
.
toUrlString
())
{
runningPlugin
?.
appState
=
AppState
.
showSettings
;
}
else
if
(
widget
.
tab
==
AppState
.
showLogs
.
toUrlString
())
{
runningPlugin
?.
appState
=
AppState
.
showLogs
;
}
else
{
runningPlugin
?.
appState
=
AppState
.
showApp
;
}
}
Future
<
void
>
_setup
()
async
{
_dataAppProvider
.
currentPlugin
=
(
await
_dataAppProvider
.
getPlugin
(
widget
.
pluginId
))
!
;
List
<
Item
>
runs
=
await
_dataAppProvider
.
getPluginRunsForPlugin
(
widget
.
pluginId
);
@override
void
didUpdateWidget
(
covariant
AppsConfigureScreen
oldWidget
)
{
if
(
runningPlugin
==
null
)
{
_dataAppProvider
.
updateRunningPlugin
(
widget
.
id
)
;
runningPlugin
=
_dataAppProvider
.
g
et
RunningPlugin
(
widget
.
id
);
if
(
runs
.
isEmpty
)
{
_dataAppProvider
.
runDataAppPlugin
(
_dataAppProvider
.
currentPlugin
!
);
}
else
{
_dataAppProvider
.
currentPluginRun
=
runs
[
0
]
;
_dataAppProvider
.
s
et
DataAppState
(
AppState
.
showApp
);
}
super
.
didUpdateWidget
(
oldWidget
);
}
@override
...
...
@@ -89,14 +82,7 @@ class _AppsConfigureScreenState extends State<AppsConfigureScreen> {
tabs:
tabs
,
child:
Consumer
<
DataAppProvider
>(
builder:
(
context
,
dataAppProvider
,
_
)
{
if
(
runningPlugin
==
null
)
{
_dataAppProvider
.
updateRunningPlugin
(
widget
.
id
);
runningPlugin
=
_dataAppProvider
.
getRunningPlugin
(
widget
.
id
);
}
if
(
runningPlugin
==
null
)
return
DataAppError
();
if
(
runningPlugin
!.
appState
==
AppState
.
deploying
)
_updateTabs
();
switch
(
runningPlugin
!.
appState
)
{
switch
(
dataAppProvider
.
currentAppState
)
{
case
AppState
.
deploying
:
return
LoadingIndicator
();
case
AppState
.
initialPredictions
:
...
...
@@ -104,10 +90,10 @@ class _AppsConfigureScreenState extends State<AppsConfigureScreen> {
case
AppState
.
showApp
:
return
DataApp
(
runningPlugin:
runningPlugin
,
pluginId:
widget
.
i
d
,
pluginId:
widget
.
pluginI
d
,
);
case
AppState
.
showLogs
:
return
DataAppLogs
(
currentRunLog:
runningPlugin
?.
r
unLog
);
return
DataAppLogs
(
currentRunLog:
dataAppProvider
.
currentR
unLog
);
case
AppState
.
showSettings
:
return
DataAppSettings
(
runningPlugin:
runningPlugin
);
}
...
...
This diff is collapsed.
Click to expand it.
lib/screens/workspace/apps/apps_feed_screen.dart
+
5
-
1
View file @
fc645b4f
...
...
@@ -95,7 +95,11 @@ class _AppsFeedScreenState extends State<AppsFeedScreen> {
radius:
17.5
,
backgroundImage:
image
,
backgroundColor:
app
.
colors
.
brandOrange
,
child:
image
==
null
child:
image
==
null
&&
provider
.
getFeedAuthorName
(
index
)
.
length
>
1
?
Text
(
provider
.
getFeedAuthorName
(
index
)
...
...
This diff is collapsed.
Click to expand it.
lib/screens/workspace/projects/projects_app_preview_screen.dart
+
5
-
6
View file @
fc645b4f
...
...
@@ -49,10 +49,9 @@ class _ProjectsAppPreviewScreen extends State<ProjectsAppPreviewScreen> {
await
projectProvider
.
setGitlabProject
();
dataAppProvider
.
currentGitProjectId
=
projectProvider
.
gitlabProjectId
;
dataAppProvider
.
setCurrentDataTypesFromProject
(
projectProvider
.
currentProject
!
);
dataAppProvider
.
currentMemriProject
=
projectProvider
.
currentProject
!
;
await
dataAppProvider
.
setInitialItems
();
if
(
dataAppProvider
.
current
Plugin
Items
.
isEmpty
)
{
if
(
dataAppProvider
.
current
DataApp
Items
.
isEmpty
)
{
dataAppProvider
.
currentAppState
=
AppState
.
deploying
;
dataAppProvider
.
runIndexerPluginFromGit
(
project:
projectProvider
.
currentProject
!
,
changeState:
true
);
...
...
@@ -160,7 +159,8 @@ class _ProjectsAppPreviewScreen extends State<ProjectsAppPreviewScreen> {
padding:
EdgeInsets
.
all
(
30
),
color:
app
.
colors
.
greyBackGround
,
child:
DataAppList
(
contents:
dataAppProvider
.
currentPluginItems
),
contents:
dataAppProvider
.
currentDataAppItems
),
),
)
else
...
...
@@ -174,8 +174,7 @@ class _ProjectsAppPreviewScreen extends State<ProjectsAppPreviewScreen> {
style:
primaryButtonStyle
,
onPressed:
()
=
>
dataAppProvider
.
handlePublishApp
(
context
,
projectProvider
.
currentProject
?.
get
(
'name'
)
??
'Unnamed App'
,
projectProvider
.
currentProject
!
,
projectProvider
.
dataSourceSelected
.
toString
()),
child:
SizedBox
(
height:
36
,
...
...
This diff is collapsed.
Click to expand it.
lib/widgets/data_app/data_app.dart
+
15
-
12
View file @
fc645b4f
...
...
@@ -27,9 +27,7 @@ class _DataAppState extends State<DataApp> {
@override
void
initState
()
{
if
(
widget
.
runningPlugin
!=
null
)
{
loadAppContent
();
}
loadAppContent
();
super
.
initState
();
}
...
...
@@ -39,8 +37,9 @@ class _DataAppState extends State<DataApp> {
return
LoadingIndicator
(
message:
'Loading your App...!'
);
}
return
SingleChildScrollView
(
child:
Container
(
return
SingleChildScrollView
(
child:
Consumer
<
DataAppProvider
>(
builder:
(
context
,
dataAppProvider
,
_
)
{
return
Container
(
padding:
EdgeInsets
.
symmetric
(
vertical:
8
),
child:
Row
(
children:
[
...
...
@@ -56,7 +55,7 @@ class _DataAppState extends State<DataApp> {
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
widget
.
runningPlugin
?.
plugin
.
get
(
'name'
)
??
_dataAppProvider
.
currentPlugin
?
.
get
(
'name'
)
??
'Untitled App'
,
style:
AppStyles
.
headline1
,
),
...
...
@@ -70,7 +69,7 @@ class _DataAppState extends State<DataApp> {
),
),
SizedBox
(
height:
50
),
DataAppList
(
contents:
appContent
),
DataAppList
(
contents:
_dataAppProvider
.
currentDataAppItems
),
],
),
),
...
...
@@ -79,15 +78,19 @@ class _DataAppState extends State<DataApp> {
Expanded
(
flex:
1
,
child:
Container
())
],
),
)
,
);
)
;
})
);
}
loadAppContent
()
async
{
contentHasLoaded
=
false
;
String
type
=
await
_dataAppProvider
.
getTypeForPluginRun
(
widget
.
pluginId
);
appContent
=
await
_dataAppProvider
.
loadAppContent
(
widget
.
pluginId
,
type
,
onlyWithPredictions:
false
);
_dataAppProvider
.
currentDataType
=
await
_dataAppProvider
.
getDataTypeForPlugin
(
widget
.
pluginId
);
_dataAppProvider
.
currentDataAppItems
=
await
_dataAppProvider
.
loadAppContent
(
widget
.
pluginId
,
_dataAppProvider
.
currentDataType
!
,
onlyWithPredictions:
false
);
contentHasLoaded
=
true
;
setState
(()
{});
}
...
...
This diff is collapsed.
Click to expand it.
lib/widgets/data_app/data_app_settings.dart
+
2
-
4
View file @
fc645b4f
...
...
@@ -82,8 +82,7 @@ class _DataAppSettingsState extends State<DataAppSettings> {
_appNameController
.
text
,
_appDescriptionController
.
text
);
_navProvider
.
setSelectedTabIndex
(
0
);
_dataAppProvider
.
setAppState
(
widget
.
runningPlugin
,
AppState
.
showApp
);
_dataAppProvider
.
setDataAppState
(
AppState
.
showApp
);
},
style:
primaryButtonStyle
,
child:
SizedBox
(
...
...
@@ -102,8 +101,7 @@ class _DataAppSettingsState extends State<DataAppSettings> {
onPressed:
()
{
resetSettingsControllers
();
_navProvider
.
setSelectedTabIndex
(
0
);
_dataAppProvider
.
setAppState
(
widget
.
runningPlugin
,
AppState
.
showApp
);
_dataAppProvider
.
setDataAppState
(
AppState
.
showApp
);
},
child:
SizedBox
(
height:
36
,
...
...
This diff is collapsed.
Click to expand it.
pubspec.yaml
+
1
-
1
View file @
fc645b4f
...
...
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version
:
2.2.
1
+0
version
:
2.2.
2
+0
environment
:
sdk
:
"
>=2.12.0
<3.0.0"
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets