Category: typescript

Bingo for meetings – part 3 – finalizing the “Create Meeting” scenario

Bingo

Bingo is a small project, written in TypeScript , and developed with Alexandru Badita in launch break (one hour - more or less). You can find sources at https://github.com/alexandru360/PresentationBingoCards/ . Those are my blog posts for Bingo : ( scroll below for the post)
NrLink
1Create meeting
2Create Tests
3Finalize Create meeting
4Sharing meeting
5Keep Score
6Add obsolete
7Finalizing obsolete
8End meeting
9Dockerize tests
10Azure CI tests
11Yarn workspaces
12CLI
13Intermezzo - CLI improvements
14typescript compile run with node
15NestJS ,swagger and create a meeting
16Finalizing API
17Intermezzo - jest vs jasmine error
18Refactor WebAPI and test service
19Heroku Deploy NestJs
20Angular
21Deploy Angular to GitHub
22WebAPI and Web
23Documentation
24Documentation of the code
25Conclusions

In the “Create Meeting” scenario it was something that we have passed : ” application generates an unique Id that I can access the bingo cards ( state : not checked) for that meeting ” ( see https://github.com/alexandru360/PresentationBingoCards/projects/1#card-24165690 )
How we can emulate this ? Obviously, the meeting starts with a set of cards – but how about participants ? Do they have the same set of cards and check them ( bingo ) ?

There are some possible things to be programmed here:

1. The meeting have the unique set of cards and the dictionary of .

2. Every participant , when joining the meeting, have a copy ( by reference ) of the meeting cards and an array to see what is checked

3. Every card keep an array of participants that shows what participant have checked the card.

Guess what is easiear to implement ?

However, we have put a function on the meeting

public AllUnchecked(): boolean{
        return (this.Cards.filter(it=>it.IsChecked()).length === 0);
    }

and a test to ensure that, when creating a meeting, the function returns false.

So now the first scenario is done !

( On a personal note, I see that yarn is better than npm )

Bingo for meetings–part 2–working at tests

Bingo

Bingo is a small project, written in TypeScript , and developed with Alexandru Badita in launch break (one hour - more or less). You can find sources at https://github.com/alexandru360/PresentationBingoCards/ . Those are my blog posts for Bingo : ( scroll below for the post)
NrLink
1Create meeting
2Create Tests
3Finalize Create meeting
4Sharing meeting
5Keep Score
6Add obsolete
7Finalizing obsolete
8End meeting
9Dockerize tests
10Azure CI tests
11Yarn workspaces
12CLI
13Intermezzo - CLI improvements
14typescript compile run with node
15NestJS ,swagger and create a meeting
16Finalizing API
17Intermezzo - jest vs jasmine error
18Refactor WebAPI and test service
19Heroku Deploy NestJs
20Angular
21Deploy Angular to GitHub
22WebAPI and Web
23Documentation
24Documentation of the code
25Conclusions

So now because we have created the objects and a function to create meetings, we do create some tests. We decided to work with JEST.

Steps:

  1. We read many tutorials (https://medium.com/@mtiller/debugging-with-typescript-jest-ts-jest-and-visual-studio-code-ef9ca8644132 , https://rjzaworski.com/2016/12/testing-typescript-with-jest , https://github.com/facebook/jest/tree/master/examples/typescript , https://amenallah.com/node-js-typescript-jest-starter/ , https://basarat.gitbooks.io/typescript/docs/testing/jest.html , https://dev.to/muhajirdev/unit-testing-with-typescript-and-jest-2gln )
  2. We solve many errors  ( forgetting put “ export default class “ , “ jest unexpected token import “ ,  jest.config.json  as opposed to jest.config.js
  3. Read jest expect documentation from https://jestjs.io/docs/en/expect.html#not
  4. We finally wrote 2 tests in order to verify meeting creation and run with npm test

 

import MeetingsFactory from '../MeetingsFactory';

import Meeting from '../meeting';

describe('Meetings creation', () => {

it('a meeting should have been created properly', () => {

const mf=new MeetingsFactory();

const m1=mf.CreateMeeting("andrei","first meeting");

expect(m1.Name).toBe("first meeting");

expect(m1.Participants.length).toBe(1);

expect(m1.Participants[0].Name).toBe("andrei");

})

it('two meeting have different ids', () => {

const mf=new MeetingsFactory();

const m1=mf.CreateMeeting("andrei","first meeting");

const m2=mf.CreateMeeting("andrei","first meeting");

expect(m1.Id).not.toBe(m2.Id);

})

})

 

And with this we just verify first use case

Create Meeting Bingo:

As a user, I want to create a new meeting bingo: I use an username and meeting name and the application generates an unique Id that I can access the bingo cards ( state :  not checked) for that meeting

 

And not even the whole(  we do not have the cards , not the state for the cards!)

New project: Bingo for meetings–part 1

Bingo

Bingo is a small project, written in TypeScript , and developed with Alexandru Badita in launch break (one hour - more or less). You can find sources at https://github.com/alexandru360/PresentationBingoCards/ . Those are my blog posts for Bingo : ( scroll below for the post)
NrLink
1Create meeting
2Create Tests
3Finalize Create meeting
4Sharing meeting
5Keep Score
6Add obsolete
7Finalizing obsolete
8End meeting
9Dockerize tests
10Azure CI tests
11Yarn workspaces
12CLI
13Intermezzo - CLI improvements
14typescript compile run with node
15NestJS ,swagger and create a meeting
16Finalizing API
17Intermezzo - jest vs jasmine error
18Refactor WebAPI and test service
19Heroku Deploy NestJs
20Angular
21Deploy Angular to GitHub
22WebAPI and Web
23Documentation
24Documentation of the code
25Conclusions

I have decided to start a new project. The name is “Bingo for meetings”. What it does: Every time in a meeting that a participant hears a phrase (like “ Hi, can you hear me?” or “ can everyone see my screen?” or others …)  he can check one of the cards. In the final you can see for the meeting how many cards you have checked.

I am doing the project with Alexandru Badita (http://alexandru360.blogspot.com/) .  We agreed to be in ONLY in TypeScript .

We are doing at Starbucks the pair programming and exchange ideas. Total time: 1 hour

In the first meeting we have  put the specifications at https://github.com/alexandru360/PresentationBingoCards/projects/1

Create Meeting Bingo:

As a user, I want to create a new meeting bingo: I use an username and meeting name and the application generates an unique Id that I can access the bingo cards ( state :  not checked) for that meeting

Share Meeting Bingo:

As a User, I can receive the meeting Id( url) . When going to this url , I can ( optionally) enter my name and check cards

Checking cards:
A total score will be displayed when checking / unchecking

EndMeeting:
The score of how many cards/ what cards were checked will be available 1 hour and 5 minutes

Meeting Obsolete:
The meeting is available for 35 minutes. After that, meeting is not available anymore.

Also, we have created the classes Meeting, Participant,  Also, we have created a MeetingsFactory that can create a Meeting.

You can fist the result of our code at https://github.com/alexandru360/PresentationBingoCards/releases/tag/firstMeeting 

.

7 Steps from (Angular) WebApplication to Windows Store

I have deployed fairly easy the .NET Core Alphabet applcation to Windows Store . Supposing that you already have registered the name of the application to the windows store (https://partner.microsoft.com/en-us/dashboard/windows/overview )

Those are the steps:

1. Compile the Angular Application ( with ng build –prod –build-optimizer  )

2. Create a new WinJS App for Universal Windows

3. Copy the results ( index.html and js )from the point 1 to a dist folder

4. Save the files with BOM ( either from VS, Save as, then save with encoding, either using dos2unix –m  <namefile>

5. Modify the main.js by adding : window.location.href=’dist/index.html’;    

6. Modify the Visual Assets to the images of your application

7. Right click the application, Store => Create App Package . And deploy to the store

As a Proof of concept, see https://www.microsoft.com/en-us/p/netcorealphabet/9pdx9rv0xhds#activetab=pivot:overviewtab 

Also, all the source code it is at https://github.com/ignatandrei/netCoreAlphabet ( and you may want to contribute, right?)

.NET Core Alphabet

What I wanted is a simple application ( Web, Mobile, Desktop) that can list , alphabetically, the .NET Core keywords. What is the purpose?

  1. For interviews – suppose you want to test the people knowledge in C#. You start the application( again: Desktop or Web or Mobile) and let the candidate choose a letter. Then you see the keywords for this letter and ask the candidate to explain some of the keywords
  2. For remembering features: there are so many features in .NET language (  https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history ) that for a programmer it is good to know – or to revisit – the features that are in the language.
  3. For contest within programmers  – like the interviews, but for the passionate programmers that want to have an easy way to decide the one with the best memory
  4. Maybe other uses that I do not know  ? Please share in comments

Now with the realization: What I want is the simple application, that has inside the database with keywords and links and any others. From this database, the code sources for the data will be generated and the application(s) will be generated. Also, data should be publicly available to profit from the crowd power –anyone that want to add something can add.

stankins.console execute -o ReceiveRestFromFile -a primaryData/netCoreAlphabet.json -o SenderToTypeScript -a “” -o TransformerConcatenateOutputString -a a.ts -o SenderOutputToFolder -a $(Build.ArtifactStagingDirectory)/data/ -a false

stankins.console execute -o ReceiveRestFromFile -a primaryData/netCoreAlphabet.json -o SenderToRazorFromFile -a primaryData/markdown.txt -o TransformerConcatenateOutputString -a cards.md -o SenderOutputToFolder -a $(Build.ArtifactStagingDirectory)/data/ -a false
 

And to complete all those, it will be put in an AzureDevops pipeline https://github.com/ignatandrei/netCoreAlphabet/blob/master/azure-pipelines.yml 

You can see the result on Android : https://play.google.com/store/apps/details?id=com.github.ignatandrei.netcorealphabet&hl=en  , WebSite: https://ignatandrei.github.io/netCoreAlphabet

Also, if you want , please contribute by making a PR by editing https://github.com/ignatandrei/netCoreAlphabet/blob/master/primaryData/netCoreAlphabet.json or by contributing to enchance the application by solving https://github.com/ignatandrei/netCoreAlphabet/issues

Literary awards–part 5 – interactive

Part 1: http://msprogrammer.serviciipeweb.ro/2018/10/08/literary-awardspart-1/

Part 2: http://msprogrammer.serviciipeweb.ro/2018/10/15/literary-awardspart-2/

Part 3: http://msprogrammer.serviciipeweb.ro/2018/10/22/literary-awardspart-3/

Part 4: http://msprogrammer.serviciipeweb.ro/2018/10/29/literary-awardspart-4/

Part 5: http://msprogrammer.serviciipeweb.ro/2018/11/05/literary-awardspart-5/

 

I was wandering how to make more attractive the application – and also gain some interactivity. I was thinking of the possibility  to can say what authors / books did you have read – and make some charts from it.

And here was the principal problem: how, between 2 versions of the data, to remember the authors read ? How to make the authros the same between the various awards ?

Turns out it is not so complicated – the only thing is to not version the “read” database .

So I turn out with just a database per table : one for Nobel, one for Booker, one for Bill Gates books, one for my books, one for reading list and one for all authors. Not a good thing, but this happens when you want to keep the database into the browser and updatable…

The source code is at github:https://github.com/ignatandrei/LiteraryAwards

Literary awards–part 4 – publish

Part 1: http://msprogrammer.serviciipeweb.ro/2018/10/08/literary-awardspart-1/

Part 2: http://msprogrammer.serviciipeweb.ro/2018/10/15/literary-awardspart-2/

Part 3: http://msprogrammer.serviciipeweb.ro/2018/10/22/literary-awardspart-3/

Part 4: http://msprogrammer.serviciipeweb.ro/2018/10/29/literary-awardspart-4/

Part 5: http://msprogrammer.serviciipeweb.ro/2018/11/05/literary-awardspart-5/

 

The publishing part is the tricky one. I wanted Web and Mobile ( could someone help me with the Windows/Linux part  ? )

Github let’s you have the gh-pages  as an website – see https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/ .

What this means in practice ? Menas that , if you deploy the Angular AOT to the gh-pages ( https://github.com/ignatandrei/LiteraryAwards/tree/gh-pages ) , then it should be visible to this url : https://ignatandrei.github.io/LiteraryAwards/

There is also a plugin, angular-cli-ghpages , that does this for you: takes the dist folder ( resulting from AOT Angular build ) and put in gh-pages. You can see the result at https://ignatandrei.github.io/LiteraryAwards/

For Mobile Android I just install the Cordova, copy the dist folder into Cordova and modify the start page in order to point to the Angular results.

But how can I compile Cordova into an Android application ? Turns out that there is a site – https://www.bitrise.io/ – that takes your code ( not only from GitHub, but for free app it is free  ) and compiles it – and it gives you back the apk. Also , it can sign the application – something that Google Play requires. ( For this, I have had some problems with generating keys:

“C:\Program Files\Java\jdk1.8.0_171\bin\keytool.exe” -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks
“C:\Program Files\Java\jdk1.8.0_171\bin\keytool.exe” -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks

)

You can find the Google Play application at https://play.google.com/store/apps/details?id=com.msprogrammer.com

 

The source code is at github:https://github.com/ignatandrei/LiteraryAwards

Literary Awards–part 3–data

Part 1: http://msprogrammer.serviciipeweb.ro/2018/10/08/literary-awardspart-1/

Part 2: http://msprogrammer.serviciipeweb.ro/2018/10/15/literary-awardspart-2/

Part 3: http://msprogrammer.serviciipeweb.ro/2018/10/22/literary-awardspart-3/

Part 4: http://msprogrammer.serviciipeweb.ro/2018/10/29/literary-awardspart-4/

Part 5: http://msprogrammer.serviciipeweb.ro/2018/11/05/literary-awardspart-5/

 

The data – this was the difficult part. As I said, I wanted the data to be local – but how can I put the first time ? And where ? I cannot be cookie, since the authors are a large database for cookies…

There are 3 options : LocalStorage, WebSql and IndexedDB . You can read about those at https://nolanlawson.com/2015/09/29/indexeddb-websql-localstorage-what-blocks-the-dom/ . I choose LocalStorage because it was simpler – however, this is making the startup of the application slower!

Now, how can I store the data ?  For me, a database with select it was fine – but can I find one that works in the browser ? And with javascript ? Apparently, yes! There is a port from C to js of SQLite – https://github.com/kripken/sql.js/ . That means , I can have a SQLIte database and access via Select. Add I can persist too – see https://github.com/kripken/sql.js/wiki/Persisting-a-Modified-Database .

 

With all those, now I am ready to have the Nobel authoirs in my application – but how can I introduce to my application ? The list exists on Wikipedia( https://en.wikipedia.org/wiki/List_of_Nobel_laureates_in_Literature)  and at Nobel site (https://www.nobelprize.org/prizes/literature/) . How can I load those into my SQLite LocalStorage database ?

Here comes another pet project of mine, stankins  . With this I can transform the wikipedia page into this:


db.run("INSERT INTO tableAuthors (Year,Laureate,Languages,Citation,Genres,PictureUrl,LaureateFullWiki,name) VALUES (?,?,?,?,?,?,?,?)", [

"1901",

"Sully Prudhomme",

"French",

'"in special recognition of his poetic composition, which gives evidence of lofty idealism, artistic perfection and a rare combination of the qualities of both heart and intellect"&#91;12&#93;',

"poetry, essay",

"//upload.wikimedia.org/wikipedia/commons/thumb/3/39/Sully-Prudhomme.jpg/75px-Sully-Prudhomme.jpg",

"https://en.wikipedia.org/wiki/Sully_Prudhomme",

"Sully_Prudhomme"

]);

db.run("INSERT INTO tableAuthors (Year,Laureate,Languages,Citation,Genres,PictureUrl,LaureateFullWiki,name) VALUES (?,?,?,?,?,?,?,?)", [

"1902",

"Theodor Mommsen",

"German",

'"the greatest living master of the art of historical writing, with special reference to his monumental work, A History of Rome"&#91;13&#93;',

"history, law",

"//upload.wikimedia.org/wikipedia/commons/thumb/e/e9/T-mommsen-2.jpg/75px-T-mommsen-2.jpg",

"https://en.wikipedia.org/wiki/Theodor_Mommsen",

"Theodor_Mommsen"

]);

Obvious, it is not perfect – but it works!

What can I do with upgrades * because , obvious, each year I should add the Nobel authors ? Nothing simpler: I will modify the name of the database with the application version from package.json

 

In environement.ts ( and in prod)


VERSION: require('../../package.json').version

In the typescript class:


public version: string = environment.VERSION;

Finally , in the create database


this.dbPers = new SQL.PersistentDatabase(

"nobel_v"+this.version,

async function(sender) {

// Initial creation of database if not found

self.createDatabase(sender).then(()=>{

sender.save();

});

},

function(e) {

// Initialization of existing database failed

alert("database failed" + e);

}

);

The source code is at github:https://github.com/ignatandrei/LiteraryAwards

Literary Awards–part 2–design

Part 1: http://msprogrammer.serviciipeweb.ro/2018/10/08/literary-awardspart-1/

Part 2: http://msprogrammer.serviciipeweb.ro/2018/10/15/literary-awardspart-2/

Part 3: http://msprogrammer.serviciipeweb.ro/2018/10/22/literary-awardspart-3/

Part 4: http://msprogrammer.serviciipeweb.ro/2018/10/29/literary-awardspart-4/

Part 5: http://msprogrammer.serviciipeweb.ro/2018/11/05/literary-awardspart-5/

 

One of the first problem that I was design. How to make a design that works on mobile and web and desktop ? Nowadays, the standard seems to be a menu on the left , that will be hidden when the mobile is rendering  . Also , this menu has three lines that allows to expand / collapse.

There are several resources at https://angular.io/resources .

I have tested all the resources with Window Resizer from Chrome and I was impressed by I was impressed by http://akveo.com/ngx-admin .

I have found the  empty starter kit (https://github.com/akveo/ngx-admin/tree/starter-kit ) and I started to modify

 

There was a learning curve here:

The search –  I did not know how to make the search  that was provided , until I found something that was called “

NbSearchService” – always search for a service …

It was a while until a figured how to add a new page to the existing pages ( and now I copy /paste)

I ended up with a bunch of images (https://github.com/akveo/ngx-admin/tree/starter-kit/src/assets/images )and other resources that were not needed

 

All in all, I think that it is more convenient to choose something simpler and not choose a big framework.

The design was pretty simple: Add links on the right to Nobel prize, Booker prize, others and list the authors / books.

And a search will be convenient to find fast the authors on the main page.

But about the data , next time

The source code is at github:https://github.com/ignatandrei/LiteraryAwards

Literary Awards–part 1–start

Part 1: http://msprogrammer.serviciipeweb.ro/2018/10/08/literary-awardspart-1/

Part 2: http://msprogrammer.serviciipeweb.ro/2018/10/15/literary-awardspart-2/

Part 3: http://msprogrammer.serviciipeweb.ro/2018/10/22/literary-awardspart-3/

Part 4: http://msprogrammer.serviciipeweb.ro/2018/10/29/literary-awardspart-4/

Part 5: http://msprogrammer.serviciipeweb.ro/2018/11/05/literary-awardspart-5/

 

I was curious to make a project for web and mobile.

The constraints:

1. database just on local, not on a central repository.

2. All with Javascript( OK, TypeScript).,

3. To work on web , mobile, desktop without changing something

 

The purpose of the project was to list the Literary awards – Nobel, Booker, others. ( I maintain myself a list of best books at http://serviciipeweb.ro/propriu/best-of/ )

You can see the final result at ( It is missing the desktop application – but – can you help me with that  – Electron ):

Site Web:https://ignatandrei.github.io/LiteraryAwards/

Google Play :https://play.google.com/store/apps/details?id=com.msprogrammer.com

Amazon :https://www.amazon.com/AOM-Literary-Awards/dp/B07HPFSZ4C/

The source code is at github:https://github.com/ignatandrei/LiteraryAwards

 

In the next blog posts I will show how I made this application – and problems / features / ideas. .

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.